X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fac3dec.c;h=82091bc6e3f4f52fcc70d7410fcbf70e1322c47f;hb=e4e8632aaf0d04145fc7133c271adbbbaefbc652;hp=56024bb7a0f738bbc064a3f0c484d2793df6a0f3;hpb=25dcd1823c6fd0be6b41a36c4909a2aa78e8096f;p=ffmpeg diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 56024bb7a0f..82091bc6e3f 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -412,20 +412,26 @@ static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, */ static void calc_transform_coeffs_cpl(AC3DecodeContext *s) { - int i, j, ch, bnd; - - i = s->start_freq[CPL_CH]; - for(bnd=0; bndnum_cpl_bands; bnd++) { - for (j = 0; j < s->cpl_band_sizes[bnd]; j++,i++) { - for(ch=1; ch<=s->fbw_channels; ch++) { - if(s->channel_in_cpl[ch]) { - s->fixed_coeffs[ch][i] = ((int64_t)s->fixed_coeffs[CPL_CH][i] * - (int64_t)s->cpl_coords[ch][bnd]) >> 23; - if (ch == 2 && s->phase_flags[bnd]) - s->fixed_coeffs[ch][i] = -s->fixed_coeffs[ch][i]; + int bin, band, ch; + + bin = s->start_freq[CPL_CH]; + for (band = 0; band < s->num_cpl_bands; band++) { + int band_start = bin; + int band_end = bin + s->cpl_band_sizes[band]; + for (ch = 1; ch <= s->fbw_channels; ch++) { + if (s->channel_in_cpl[ch]) { + int64_t cpl_coord = s->cpl_coords[ch][band]; + for (bin = band_start; bin < band_end; bin++) { + s->fixed_coeffs[ch][bin] = ((int64_t)s->fixed_coeffs[CPL_CH][bin] * + cpl_coord) >> 23; + } + if (ch == 2 && s->phase_flags[band]) { + for (bin = band_start; bin < band_end; bin++) + s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin]; } } } + bin = band_end; } } @@ -462,7 +468,7 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma switch(bap){ case 0: if (dither) - mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; + mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; else mantissa = 0; break; @@ -598,7 +604,6 @@ static void do_rematrixing(AC3DecodeContext *s) { int bnd, i; int end, bndend; - int tmp0, tmp1; end = FFMIN(s->end_freq[1], s->end_freq[2]); @@ -606,10 +611,9 @@ static void do_rematrixing(AC3DecodeContext *s) if(s->rematrixing_flags[bnd]) { bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]); for(i=ff_ac3_rematrix_band_tab[bnd]; ifixed_coeffs[1][i]; - tmp1 = s->fixed_coeffs[2][i]; - s->fixed_coeffs[1][i] = tmp0 + tmp1; - s->fixed_coeffs[2][i] = tmp0 - tmp1; + int tmp0 = s->fixed_coeffs[1][i]; + s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i]; + s->fixed_coeffs[2][i] = tmp0 - s->fixed_coeffs[2][i]; } } } @@ -936,8 +940,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) for(bnd=0; bndnum_rematrixing_bands; bnd++) s->rematrixing_flags[bnd] = get_bits1(gbc); } else if (!blk) { - av_log(s->avctx, AV_LOG_ERROR, "new rematrixing strategy must be present in block 0\n"); - return -1; + av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n"); + s->num_rematrixing_bands = 0; } } @@ -1163,7 +1167,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) for(ch=1; ch<=s->channels; ch++) { float gain = s->mul_bias / 4194304.0f; if(s->channel_mode == AC3_CHMODE_DUALMONO) { - gain *= s->dynamic_range[ch-1]; + gain *= s->dynamic_range[2-ch]; } else { gain *= s->dynamic_range[0]; }