libavcodec/dcadec.c:1483: error: Buffer Overrun L2
  Offset: [0, 1085+max(7, `avctx->priv_data->prim_channels`)] (⇐ [0, -1+max(7, `avctx->priv_data->prim_channels`)] + [0, 1086]) Size: 7 by call to `dca_filter_channels`.

libavcodec/dcadec.c:1347:1: Parameter `avctx->priv_data->prim_channels`
1345.  * FIXME add arguments
1346.  */
1347. static int dca_decode_frame(AVCodecContext *avctx, void *data,
      ^
1348.                             int *got_frame_ptr, AVPacket *avpkt)
1349. {

libavcodec/dcadec.c:1372:16: Call
1370.     }
1371. 
1372.     if ((ret = dca_parse_frame_header(s)) < 0) {
                     ^
1373.         // seems like the frame is corrupt, try with the next one
1374.         return ret;

libavcodec/dcadec.c:281:1: Parameter `s->prim_channels`
  279. }
  280. 
  281. static int dca_parse_frame_header(DCAContext *s)
       ^
  282. {
  283.     init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);

libavcodec/dcadec.c:1397:11: Call
1395.         s->core_ext_mask = 0;
1396. 
1397.     ret = scan_for_extensions(avctx);
                ^
1398. 
1399.     avctx->profile = s->profile;

libavcodec/dcadec.c:1147:1: Parameter `avctx->priv_data->prim_channels`
  1145. }
  1146. 
  1147. static int scan_for_extensions(AVCodecContext *avctx)
        ^
  1148. {
  1149.     DCAContext *s = avctx->priv_data;

libavcodec/dcadec.c:1403:11: Call
1401.     full_channels = channels = s->prim_channels + !!s->lfe;
1402. 
1403.     ret = set_channel_layout(avctx, channels, num_core_channels);
                ^
1404.     if (ret < 0)
1405.         return ret;

libavcodec/dcadec.c:1249:1: Parameter `avctx->priv_data->prim_channels`
  1247. }
  1248. 
  1249. static int set_channel_layout(AVCodecContext *avctx, int channels, int num_core_channels)
        ^
  1250. {
  1251.     DCAContext *s = avctx->priv_data;

libavcodec/dcadec.c:1483:9: Call
1481.             s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * block;
1482. 
1483.         dca_filter_channels(s, i, upsample);
              ^
1484. 
1485.         /* If this was marked as a DTS-ES stream we need to subtract back- */

libavcodec/dcadec.c:935:1: Parameter `s->prim_channels`
  933. }
  934. 
  935. static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
       ^
  936. {
  937.     float (*subband_samples)[DCA_SUBBANDS][SAMPLES_PER_SUBBAND] = s->subband_samples[block_index];

libavcodec/dcadec.c:950:17: Call
  948.         for (k = 0; k < s->prim_channels; k++) {
  949.             if (s->channel_order_tab[k] >= 0)
  950.                 qmf_64_subbands(s, k, subband_samples[k],
                       ^
  951.                                 s->samples_chanptr[s->channel_order_tab[k]],
  952.                                 /* Upsampling needs a factor 2 here. */

libavcodec/dcadec.c:619:14: <Offset trace>
617.         }
618. 
619.         for (i = 0; i < 64; i++) {
                  ^
620.             float out = raZ[i];
621.             for (j = 0; j < 1024; j += 128)

libavcodec/dcadec.c:619:14: Assignment
    617.         }
    618. 
    619.         for (i = 0; i < 64; i++) {
                      ^
    620.             float out = raZ[i];
    621.             for (j = 0; j < 1024; j += 128)

libavcodec/dcadec.c:589:1: <Length trace>
587.  * http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
588.  * for doubling the size. */
589. static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPLES_PER_SUBBAND],
     ^
590.                             float *samples_out, float scale)
591. {

libavcodec/dcadec.c:589:1: Parameter `chans`
    587.  * http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
    588.  * for doubling the size. */
    589. static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPLES_PER_SUBBAND],
         ^
    590.                             float *samples_out, float scale)
    591. {

libavcodec/dcadec.c:594:5: Assignment
    592.     float raXin[64];
    593.     float A[32], B[32];
    594.     float *raX = s->subband_fir_hist[chans];
             ^
    595.     float *raZ = s->subband_fir_noidea[chans];
    596.     unsigned i, j, k, subindex;

libavcodec/dcadec.c:622:53: Array access: Offset: [0, 1085+max(7, avctx->priv_data->prim_channels)] (⇐ [0, -1+max(7, avctx->priv_data->prim_channels)] + [0, 1086]) Size: 7 by call to `dca_filter_channels` 
    620.             float out = raZ[i];
    621.             for (j = 0; j < 1024; j += 128)
    622.                 out += ff_dca_fir_64bands[j + i] * (raX[j + i] - raX[j + 63 - i]);
                                                             ^
    623.             *samples_out++ = out * scale;
    624.         }

