static void dca_downmix(float **samples, int srcfmt, int lfe_present,
                        float coef[DCA_PRIM_CHANNELS_MAX + 1][2],
                        const int8_t *channel_mapping)
{
    int c, l, r, sl, sr, s;
    int i;
    float t, u, v;
    switch (srcfmt) {
    case DCA_MONO:
    case DCA_4F2R:
        av_log(NULL, 0, "Not implemented!\n");
        break;
    case DCA_CHANNEL:
    case DCA_STEREO:
    case DCA_STEREO_TOTAL:
    case DCA_STEREO_SUMDIFF:
        break;
    case DCA_3F:
        c = channel_mapping[0];
        l = channel_mapping[1];
        r = channel_mapping[2];
        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), );
        break;
    case DCA_2F1R:
        s = channel_mapping[2];
        DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), );
        break;
    case DCA_3F1R:
        c = channel_mapping[0];
        l = channel_mapping[1];
        r = channel_mapping[2];
        s = channel_mapping[3];
        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
                          MIX_REAR1(samples, s, 3, coef));
        break;
    case DCA_2F2R:
        sl = channel_mapping[2];
        sr = channel_mapping[3];
        DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), );
        break;
    case DCA_3F2R:
        c  = channel_mapping[0];
        l  = channel_mapping[1];
        r  = channel_mapping[2];
        sl = channel_mapping[3];
        sr = channel_mapping[4];
        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
                          MIX_REAR2(samples, sl, sr, 3, coef));
        break;
    }
    if (lfe_present) {
        int lf_buf = ff_dca_lfe_index[srcfmt];
        int lf_idx =  ff_dca_channels[srcfmt];
        for (i = 0; i < 256; i++) {
            samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];
            samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];
        }
    }
}
['static int dca_filter_channels(DCAContext *s, int block_index, int upsample)\n{\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->audio_header.prim_channels; k++) {\n            float (*subband_samples)[SAMPLES_PER_SUBBAND] = s->dca_chan[k].subband_samples[block_index];\n            if (s->channel_order_tab[k] >= 0)\n                qmf_64_subbands(s, k, subband_samples,\n                                s->samples_chanptr[s->channel_order_tab[k]],\n                                M_SQRT2 / 32768.0);\n        }\n    } else {\n        for (k = 0; k < s->audio_header.prim_channels; k++) {\n            float (*subband_samples)[SAMPLES_PER_SUBBAND] = s->dca_chan[k].subband_samples[block_index];\n            if (s->channel_order_tab[k] >= 0)\n                qmf_32_subbands(s, k, subband_samples,\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->audio_header.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 dca_downmix(float **samples, int srcfmt, int lfe_present,\n                        float coef[DCA_PRIM_CHANNELS_MAX + 1][2],\n                        const int8_t *channel_mapping)\n{\n    int c, l, r, sl, sr, s;\n    int i;\n    float t, u, v;\n    switch (srcfmt) {\n    case DCA_MONO:\n    case DCA_4F2R:\n        av_log(NULL, 0, "Not implemented!\\n");\n        break;\n    case DCA_CHANNEL:\n    case DCA_STEREO:\n    case DCA_STEREO_TOTAL:\n    case DCA_STEREO_SUMDIFF:\n        break;\n    case DCA_3F:\n        c = channel_mapping[0];\n        l = channel_mapping[1];\n        r = channel_mapping[2];\n        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), );\n        break;\n    case DCA_2F1R:\n        s = channel_mapping[2];\n        DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), );\n        break;\n    case DCA_3F1R:\n        c = channel_mapping[0];\n        l = channel_mapping[1];\n        r = channel_mapping[2];\n        s = channel_mapping[3];\n        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),\n                          MIX_REAR1(samples, s, 3, coef));\n        break;\n    case DCA_2F2R:\n        sl = channel_mapping[2];\n        sr = channel_mapping[3];\n        DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), );\n        break;\n    case DCA_3F2R:\n        c  = channel_mapping[0];\n        l  = channel_mapping[1];\n        r  = channel_mapping[2];\n        sl = channel_mapping[3];\n        sr = channel_mapping[4];\n        DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),\n                          MIX_REAR2(samples, sl, sr, 3, coef));\n        break;\n    }\n    if (lfe_present) {\n        int lf_buf = ff_dca_lfe_index[srcfmt];\n        int lf_idx =  ff_dca_channels[srcfmt];\n        for (i = 0; i < 256; i++) {\n            samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];\n            samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];\n        }\n    }\n}']