libavcodec/dca.c:1318: error: Buffer Overrun L2
  Offset: [0, 6] Size: 5 by call to `dca_decode_block`.

libavcodec/dca.c:1315:13: Call
1313. 
1314.             /* much like core primary audio coding header */
1315.             dca_parse_audio_coding_header(s, ext_base_ch);
                  ^
1316. 
1317.             for (i = 0; i < (s->sample_blocks / 8); i++) {

libavcodec/dca.c:377:9: Assignment
  375. 
  376.     if (s->prim_channels > DCA_PRIM_CHANNELS_MAX)
  377.         s->prim_channels = DCA_PRIM_CHANNELS_MAX;
               ^
  378. 
  379. 

libavcodec/dca.c:1318:17: Call
1316. 
1317.             for (i = 0; i < (s->sample_blocks / 8); i++) {
1318.                 dca_decode_block(s, ext_base_ch, i);
                      ^
1319.             }
1320. 

libavcodec/dca.c:1164:1: Parameter `base_channel`
  1162.  */
  1163. 
  1164. static int dca_decode_block(DCAContext * s, int base_channel, int block_index)
        ^
  1165. {
  1166. 

libavcodec/dca.c:1179:13: Call
  1177. #endif
  1178.         /* Read subframe header */
  1179.         if (dca_subframe_header(s, base_channel, block_index))
                    ^
  1180.             return -1;
  1181.     }

libavcodec/dca.c:551:1: <Offset trace>
549. }
550. 
551. static int dca_subframe_header(DCAContext * s, int base_channel, int block_index)
     ^
552. {
553.     /* Primary audio coding side information */

libavcodec/dca.c:551:1: Parameter `s->prim_channels`
    549. }
    550. 
    551. static int dca_subframe_header(DCAContext * s, int base_channel, int block_index)
         ^
    552. {
    553.     /* Primary audio coding side information */

libavcodec/dcadata.h:7531:1: <Length trace>
7529. };
7530. 
7531. static const uint8_t dca_default_coeffs[16][5][2] = {
      ^
7532.     { { 13, 13 },                                                 },
7533.     { {  0, 64 }, { 64,  0 },                                     },

libavcodec/dcadata.h:7531:1: Array declaration
    7529. };
    7530. 
    7531. static const uint8_t dca_default_coeffs[16][5][2] = {
          ^
    7532.     { { 13, 13 },                                                 },
    7533.     { {  0, 64 }, { 64,  0 },                                     },

libavcodec/dca.c:683:41: Array access: Offset: [0, 6] Size: 5 by call to `dca_decode_block` 
    681.             int am = s->amode & DCA_CHANNEL_MASK;
    682.             for (j = base_channel; j < s->prim_channels; j++) {
    683.                 s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
                                                 ^
    684.                 s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
    685.             }

static int dca_subframe_header(DCAContext * s, int base_channel, int block_index)
{
    int j, k;
    if (!base_channel) {
        s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;
        s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        for (k = 0; k < s->subband_activity[j]; k++)
            s->prediction_mode[j][k] = get_bits(&s->gb, 1);
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        for (k = 0; k < s->subband_activity[j]; k++) {
            if (s->prediction_mode[j][k] > 0) {
                s->prediction_vq[j][k] = get_bits(&s->gb, 12);
            }
        }
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        for (k = 0; k < s->vq_start_subband[j]; k++) {
            if (s->bitalloc_huffman[j] == 6)
                s->bitalloc[j][k] = get_bits(&s->gb, 5);
            else if (s->bitalloc_huffman[j] == 5)
                s->bitalloc[j][k] = get_bits(&s->gb, 4);
            else if (s->bitalloc_huffman[j] == 7) {
                av_log(s->avctx, AV_LOG_ERROR,
                       "Invalid bit allocation index\n");
                return -1;
            } else {
                s->bitalloc[j][k] =
                    get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]);
            }
            if (s->bitalloc[j][k] > 26) {
                return -1;
            }
        }
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        for (k = 0; k < s->subband_activity[j]; k++) {
            s->transition_mode[j][k] = 0;
            if (s->subsubframes[s->current_subframe] > 1 &&
                k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
                s->transition_mode[j][k] =
                    get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
            }
        }
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        const uint32_t *scale_table;
        int scale_sum;
        memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
        if (s->scalefactor_huffman[j] == 6)
            scale_table = scale_factor_quant7;
        else
            scale_table = scale_factor_quant6;
        scale_sum = 0;
        for (k = 0; k < s->subband_activity[j]; k++) {
            if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
                scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
                s->scale_factor[j][k][0] = scale_table[scale_sum];
            }
            if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
                scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
                s->scale_factor[j][k][1] = scale_table[scale_sum];
            }
        }
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        if (s->joint_intensity[j] > 0)
            s->joint_huff[j] = get_bits(&s->gb, 3);
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        int source_channel;
        if (s->joint_intensity[j] > 0) {
            int scale = 0;
            source_channel = s->joint_intensity[j] - 1;
            for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
                scale = get_scale(&s->gb, s->joint_huff[j], 0);
                scale += 64;
                s->joint_scale_factor[j][k] = scale;
            }
            if (!(s->debug_flag & 0x02)) {
                av_log(s->avctx, AV_LOG_DEBUG,
                       "Joint stereo coding not supported\n");
                s->debug_flag |= 0x02;
            }
        }
    }
    if (!base_channel && s->prim_channels > 2) {
        if (s->downmix) {
            for (j = base_channel; j < s->prim_channels; j++) {
                s->downmix_coef[j][0] = get_bits(&s->gb, 7);
                s->downmix_coef[j][1] = get_bits(&s->gb, 7);
            }
        } else {
            int am = s->amode & DCA_CHANNEL_MASK;
            for (j = base_channel; j < s->prim_channels; j++) {
                s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
                s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
            }
        }
    }
    if (s->dynrange)
        s->dynrange_coef = get_bits(&s->gb, 8);
    if (s->crc_present) {
        get_bits(&s->gb, 16);
    }
    for (j = base_channel; j < s->prim_channels; j++)
        for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
            s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
    if (!base_channel && s->lfe) {
        int lfe_samples = 2 * s->lfe * (4 + block_index);
        int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
        float lfe_scale;
        for (j = lfe_samples; j < lfe_end_sample; j++) {
            s->lfe_data[j] = get_sbits(&s->gb, 8);
        }
        s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];
        lfe_scale = 0.035 * s->lfe_scale_factor;
        for (j = lfe_samples; j < lfe_end_sample; j++)
            s->lfe_data[j] *= lfe_scale;
    }