static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPLES_PER_SUBBAND],
                            float *samples_out, float scale)
{
    float raXin[64];
    float A[32], B[32];
    float *raX = s->subband_fir_hist[chans];
    float *raZ = s->subband_fir_noidea[chans];
    unsigned i, j, k, subindex;
    for (i = s->subband_activity[chans]; i < 64; i++)
        raXin[i] = 0.0;
    for (subindex = 0; subindex < SAMPLES_PER_SUBBAND; subindex++) {
        for (i = 0; i < s->subband_activity[chans]; i++)
            raXin[i] = samples_in[i][subindex];
        for (k = 0; k < 32; k++) {
            A[k] = 0.0;
            for (i = 0; i < 32; i++)
                A[k] += (raXin[2 * i] + raXin[2 * i + 1]) * s->qmf64_table->dct4_coeff[k][i];
        }
        for (k = 0; k < 32; k++) {
            B[k] = raXin[0] * s->qmf64_table->dct2_coeff[k][0];
            for (i = 1; i < 32; i++)
                B[k] += (raXin[2 * i] + raXin[2 * i - 1]) * s->qmf64_table->dct2_coeff[k][i];
        }
        for (k = 0; k < 32; k++) {
            raX[k]      = s->qmf64_table->rcos[k] * (A[k] + B[k]);
            raX[63 - k] = s->qmf64_table->rsin[k] * (A[k] - B[k]);
        }
        for (i = 0; i < 64; i++) {
            float out = raZ[i];
            for (j = 0; j < 1024; j += 128)
                out += ff_dca_fir_64bands[j + i] * (raX[j + i] - raX[j + 63 - i]);
            *samples_out++ = out * scale;
        }
        for (i = 0; i < 64; i++) {
            float hist = 0.0;
            for (j = 0; j < 1024; j += 128)
                hist += ff_dca_fir_64bands[64 + j + i] * (-raX[i + j] - raX[j + 63 - i]);
            raZ[i] = hist;
        }
        memmove(raX + 64, raX, (1024 - 64) * sizeof(*raX));
    }
}
['static int dca_decode_frame(AVCodecContext *avctx, void *data,\n                            int *got_frame_ptr, AVPacket *avpkt)\n{\n    AVFrame *frame     = data;\n    const uint8_t *buf = avpkt->data;\n    int buf_size       = avpkt->size;\n    int lfe_samples;\n    int num_core_channels = 0;\n    int i, ret;\n    float  **samples_flt;\n    DCAContext *s = avctx->priv_data;\n    int channels, full_channels;\n    int upsample = 0;\n    s->exss_ext_mask = 0;\n    s->xch_present   = 0;\n    s->dca_buffer_size = ff_dca_convert_bitstream(buf, buf_size, s->dca_buffer,\n                                                  DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE);\n    if (s->dca_buffer_size == AVERROR_INVALIDDATA) {\n        av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if ((ret = dca_parse_frame_header(s)) < 0) {\n        return ret;\n    }\n    avctx->sample_rate = s->sample_rate;\n    avctx->bit_rate    = s->bit_rate;\n    s->profile = FF_PROFILE_DTS;\n    for (i = 0; i < (s->sample_blocks / SAMPLES_PER_SUBBAND); i++) {\n        if ((ret = dca_decode_block(s, 0, i))) {\n            av_log(avctx, AV_LOG_ERROR, "error decoding block\\n");\n            return ret;\n        }\n    }\n    num_core_channels = s->prim_channels;\n    if (s->ext_coding)\n        s->core_ext_mask = dca_ext_audio_descr_mask[s->ext_descr];\n    else\n        s->core_ext_mask = 0;\n    ret = scan_for_extensions(avctx);\n    avctx->profile = s->profile;\n    full_channels = channels = s->prim_channels + !!s->lfe;\n    ret = set_channel_layout(avctx, channels, num_core_channels);\n    if (ret < 0)\n        return ret;\n    avctx->channels = channels;\n    frame->nb_samples = 256 * (s->sample_blocks / SAMPLES_PER_SUBBAND);\n    if (s->exss_ext_mask & DCA_EXT_EXSS_XLL) {\n        int xll_nb_samples = s->xll_segments * s->xll_smpl_in_seg;\n        if (s->xll_residual_channels > channels) {\n            av_log(s->avctx, AV_LOG_WARNING,\n                   "DCA: too many residual channels (%d, core channels %d). Disabling XLL\\n",\n                   s->xll_residual_channels, channels);\n            s->exss_ext_mask &= ~DCA_EXT_EXSS_XLL;\n        } else if (xll_nb_samples != frame->nb_samples &&\n                   2 * frame->nb_samples != xll_nb_samples) {\n            av_log(s->avctx, AV_LOG_WARNING,\n                   "DCA: unsupported upsampling (%d XLL samples, %d core samples). Disabling XLL\\n",\n                   xll_nb_samples, frame->nb_samples);\n            s->exss_ext_mask &= ~DCA_EXT_EXSS_XLL;\n        } else {\n            if (2 * frame->nb_samples == xll_nb_samples) {\n                av_log(s->avctx, AV_LOG_INFO,\n                       "XLL: upsampling core channels by a factor of 2\\n");\n                upsample = 1;\n                frame->nb_samples = xll_nb_samples;\n                avctx->sample_rate = s->xll_chsets[0].sampling_frequency;\n            }\n            if (!s->xch_disable)\n                avctx->channels += s->xll_channels - s->xll_residual_channels;\n        }\n    }\n    if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels)\n        avctx->channel_layout = 0;\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    samples_flt = (float **) frame->extended_data;\n    if (avctx->channels < full_channels) {\n        ret = av_samples_get_buffer_size(NULL, full_channels - channels,\n                                         frame->nb_samples,\n                                         avctx->sample_fmt, 0);\n        if (ret < 0)\n            return ret;\n        av_fast_malloc(&s->extra_channels_buffer,\n                       &s->extra_channels_buffer_size, ret);\n        if (!s->extra_channels_buffer)\n            return AVERROR(ENOMEM);\n        ret = av_samples_fill_arrays((uint8_t **) s->extra_channels, NULL,\n                                     s->extra_channels_buffer,\n                                     full_channels - channels,\n                                     frame->nb_samples, avctx->sample_fmt, 0);\n        if (ret < 0)\n            return ret;\n    }\n    for (i = 0; i < (s->sample_blocks / SAMPLES_PER_SUBBAND); i++) {\n        int ch;\n        unsigned block = upsample ? 512 : 256;\n        for (ch = 0; ch < channels; ch++)\n            s->samples_chanptr[ch] = samples_flt[ch] + i * block;\n        for (; ch < full_channels; ch++)\n            s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * block;\n        dca_filter_channels(s, i, upsample);\n        if ((s->source_pcm_res & 1) && s->xch_present) {\n            float *back_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel]];\n            float *lt_chan   = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 2]];\n            float *rt_chan   = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 1]];\n            s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);\n            s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);\n        }\n    }\n    lfe_samples = 2 * s->lfe * (s->sample_blocks / SAMPLES_PER_SUBBAND);\n    for (i = 0; i < 2 * s->lfe * 4; i++)\n        s->lfe_data[i] = s->lfe_data[i + lfe_samples];\n    if (s->exss_ext_mask & DCA_EXT_EXSS_XLL) {\n        ret = ff_dca_xll_decode_audio(s, frame);\n        if (ret < 0)\n            return ret;\n    }\n    ret = ff_side_data_update_matrix_encoding(frame,\n                                              (s->output & ~DCA_LFE) == DCA_STEREO_TOTAL ?\n                                              AV_MATRIX_ENCODING_DOLBY : AV_MATRIX_ENCODING_NONE);\n    if (ret < 0)\n        return ret;\n    *got_frame_ptr = 1;\n    return buf_size;\n}', 'static int dca_parse_frame_header(DCAContext *s)\n{\n    init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);\n    skip_bits_long(&s->gb, 32);\n    s->frame_type        = get_bits(&s->gb, 1);\n    s->samples_deficit   = get_bits(&s->gb, 5) + 1;\n    s->crc_present       = get_bits(&s->gb, 1);\n    s->sample_blocks     = get_bits(&s->gb, 7) + 1;\n    s->frame_size        = get_bits(&s->gb, 14) + 1;\n    if (s->frame_size < 95)\n        return AVERROR_INVALIDDATA;\n    s->amode             = get_bits(&s->gb, 6);\n    s->sample_rate       = avpriv_dca_sample_rates[get_bits(&s->gb, 4)];\n    if (!s->sample_rate)\n        return AVERROR_INVALIDDATA;\n    s->bit_rate_index    = get_bits(&s->gb, 5);\n    s->bit_rate          = ff_dca_bit_rates[s->bit_rate_index];\n    if (!s->bit_rate)\n        return AVERROR_INVALIDDATA;\n    skip_bits1(&s->gb);\n    s->dynrange          = get_bits(&s->gb, 1);\n    s->timestamp         = get_bits(&s->gb, 1);\n    s->aux_data          = get_bits(&s->gb, 1);\n    s->hdcd              = get_bits(&s->gb, 1);\n    s->ext_descr         = get_bits(&s->gb, 3);\n    s->ext_coding        = get_bits(&s->gb, 1);\n    s->aspf              = get_bits(&s->gb, 1);\n    s->lfe               = get_bits(&s->gb, 2);\n    s->predictor_history = get_bits(&s->gb, 1);\n    if (s->lfe > 2) {\n        av_log(s->avctx, AV_LOG_ERROR, "Invalid LFE value: %d\\n", s->lfe);\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->crc_present)\n        s->header_crc    = get_bits(&s->gb, 16);\n    s->multirate_inter   = get_bits(&s->gb, 1);\n    s->version           = get_bits(&s->gb, 4);\n    s->copy_history      = get_bits(&s->gb, 2);\n    s->source_pcm_res    = get_bits(&s->gb, 3);\n    s->front_sum         = get_bits(&s->gb, 1);\n    s->surround_sum      = get_bits(&s->gb, 1);\n    s->dialog_norm       = get_bits(&s->gb, 4);\n    s->output = s->amode;\n    if (s->lfe)\n        s->output |= DCA_LFE;\n    s->subframes = get_bits(&s->gb, 4) + 1;\n    return dca_parse_audio_coding_header(s, 0);\n}', 'static int scan_for_extensions(AVCodecContext *avctx)\n{\n    DCAContext *s = avctx->priv_data;\n    int core_ss_end, ret;\n    core_ss_end = FFMIN(s->frame_size, s->dca_buffer_size) * 8;\n    if (s->core_ext_mask < 0 || s->core_ext_mask & DCA_EXT_XCH) {\n        s->core_ext_mask = FFMAX(s->core_ext_mask, 0);\n        skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);\n        while (core_ss_end - get_bits_count(&s->gb) >= 32) {\n            uint32_t bits = get_bits_long(&s->gb, 32);\n            int i;\n            switch (bits) {\n            case DCA_SYNCWORD_XCH: {\n                int ext_amode, xch_fsize;\n                s->xch_base_channel = s->prim_channels;\n                xch_fsize = show_bits(&s->gb, 10);\n                if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&\n                    (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))\n                    continue;\n                skip_bits(&s->gb, 10);\n                s->core_ext_mask |= DCA_EXT_XCH;\n                if ((ext_amode = get_bits(&s->gb, 4)) != 1) {\n                    av_log(avctx, AV_LOG_ERROR,\n                           "XCh extension amode %d not supported!\\n",\n                           ext_amode);\n                    continue;\n                }\n                dca_parse_audio_coding_header(s, s->xch_base_channel);\n                for (i = 0; i < (s->sample_blocks / 8); i++)\n                    if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {\n                        av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\\n");\n                        continue;\n                    }\n                s->xch_present = 1;\n                break;\n            }\n            case DCA_SYNCWORD_XXCH:\n                s->core_ext_mask |= DCA_EXT_XXCH;\n                break;\n            case 0x1d95f262: {\n                int fsize96 = show_bits(&s->gb, 12) + 1;\n                if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)\n                    continue;\n                av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\\n",\n                       get_bits_count(&s->gb));\n                skip_bits(&s->gb, 12);\n                av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\\n", fsize96);\n                av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\\n", get_bits(&s->gb, 4));\n                s->core_ext_mask |= DCA_EXT_X96;\n                break;\n            }\n            }\n            skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);\n        }\n    } else {\n        skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));\n    }\n    if (s->core_ext_mask & DCA_EXT_X96)\n        s->profile = FF_PROFILE_DTS_96_24;\n    else if (s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH))\n        s->profile = FF_PROFILE_DTS_ES;\n    if (s->dca_buffer_size - s->frame_size > 32 &&\n        get_bits_long(&s->gb, 32) == DCA_SYNCWORD_SUBSTREAM)\n        ff_dca_exss_parse_header(s);\n    return ret;\n}', 'static int set_channel_layout(AVCodecContext *avctx, int channels, int num_core_channels)\n{\n    DCAContext *s = avctx->priv_data;\n    int i;\n    if (s->amode < 16) {\n        avctx->channel_layout = dca_core_channel_layout[s->amode];\n        if (s->prim_channels + !!s->lfe > 2 &&\n            avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {\n            s->xch_disable = 1;\n        }\n        if (s->xch_present && !s->xch_disable) {\n            avctx->channel_layout |= AV_CH_BACK_CENTER;\n            if (s->lfe) {\n                avctx->channel_layout |= AV_CH_LOW_FREQUENCY;\n                s->channel_order_tab = ff_dca_channel_reorder_lfe_xch[s->amode];\n            } else {\n                s->channel_order_tab = ff_dca_channel_reorder_nolfe_xch[s->amode];\n            }\n        } else {\n            channels       = num_core_channels + !!s->lfe;\n            s->xch_present = 0;\n            if (s->lfe) {\n                avctx->channel_layout |= AV_CH_LOW_FREQUENCY;\n                s->channel_order_tab = ff_dca_channel_reorder_lfe[s->amode];\n            } else\n                s->channel_order_tab = ff_dca_channel_reorder_nolfe[s->amode];\n        }\n        if (channels > !!s->lfe &&\n            s->channel_order_tab[channels - 1 - !!s->lfe] < 0)\n            return AVERROR_INVALIDDATA;\n        if (num_core_channels + !!s->lfe > 2 &&\n            avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {\n            channels              = 2;\n            s->output             = s->prim_channels == 2 ? s->amode : DCA_STEREO;\n            avctx->channel_layout = AV_CH_LAYOUT_STEREO;\n            if (s->core_downmix && (s->core_downmix_amode == DCA_STEREO ||\n                                    s->core_downmix_amode == DCA_STEREO_TOTAL)) {\n                for (i = 0; i < num_core_channels + !!s->lfe; i++) {\n                    s->downmix_coef[i][0] = dca_dmix_code(s->core_downmix_codes[i][0]);\n                    s->downmix_coef[i][1] = dca_dmix_code(s->core_downmix_codes[i][1]);\n                }\n                s->output = s->core_downmix_amode;\n            } else {\n                int am = s->amode & DCA_CHANNEL_MASK;\n                if (am >= FF_ARRAY_ELEMS(ff_dca_default_coeffs)) {\n                    av_log(s->avctx, AV_LOG_ERROR,\n                           "Invalid channel mode %d\\n", am);\n                    return AVERROR_INVALIDDATA;\n                }\n                if (num_core_channels + !!s->lfe >\n                    FF_ARRAY_ELEMS(ff_dca_default_coeffs[0])) {\n                    avpriv_request_sample(s->avctx, "Downmixing %d channels",\n                                          s->prim_channels + !!s->lfe);\n                    return AVERROR_PATCHWELCOME;\n                }\n                for (i = 0; i < num_core_channels + !!s->lfe; i++) {\n                    s->downmix_coef[i][0] = ff_dca_default_coeffs[am][i][0];\n                    s->downmix_coef[i][1] = ff_dca_default_coeffs[am][i][1];\n                }\n            }\n            ff_dlog(s->avctx, "Stereo downmix coeffs:\\n");\n            for (i = 0; i < num_core_channels + !!s->lfe; i++) {\n                ff_dlog(s->avctx, "L, input channel %d = %f\\n", i,\n                        s->downmix_coef[i][0]);\n                ff_dlog(s->avctx, "R, input channel %d = %f\\n", i,\n                        s->downmix_coef[i][1]);\n            }\n            ff_dlog(s->avctx, "\\n");\n        }\n    } else {\n        av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\\n", s->amode);\n        return AVERROR_INVALIDDATA;\n    }\n    return 0;\n}', 'static int dca_filter_channels(DCAContext *s, int block_index, int upsample)\n{\n    float (*subband_samples)[DCA_SUBBANDS][SAMPLES_PER_SUBBAND] = s->subband_samples[block_index];\n    int k;\n    if (upsample) {\n        if (!s->qmf64_table) {\n            s->qmf64_table = qmf64_precompute();\n            if (!s->qmf64_table)\n                return AVERROR(ENOMEM);\n        }\n        for (k = 0; k < s->prim_channels; k++) {\n            if (s->channel_order_tab[k] >= 0)\n                qmf_64_subbands(s, k, subband_samples[k],\n                                s->samples_chanptr[s->channel_order_tab[k]],\n                                M_SQRT2 / 32768.0);\n        }\n    } else {\n        for (k = 0; k < s->prim_channels; k++) {\n            if (s->channel_order_tab[k] >= 0)\n                qmf_32_subbands(s, k, subband_samples[k],\n                                s->samples_chanptr[s->channel_order_tab[k]],\n                                M_SQRT1_2 / 32768.0);\n        }\n    }\n    if (s->lfe) {\n        float *samples = s->samples_chanptr[ff_dca_lfe_index[s->amode]];\n        lfe_interpolation_fir(s,\n                              s->lfe_data + 2 * s->lfe * (block_index + 4),\n                              samples);\n        if (upsample) {\n            unsigned i;\n            for (i = 511; i > 0; i--) {\n                samples[2 * i]     =\n                samples[2 * i + 1] = samples[i];\n            }\n            samples[1] = samples[0];\n        }\n    }\n    if (s->prim_channels + !!s->lfe > 2 &&\n        s->avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {\n        dca_downmix(s->samples_chanptr, s->amode, !!s->lfe, s->downmix_coef,\n                    s->channel_order_tab);\n    }\n    return 0;\n}', 'static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPLES_PER_SUBBAND],\n                            float *samples_out, float scale)\n{\n    float raXin[64];\n    float A[32], B[32];\n    float *raX = s->subband_fir_hist[chans];\n    float *raZ = s->subband_fir_noidea[chans];\n    unsigned i, j, k, subindex;\n    for (i = s->subband_activity[chans]; i < 64; i++)\n        raXin[i] = 0.0;\n    for (subindex = 0; subindex < SAMPLES_PER_SUBBAND; subindex++) {\n        for (i = 0; i < s->subband_activity[chans]; i++)\n            raXin[i] = samples_in[i][subindex];\n        for (k = 0; k < 32; k++) {\n            A[k] = 0.0;\n            for (i = 0; i < 32; i++)\n                A[k] += (raXin[2 * i] + raXin[2 * i + 1]) * s->qmf64_table->dct4_coeff[k][i];\n        }\n        for (k = 0; k < 32; k++) {\n            B[k] = raXin[0] * s->qmf64_table->dct2_coeff[k][0];\n            for (i = 1; i < 32; i++)\n                B[k] += (raXin[2 * i] + raXin[2 * i - 1]) * s->qmf64_table->dct2_coeff[k][i];\n        }\n        for (k = 0; k < 32; k++) {\n            raX[k]      = s->qmf64_table->rcos[k] * (A[k] + B[k]);\n            raX[63 - k] = s->qmf64_table->rsin[k] * (A[k] - B[k]);\n        }\n        for (i = 0; i < 64; i++) {\n            float out = raZ[i];\n            for (j = 0; j < 1024; j += 128)\n                out += ff_dca_fir_64bands[j + i] * (raX[j + i] - raX[j + 63 - i]);\n            *samples_out++ = out * scale;\n        }\n        for (i = 0; i < 64; i++) {\n            float hist = 0.0;\n            for (j = 0; j < 1024; j += 128)\n                hist += ff_dca_fir_64bands[64 + j + i] * (-raX[i + j] - raX[j + 63 - i]);\n            raZ[i] = hist;\n        }\n        memmove(raX + 64, raX, (1024 - 64) * sizeof(*raX));\n    }\n}']