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

                            const AVFrame *frame, int *got_packet_ptr)

{

    MpegAudioContext *s = avctx->priv_data;

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

    short smr[MPA_MAX_CHANNELS][SBLIMIT];

    unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];

    int padding, i, ret;



    for(i=0;i<s->nb_channels;i++) {

        filter(s, i, samples + i, s->nb_channels);

    }



    for(i=0;i<s->nb_channels;i++) {

        compute_scale_factors(s, s->scale_code[i], s->scale_factors[i],

                              s->sb_samples[i], s->sblimit);

    }

    for(i=0;i<s->nb_channels;i++) {

        psycho_acoustic_model(s, smr[i]);

    }

    compute_bit_allocation(s, smr, bit_alloc, &padding);



    if ((ret = ff_alloc_packet(avpkt, MPA_MAX_CODED_FRAME_SIZE))) {

        av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");

        return ret;

    }



    init_put_bits(&s->pb, avpkt->data, avpkt->size);



    encode_frame(s, bit_alloc, padding);



    if (frame->pts != AV_NOPTS_VALUE)

        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);



    avpkt->size = put_bits_count(&s->pb) / 8;

    *got_packet_ptr = 1;

    return 0;

}

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

                            const AVFrame *frame, int *got_packet_ptr)

{

    MpegAudioContext *s = avctx->priv_data;

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

    short smr[MPA_MAX_CHANNELS][SBLIMIT];

    unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];

    int padding, i, ret;



    for(i=0;i<s->nb_channels;i++) {

        filter(s, i, samples + i, s->nb_channels);

    }



    for(i=0;i<s->nb_channels;i++) {

        compute_scale_factors(s, s->scale_code[i], s->scale_factors[i],

                              s->sb_samples[i], s->sblimit);

    }

    for(i=0;i<s->nb_channels;i++) {

        psycho_acoustic_model(s, smr[i]);

    }

    compute_bit_allocation(s, smr, bit_alloc, &padding);



    if ((ret = ff_alloc_packet(avpkt, MPA_MAX_CODED_FRAME_SIZE))) {

        av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");

        return ret;

    }



    init_put_bits(&s->pb, avpkt->data, avpkt->size);



    encode_frame(s, bit_alloc, padding);



    if (frame->pts != AV_NOPTS_VALUE)

        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);



    avpkt->size = put_bits_count(&s->pb) / 8;

    *got_packet_ptr = 1;

    return 0;

}

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

                            const AVFrame *VAR_2, int *VAR_3)

{

    MpegAudioContext *s = VAR_0->priv_data;

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

    short VAR_5[MPA_MAX_CHANNELS][SBLIMIT];

    unsigned char VAR_6[MPA_MAX_CHANNELS][SBLIMIT];

    int VAR_7, VAR_8, VAR_9;



    for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) {

        filter(s, VAR_8, VAR_4 + VAR_8, s->nb_channels);

    }



    for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) {

        compute_scale_factors(s, s->scale_code[VAR_8], s->scale_factors[VAR_8],

                              s->sb_samples[VAR_8], s->sblimit);

    }

    for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) {

        psycho_acoustic_model(s, VAR_5[VAR_8]);

    }

    compute_bit_allocation(s, VAR_5, VAR_6, &VAR_7);



    if ((VAR_9 = ff_alloc_packet(VAR_1, MPA_MAX_CODED_FRAME_SIZE))) {

        av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet\n");

        return VAR_9;

    }



    init_put_bits(&s->pb, VAR_1->data, VAR_1->size);



    encode_frame(s, VAR_6, VAR_7);



    if (VAR_2->pts != AV_NOPTS_VALUE)

        VAR_1->pts = VAR_2->pts - ff_samples_to_time_base(VAR_0, VAR_0->delay);



    VAR_1->size = put_bits_count(&s->pb) / 8;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ MpegAudioContext *s = VAR_0->priv_data; const int16_t *VAR_4 = (const int16_t *)VAR_2->data[0]; short VAR_5[MPA_MAX_CHANNELS][SBLIMIT]; unsigned char VAR_6[MPA_MAX_CHANNELS][SBLIMIT]; int VAR_7, VAR_8, VAR_9; for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) { filter(s, VAR_8, VAR_4 + VAR_8, s->nb_channels); } for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) { compute_scale_factors(s, s->scale_code[VAR_8], s->scale_factors[VAR_8],
s->sb_samples[VAR_8], s->sblimit); } for(VAR_8=0;VAR_8<s->nb_channels;VAR_8++) { psycho_acoustic_model(s, VAR_5[VAR_8]); } compute_bit_allocation(s, VAR_5, VAR_6, &VAR_7); if ((VAR_9 = ff_alloc_packet(VAR_1, MPA_MAX_CODED_FRAME_SIZE))) { av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet\n"); return VAR_9; } init_put_bits(&s->pb, VAR_1->data, VAR_1->size); encode_frame(s, VAR_6, VAR_7); if (VAR_2->pts != AV_NOPTS_VALUE)
VAR_1->pts = VAR_2->pts - ff_samples_to_time_base(VAR_0, VAR_0->delay); VAR_1->size = put_bits_count(&s->pb) / 8; *VAR_3 = 1; return 0; }