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

                               int *got_frame_ptr, AVPacket *avpkt)

{

    AVFrame *frame         = data;

    const uint8_t *buf     = avpkt->data;

    int buf_size           = avpkt->size;

    MP3On4DecodeContext *s = avctx->priv_data;

    MPADecodeContext *m;

    int fsize, len = buf_size, out_size = 0;

    uint32_t header;

    OUT_INT **out_samples;

    OUT_INT *outptr[2];

    int fr, ch, ret;



    /* get output buffer */

    frame->nb_samples = MPA_FRAME_SIZE;

    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {

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

        return ret;

    }

    out_samples = (OUT_INT **)frame->extended_data;



    // Discard too short frames

    if (buf_size < HEADER_SIZE)

        return AVERROR_INVALIDDATA;



    avctx->bit_rate = 0;



    ch = 0;

    for (fr = 0; fr < s->frames; fr++) {

        fsize = AV_RB16(buf) >> 4;

        fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE);

        m     = s->mp3decctx[fr];

        assert(m != NULL);



        if (fsize < HEADER_SIZE) {

            av_log(avctx, AV_LOG_ERROR, "Frame size smaller than header size\n");

            return AVERROR_INVALIDDATA;

        }

        header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header



        if (ff_mpa_check_header(header) < 0) // Bad header, discard block

            break;



        avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);



        if (ch + m->nb_channels > avctx->channels ||

            s->coff[fr] + m->nb_channels > avctx->channels) {

            av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "

                                        "channel count\n");

            return AVERROR_INVALIDDATA;

        }

        ch += m->nb_channels;



        outptr[0] = out_samples[s->coff[fr]];

        if (m->nb_channels > 1)

            outptr[1] = out_samples[s->coff[fr] + 1];



        if ((ret = mp_decode_frame(m, outptr, buf, fsize)) < 0)

            return ret;



        out_size += ret;

        buf      += fsize;

        len      -= fsize;



        avctx->bit_rate += m->bit_rate;

    }



    /* update codec info */

    avctx->sample_rate = s->mp3decctx[0]->sample_rate;



    frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT));

    *got_frame_ptr    = 1;



    return buf_size;

}

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

                               int *got_frame_ptr, AVPacket *avpkt)

{

    AVFrame *frame         = data;

    const uint8_t *buf     = avpkt->data;

    int buf_size           = avpkt->size;

    MP3On4DecodeContext *s = avctx->priv_data;

    MPADecodeContext *m;

    int fsize, len = buf_size, out_size = 0;

    uint32_t header;

    OUT_INT **out_samples;

    OUT_INT *outptr[2];

    int fr, ch, ret;



    

    frame->nb_samples = MPA_FRAME_SIZE;

    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {

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

        return ret;

    }

    out_samples = (OUT_INT **)frame->extended_data;



    

    if (buf_size < HEADER_SIZE)

        return AVERROR_INVALIDDATA;



    avctx->bit_rate = 0;



    ch = 0;

    for (fr = 0; fr < s->frames; fr++) {

        fsize = AV_RB16(buf) >> 4;

        fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE);

        m     = s->mp3decctx[fr];

        assert(m != NULL);



        if (fsize < HEADER_SIZE) {

            av_log(avctx, AV_LOG_ERROR, "Frame size smaller than header size\n");

            return AVERROR_INVALIDDATA;

        }

        header = (AV_RB32(buf) & 0x000fffff) | s->syncword; 



        if (ff_mpa_check_header(header) < 0) 

            break;



        avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);



        if (ch + m->nb_channels > avctx->channels ||

            s->coff[fr] + m->nb_channels > avctx->channels) {

            av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "

                                        "channel count\n");

            return AVERROR_INVALIDDATA;

        }

        ch += m->nb_channels;



        outptr[0] = out_samples[s->coff[fr]];

        if (m->nb_channels > 1)

            outptr[1] = out_samples[s->coff[fr] + 1];



        if ((ret = mp_decode_frame(m, outptr, buf, fsize)) < 0)

            return ret;



        out_size += ret;

        buf      += fsize;

        len      -= fsize;



        avctx->bit_rate += m->bit_rate;

    }



    

    avctx->sample_rate = s->mp3decctx[0]->sample_rate;



    frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT));

    *got_frame_ptr    = 1;



    return buf_size;

}

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

                               int *VAR_2, AVPacket *VAR_3)

