# HG changeset patch # User ramiro # Date 1242401662 0 # Node ID d0fe5dc427f09048fd3633f61c258e714c254868 # Parent b8b9ff6fa077d382cb4b4d8d22c71fdd4484d611 mlp: Simplify adressing of state and coeffs arrays for both filters by making the arrays sequential. diff -r b8b9ff6fa077 -r d0fe5dc427f0 dsputil.h --- a/dsputil.h Fri May 15 15:30:43 2009 +0000 +++ b/dsputil.h Fri May 15 15:34:22 2009 +0000 @@ -476,8 +476,8 @@ void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); /* mlp/truehd functions */ - void (*mlp_filter_channel)(int32_t *firbuf, const int32_t *fircoeff, int firorder, - int32_t *iirbuf, const int32_t *iircoeff, int iirorder, + void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff, + int firorder, int iirorder, unsigned int filter_shift, int32_t mask, int blocksize, int32_t *sample_buffer); diff -r b8b9ff6fa077 -r d0fe5dc427f0 mlp.h --- a/mlp.h Fri May 15 15:30:43 2009 +0000 +++ b/mlp.h Fri May 15 15:34:22 2009 +0000 @@ -73,13 +73,13 @@ uint8_t order; ///< number of taps in filter uint8_t shift; ///< Right shift to apply to output of filter. - int32_t coeff[MAX_FIR_ORDER]; int32_t state[MAX_FIR_ORDER]; } FilterParams; /** sample data coding information */ typedef struct { FilterParams filter_params[NUM_FILTERS]; + int32_t coeff[NUM_FILTERS][MAX_FIR_ORDER]; int16_t huff_offset; ///< Offset to apply to residual values. int32_t sign_huff_offset; ///< sign/rounding-corrected version of huff_offset diff -r b8b9ff6fa077 -r d0fe5dc427f0 mlpdec.c --- a/mlpdec.c Fri May 15 15:30:43 2009 +0000 +++ b/mlpdec.c Fri May 15 15:34:22 2009 +0000 @@ -495,6 +495,7 @@ fp->order = order; if (order > 0) { + int32_t *fcoeff = m->channel_params[channel].coeff[filter]; int coeff_bits, coeff_shift; fp->shift = get_bits(gbp, 4); @@ -515,7 +516,7 @@ } for (i = 0; i < order; i++) - fp->coeff[i] = get_sbits(gbp, coeff_bits) << coeff_shift; + fcoeff[i] = get_sbits(gbp, coeff_bits) << coeff_shift; if (get_bits1(gbp)) { int state_bits, state_shift; @@ -718,10 +719,10 @@ unsigned int channel) { SubStream *s = &m->substream[substr]; - int32_t fir_state_buffer[MAX_BLOCKSIZE + MAX_FIR_ORDER]; - int32_t iir_state_buffer[MAX_BLOCKSIZE + MAX_IIR_ORDER]; - int32_t *firbuf = fir_state_buffer + MAX_BLOCKSIZE; - int32_t *iirbuf = iir_state_buffer + MAX_BLOCKSIZE; + const int32_t *fircoeff = m->channel_params[channel].coeff[FIR]; + int32_t state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER]; + int32_t *firbuf = state_buffer[FIR] + MAX_BLOCKSIZE; + int32_t *iirbuf = state_buffer[IIR] + MAX_BLOCKSIZE; FilterParams *fir = &m->channel_params[channel].filter_params[FIR]; FilterParams *iir = &m->channel_params[channel].filter_params[IIR]; unsigned int filter_shift = fir->shift; @@ -730,8 +731,8 @@ memcpy(firbuf, fir->state, MAX_FIR_ORDER * sizeof(int32_t)); memcpy(iirbuf, iir->state, MAX_IIR_ORDER * sizeof(int32_t)); - m->dsp.mlp_filter_channel(firbuf, fir->coeff, fir->order, - iirbuf, iir->coeff, iir->order, + m->dsp.mlp_filter_channel(firbuf, fircoeff, + fir->order, iir->order, filter_shift, mask, s->blocksize, &m->sample_buffer[s->blockpos][channel]); diff -r b8b9ff6fa077 -r d0fe5dc427f0 mlpdsp.c --- a/mlpdsp.c Fri May 15 15:30:43 2009 +0000 +++ b/mlpdsp.c Fri May 15 15:34:22 2009 +0000 @@ -22,11 +22,15 @@ #include "libavcodec/mlp.h" #include "dsputil.h" -static void ff_mlp_filter_channel(int32_t *firbuf, const int32_t *fircoeff, int firorder, - int32_t *iirbuf, const int32_t *iircoeff, int iirorder, +static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff, + int firorder, int iirorder, unsigned int filter_shift, int32_t mask, int blocksize, int32_t *sample_buffer) { + int32_t *firbuf = state; + int32_t *iirbuf = state + MAX_BLOCKSIZE + MAX_FIR_ORDER; + const int32_t *fircoeff = coeff; + const int32_t *iircoeff = coeff + MAX_FIR_ORDER; int i; for (i = 0; i < blocksize; i++) {