libavcodec/ac3dec.c:1387: error: Buffer Overrun L3
  Offset: [-1, +oo] Size: 6 by call to `decode_audio_block`.

libavcodec/ac3dec.c:1386:10: Assignment
1384.         output[ch] = s->output[ch];
1385.     }
1386.     for (blk = 0; blk < s->num_blocks; blk++) {
               ^
1387.         if (!err && decode_audio_block(s, blk)) {
1388.             av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");

libavcodec/ac3dec.c:1387:21: Call
1385.     }
1386.     for (blk = 0; blk < s->num_blocks; blk++) {
1387.         if (!err && decode_audio_block(s, blk)) {
                          ^
1388.             av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
1389.             err = 1;

libavcodec/ac3dec.c:719:1: <Offset trace>
717.  * Decode a single audio block from the AC-3 bitstream.
718.  */
719. static int decode_audio_block(AC3DecodeContext *s, int blk)
     ^
720. {
721.     int fbw_channels = s->fbw_channels;

libavcodec/ac3dec.c:719:1: Parameter `blk`
  717.  * Decode a single audio block from the AC-3 bitstream.
  718.  */
  719. static int decode_audio_block(AC3DecodeContext *s, int blk)
       ^
  720. {
  721.     int fbw_channels = s->fbw_channels;

libavcodec/ac3dec.c:719:1: <Length trace>
717.  * Decode a single audio block from the AC-3 bitstream.
718.  */
719. static int decode_audio_block(AC3DecodeContext *s, int blk)
     ^
720. {
721.     int fbw_channels = s->fbw_channels;

libavcodec/ac3dec.c:719:1: Parameter `s->cpl_in_use[*]`
  717.  * Decode a single audio block from the AC-3 bitstream.
  718.  */
  719. static int decode_audio_block(AC3DecodeContext *s, int blk)
       ^
  720. {
  721.     int fbw_channels = s->fbw_channels;

libavcodec/ac3dec.c:926:34: Array access: Offset: [-1, +oo] Size: 6 by call to `decode_audio_block` 
  924.             return -1;
  925.         } else {
  926.             s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
                                        ^
  927.         }
  928.     }

static int decode_audio_block(AC3DecodeContext *s, int blk)
{
    int fbw_channels = s->fbw_channels;
    int channel_mode = s->channel_mode;
    int i, bnd, seg, ch;
    int different_transforms;
    int downmix_output;
    int cpl_in_use;
    GetBitContext *gbc = &s->gbc;
    uint8_t bit_alloc_stages[AC3_MAX_CHANNELS] = { 0 };
    different_transforms = 0;
    if (s->block_switch_syntax) {
        for (ch = 1; ch <= fbw_channels; ch++) {
            s->block_switch[ch] = get_bits1(gbc);
            if (ch > 1 && s->block_switch[ch] != s->block_switch[1])
                different_transforms = 1;
        }
    }
    if (s->dither_flag_syntax) {
        for (ch = 1; ch <= fbw_channels; ch++) {
            s->dither_flag[ch] = get_bits1(gbc);
        }
    }
    i = !s->channel_mode;
    do {
        if (get_bits1(gbc)) {
            s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)] - 1.0) *
                                  s->drc_scale) + 1.0;
        } else if (blk == 0) {
            s->dynamic_range[i] = 1.0f;
        }
    } while (i--);
    if (s->eac3 && (!blk || get_bits1(gbc))) {
        s->spx_in_use = get_bits1(gbc);
        if (s->spx_in_use) {
            int dst_start_freq, dst_end_freq, src_start_freq,
                start_subband, end_subband;
            if (s->channel_mode == AC3_CHMODE_MONO) {
                s->channel_uses_spx[1] = 1;
            } else {
                for (ch = 1; ch <= fbw_channels; ch++)
                    s->channel_uses_spx[ch] = get_bits1(gbc);
            }
            dst_start_freq = get_bits(gbc, 2);
            start_subband  = get_bits(gbc, 3) + 2;
            if (start_subband > 7)
                start_subband += start_subband - 7;
            end_subband    = get_bits(gbc, 3) + 5;
            if (end_subband   > 7)
                end_subband   += end_subband   - 7;
            dst_start_freq = dst_start_freq * 12 + 25;
            src_start_freq = start_subband  * 12 + 25;
            dst_end_freq   = end_subband    * 12 + 25;
            if (start_subband >= end_subband) {
                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
                       "range (%d >= %d)\n", start_subband, end_subband);
                return -1;
            }
            if (dst_start_freq >= src_start_freq) {
                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
                       "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
                return -1;
            }
            s->spx_dst_start_freq = dst_start_freq;
            s->spx_src_start_freq = src_start_freq;
            s->spx_dst_end_freq   = dst_end_freq;
            decode_band_structure(gbc, blk, s->eac3, 0,
                                  start_subband, end_subband,
                                  ff_eac3_default_spx_band_struct,
                                  &s->num_spx_bands,
                                  s->spx_band_sizes);
        } else {
            for (ch = 1; ch <= fbw_channels; ch++) {
                s->channel_uses_spx[ch] = 0;
                s->first_spx_coords[ch] = 1;
            }
        }
    }
    if (s->spx_in_use) {
        for (ch = 1; ch <= fbw_channels; ch++) {
            if (s->channel_uses_spx[ch]) {
                if (s->first_spx_coords[ch] || get_bits1(gbc)) {
                    float spx_blend;
                    int bin, master_spx_coord;
                    s->first_spx_coords[ch] = 0;
                    spx_blend = get_bits(gbc, 5) * (1.0f/32);
                    master_spx_coord = get_bits(gbc, 2) * 3;
                    bin = s->spx_src_start_freq;
                    for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
                        int bandsize;
                        int spx_coord_exp, spx_coord_mant;
                        float nratio, sblend, nblend, spx_coord;
                        bandsize = s->spx_band_sizes[bnd];
                        nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend;
                        nratio = av_clipf(nratio, 0.0f, 1.0f);
                        nblend = sqrtf(3.0f * nratio);
                        sblend = sqrtf(1.0f - nratio);
                        bin += bandsize;
                        spx_coord_exp  = get_bits(gbc, 4);
                        spx_coord_mant = get_bits(gbc, 2);
                        if (spx_coord_exp == 15) spx_coord_mant <<= 1;
                        else                     spx_coord_mant += 4;
                        spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
                        spx_coord = spx_coord_mant * (1.0f / (1 << 23));
                        s->spx_noise_blend [ch][bnd] = nblend * spx_coord;
                        s->spx_signal_blend[ch][bnd] = sblend * spx_coord;
                    }
                }
            } else {
                s->first_spx_coords[ch] = 1;
            }
        }
    }
    if (s->eac3 ? s->cpl_strategy_exists[blk] : get_bits1(gbc)) {
        memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
        if (!s->eac3)
            s->cpl_in_use[blk] = get_bits1(gbc);
        if (s->cpl_in_use[blk]) {
            int cpl_start_subband, cpl_end_subband;
            if (channel_mode < AC3_CHMODE_STEREO) {
                av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
                return -1;
            }
            if (s->eac3 && get_bits1(gbc)) {
                av_log_missing_feature(s->avctx, "Enhanced coupling", 1);
                return AVERROR_PATCHWELCOME;
            }
            if (s->eac3 && s->channel_mode == AC3_CHMODE_STEREO) {
                s->channel_in_cpl[1] = 1;
                s->channel_in_cpl[2] = 1;
            } else {
                for (ch = 1; ch <= fbw_channels; ch++)
                    s->channel_in_cpl[ch] = get_bits1(gbc);
            }
            if (channel_mode == AC3_CHMODE_STEREO)
                s->phase_flags_in_use = get_bits1(gbc);
            cpl_start_subband = get_bits(gbc, 4);
            cpl_end_subband = s->spx_in_use ? (s->spx_src_start_freq - 37) / 12 :
                                              get_bits(gbc, 4) + 3;
            if (cpl_start_subband >= cpl_end_subband) {
                av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
                       cpl_start_subband, cpl_end_subband);
                return -1;
            }
            s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
            s->end_freq[CPL_CH]   = cpl_end_subband   * 12 + 37;
            decode_band_structure(gbc, blk, s->eac3, 0, cpl_start_subband,
                                  cpl_end_subband,
                                  ff_eac3_default_cpl_band_struct,
                                  &s->num_cpl_bands, s->cpl_band_sizes);
        } else {
            for (ch = 1; ch <= fbw_channels; ch++) {
                s->channel_in_cpl[ch] = 0;
                s->first_cpl_coords[ch] = 1;
            }
            s->first_cpl_leak = s->eac3;
            s->phase_flags_in_use = 0;
        }
    } else if (!s->eac3) {
        if (!blk) {
            av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
                   "be present in block 0\n");
            return -1;
        } else {
            s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
        }
    }
    cpl_in_use = s->cpl_in_use[blk];
    if (cpl_in_use) {
        int cpl_coords_exist = 0;
        for (ch = 1; ch <= fbw_channels; ch++) {
            if (s->channel_in_cpl[ch]) {
                if ((s->eac3 && s->first_cpl_coords[ch]) || get_bits1(gbc)) {
                    int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
                    s->first_cpl_coords[ch] = 0;
                    cpl_coords_exist = 1;
                    master_cpl_coord = 3 * get_bits(gbc, 2);
                    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
                        cpl_coord_exp = get_bits(gbc, 4);
                        cpl_coord_mant = get_bits(gbc, 4);
                        if (cpl_coord_exp == 15)
                            s->cpl_coords[ch][bnd] = cpl_coord_mant << 22;
                        else
                            s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;
                        s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
                    }
                } else if (!blk) {
                    av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
                           "be present in block 0\n");
                    return -1;
                }
            } else {
                s->first_cpl_coords[ch] = 1;
            }
        }
        if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) {
            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
                s->phase_flags[bnd] = s->phase_flags_in_use? get_bits1(gbc) : 0;
            }
        }
    }
    if (channel_mode == AC3_CHMODE_STEREO) {
        if ((s->eac3 && !blk) || get_bits1(gbc)) {
            s->num_rematrixing_bands = 4;
            if (cpl_in_use && s->start_freq[CPL_CH] <= 61) {
                s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37);
            } else if (s->spx_in_use && s->spx_src_start_freq <= 61) {
                s->num_rematrixing_bands--;
            }
            for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++)
                s->rematrixing_flags[bnd] = get_bits1(gbc);
        } else if (!blk) {
            av_log(s->avctx, AV_LOG_WARNING, "Warning: "
                   "new rematrixing strategy not present in block 0\n");
            s->num_rematrixing_bands = 0;
        }
    }
    for (ch = !cpl_in_use; ch <= s->channels; ch++) {
        if (!s->eac3)
            s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch));
        if (s->exp_strategy[blk][ch] != EXP_REUSE)
            bit_alloc_stages[ch] = 3;
    }
    for (ch = 1; ch <= fbw_channels; ch++) {
        s->start_freq[ch] = 0;
        if (s->exp_strategy[blk][ch] != EXP_REUSE) {
            int group_size;
            int prev = s->end_freq[ch];
            if (s->channel_in_cpl[ch])
                s->end_freq[ch] = s->start_freq[CPL_CH];
            else if (s->channel_uses_spx[ch])
                s->end_freq[ch] = s->spx_src_start_freq;
            else {
                int bandwidth_code = get_bits(gbc, 6);
                if (bandwidth_code > 60) {
                    av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code);
                    return -1;
                }
                s->end_freq[ch] = bandwidth_code * 3 + 73;
            }
            group_size = 3 << (s->exp_strategy[blk][ch] - 1);
            s->num_exp_groups[ch] = (s->end_freq[ch] + group_size-4) / group_size;
            if (blk > 0 && s->end_freq[ch] != prev)
                memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
        }
    }
    if (cpl_in_use && s->exp_strategy[blk][CPL_CH] != EXP_REUSE) {
        s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) /
                                    (3 << (s->exp_strategy[blk][CPL_CH] - 1));
    }
    for (ch = !cpl_in_use; ch <= s->channels; ch++) {
        if (s->exp_strategy[blk][ch] != EXP_REUSE) {
            s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
            if (decode_exponents(gbc, s->exp_strategy[blk][ch],
                                 s->num_exp_groups[ch], s->dexps[ch][0],
                                 &s->dexps[ch][s->start_freq[ch]+!!ch])) {
                av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
                return -1;
            }
            if (ch != CPL_CH && ch != s->lfe_ch)
                skip_bits(gbc, 2);
        }
    }
    if (s->bit_allocation_syntax) {
        if (get_bits1(gbc)) {
            s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;
            s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;
            s->bit_alloc_params.slow_gain  = ff_ac3_slow_gain_tab[get_bits(gbc, 2)];
            s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)];
            s->bit_alloc_params.floor  = ff_ac3_floor_tab[get_bits(gbc, 3)];
            for (ch = !cpl_in_use; ch <= s->channels; ch++)
                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
        } else if (!blk) {
            av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
                   "be present in block 0\n");
            return -1;
        }
    }
    if (!s->eac3 || !blk) {
        if (s->snr_offset_strategy && get_bits1(gbc)) {
            int snr = 0;
            int csnr;
            csnr = (get_bits(gbc, 6) - 15) << 4;
            for (i = ch = !cpl_in_use; ch <= s->channels; ch++) {
                if (ch == i || s->snr_offset_strategy == 2)
                    snr = (csnr + get_bits(gbc, 4)) << 2;
                if (blk && s->snr_offset[ch] != snr) {
                    bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1);
                }
                s->snr_offset[ch] = snr;
                if (!s->eac3) {
                    int prev = s->fast_gain[ch];
                    s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
                    if (blk && prev != s->fast_gain[ch])
                        bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
                }
            }
        } else if (!s->eac3 && !blk) {
            av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n");
            return -1;
        }
    }
    if (s->fast_gain_syntax && get_bits1(gbc)) {
        for (ch = !cpl_in_use; ch <= s->channels; ch++) {
            int prev = s->fast_gain[ch];
            s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
            if (blk && prev != s->fast_gain[ch])
                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
        }
    } else if (s->eac3 && !blk) {
        for (ch = !cpl_in_use; ch <= s->channels; ch++)
            s->fast_gain[ch] = ff_ac3_fast_gain_tab[4];
    }
    if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && get_bits1(gbc)) {
        skip_bits(gbc, 10);
    }
    if (cpl_in_use) {
        if (s->first_cpl_leak || get_bits1(gbc)) {
            int fl = get_bits(gbc, 3);
            int sl = get_bits(gbc, 3);
            if (blk && (fl != s->bit_alloc_params.cpl_fast_leak ||
                sl != s->bit_alloc_params.cpl_slow_leak)) {
                bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);
            }
            s->bit_alloc_params.cpl_fast_leak = fl;
            s->bit_alloc_params.cpl_slow_leak = sl;
        } else if (!s->eac3 && !blk) {
            av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
                   "be present in block 0\n");
            return -1;
        }
        s->first_cpl_leak = 0;
    }
    if (s->dba_syntax && get_bits1(gbc)) {
        for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
            s->dba_mode[ch] = get_bits(gbc, 2);
            if (s->dba_mode[ch] == DBA_RESERVED) {
                av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
                return -1;
            }
            bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
        }
        for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
            if (s->dba_mode[ch] == DBA_NEW) {
                s->dba_nsegs[ch] = get_bits(gbc, 3) + 1;
                for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {
                    s->dba_offsets[ch][seg] = get_bits(gbc, 5);
                    s->dba_lengths[ch][seg] = get_bits(gbc, 4);
                    s->dba_values[ch][seg]  = get_bits(gbc, 3);
                }
                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
            }
        }
    } else if (blk == 0) {
        for (ch = 0; ch <= s->channels; ch++) {
            s->dba_mode[ch] = DBA_NONE;
        }
    }
    for (ch = !cpl_in_use; ch <= s->channels; ch++) {
        if (bit_alloc_stages[ch] > 2) {
            ff_ac3_bit_alloc_calc_psd(s->dexps[ch],
                                      s->start_freq[ch], s->end_freq[ch],
                                      s->psd[ch], s->band_psd[ch]);
        }
        if (bit_alloc_stages[ch] > 1) {
            if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch],
                                           s->start_freq[ch],  s->end_freq[ch],
                                           s->fast_gain[ch],   (ch == s->lfe_ch),
                                           s->dba_mode[ch],    s->dba_nsegs[ch],
                                           s->dba_offsets[ch], s->dba_lengths[ch],
                                           s->dba_values[ch],  s->mask[ch])) {
                av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
                return -1;
            }
        }
        if (bit_alloc_stages[ch] > 0) {
            const uint8_t *bap_tab = s->channel_uses_aht[ch] ?
                                     ff_eac3_hebap_tab : ff_ac3_bap_tab;
            s->ac3dsp.bit_alloc_calc_bap(s->mask[ch], s->psd[ch],
                                      s->start_freq[ch], s->end_freq[ch],
                                      s->snr_offset[ch],
                                      s->bit_alloc_params.floor,
                                      bap_tab, s->bap[ch]);
        }
    }
    if (s->skip_syntax && get_bits1(gbc)) {
        int skipl = get_bits(gbc, 9);
        while (skipl--)
            skip_bits(gbc, 8);
    }
    decode_transform_coeffs(s, blk);
    if (s->channel_mode == AC3_CHMODE_STEREO)
        do_rematrixing(s);
    for (ch = 1; ch <= s->channels; ch++) {
        float gain = 1.0 / 4194304.0f;
        if (s->channel_mode == AC3_CHMODE_DUALMONO) {
            gain *= s->dynamic_range[2 - ch];
        } else {
            gain *= s->dynamic_range[0];
        }
        s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch],
                                               s->fixed_coeffs[ch], gain, 256);
    }
    if (s->spx_in_use && CONFIG_EAC3_DECODER) {
        ff_eac3_apply_spectral_extension(s);
    }
    downmix_output = s->channels != s->out_channels &&
                     !((s->output_mode & AC3_OUTPUT_LFEON) &&
                     s->fbw_channels == s->out_channels);
    if (different_transforms) {
        if (s->downmixed) {
            s->downmixed = 0;
            ac3_upmix_delay(s);
        }
        do_imdct(s, s->channels);
        if (downmix_output) {
            s->ac3dsp.downmix(s->outptr, s->downmix_coeffs,
                              s->out_channels, s->fbw_channels, 256);
        }
    } else {
        if (downmix_output) {
            s->ac3dsp.downmix(s->xcfptr + 1, s->downmix_coeffs,
                              s->out_channels, s->fbw_channels, 256);
        }
        if (downmix_output && !s->downmixed) {
            s->downmixed = 1;
            s->ac3dsp.downmix(s->dlyptr, s->downmix_coeffs, s->out_channels,
                              s->fbw_channels, 128);
        }
        do_imdct(s, s->out_channels);
    }
    return 0;
}
['static int ac3_decode_frame(AVCodecContext * avctx, void *data,\n                            int *got_frame_ptr, AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    AC3DecodeContext *s = avctx->priv_data;\n    int blk, ch, err, ret;\n    const uint8_t *channel_map;\n    const float *output[AC3_MAX_CHANNELS];\n    if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {\n        int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;\n        s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);\n    } else\n        memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));\n    buf = s->input_buffer;\n    init_get_bits(&s->gbc, buf, buf_size * 8);\n    err = parse_frame_header(s);\n    if (err) {\n        switch (err) {\n        case AAC_AC3_PARSE_ERROR_SYNC:\n            av_log(avctx, AV_LOG_ERROR, "frame sync error\\n");\n            return -1;\n        case AAC_AC3_PARSE_ERROR_BSID:\n            av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\\n");\n            break;\n        case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:\n            av_log(avctx, AV_LOG_ERROR, "invalid sample rate\\n");\n            break;\n        case AAC_AC3_PARSE_ERROR_FRAME_SIZE:\n            av_log(avctx, AV_LOG_ERROR, "invalid frame size\\n");\n            break;\n        case AAC_AC3_PARSE_ERROR_FRAME_TYPE:\n            if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {\n                av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "\n                       "skipping frame\\n");\n                *got_frame_ptr = 0;\n                return s->frame_size;\n            } else {\n                av_log(avctx, AV_LOG_ERROR, "invalid frame type\\n");\n            }\n            break;\n        default:\n            av_log(avctx, AV_LOG_ERROR, "invalid header\\n");\n            break;\n        }\n    } else {\n        if (s->frame_size > buf_size) {\n            av_log(avctx, AV_LOG_ERROR, "incomplete frame\\n");\n            err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;\n        } else if (avctx->err_recognition & AV_EF_CRCCHECK) {\n            if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],\n                       s->frame_size - 2)) {\n                av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\\n");\n                err = AAC_AC3_PARSE_ERROR_CRC;\n            }\n        }\n    }\n    if (!err) {\n        avctx->sample_rate = s->sample_rate;\n        avctx->bit_rate    = s->bit_rate;\n        s->out_channels = s->channels;\n        s->output_mode  = s->channel_mode;\n        if (s->lfe_on)\n            s->output_mode |= AC3_OUTPUT_LFEON;\n        if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&\n                avctx->request_channels < s->channels) {\n            s->out_channels = avctx->request_channels;\n            s->output_mode  = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;\n            s->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];\n        }\n        avctx->channels       = s->out_channels;\n        avctx->channel_layout = s->channel_layout;\n        if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&\n                s->fbw_channels == s->out_channels)) {\n            set_downmix_coeffs(s);\n        }\n    } else if (!s->out_channels) {\n        s->out_channels = avctx->channels;\n        if (s->out_channels < s->channels)\n            s->output_mode  = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;\n    }\n    avctx->audio_service_type = s->bitstream_mode;\n    if (s->bitstream_mode == 0x7 && s->channels > 1)\n        avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;\n    avctx->channels = s->out_channels;\n    s->frame.nb_samples = s->num_blocks * 256;\n    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];\n    for (ch = 0; ch < s->channels; ch++) {\n        if (ch < s->out_channels)\n            s->outptr[channel_map[ch]] = (float *)s->frame.data[ch];\n        else\n            s->outptr[ch] = s->output[ch];\n        output[ch] = s->output[ch];\n    }\n    for (blk = 0; blk < s->num_blocks; blk++) {\n        if (!err && decode_audio_block(s, blk)) {\n            av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\\n");\n            err = 1;\n        }\n        if (err)\n            for (ch = 0; ch < s->out_channels; ch++)\n                memcpy(s->outptr[channel_map[ch]], output[ch], 1024);\n        for (ch = 0; ch < s->out_channels; ch++) {\n            output[ch] = s->outptr[channel_map[ch]];\n            s->outptr[channel_map[ch]] += AC3_BLOCK_SIZE;\n        }\n    }\n    for (ch = 0; ch < s->out_channels; ch++)\n        memcpy(s->output[ch], output[ch], 1024);\n    *got_frame_ptr   = 1;\n    *(AVFrame *)data = s->frame;\n    return FFMIN(buf_size, s->frame_size);\n}', 'static int decode_audio_block(AC3DecodeContext *s, int blk)\n{\n    int fbw_channels = s->fbw_channels;\n    int channel_mode = s->channel_mode;\n    int i, bnd, seg, ch;\n    int different_transforms;\n    int downmix_output;\n    int cpl_in_use;\n    GetBitContext *gbc = &s->gbc;\n    uint8_t bit_alloc_stages[AC3_MAX_CHANNELS] = { 0 };\n    different_transforms = 0;\n    if (s->block_switch_syntax) {\n        for (ch = 1; ch <= fbw_channels; ch++) {\n            s->block_switch[ch] = get_bits1(gbc);\n            if (ch > 1 && s->block_switch[ch] != s->block_switch[1])\n                different_transforms = 1;\n        }\n    }\n    if (s->dither_flag_syntax) {\n        for (ch = 1; ch <= fbw_channels; ch++) {\n            s->dither_flag[ch] = get_bits1(gbc);\n        }\n    }\n    i = !s->channel_mode;\n    do {\n        if (get_bits1(gbc)) {\n            s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)] - 1.0) *\n                                  s->drc_scale) + 1.0;\n        } else if (blk == 0) {\n            s->dynamic_range[i] = 1.0f;\n        }\n    } while (i--);\n    if (s->eac3 && (!blk || get_bits1(gbc))) {\n        s->spx_in_use = get_bits1(gbc);\n        if (s->spx_in_use) {\n            int dst_start_freq, dst_end_freq, src_start_freq,\n                start_subband, end_subband;\n            if (s->channel_mode == AC3_CHMODE_MONO) {\n                s->channel_uses_spx[1] = 1;\n            } else {\n                for (ch = 1; ch <= fbw_channels; ch++)\n                    s->channel_uses_spx[ch] = get_bits1(gbc);\n            }\n            dst_start_freq = get_bits(gbc, 2);\n            start_subband  = get_bits(gbc, 3) + 2;\n            if (start_subband > 7)\n                start_subband += start_subband - 7;\n            end_subband    = get_bits(gbc, 3) + 5;\n            if (end_subband   > 7)\n                end_subband   += end_subband   - 7;\n            dst_start_freq = dst_start_freq * 12 + 25;\n            src_start_freq = start_subband  * 12 + 25;\n            dst_end_freq   = end_subband    * 12 + 25;\n            if (start_subband >= end_subband) {\n                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "\n                       "range (%d >= %d)\\n", start_subband, end_subband);\n                return -1;\n            }\n            if (dst_start_freq >= src_start_freq) {\n                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "\n                       "copy start bin (%d >= %d)\\n", dst_start_freq, src_start_freq);\n                return -1;\n            }\n            s->spx_dst_start_freq = dst_start_freq;\n            s->spx_src_start_freq = src_start_freq;\n            s->spx_dst_end_freq   = dst_end_freq;\n            decode_band_structure(gbc, blk, s->eac3, 0,\n                                  start_subband, end_subband,\n                                  ff_eac3_default_spx_band_struct,\n                                  &s->num_spx_bands,\n                                  s->spx_band_sizes);\n        } else {\n            for (ch = 1; ch <= fbw_channels; ch++) {\n                s->channel_uses_spx[ch] = 0;\n                s->first_spx_coords[ch] = 1;\n            }\n        }\n    }\n    if (s->spx_in_use) {\n        for (ch = 1; ch <= fbw_channels; ch++) {\n            if (s->channel_uses_spx[ch]) {\n                if (s->first_spx_coords[ch] || get_bits1(gbc)) {\n                    float spx_blend;\n                    int bin, master_spx_coord;\n                    s->first_spx_coords[ch] = 0;\n                    spx_blend = get_bits(gbc, 5) * (1.0f/32);\n                    master_spx_coord = get_bits(gbc, 2) * 3;\n                    bin = s->spx_src_start_freq;\n                    for (bnd = 0; bnd < s->num_spx_bands; bnd++) {\n                        int bandsize;\n                        int spx_coord_exp, spx_coord_mant;\n                        float nratio, sblend, nblend, spx_coord;\n                        bandsize = s->spx_band_sizes[bnd];\n                        nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend;\n                        nratio = av_clipf(nratio, 0.0f, 1.0f);\n                        nblend = sqrtf(3.0f * nratio);\n                        sblend = sqrtf(1.0f - nratio);\n                        bin += bandsize;\n                        spx_coord_exp  = get_bits(gbc, 4);\n                        spx_coord_mant = get_bits(gbc, 2);\n                        if (spx_coord_exp == 15) spx_coord_mant <<= 1;\n                        else                     spx_coord_mant += 4;\n                        spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);\n                        spx_coord = spx_coord_mant * (1.0f / (1 << 23));\n                        s->spx_noise_blend [ch][bnd] = nblend * spx_coord;\n                        s->spx_signal_blend[ch][bnd] = sblend * spx_coord;\n                    }\n                }\n            } else {\n                s->first_spx_coords[ch] = 1;\n            }\n        }\n    }\n    if (s->eac3 ? s->cpl_strategy_exists[blk] : get_bits1(gbc)) {\n        memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);\n        if (!s->eac3)\n            s->cpl_in_use[blk] = get_bits1(gbc);\n        if (s->cpl_in_use[blk]) {\n            int cpl_start_subband, cpl_end_subband;\n            if (channel_mode < AC3_CHMODE_STEREO) {\n                av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\\n");\n                return -1;\n            }\n            if (s->eac3 && get_bits1(gbc)) {\n                av_log_missing_feature(s->avctx, "Enhanced coupling", 1);\n                return AVERROR_PATCHWELCOME;\n            }\n            if (s->eac3 && s->channel_mode == AC3_CHMODE_STEREO) {\n                s->channel_in_cpl[1] = 1;\n                s->channel_in_cpl[2] = 1;\n            } else {\n                for (ch = 1; ch <= fbw_channels; ch++)\n                    s->channel_in_cpl[ch] = get_bits1(gbc);\n            }\n            if (channel_mode == AC3_CHMODE_STEREO)\n                s->phase_flags_in_use = get_bits1(gbc);\n            cpl_start_subband = get_bits(gbc, 4);\n            cpl_end_subband = s->spx_in_use ? (s->spx_src_start_freq - 37) / 12 :\n                                              get_bits(gbc, 4) + 3;\n            if (cpl_start_subband >= cpl_end_subband) {\n                av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\\n",\n                       cpl_start_subband, cpl_end_subband);\n                return -1;\n            }\n            s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;\n            s->end_freq[CPL_CH]   = cpl_end_subband   * 12 + 37;\n            decode_band_structure(gbc, blk, s->eac3, 0, cpl_start_subband,\n                                  cpl_end_subband,\n                                  ff_eac3_default_cpl_band_struct,\n                                  &s->num_cpl_bands, s->cpl_band_sizes);\n        } else {\n            for (ch = 1; ch <= fbw_channels; ch++) {\n                s->channel_in_cpl[ch] = 0;\n                s->first_cpl_coords[ch] = 1;\n            }\n            s->first_cpl_leak = s->eac3;\n            s->phase_flags_in_use = 0;\n        }\n    } else if (!s->eac3) {\n        if (!blk) {\n            av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "\n                   "be present in block 0\\n");\n            return -1;\n        } else {\n            s->cpl_in_use[blk] = s->cpl_in_use[blk-1];\n        }\n    }\n    cpl_in_use = s->cpl_in_use[blk];\n    if (cpl_in_use) {\n        int cpl_coords_exist = 0;\n        for (ch = 1; ch <= fbw_channels; ch++) {\n            if (s->channel_in_cpl[ch]) {\n                if ((s->eac3 && s->first_cpl_coords[ch]) || get_bits1(gbc)) {\n                    int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;\n                    s->first_cpl_coords[ch] = 0;\n                    cpl_coords_exist = 1;\n                    master_cpl_coord = 3 * get_bits(gbc, 2);\n                    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n                        cpl_coord_exp = get_bits(gbc, 4);\n                        cpl_coord_mant = get_bits(gbc, 4);\n                        if (cpl_coord_exp == 15)\n                            s->cpl_coords[ch][bnd] = cpl_coord_mant << 22;\n                        else\n                            s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;\n                        s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);\n                    }\n                } else if (!blk) {\n                    av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "\n                           "be present in block 0\\n");\n                    return -1;\n                }\n            } else {\n                s->first_cpl_coords[ch] = 1;\n            }\n        }\n        if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) {\n            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n                s->phase_flags[bnd] = s->phase_flags_in_use? get_bits1(gbc) : 0;\n            }\n        }\n    }\n    if (channel_mode == AC3_CHMODE_STEREO) {\n        if ((s->eac3 && !blk) || get_bits1(gbc)) {\n            s->num_rematrixing_bands = 4;\n            if (cpl_in_use && s->start_freq[CPL_CH] <= 61) {\n                s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37);\n            } else if (s->spx_in_use && s->spx_src_start_freq <= 61) {\n                s->num_rematrixing_bands--;\n            }\n            for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++)\n                s->rematrixing_flags[bnd] = get_bits1(gbc);\n        } else if (!blk) {\n            av_log(s->avctx, AV_LOG_WARNING, "Warning: "\n                   "new rematrixing strategy not present in block 0\\n");\n            s->num_rematrixing_bands = 0;\n        }\n    }\n    for (ch = !cpl_in_use; ch <= s->channels; ch++) {\n        if (!s->eac3)\n            s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch));\n        if (s->exp_strategy[blk][ch] != EXP_REUSE)\n            bit_alloc_stages[ch] = 3;\n    }\n    for (ch = 1; ch <= fbw_channels; ch++) {\n        s->start_freq[ch] = 0;\n        if (s->exp_strategy[blk][ch] != EXP_REUSE) {\n            int group_size;\n            int prev = s->end_freq[ch];\n            if (s->channel_in_cpl[ch])\n                s->end_freq[ch] = s->start_freq[CPL_CH];\n            else if (s->channel_uses_spx[ch])\n                s->end_freq[ch] = s->spx_src_start_freq;\n            else {\n                int bandwidth_code = get_bits(gbc, 6);\n                if (bandwidth_code > 60) {\n                    av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\\n", bandwidth_code);\n                    return -1;\n                }\n                s->end_freq[ch] = bandwidth_code * 3 + 73;\n            }\n            group_size = 3 << (s->exp_strategy[blk][ch] - 1);\n            s->num_exp_groups[ch] = (s->end_freq[ch] + group_size-4) / group_size;\n            if (blk > 0 && s->end_freq[ch] != prev)\n                memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);\n        }\n    }\n    if (cpl_in_use && s->exp_strategy[blk][CPL_CH] != EXP_REUSE) {\n        s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) /\n                                    (3 << (s->exp_strategy[blk][CPL_CH] - 1));\n    }\n    for (ch = !cpl_in_use; ch <= s->channels; ch++) {\n        if (s->exp_strategy[blk][ch] != EXP_REUSE) {\n            s->dexps[ch][0] = get_bits(gbc, 4) << !ch;\n            if (decode_exponents(gbc, s->exp_strategy[blk][ch],\n                                 s->num_exp_groups[ch], s->dexps[ch][0],\n                                 &s->dexps[ch][s->start_freq[ch]+!!ch])) {\n                av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\\n");\n                return -1;\n            }\n            if (ch != CPL_CH && ch != s->lfe_ch)\n                skip_bits(gbc, 2);\n        }\n    }\n    if (s->bit_allocation_syntax) {\n        if (get_bits1(gbc)) {\n            s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;\n            s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;\n            s->bit_alloc_params.slow_gain  = ff_ac3_slow_gain_tab[get_bits(gbc, 2)];\n            s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)];\n            s->bit_alloc_params.floor  = ff_ac3_floor_tab[get_bits(gbc, 3)];\n            for (ch = !cpl_in_use; ch <= s->channels; ch++)\n                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);\n        } else if (!blk) {\n            av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "\n                   "be present in block 0\\n");\n            return -1;\n        }\n    }\n    if (!s->eac3 || !blk) {\n        if (s->snr_offset_strategy && get_bits1(gbc)) {\n            int snr = 0;\n            int csnr;\n            csnr = (get_bits(gbc, 6) - 15) << 4;\n            for (i = ch = !cpl_in_use; ch <= s->channels; ch++) {\n                if (ch == i || s->snr_offset_strategy == 2)\n                    snr = (csnr + get_bits(gbc, 4)) << 2;\n                if (blk && s->snr_offset[ch] != snr) {\n                    bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1);\n                }\n                s->snr_offset[ch] = snr;\n                if (!s->eac3) {\n                    int prev = s->fast_gain[ch];\n                    s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];\n                    if (blk && prev != s->fast_gain[ch])\n                        bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);\n                }\n            }\n        } else if (!s->eac3 && !blk) {\n            av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\\n");\n            return -1;\n        }\n    }\n    if (s->fast_gain_syntax && get_bits1(gbc)) {\n        for (ch = !cpl_in_use; ch <= s->channels; ch++) {\n            int prev = s->fast_gain[ch];\n            s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];\n            if (blk && prev != s->fast_gain[ch])\n                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);\n        }\n    } else if (s->eac3 && !blk) {\n        for (ch = !cpl_in_use; ch <= s->channels; ch++)\n            s->fast_gain[ch] = ff_ac3_fast_gain_tab[4];\n    }\n    if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && get_bits1(gbc)) {\n        skip_bits(gbc, 10);\n    }\n    if (cpl_in_use) {\n        if (s->first_cpl_leak || get_bits1(gbc)) {\n            int fl = get_bits(gbc, 3);\n            int sl = get_bits(gbc, 3);\n            if (blk && (fl != s->bit_alloc_params.cpl_fast_leak ||\n                sl != s->bit_alloc_params.cpl_slow_leak)) {\n                bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);\n            }\n            s->bit_alloc_params.cpl_fast_leak = fl;\n            s->bit_alloc_params.cpl_slow_leak = sl;\n        } else if (!s->eac3 && !blk) {\n            av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "\n                   "be present in block 0\\n");\n            return -1;\n        }\n        s->first_cpl_leak = 0;\n    }\n    if (s->dba_syntax && get_bits1(gbc)) {\n        for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {\n            s->dba_mode[ch] = get_bits(gbc, 2);\n            if (s->dba_mode[ch] == DBA_RESERVED) {\n                av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\\n");\n                return -1;\n            }\n            bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);\n        }\n        for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {\n            if (s->dba_mode[ch] == DBA_NEW) {\n                s->dba_nsegs[ch] = get_bits(gbc, 3) + 1;\n                for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {\n                    s->dba_offsets[ch][seg] = get_bits(gbc, 5);\n                    s->dba_lengths[ch][seg] = get_bits(gbc, 4);\n                    s->dba_values[ch][seg]  = get_bits(gbc, 3);\n                }\n                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);\n            }\n        }\n    } else if (blk == 0) {\n        for (ch = 0; ch <= s->channels; ch++) {\n            s->dba_mode[ch] = DBA_NONE;\n        }\n    }\n    for (ch = !cpl_in_use; ch <= s->channels; ch++) {\n        if (bit_alloc_stages[ch] > 2) {\n            ff_ac3_bit_alloc_calc_psd(s->dexps[ch],\n                                      s->start_freq[ch], s->end_freq[ch],\n                                      s->psd[ch], s->band_psd[ch]);\n        }\n        if (bit_alloc_stages[ch] > 1) {\n            if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch],\n                                           s->start_freq[ch],  s->end_freq[ch],\n                                           s->fast_gain[ch],   (ch == s->lfe_ch),\n                                           s->dba_mode[ch],    s->dba_nsegs[ch],\n                                           s->dba_offsets[ch], s->dba_lengths[ch],\n                                           s->dba_values[ch],  s->mask[ch])) {\n                av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\\n");\n                return -1;\n            }\n        }\n        if (bit_alloc_stages[ch] > 0) {\n            const uint8_t *bap_tab = s->channel_uses_aht[ch] ?\n                                     ff_eac3_hebap_tab : ff_ac3_bap_tab;\n            s->ac3dsp.bit_alloc_calc_bap(s->mask[ch], s->psd[ch],\n                                      s->start_freq[ch], s->end_freq[ch],\n                                      s->snr_offset[ch],\n                                      s->bit_alloc_params.floor,\n                                      bap_tab, s->bap[ch]);\n        }\n    }\n    if (s->skip_syntax && get_bits1(gbc)) {\n        int skipl = get_bits(gbc, 9);\n        while (skipl--)\n            skip_bits(gbc, 8);\n    }\n    decode_transform_coeffs(s, blk);\n    if (s->channel_mode == AC3_CHMODE_STEREO)\n        do_rematrixing(s);\n    for (ch = 1; ch <= s->channels; ch++) {\n        float gain = 1.0 / 4194304.0f;\n        if (s->channel_mode == AC3_CHMODE_DUALMONO) {\n            gain *= s->dynamic_range[2 - ch];\n        } else {\n            gain *= s->dynamic_range[0];\n        }\n        s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch],\n                                               s->fixed_coeffs[ch], gain, 256);\n    }\n    if (s->spx_in_use && CONFIG_EAC3_DECODER) {\n        ff_eac3_apply_spectral_extension(s);\n    }\n    downmix_output = s->channels != s->out_channels &&\n                     !((s->output_mode & AC3_OUTPUT_LFEON) &&\n                     s->fbw_channels == s->out_channels);\n    if (different_transforms) {\n        if (s->downmixed) {\n            s->downmixed = 0;\n            ac3_upmix_delay(s);\n        }\n        do_imdct(s, s->channels);\n        if (downmix_output) {\n            s->ac3dsp.downmix(s->outptr, s->downmix_coeffs,\n                              s->out_channels, s->fbw_channels, 256);\n        }\n    } else {\n        if (downmix_output) {\n            s->ac3dsp.downmix(s->xcfptr + 1, s->downmix_coeffs,\n                              s->out_channels, s->fbw_channels, 256);\n        }\n        if (downmix_output && !s->downmixed) {\n            s->downmixed = 1;\n            s->ac3dsp.downmix(s->dlyptr, s->downmix_coeffs, s->out_channels,\n                              s->fbw_channels, 128);\n        }\n        do_imdct(s, s->out_channels);\n    }\n    return 0;\n}']