{

    AVFrame *frame         = VAR_1;

    const uint8_t *VAR_4     = VAR_3->VAR_1;

    int VAR_5           = VAR_3->size;

    MP3On4DecodeContext *s = VAR_0->priv_data;

    MPADecodeContext *m;

    int VAR_6, VAR_7 = VAR_5, VAR_8 = 0;

    uint32_t header;

    OUT_INT **out_samples;

    OUT_INT *outptr[2];

    int VAR_9, VAR_10, VAR_11;



    

    frame->nb_samples = MPA_FRAME_SIZE;

    if ((VAR_11 = ff_get_buffer(VAR_0, frame, 0)) < 0) {

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

        return VAR_11;

    }

    out_samples = (OUT_INT **)frame->extended_data;



    

    if (VAR_5 < HEADER_SIZE)

        return AVERROR_INVALIDDATA;



    VAR_0->bit_rate = 0;



    VAR_10 = 0;

    for (VAR_9 = 0; VAR_9 < s->frames; VAR_9++) {

        VAR_6 = AV_RB16(VAR_4) >> 4;

        VAR_6 = FFMIN3(VAR_6, VAR_7, MPA_MAX_CODED_FRAME_SIZE);

        m     = s->mp3decctx[VAR_9];

        assert(m != NULL);



        if (VAR_6 < HEADER_SIZE) {

            av_log(VAR_0, AV_LOG_ERROR, "Frame size smaller than header size\n");

            return AVERROR_INVALIDDATA;

        }

        header = (AV_RB32(VAR_4) & 0x000fffff) | s->syncword; 



        if (ff_mpa_check_header(header) < 0) 

            break;



        avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);



        if (VAR_10 + m->nb_channels > VAR_0->channels ||

            s->coff[VAR_9] + m->nb_channels > VAR_0->channels) {

            av_log(VAR_0, AV_LOG_ERROR, "frame channel count exceeds codec "

                                        "channel count\n");

            return AVERROR_INVALIDDATA;

        }

        VAR_10 += m->nb_channels;



        outptr[0] = out_samples[s->coff[VAR_9]];

        if (m->nb_channels > 1)

            outptr[1] = out_samples[s->coff[VAR_9] + 1];



        if ((VAR_11 = mp_decode_frame(m, outptr, VAR_4, VAR_6)) < 0)

            return VAR_11;



        VAR_8 += VAR_11;

        VAR_4      += VAR_6;

        VAR_7      -= VAR_6;



        VAR_0->bit_rate += m->bit_rate;

    }



    

    VAR_0->sample_rate = s->mp3decctx[0]->sample_rate;



    frame->nb_samples = VAR_8 / (VAR_0->channels * sizeof(OUT_INT));

    *VAR_2    = 1;



    return VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ AVFrame *frame         = VAR_1; const uint8_t *VAR_4     = VAR_3->VAR_1; int VAR_5           = VAR_3->size; MP3On4DecodeContext *s = VAR_0->priv_data; MPADecodeContext *m; int VAR_6, VAR_7 = VAR_5, VAR_8 = 0; uint32_t header; OUT_INT **out_samples; OUT_INT *outptr[2]; int VAR_9, VAR_10, VAR_11; frame->nb_samples = MPA_FRAME_SIZE; if ((VAR_11 = ff_get_buffer(VAR_0, frame, 0)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_11; } out_samples = (OUT_INT **)frame->extended_data; if (VAR_5 < HEADER_SIZE)
return AVERROR_INVALIDDATA; VAR_0->bit_rate = 0; VAR_10 = 0; for (VAR_9 = 0; VAR_9 < s->frames; VAR_9++) { VAR_6 = AV_RB16(VAR_4) >> 4; VAR_6 = FFMIN3(VAR_6, VAR_7, MPA_MAX_CODED_FRAME_SIZE); m     = s->mp3decctx[VAR_9]; assert(m != NULL); if (VAR_6 < HEADER_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "Frame size smaller than header size\n"); return AVERROR_INVALIDDATA; } header = (AV_RB32(VAR_4) & 0x000fffff) | s->syncword; if (ff_mpa_check_header(header) < 0)
break; avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header); if (VAR_10 + m->nb_channels > VAR_0->channels ||
s->coff[VAR_9] + m->nb_channels > VAR_0->channels) { av_log(VAR_0, AV_LOG_ERROR, "frame channel count exceeds codec "
"channel count\n"); return AVERROR_INVALIDDATA; } VAR_10 += m->nb_channels; outptr[0] = out_samples[s->coff[VAR_9]]; if (m->nb_channels > 1)
outptr[1] = out_samples[s->coff[VAR_9] + 1]; if ((VAR_11 = mp_decode_frame(m, outptr, VAR_4, VAR_6)) < 0)
return VAR_11; VAR_8 += VAR_11; VAR_4      += VAR_6; VAR_7      -= VAR_6; VAR_0->bit_rate += m->bit_rate; } VAR_0->sample_rate = s->mp3decctx[0]->sample_rate; frame->nb_samples = VAR_8 / (VAR_0->channels * sizeof(OUT_INT)); *VAR_2    = 1; return VAR_5; }