Revision 0d8837bd

View differences:

libavcodec/alacenc.c
51 51
    int rice_modifier;
52 52
} RiceContext;
53 53

  
54
typedef struct LPCContext {
54
typedef struct AlacLPCContext {
55 55
    int lpc_order;
56 56
    int lpc_coeff[ALAC_MAX_LPC_ORDER+1];
57 57
    int lpc_quant;
58
} LPCContext;
58
} AlacLPCContext;
59 59

  
60 60
typedef struct AlacEncodeContext {
61 61
    int compression_level;
......
69 69
    int interlacing_leftweight;
70 70
    PutBitContext pbctx;
71 71
    RiceContext rc;
72
    LPCContext lpc[MAX_CHANNELS];
73
    DSPContext dspctx;
72
    AlacLPCContext lpc[MAX_CHANNELS];
73
    LPCContext lpc_ctx;
74 74
    AVCodecContext *avctx;
75 75
} AlacEncodeContext;
76 76

  
......
141 141
        s->lpc[ch].lpc_coeff[4] =   80;
142 142
        s->lpc[ch].lpc_coeff[5] =  -25;
143 143
    } else {
144
        opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch],
144
        opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, s->sample_buf[ch],
145 145
                                      s->avctx->frame_size,
146 146
                                      s->min_prediction_order,
147 147
                                      s->max_prediction_order,
......
237 237
static void alac_linear_predictor(AlacEncodeContext *s, int ch)
238 238
{
239 239
    int i;
240
    LPCContext lpc = s->lpc[ch];
240
    AlacLPCContext lpc = s->lpc[ch];
241 241

  
242 242
    if(lpc.lpc_order == 31) {
243 243
        s->predictor_buf[0] = s->sample_buf[ch][0];
......
455 455
    avctx->coded_frame->key_frame = 1;
456 456

  
457 457
    s->avctx = avctx;
458
    dsputil_init(&s->dspctx, avctx);
458
    ff_lpc_init(&s->lpc_ctx);
459 459

  
460 460
    return 0;
461 461
}
libavcodec/arm/asm-offsets.h
33 33
#define Y_DC_SCALE               0xab4
34 34
#define C_DC_SCALE               0xab8
35 35
#define AC_PRED                  0xae0
36
#define BLOCK_LAST_INDEX         0x21c0
37
#define INTER_SCANTAB_RASTER_END 0x23c0
38
#define H263_AIC                 0x2670
36
#define BLOCK_LAST_INDEX         0x21bc
37
#define INTER_SCANTAB_RASTER_END 0x23bc
38
#define H263_AIC                 0x2668
39 39
#elif defined(__APPLE__)
40 40
#define Y_DC_SCALE               0xa70
41 41
#define C_DC_SCALE               0xa74
42 42
#define AC_PRED                  0xa9c
43
#define BLOCK_LAST_INDEX         0x217c
44
#define INTER_SCANTAB_RASTER_END 0x237c
45
#define H263_AIC                 0x2620
43
#define BLOCK_LAST_INDEX         0x2178
44
#define INTER_SCANTAB_RASTER_END 0x2378
45
#define H263_AIC                 0x261c
46 46
#endif
47 47

  
48 48
#endif
libavcodec/dsputil.c
36 36
#include "mathops.h"
37 37
#include "mpegvideo.h"
38 38
#include "config.h"
39
#include "lpc.h"
40 39
#include "ac3dec.h"
41 40
#include "vorbis.h"
42 41
#include "png.h"
......
4431 4430
#if CONFIG_AC3_DECODER
4432 4431
    c->ac3_downmix = ff_ac3_downmix_c;
4433 4432
#endif
4434
#if CONFIG_LPC
4435
    c->lpc_compute_autocorr = ff_lpc_compute_autocorr;
4436
#endif
4437 4433
    c->vector_fmul = vector_fmul_c;
4438 4434
    c->vector_fmul_reverse = vector_fmul_reverse_c;
4439 4435
    c->vector_fmul_add = vector_fmul_add_c;
libavcodec/dsputil.h
374 374
    /* assume len is a multiple of 4, and arrays are 16-byte aligned */
375 375
    void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
376 376
    void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
377
    /* no alignment needed */
378
    void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
379 377
    /* assume len is a multiple of 8, and arrays are 16-byte aligned */
380 378
    void (*vector_fmul)(float *dst, const float *src, int len);
381 379
    void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
libavcodec/flacenc.c
23 23
#include "libavutil/md5.h"
24 24
#include "avcodec.h"
25 25
#include "get_bits.h"
26
#include "dsputil.h"
27 26
#include "golomb.h"
28 27
#include "lpc.h"
29 28
#include "flac.h"
......
95 94
    FlacFrame frame;
96 95
    CompressionOptions options;
97 96
    AVCodecContext *avctx;
98
    DSPContext dsp;
97
    LPCContext lpc_ctx;
99 98
    struct AVMD5 *md5ctx;
100 99
} FlacEncodeContext;
101 100

  
......
217 216

  
218 217
    s->avctx = avctx;
