mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Move lpc_compute_autocorr() from DSPContext to a new struct LPCContext.
Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
50196a982b
commit
56f8952b25
@ -51,11 +51,11 @@ typedef struct RiceContext {
|
||||
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;
|
||||
@ -69,8 +69,8 @@ typedef struct AlacEncodeContext {
|
||||
int interlacing_leftweight;
|
||||
PutBitContext pbctx;
|
||||
RiceContext rc;
|
||||
LPCContext lpc[MAX_CHANNELS];
|
||||
DSPContext dspctx;
|
||||
AlacLPCContext lpc[MAX_CHANNELS];
|
||||
LPCContext lpc_ctx;
|
||||
AVCodecContext *avctx;
|
||||
} AlacEncodeContext;
|
||||
|
||||
@ -141,7 +141,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch)
|
||||
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,
|
||||
@ -237,7 +237,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s)
|
||||
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];
|
||||
@ -455,7 +455,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
|
||||
avctx->coded_frame->key_frame = 1;
|
||||
|
||||
s->avctx = avctx;
|
||||
dsputil_init(&s->dspctx, avctx);
|
||||
ff_lpc_init(&s->lpc_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,16 +33,16 @@
|
||||
#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
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "mathops.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "config.h"
|
||||
#include "lpc.h"
|
||||
#include "ac3dec.h"
|
||||
#include "vorbis.h"
|
||||
#include "png.h"
|
||||
@ -4430,9 +4429,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
|
||||
#endif
|
||||
#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;
|
||||
|
@ -374,8 +374,6 @@ typedef struct DSPContext {
|
||||
/* 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);
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "libavutil/md5.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "golomb.h"
|
||||
#include "lpc.h"
|
||||
#include "flac.h"
|
||||
@ -95,7 +94,7 @@ typedef struct FlacEncodeContext {
|
||||
FlacFrame frame;
|
||||
CompressionOptions options;
|
||||
AVCodecContext *avctx;
|
||||
DSPContext dsp;
|
||||
LPCContext lpc_ctx;
|
||||
struct AVMD5 *md5ctx;
|
||||
} FlacEncodeContext;
|
||||
|
||||
@ -217,7 +216,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
ff_lpc_init(&s->lpc_ctx);
|
||||
|
||||
if (avctx->sample_fmt != AV_SAMPLE_FMT_S16)
|
||||
return -1;
|
||||
@ -902,7 +901,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
|
||||
|
||||
/* 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);
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/lls.h"
|
||||
#include "dsputil.h"
|
||||
|
||||
#define LPC_USE_DOUBLE
|
||||
#include "lpc.h"
|
||||
@ -55,7 +54,7 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data)
|
||||
* 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;
|
||||
@ -162,7 +161,7 @@ static int estimate_best_order(double *ref, int min_order, int max_order)
|
||||
* 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,
|
||||
@ -236,3 +235,11 @@ int ff_lpc_calc_coefs(DSPContext *s,
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -36,18 +36,36 @@
|
||||
#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
|
||||
|
@ -23,7 +23,7 @@
|
||||
#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
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
typedef struct {
|
||||
AVCodecContext *avctx;
|
||||
DSPContext dsp;
|
||||
LPCContext lpc_ctx;
|
||||
|
||||
unsigned int old_energy; ///< previous frame energy
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "put_bits.h"
|
||||
#include "lpc.h"
|
||||
#include "celp_filters.h"
|
||||
#include "ra144.h"
|
||||
|
||||
@ -53,7 +52,7 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -451,7 +450,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame,
|
||||
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++)
|
||||
|
@ -200,9 +200,6 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx);
|
||||
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);
|
||||
|
||||
|
@ -1166,10 +1166,6 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
|
||||
#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)){
|
||||
|
@ -20,7 +20,8 @@
|
||||
*/
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -68,7 +69,7 @@ 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];
|
||||
@ -141,3 +142,12 @@ void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user