#ifdef TRACE
    av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]);
    av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
           s->partial_samples[s->current_subframe]);
    for (j = base_channel; j < s->prim_channels; j++) {
        av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
        for (k = 0; k < s->subband_activity[j]; k++)
            av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        for (k = 0; k < s->subband_activity[j]; k++)
                av_log(s->avctx, AV_LOG_DEBUG,
                       "prediction coefs: %f, %f, %f, %f\n",
                       (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
                       (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
                       (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
                       (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
        for (k = 0; k < s->vq_start_subband[j]; k++)
            av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
        for (k = 0; k < s->subband_activity[j]; k++)
            av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
        for (k = 0; k < s->subband_activity[j]; k++) {
            if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
                av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
            if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
                av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
        }
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
    for (j = base_channel; j < s->prim_channels; j++) {
        if (s->joint_intensity[j] > 0) {
            int source_channel = s->joint_intensity[j] - 1;
            av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
            for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
                av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
            av_log(s->avctx, AV_LOG_DEBUG, "\n");
        }
    }
    if (!base_channel && s->prim_channels > 2 && s->downmix) {
        av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
        for (j = 0; j < s->prim_channels; j++) {
            av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);
            av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);
        }
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
    for (j = base_channel; j < s->prim_channels; j++)
        for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
            av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
    if (!base_channel && s->lfe) {
        int lfe_samples = 2 * s->lfe * (4 + block_index);
        int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
        av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
        for (j = lfe_samples; j < lfe_end_sample; j++)
            av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
        av_log(s->avctx, AV_LOG_DEBUG, "\n");
    }
#endif
    return 0;
}
['static int dca_decode_frame(AVCodecContext * avctx,\n                            void *data, int *data_size,\n                            AVPacket *avpkt)\n{\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;\n    int xch_present = 0;\n    int16_t *samples = data;\n    DCAContext *s = avctx->priv_data;\n    int channels;\n    s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);\n    if (s->dca_buffer_size == -1) {\n        av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\\n");\n        return -1;\n    }\n    init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);\n    if (dca_parse_frame_header(s) < 0) {\n        *data_size=0;\n        return buf_size;\n    }\n    avctx->sample_rate = s->sample_rate;\n    avctx->bit_rate = s->bit_rate;\n    for (i = 0; i < (s->sample_blocks / 8); i++) {\n        dca_decode_block(s, 0, i);\n    }\n    num_core_channels = s->prim_channels;\n    skip_bits(&s->gb, (-get_bits_count(&s->gb)) & 31);\n    while(get_bits_left(&s->gb) >= 32) {\n        uint32_t bits = get_bits(&s->gb, 32);\n        switch(bits) {\n        case 0x5a5a5a5a: {\n            int ext_base_ch = s->prim_channels;\n            int ext_amode;\n            skip_bits(&s->gb, 10);\n            if ((ext_amode = get_bits(&s->gb, 4)) != 1) {\n                av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"\n                       " supported!\\n",ext_amode);\n                continue;\n            }\n            dca_parse_audio_coding_header(s, ext_base_ch);\n            for (i = 0; i < (s->sample_blocks / 8); i++) {\n                dca_decode_block(s, ext_base_ch, i);\n            }\n            xch_present = 1;\n            break;\n        }\n        case 0x1d95f262:\n            av_log(avctx, AV_LOG_DEBUG, "Possible X96 extension found at %d bits\\n", get_bits_count(&s->gb));\n            av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\\n", get_bits(&s->gb, 12)+1);\n            av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\\n", get_bits(&s->gb, 4));\n            break;\n        }\n        skip_bits(&s->gb, (-get_bits_count(&s->gb)) & 31);\n    }\n    channels = s->prim_channels + !!s->lfe;\n    if (s->amode<16) {\n        avctx->channel_layout = dca_core_channel_layout[s->amode];\n        if (xch_present && (!avctx->request_channels ||\n                            avctx->request_channels > num_core_channels)) {\n            avctx->channel_layout |= CH_BACK_CENTER;\n            if (s->lfe) {\n                avctx->channel_layout |= CH_LOW_FREQUENCY;\n                s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode];\n            } else {\n                s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode];\n            }\n        } else {\n            if (s->lfe) {\n                avctx->channel_layout |= CH_LOW_FREQUENCY;\n                s->channel_order_tab = dca_channel_reorder_lfe[s->amode];\n            } else\n                s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];\n        }\n        if (s->prim_channels > 0 &&\n            s->channel_order_tab[s->prim_channels - 1] < 0)\n            return -1;\n        if (avctx->request_channels == 2 && s->prim_channels > 2) {\n            channels = 2;\n            s->output = DCA_STEREO;\n            avctx->channel_layout = CH_LAYOUT_STEREO;\n        }\n    } else {\n        av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\\n",s->amode);\n        return -1;\n    }\n    if (!avctx->channels)\n        avctx->channels = channels;\n    if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)\n        return -1;\n    *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels;\n    for (i = 0; i < (s->sample_blocks / 8); i++) {\n        dca_filter_channels(s, i);\n        s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);\n        samples += 256 * channels;\n    }\n    lfe_samples = 2 * s->lfe * (s->sample_blocks / 8);\n    for (i = 0; i < 2 * s->lfe * 4; i++) {\n        s->lfe_data[i] = s->lfe_data[i + lfe_samples];\n    }\n    return buf_size;\n}', 'static int dca_parse_audio_coding_header(DCAContext * s, int base_channel)\n{\n    int i, j;\n    static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };\n    static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };\n    static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };\n    s->total_channels    = get_bits(&s->gb, 3) + 1 + base_channel;\n    s->prim_channels     = s->total_channels;\n    if (s->prim_channels > DCA_PRIM_CHANNELS_MAX)\n        s->prim_channels = DCA_PRIM_CHANNELS_MAX;\n    for (i = base_channel; i < s->prim_channels; i++) {\n        s->subband_activity[i] = get_bits(&s->gb, 5) + 2;\n        if (s->subband_activity[i] > DCA_SUBBANDS)\n            s->subband_activity[i] = DCA_SUBBANDS;\n    }\n    for (i = base_channel; i < s->prim_channels; i++) {\n        s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1;\n        if (s->vq_start_subband[i] > DCA_SUBBANDS)\n            s->vq_start_subband[i] = DCA_SUBBANDS;\n    }\n    get_array(&s->gb, s->joint_intensity + base_channel,     s->prim_channels - base_channel, 3);\n    get_array(&s->gb, s->transient_huffman + base_channel,   s->prim_channels - base_channel, 2);\n    get_array(&s->gb, s->scalefactor_huffman + base_channel, s->prim_channels - base_channel, 3);\n    get_array(&s->gb, s->bitalloc_huffman + base_channel,    s->prim_channels - base_channel, 3);\n    if (!base_channel)\n        memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman));\n    for (j = 1; j < 11; j++)\n        for (i = base_channel; i < s->prim_channels; i++)\n            s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]);\n    for (j = 0; j < 11; j++)\n        for (i = base_channel; i < s->prim_channels; i++)\n            s->scalefactor_adj[i][j] = 1;\n    for (j = 1; j < 11; j++)\n        for (i = base_channel; i < s->prim_channels; i++)\n            if (s->quant_index_huffman[i][j] < thr[j])\n                s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)];\n    if (s->crc_present) {\n        get_bits(&s->gb, 16);\n    }\n    s->current_subframe = 0;\n    s->current_subsubframe = 0;\n#ifdef TRACE\n    av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\\n", s->subframes);\n    av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\\n", s->prim_channels);\n    for (i = base_channel; i < s->prim_channels; i++){\n        av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\\n", s->subband_activity[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\\n", s->vq_start_subband[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\\n", s->joint_intensity[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\\n", s->transient_huffman[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\\n", s->scalefactor_huffman[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\\n", s->bitalloc_huffman[i]);\n        av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");\n        for (j = 0; j < 11; j++)\n            av_log(s->avctx, AV_LOG_DEBUG, " %i",\n                   s->quant_index_huffman[i][j]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n        av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");\n        for (j = 0; j < 11; j++)\n            av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n#endif\n  return 0;\n}', 'static int dca_decode_block(DCAContext * s, int base_channel, int block_index)\n{\n    if (s->current_subframe >= s->subframes) {\n        av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i",\n               s->current_subframe, s->subframes);\n        return -1;\n    }\n    if (!s->current_subsubframe) {\n#ifdef TRACE\n        av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\\n");\n#endif\n        if (dca_subframe_header(s, base_channel, block_index))\n            return -1;\n    }\n#ifdef TRACE\n    av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\\n");\n#endif\n    if (dca_subsubframe(s, base_channel, block_index))\n        return -1;\n    s->current_subsubframe++;\n    if (s->current_subsubframe >= s->subsubframes[s->current_subframe]) {\n        s->current_subsubframe = 0;\n        s->current_subframe++;\n    }\n    if (s->current_subframe >= s->subframes) {\n#ifdef TRACE\n        av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\\n");\n#endif\n        if (dca_subframe_footer(s, base_channel))\n            return -1;\n    }\n    return 0;\n}', 'static int dca_subframe_header(DCAContext * s, int base_channel, int block_index)\n{\n    int j, k;\n    if (!base_channel) {\n        s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;\n        s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        for (k = 0; k < s->subband_activity[j]; k++)\n            s->prediction_mode[j][k] = get_bits(&s->gb, 1);\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        for (k = 0; k < s->subband_activity[j]; k++) {\n            if (s->prediction_mode[j][k] > 0) {\n                s->prediction_vq[j][k] = get_bits(&s->gb, 12);\n            }\n        }\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        for (k = 0; k < s->vq_start_subband[j]; k++) {\n            if (s->bitalloc_huffman[j] == 6)\n                s->bitalloc[j][k] = get_bits(&s->gb, 5);\n            else if (s->bitalloc_huffman[j] == 5)\n                s->bitalloc[j][k] = get_bits(&s->gb, 4);\n            else if (s->bitalloc_huffman[j] == 7) {\n                av_log(s->avctx, AV_LOG_ERROR,\n                       "Invalid bit allocation index\\n");\n                return -1;\n            } else {\n                s->bitalloc[j][k] =\n                    get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]);\n            }\n            if (s->bitalloc[j][k] > 26) {\n                return -1;\n            }\n        }\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        for (k = 0; k < s->subband_activity[j]; k++) {\n            s->transition_mode[j][k] = 0;\n            if (s->subsubframes[s->current_subframe] > 1 &&\n                k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {\n                s->transition_mode[j][k] =\n                    get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);\n            }\n        }\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        const uint32_t *scale_table;\n        int scale_sum;\n        memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);\n        if (s->scalefactor_huffman[j] == 6)\n            scale_table = scale_factor_quant7;\n        else\n            scale_table = scale_factor_quant6;\n        scale_sum = 0;\n        for (k = 0; k < s->subband_activity[j]; k++) {\n            if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {\n                scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);\n                s->scale_factor[j][k][0] = scale_table[scale_sum];\n            }\n            if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {\n                scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);\n                s->scale_factor[j][k][1] = scale_table[scale_sum];\n            }\n        }\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        if (s->joint_intensity[j] > 0)\n            s->joint_huff[j] = get_bits(&s->gb, 3);\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        int source_channel;\n        if (s->joint_intensity[j] > 0) {\n            int scale = 0;\n            source_channel = s->joint_intensity[j] - 1;\n            for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {\n                scale = get_scale(&s->gb, s->joint_huff[j], 0);\n                scale += 64;\n                s->joint_scale_factor[j][k] = scale;\n            }\n            if (!(s->debug_flag & 0x02)) {\n                av_log(s->avctx, AV_LOG_DEBUG,\n                       "Joint stereo coding not supported\\n");\n                s->debug_flag |= 0x02;\n            }\n        }\n    }\n    if (!base_channel && s->prim_channels > 2) {\n        if (s->downmix) {\n            for (j = base_channel; j < s->prim_channels; j++) {\n                s->downmix_coef[j][0] = get_bits(&s->gb, 7);\n                s->downmix_coef[j][1] = get_bits(&s->gb, 7);\n            }\n        } else {\n            int am = s->amode & DCA_CHANNEL_MASK;\n            for (j = base_channel; j < s->prim_channels; j++) {\n                s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];\n                s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];\n            }\n        }\n    }\n    if (s->dynrange)\n        s->dynrange_coef = get_bits(&s->gb, 8);\n    if (s->crc_present) {\n        get_bits(&s->gb, 16);\n    }\n    for (j = base_channel; j < s->prim_channels; j++)\n        for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)\n            s->high_freq_vq[j][k] = get_bits(&s->gb, 10);\n    if (!base_channel && s->lfe) {\n        int lfe_samples = 2 * s->lfe * (4 + block_index);\n        int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);\n        float lfe_scale;\n        for (j = lfe_samples; j < lfe_end_sample; j++) {\n            s->lfe_data[j] = get_sbits(&s->gb, 8);\n        }\n        s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];\n        lfe_scale = 0.035 * s->lfe_scale_factor;\n        for (j = lfe_samples; j < lfe_end_sample; j++)\n            s->lfe_data[j] *= lfe_scale;\n    }\n#ifdef TRACE\n    av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\\n", s->subsubframes[s->current_subframe]);\n    av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\\n",\n           s->partial_samples[s->current_subframe]);\n    for (j = base_channel; j < s->prim_channels; j++) {\n        av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");\n        for (k = 0; k < s->subband_activity[j]; k++)\n            av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        for (k = 0; k < s->subband_activity[j]; k++)\n                av_log(s->avctx, AV_LOG_DEBUG,\n                       "prediction coefs: %f, %f, %f, %f\\n",\n                       (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,\n                       (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,\n                       (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,\n                       (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");\n        for (k = 0; k < s->vq_start_subband[j]; k++)\n            av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");\n        for (k = 0; k < s->subband_activity[j]; k++)\n            av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");\n        for (k = 0; k < s->subband_activity[j]; k++) {\n            if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)\n                av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);\n            if (k < s->vq_start_subband[j] && s->transition_mode[j][k])\n                av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);\n        }\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n    for (j = base_channel; j < s->prim_channels; j++) {\n        if (s->joint_intensity[j] > 0) {\n            int source_channel = s->joint_intensity[j] - 1;\n            av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\\n");\n            for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)\n                av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);\n            av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n        }\n    }\n    if (!base_channel && s->prim_channels > 2 && s->downmix) {\n        av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\\n");\n        for (j = 0; j < s->prim_channels; j++) {\n            av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);\n            av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);\n        }\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n    for (j = base_channel; j < s->prim_channels; j++)\n        for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)\n            av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\\n", s->high_freq_vq[j][k]);\n    if (!base_channel && s->lfe) {\n        int lfe_samples = 2 * s->lfe * (4 + block_index);\n        int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);\n        av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\\n");\n        for (j = lfe_samples; j < lfe_end_sample; j++)\n            av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);\n        av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n    }\n#endif\n    return 0;\n}']