static int atrac3_decode_frame(AVCodecContext *avctx,

            void *data, int *data_size,

            AVPacket *avpkt) {

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    ATRAC3Context *q = avctx->priv_data;

    int result = 0;

    const uint8_t* databuf;

    float *samples = data;



    if (buf_size < avctx->block_align) {

        av_log(avctx, AV_LOG_ERROR,

               "Frame too small (%d bytes). Truncated file?\n", buf_size);

        *data_size = 0;

        return buf_size;

    }



    /* Check if we need to descramble and what buffer to pass on. */

    if (q->scrambled_stream) {

        decode_bytes(buf, q->decoded_bytes_buffer, avctx->block_align);

        databuf = q->decoded_bytes_buffer;

    } else {

        databuf = buf;

    }



    result = decodeFrame(q, databuf, q->channels == 2 ? q->outSamples : &samples);



    if (result != 0) {

        av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n");

        return -1;

    }



    /* interleave */

    if (q->channels == 2) {

        q->fmt_conv.float_interleave(samples, (const float **)q->outSamples,

                                     1024, 2);

    }

    *data_size = 1024 * q->channels * av_get_bytes_per_sample(avctx->sample_fmt);



    return avctx->block_align;

}

static int atrac3_decode_frame(AVCodecContext *avctx,

            void *data, int *data_size,

            AVPacket *avpkt) {

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    ATRAC3Context *q = avctx->priv_data;

    int result = 0;

    const uint8_t* databuf;

    float *samples = data;



    if (buf_size < avctx->block_align) {

        av_log(avctx, AV_LOG_ERROR,

               "Frame too small (%d bytes). Truncated file?\n", buf_size);

        *data_size = 0;

        return buf_size;

    }



    

    if (q->scrambled_stream) {

        decode_bytes(buf, q->decoded_bytes_buffer, avctx->block_align);

        databuf = q->decoded_bytes_buffer;

    } else {

        databuf = buf;

    }



    result = decodeFrame(q, databuf, q->channels == 2 ? q->outSamples : &samples);



    if (result != 0) {

        av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n");

        return -1;

    }



    

    if (q->channels == 2) {

        q->fmt_conv.float_interleave(samples, (const float **)q->outSamples,

                                     1024, 2);

    }

    *data_size = 1024 * q->channels * av_get_bytes_per_sample(avctx->sample_fmt);



    return avctx->block_align;

}

static int FUNC_0(AVCodecContext *VAR_0,

            void *VAR_1, int *VAR_2,

            AVPacket *VAR_3) {

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    ATRAC3Context *q = VAR_0->priv_data;

    int VAR_6 = 0;

    const uint8_t* VAR_7;

    float *VAR_8 = VAR_1;



    if (VAR_5 < VAR_0->block_align) {

        av_log(VAR_0, AV_LOG_ERROR,

               "Frame too small (%d bytes). Truncated file?\n", VAR_5);

        *VAR_2 = 0;

        return VAR_5;

    }



    

    if (q->scrambled_stream) {

        decode_bytes(VAR_4, q->decoded_bytes_buffer, VAR_0->block_align);

        VAR_7 = q->decoded_bytes_buffer;

    } else {

        VAR_7 = VAR_4;

    }



    VAR_6 = decodeFrame(q, VAR_7, q->channels == 2 ? q->outSamples : &VAR_8);



    if (VAR_6 != 0) {

        av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n");

        return -1;

    }



    

    if (q->channels == 2) {

        q->fmt_conv.float_interleave(VAR_8, (const float **)q->outSamples,

                                     1024, 2);

    }

    *VAR_2 = 1024 * q->channels * av_get_bytes_per_sample(VAR_0->sample_fmt);



    return VAR_0->block_align;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; ATRAC3Context *q = VAR_0->priv_data; int VAR_6 = 0; const uint8_t* VAR_7; float *VAR_8 = VAR_1; if (VAR_5 < VAR_0->block_align) { av_log(VAR_0, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", VAR_5); *VAR_2 = 0; return VAR_5; } if (q->scrambled_stream) { decode_bytes(VAR_4, q->decoded_bytes_buffer, VAR_0->block_align); VAR_7 = q->decoded_bytes_buffer; } else { VAR_7 = VAR_4; } VAR_6 = decodeFrame(q, VAR_7, q->channels == 2 ? q->outSamples : &VAR_8); if (VAR_6 != 0) { av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n"); return -1; } if (q->channels == 2) { q->fmt_conv.float_interleave(VAR_8, (const float **)q->outSamples,
1024, 2); } *VAR_2 = 1024 * q->channels * av_get_bytes_per_sample(VAR_0->sample_fmt); return VAR_0->block_align; }