219 218

  
220
    dsputil_init(&s->dsp, avctx);
219
    ff_lpc_init(&s->lpc_ctx);
221 220

  
222 221
    if (avctx->sample_fmt != AV_SAMPLE_FMT_S16)
223 222
        return -1;
......
902 901

  
903 902
    /* LPC */
904 903
    sub->type = FLAC_SUBFRAME_LPC;
905
    opt_order = ff_lpc_calc_coefs(&s->dsp, smp, n, min_order, max_order,
904
    opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, smp, n, min_order, max_order,
906 905
                                  s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type,
907 906
                                  s->options.lpc_passes, omethod,
908 907
                                  MAX_LPC_SHIFT, 0);
libavcodec/lpc.c
20 20
 */
21 21

  
22 22
#include "libavutil/lls.h"
23
#include "dsputil.h"
24 23

  
25 24
#define LPC_USE_DOUBLE
26 25
#include "lpc.h"
......
55 54
 * Calculate autocorrelation data from audio samples
56 55
 * A Welch window function is applied before calculation.
57 56
 */
58
void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
57
static void lpc_compute_autocorr_c(const int32_t *data, int len, int lag,
59 58
                             double *autoc)
60 59
{
61 60
    int i, j;
......
162 161
 * 1  = LPC with coeffs determined by Levinson-Durbin recursion
163 162
 * 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes.
164 163
 */
165
int ff_lpc_calc_coefs(DSPContext *s,
164
int ff_lpc_calc_coefs(LPCContext *s,
166 165
                      const int32_t *samples, int blocksize, int min_order,
167 166
                      int max_order, int precision,
168 167
                      int32_t coefs[][MAX_LPC_ORDER], int *shift,
......
236 235

  
237 236
    return opt_order;
238 237
}
238

  
239
av_cold void ff_lpc_init(LPCContext *s)
240
{
241
    s->lpc_compute_autocorr = lpc_compute_autocorr_c;
242

  
243
    if (HAVE_MMX)
244
        ff_lpc_init_x86(s);
245
}
libavcodec/lpc.h
36 36
#define MAX_LPC_ORDER       32
37 37

  
38 38

  
39
typedef struct LPCContext {
40
    /**
41
     * Perform autocorrelation on input samples with delay of 0 to lag.
42
     * @param data  input samples.
43
     *              no alignment needed.
44
     * @param len   number of input samples to process
45
     * @param lag   maximum delay to calculate
46
     * @param autoc output autocorrelation coefficients.
47
     *              constraints: array size must be at least lag+1.
48
     */
49
    void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag,
50
                                 double *autoc);
51
} LPCContext;
52

  
53

  
39 54
/**
40 55
 * Calculate LPC coefficients for multiple orders
41 56
 */
42
int ff_lpc_calc_coefs(DSPContext *s,
57
int ff_lpc_calc_coefs(LPCContext *s,
43 58
                      const int32_t *samples, int blocksize, int min_order,
44 59
                      int max_order, int precision,
45 60
                      int32_t coefs[][MAX_LPC_ORDER], int *shift,
46 61
                      enum AVLPCType lpc_type, int lpc_passes,
47 62
                      int omethod, int max_shift, int zero_shift);
48 63

  
49
void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
50
                             double *autoc);
64
/**
65
 * Initialize LPCContext.
66
 */
67
void ff_lpc_init(LPCContext *s);
68
void ff_lpc_init_x86(LPCContext *s);
51 69

  
52 70
#ifdef LPC_USE_DOUBLE
53 71
#define LPC_TYPE double
libavcodec/ra144.h
23 23
#define AVCODEC_RA144_H
24 24

  
25 25
#include <stdint.h>
26
#include "dsputil.h"
26
#include "lpc.h"
27 27

  
28 28
#define NBLOCKS         4       ///< number of subblocks within a block
29 29
#define BLOCKSIZE       40      ///< subblock size in 16-bit words
......
34 34

  
35 35
typedef struct {
36 36
    AVCodecContext *avctx;
37
    DSPContext dsp;
37
    LPCContext lpc_ctx;
38 38

  
39 39
    unsigned int     old_energy;        ///< previous frame energy
40 40

  
libavcodec/ra144enc.c
29 29

  
30 30
#include "avcodec.h"
31 31
#include "put_bits.h"
32
#include "lpc.h"
33 32
#include "celp_filters.h"
34 33
#include "ra144.h"
35 34

  
......
53 52
    ractx->lpc_coef[0] = ractx->lpc_tables[0];
54 53
    ractx->lpc_coef[1] = ractx->lpc_tables[1];
55 54
    ractx->avctx = avctx;
56
    dsputil_init(&ractx->dsp, avctx);
55
    ff_lpc_init(&ractx->lpc_ctx);
57 56
    return 0;
58 57
}
59 58

  
......
451 450
    energy = ff_energy_tab[quantize(ff_t_sqrt(energy >> 5) >> 10, ff_energy_tab,
452 451
                                    32)];
453 452

  
454
    ff_lpc_calc_coefs(&ractx->dsp, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
453
    ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
455 454
                      LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON,
456 455
                      0, ORDER_METHOD_EST, 12, 0);
457 456
    for (i = 0; i < LPC_ORDER; i++)
libavcodec/x86/dsputil_mmx.h
200 200
void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
201 201
void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd);
202 202

  
203
void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
204
                                   double *autoc);
