static int adx_decode_frame(AVCodecContext *avctx, void *data,

                            int *got_frame_ptr, AVPacket *avpkt)

{

    int buf_size        = avpkt->size;

    ADXContext *c       = avctx->priv_data;

    int16_t *samples;

    const uint8_t *buf  = avpkt->data;

    int num_blocks, ch, ret;



    if (c->eof) {

        *got_frame_ptr = 0;

        return buf_size;

    }



    if(AV_RB16(buf) == 0x8000){

        int header_size;

        if ((ret = avpriv_adx_decode_header(avctx, buf,

                                            buf_size, &header_size,

                                            c->coeff)) < 0) {

            av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");


        }

        c->channels = avctx->channels;

        if(buf_size < header_size)


        buf += header_size;

        buf_size -= header_size;

    }





    /* calculate number of blocks in the packet */

    num_blocks = buf_size / (BLOCK_SIZE * c->channels);



    /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF

       packet */

    if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) {

        if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {

            c->eof = 1;

            *got_frame_ptr = 0;

            return avpkt->size;

        }


    }



    /* get output buffer */

    c->frame.nb_samples = num_blocks * BLOCK_SAMPLES;

    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }

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



    while (num_blocks--) {

        for (ch = 0; ch < c->channels; ch++) {

            if (adx_decode(c, samples + ch, buf, ch)) {

                c->eof = 1;

                buf = avpkt->data + avpkt->size;

                break;

            }

            buf_size -= BLOCK_SIZE;

            buf      += BLOCK_SIZE;

        }

        samples += BLOCK_SAMPLES * c->channels;

    }



    *got_frame_ptr   = 1;

    *(AVFrame *)data = c->frame;



    return buf - avpkt->data;

}
static int adx_decode_frame(AVCodecContext *avctx, void *data,

                            int *got_frame_ptr, AVPacket *avpkt)

{

    int buf_size        = avpkt->size;

    ADXContext *c       = avctx->priv_data;

    int16_t *samples;

    const uint8_t *buf  = avpkt->data;

    int num_blocks, ch, ret;



    if (c->eof) {

        *got_frame_ptr = 0;

        return buf_size;

    }



    if(AV_RB16(buf) == 0x8000){

        int header_size;

        if ((ret = avpriv_adx_decode_header(avctx, buf,

                                            buf_size, &header_size,

                                            c->coeff)) < 0) {

            av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");


        }

        c->channels = avctx->channels;

        if(buf_size < header_size)


        buf += header_size;

        buf_size -= header_size;

    }





    

    num_blocks = buf_size / (BLOCK_SIZE * c->channels);



    



    if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) {

        if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {

            c->eof = 1;

            *got_frame_ptr = 0;

            return avpkt->size;

        }


    }



    

    c->frame.nb_samples = num_blocks * BLOCK_SAMPLES;

    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }

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



    while (num_blocks--) {

        for (ch = 0; ch < c->channels; ch++) {

            if (adx_decode(c, samples + ch, buf, ch)) {

                c->eof = 1;

                buf = avpkt->data + avpkt->size;

                break;

            }

            buf_size -= BLOCK_SIZE;

            buf      += BLOCK_SIZE;

        }

        samples += BLOCK_SAMPLES * c->channels;

    }



    *got_frame_ptr   = 1;

    *(AVFrame *)data = c->frame;



    return buf - avpkt->data;

}
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,

                            int *VAR_2, AVPacket *VAR_3)

{

    int VAR_4        = VAR_3->size;

    ADXContext *c       = VAR_0->priv_data;

    int16_t *samples;

    const uint8_t *VAR_5  = VAR_3->VAR_1;

    int VAR_6, VAR_7, VAR_8;



    if (c->eof) {

        *VAR_2 = 0;

        return VAR_4;

    }



    if(AV_RB16(VAR_5) == 0x8000){

        int VAR_9;

        if ((VAR_8 = avpriv_adx_decode_header(VAR_0, VAR_5,

                                            VAR_4, &VAR_9,

                                            c->coeff)) < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "error parsing ADX header\n");


        }

        c->channels = VAR_0->channels;

        if(VAR_4 < VAR_9)


        VAR_5 += VAR_9;

        VAR_4 -= VAR_9;

    }





    

    VAR_6 = VAR_4 / (BLOCK_SIZE * c->channels);



    



    if (!VAR_6 || VAR_4 % (BLOCK_SIZE * VAR_0->channels)) {

        if (VAR_4 >= 4 && (AV_RB16(VAR_5) & 0x8000)) {

            c->eof = 1;

            *VAR_2 = 0;

            return VAR_3->size;

        }


    }



    

    c->frame.nb_samples = VAR_6 * BLOCK_SAMPLES;

    if ((VAR_8 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return VAR_8;

    }

    samples = (int16_t *)c->frame.VAR_1[0];



    while (VAR_6--) {

        for (VAR_7 = 0; VAR_7 < c->channels; VAR_7++) {

            if (adx_decode(c, samples + VAR_7, VAR_5, VAR_7)) {

                c->eof = 1;

                VAR_5 = VAR_3->VAR_1 + VAR_3->size;

                break;

            }

            VAR_4 -= BLOCK_SIZE;

            VAR_5      += BLOCK_SIZE;

        }

        samples += BLOCK_SAMPLES * c->channels;

    }



    *VAR_2   = 1;

    *(AVFrame *)VAR_1 = c->frame;



    return VAR_5 - VAR_3->VAR_1;

}
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ int VAR_4        = VAR_3->size; ADXContext *c       = VAR_0->priv_data; int16_t *samples; const uint8_t *VAR_5  = VAR_3->VAR_1; int VAR_6, VAR_7, VAR_8; if (c->eof) { *VAR_2 = 0; return VAR_4; } if(AV_RB16(VAR_5) == 0x8000){ int VAR_9; if ((VAR_8 = avpriv_adx_decode_header(VAR_0, VAR_5,
VAR_4, &VAR_9,
c->coeff)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "error parsing ADX header\n"); } c->channels = VAR_0->channels; if(VAR_4 < VAR_9)
VAR_5 += VAR_9; VAR_4 -= VAR_9; } VAR_6 = VAR_4 / (BLOCK_SIZE * c->channels); if (!VAR_6 || VAR_4 % (BLOCK_SIZE * VAR_0->channels)) { if (VAR_4 >= 4 && (AV_RB16(VAR_5) & 0x8000)) { c->eof = 1; *VAR_2 = 0; return VAR_3->size; } } c->frame.nb_samples = VAR_6 * BLOCK_SAMPLES; if ((VAR_8 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_8; } samples = (int16_t *)c->frame.VAR_1[0]; while (VAR_6--) { for (VAR_7 = 0; VAR_7 < c->channels; VAR_7++) { if (adx_decode(c, samples + VAR_7, VAR_5, VAR_7)) { c->eof = 1; VAR_5 = VAR_3->VAR_1 + VAR_3->size; break; } VAR_4 -= BLOCK_SIZE; VAR_5      += BLOCK_SIZE; } samples += BLOCK_SAMPLES * c->channels; } *VAR_2   = 1; *(AVFrame *)VAR_1 = c->frame; return VAR_5 - VAR_3->VAR_1; }