diff --git a/libavcodec/dca.c b/libavcodec/dca.c index ff44ec78dd..aa576253a6 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -879,17 +879,19 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, /* downmixing routines */ #define MIX_REAR1(samples, si1, rs, coef) \ - samples[i] += samples[si1] * coef[rs][0]; \ - samples[i+256] += samples[si1] * coef[rs][1]; + samples[i] += (samples[si1] - add_bias) * coef[rs][0]; \ + samples[i+256] += (samples[si1] - add_bias) * coef[rs][1]; #define MIX_REAR2(samples, si1, si2, rs, coef) \ - samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs+1][0]; \ - samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1]; + samples[i] += (samples[si1] - add_bias) * coef[rs][0] + (samples[si2] - add_bias) * coef[rs+1][0]; \ + samples[i+256] += (samples[si1] - add_bias) * coef[rs][1] + (samples[si2] - add_bias) * coef[rs+1][1]; #define MIX_FRONT3(samples, coef) \ - t = samples[i]; \ - samples[i] = t * coef[0][0] + samples[i+256] * coef[1][0] + samples[i+512] * coef[2][0]; \ - samples[i+256] = t * coef[0][1] + samples[i+256] * coef[1][1] + samples[i+512] * coef[2][1]; + t = samples[i+c] - add_bias; \ + u = samples[i+l] - add_bias; \ + v = samples[i+r] - add_bias; \ + samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0] + add_bias; \ + samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1] + add_bias; #define DOWNMIX_TO_STEREO(op1, op2) \ for (i = 0; i < 256; i++){ \ @@ -898,10 +900,12 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, } static void dca_downmix(float *samples, int srcfmt, - int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]) + int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], + const int8_t *channel_mapping, float add_bias) { + int c,l,r,sl,sr,s; int i; - float t; + float t, u, v; float coef[DCA_PRIM_CHANNELS_MAX][2]; for (i=0; iavctx->request_channels == 2 && s->prim_channels > 2) { - dca_downmix(s->samples, s->amode, s->downmix_coef); + dca_downmix(s->samples, s->amode, s->downmix_coef, s->channel_order_tab, s->add_bias); } /* Generate LFE samples for this subsubframe FIXME!!! */