205

  
206 203
void ff_mmx_idct(DCTELEM *block);
207 204
void ff_mmxext_idct(DCTELEM *block);
208 205

  
libavcodec/x86/dsputilenc_mmx.c
1166 1166
#endif
1167 1167
        }
1168 1168

  
1169
        if (CONFIG_LPC && mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
1170
            c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2;
1171
        }
1172

  
1173 1169
#if HAVE_SSSE3
1174 1170
        if(mm_flags & AV_CPU_FLAG_SSSE3){
1175 1171
            if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
libavcodec/x86/lpc_mmx.c
20 20
 */
21 21

  
22 22
#include "libavutil/x86_cpu.h"
23
#include "dsputil_mmx.h"
23
#include "libavutil/cpu.h"
24
#include "libavcodec/lpc.h"
24 25

  
25 26
static void apply_welch_window_sse2(const int32_t *data, int len, double *w_data)
26 27
{
......
68 69
#undef WELCH
69 70
}
70 71

  
71
void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
72
static void lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
72 73
                                   double *autoc)
73 74
{
74 75
    double tmp[len + lag + 2];
......
141 142
        }
142 143
    }
143 144
}
145

  
146
av_cold void ff_lpc_init_x86(LPCContext *c)
147
{
148
    int mm_flags = av_get_cpu_flags();
149

  
150
    if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
151
        c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
152
    }
153
}

Also available in: Unified diff