static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,

                        const AVFrame *frame, int *got_packet_ptr)

{

    int i, k, channel;

    DCAContext *c = avctx->priv_data;

    const int16_t *samples;

    int ret, real_channel = 0;



    if ((ret = ff_alloc_packet2(avctx, avpkt, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE)))

        return ret;



    samples = (const int16_t *)frame->data[0];

    for (i = 0; i < PCM_SAMPLES; i ++) { /* i is the decimated sample number */

        for (channel = 0; channel < c->prim_channels + 1; channel++) {

            real_channel = c->channel_order_tab[channel];

            if (real_channel >= 0) {

                /* Get 32 PCM samples */

                for (k = 0; k < 32; k++) { /* k is the sample number in a 32-sample block */

                    c->pcm[k] = samples[avctx->channels * (32 * i + k) + channel] << 16;

                }

                /* Put subband samples into the proper place */

                qmf_decompose(c, c->pcm, &c->subband[i][real_channel][0], real_channel);

            }

        }

    }



    if (c->lfe_channel) {

        for (i = 0; i < PCM_SAMPLES / 2; i++) {

            for (k = 0; k < LFE_INTERPOLATION; k++) /* k is the sample number in a 32-sample block */

                c->pcm[k] = samples[avctx->channels * (LFE_INTERPOLATION*i+k) + c->lfe_offset] << 16;

            c->lfe_data[i] = lfe_downsample(c, c->pcm);

        }

    }



    put_frame(c, c->subband, avpkt->data);



    avpkt->size     = c->frame_size;

    *got_packet_ptr = 1;

    return 0;

}

static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,

                        const AVFrame *frame, int *got_packet_ptr)

{

    int i, k, channel;

    DCAContext *c = avctx->priv_data;

    const int16_t *samples;

    int ret, real_channel = 0;



    if ((ret = ff_alloc_packet2(avctx, avpkt, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE)))

        return ret;



    samples = (const int16_t *)frame->data[0];

    for (i = 0; i < PCM_SAMPLES; i ++) { 

        for (channel = 0; channel < c->prim_channels + 1; channel++) {

            real_channel = c->channel_order_tab[channel];

            if (real_channel >= 0) {

                

                for (k = 0; k < 32; k++) { 

                    c->pcm[k] = samples[avctx->channels * (32 * i + k) + channel] << 16;

                }

                

                qmf_decompose(c, c->pcm, &c->subband[i][real_channel][0], real_channel);

            }

        }

    }



    if (c->lfe_channel) {

        for (i = 0; i < PCM_SAMPLES / 2; i++) {

            for (k = 0; k < LFE_INTERPOLATION; k++) 

                c->pcm[k] = samples[avctx->channels * (LFE_INTERPOLATION*i+k) + c->lfe_offset] << 16;

            c->lfe_data[i] = lfe_downsample(c, c->pcm);

        }

    }



    put_frame(c, c->subband, avpkt->data);



    avpkt->size     = c->frame_size;

    *got_packet_ptr = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,

                        const AVFrame *VAR_2, int *VAR_3)

{

    int VAR_4, VAR_5, VAR_6;

    DCAContext *c = VAR_0->priv_data;

    const int16_t *VAR_7;

    int VAR_8, VAR_9 = 0;



    if ((VAR_8 = ff_alloc_packet2(VAR_0, VAR_1, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE)))

        return VAR_8;



    VAR_7 = (const int16_t *)VAR_2->data[0];

    for (VAR_4 = 0; VAR_4 < PCM_SAMPLES; VAR_4 ++) { 

        for (VAR_6 = 0; VAR_6 < c->prim_channels + 1; VAR_6++) {

            VAR_9 = c->channel_order_tab[VAR_6];

            if (VAR_9 >= 0) {

                

                for (VAR_5 = 0; VAR_5 < 32; VAR_5++) { 

                    c->pcm[VAR_5] = VAR_7[VAR_0->channels * (32 * VAR_4 + VAR_5) + VAR_6] << 16;

                }

                

                qmf_decompose(c, c->pcm, &c->subband[VAR_4][VAR_9][0], VAR_9);

            }

        }

    }



    if (c->lfe_channel) {

        for (VAR_4 = 0; VAR_4 < PCM_SAMPLES / 2; VAR_4++) {

            for (VAR_5 = 0; VAR_5 < LFE_INTERPOLATION; VAR_5++) 

                c->pcm[VAR_5] = VAR_7[VAR_0->channels * (LFE_INTERPOLATION*VAR_4+VAR_5) + c->lfe_offset] << 16;

            c->lfe_data[VAR_4] = lfe_downsample(c, c->pcm);

        }

    }



    put_frame(c, c->subband, VAR_1->data);



    VAR_1->size     = c->frame_size;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ int VAR_4, VAR_5, VAR_6; DCAContext *c = VAR_0->priv_data; const int16_t *VAR_7; int VAR_8, VAR_9 = 0; if ((VAR_8 = ff_alloc_packet2(VAR_0, VAR_1, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE)))
return VAR_8; VAR_7 = (const int16_t *)VAR_2->data[0]; for (VAR_4 = 0; VAR_4 < PCM_SAMPLES; VAR_4 ++) { for (VAR_6 = 0; VAR_6 < c->prim_channels + 1; VAR_6++) { VAR_9 = c->channel_order_tab[VAR_6]; if (VAR_9 >= 0) { for (VAR_5 = 0; VAR_5 < 32; VAR_5++) { c->pcm[VAR_5] = VAR_7[VAR_0->channels * (32 * VAR_4 + VAR_5) + VAR_6] << 16; } qmf_decompose(c, c->pcm, &c->subband[VAR_4][VAR_9][0], VAR_9); } } } if (c->lfe_channel) { for (VAR_4 = 0; VAR_4 < PCM_SAMPLES / 2; VAR_4++) { for (VAR_5 = 0; VAR_5 < LFE_INTERPOLATION; VAR_5++) c->pcm[VAR_5] = VAR_7[VAR_0->channels * (LFE_INTERPOLATION*VAR_4+VAR_5) + c->lfe_offset] << 16; c->lfe_data[VAR_4] = lfe_downsample(c, c->pcm); } } put_frame(c, c->subband, VAR_1->data); VAR_1->size     = c->frame_size; *VAR_3 = 1; return 0; }