int rice_modifier;
} RiceContext;
-typedef struct LPCContext {
+typedef struct AlacLPCContext {
int lpc_order;
int lpc_coeff[ALAC_MAX_LPC_ORDER+1];
int lpc_quant;
-} LPCContext;
+} AlacLPCContext;
typedef struct AlacEncodeContext {
int compression_level;
int interlacing_leftweight;
PutBitContext pbctx;
RiceContext rc;
- LPCContext lpc[MAX_CHANNELS];
- DSPContext dspctx;
+ AlacLPCContext lpc[MAX_CHANNELS];
+ LPCContext lpc_ctx;
AVCodecContext *avctx;
} AlacEncodeContext;
s->lpc[ch].lpc_coeff[4] = 80;
s->lpc[ch].lpc_coeff[5] = -25;
} else {
- opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch],
+ opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, s->sample_buf[ch],
s->avctx->frame_size,
s->min_prediction_order,
s->max_prediction_order,
static void alac_linear_predictor(AlacEncodeContext *s, int ch)
{
int i;
- LPCContext lpc = s->lpc[ch];
+ AlacLPCContext lpc = s->lpc[ch];
if(lpc.lpc_order == 31) {
s->predictor_buf[0] = s->sample_buf[ch][0];
avctx->coded_frame->key_frame = 1;
s->avctx = avctx;
- dsputil_init(&s->dspctx, avctx);
+ ff_lpc_init(&s->lpc_ctx);
return 0;
}
#define Y_DC_SCALE 0xab4
#define C_DC_SCALE 0xab8
#define AC_PRED 0xae0
-#define BLOCK_LAST_INDEX 0x21c0
-#define INTER_SCANTAB_RASTER_END 0x23c0
-#define H263_AIC 0x2670
+#define BLOCK_LAST_INDEX 0x21bc
+#define INTER_SCANTAB_RASTER_END 0x23bc
+#define H263_AIC 0x2668
#elif defined(__APPLE__)
#define Y_DC_SCALE 0xa70
#define C_DC_SCALE 0xa74
#define AC_PRED 0xa9c
-#define BLOCK_LAST_INDEX 0x217c
-#define INTER_SCANTAB_RASTER_END 0x237c
-#define H263_AIC 0x2620
+#define BLOCK_LAST_INDEX 0x2178
+#define INTER_SCANTAB_RASTER_END 0x2378
+#define H263_AIC 0x261c
#endif
#endif
#include "mathops.h"
#include "mpegvideo.h"
#include "config.h"
-#include "lpc.h"
#include "ac3dec.h"
#include "vorbis.h"
#include "png.h"
#if CONFIG_AC3_DECODER
c->ac3_downmix = ff_ac3_downmix_c;
#endif
-#if CONFIG_LPC
- c->lpc_compute_autocorr = ff_lpc_compute_autocorr;
-#endif
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
/* assume len is a multiple of 4, and arrays are 16-byte aligned */
void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
- /* no alignment needed */
- void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
void (*vector_fmul)(float *dst, const float *src, int len);
void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
#include "libavutil/md5.h"
#include "avcodec.h"
#include "get_bits.h"
-#include "dsputil.h"
#include "golomb.h"
#include "lpc.h"
#include "flac.h"
FlacFrame frame;
CompressionOptions options;
AVCodecContext *avctx;
- DSPContext dsp;
+ LPCContext lpc_ctx;
struct AVMD5 *md5ctx;
} FlacEncodeContext;
s->avctx = avctx;
- dsputil_init(&s->dsp, avctx);
+ ff_lpc_init(&s->lpc_ctx);
if (avctx->sample_fmt != AV_SAMPLE_FMT_S16)
return -1;
/* LPC */
sub->type = FLAC_SUBFRAME_LPC;
- opt_order = ff_lpc_calc_coefs(&s->dsp, smp, n, min_order, max_order,
+ opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, smp, n, min_order, max_order,
s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type,
s->options.lpc_passes, omethod,
MAX_LPC_SHIFT, 0);
*/
#include "libavutil/lls.h"
-#include "dsputil.h"
#define LPC_USE_DOUBLE
#include "lpc.h"
* Calculate autocorrelation data from audio samples
* A Welch window function is applied before calculation.
*/
-void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
+static void lpc_compute_autocorr_c(const int32_t *data, int len, int lag,
double *autoc)
{
int i, j;
* 1 = LPC with coeffs determined by Levinson-Durbin recursion
* 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes.
*/
-int ff_lpc_calc_coefs(DSPContext *s,
+int ff_lpc_calc_coefs(LPCContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
return opt_order;
}
+
+av_cold void ff_lpc_init(LPCContext *s)
+{
+ s->lpc_compute_autocorr = lpc_compute_autocorr_c;
+
+ if (HAVE_MMX)
+ ff_lpc_init_x86(s);
+}
#define MAX_LPC_ORDER 32
+typedef struct LPCContext {
+ /**
+ * Perform autocorrelation on input samples with delay of 0 to lag.
+ * @param data input samples.
+ * no alignment needed.
+ * @param len number of input samples to process
+ * @param lag maximum delay to calculate
+ * @param autoc output autocorrelation coefficients.
+ * constraints: array size must be at least lag+1.
+ */
+ void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag,
+ double *autoc);
+} LPCContext;
+
+
/**
* Calculate LPC coefficients for multiple orders
*/
-int ff_lpc_calc_coefs(DSPContext *s,
+int ff_lpc_calc_coefs(LPCContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
enum AVLPCType lpc_type, int lpc_passes,
int omethod, int max_shift, int zero_shift);
-void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
- double *autoc);
+/**
+ * Initialize LPCContext.
+ */
+void ff_lpc_init(LPCContext *s);
+void ff_lpc_init_x86(LPCContext *s);
#ifdef LPC_USE_DOUBLE
#define LPC_TYPE double
#define AVCODEC_RA144_H
#include <stdint.h>
-#include "dsputil.h"
+#include "lpc.h"
#define NBLOCKS 4 ///< number of subblocks within a block
#define BLOCKSIZE 40 ///< subblock size in 16-bit words
typedef struct {
AVCodecContext *avctx;
- DSPContext dsp;
+ LPCContext lpc_ctx;
unsigned int old_energy; ///< previous frame energy
#include "avcodec.h"
#include "put_bits.h"
-#include "lpc.h"
#include "celp_filters.h"
#include "ra144.h"
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
ractx->avctx = avctx;
- dsputil_init(&ractx->dsp, avctx);
+ ff_lpc_init(&ractx->lpc_ctx);
return 0;
}
energy = ff_energy_tab[quantize(ff_t_sqrt(energy >> 5) >> 10, ff_energy_tab,
32)];
- ff_lpc_calc_coefs(&ractx->dsp, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
+ ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON,
0, ORDER_METHOD_EST, 12, 0);
for (i = 0; i < LPC_ORDER; i++)
void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
- double *autoc);
-
void ff_mmx_idct(DCTELEM *block);
void ff_mmxext_idct(DCTELEM *block);
#endif
}
- if (CONFIG_LPC && mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
- c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2;
- }
-
#if HAVE_SSSE3
if(mm_flags & AV_CPU_FLAG_SSSE3){
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
*/
#include "libavutil/x86_cpu.h"
-#include "dsputil_mmx.h"
+#include "libavutil/cpu.h"
+#include "libavcodec/lpc.h"
static void apply_welch_window_sse2(const int32_t *data, int len, double *w_data)
{
#undef WELCH
}
-void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
+static void lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
double *autoc)
{
double tmp[len + lag + 2];
}
}
}
+
+av_cold void ff_lpc_init_x86(LPCContext *c)
+{
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
+ c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
+ }
+}