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

                               const AVFrame *frame, int *got_packet_ptr)

{

    AMRWBContext *s = avctx->priv_data;

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

    int size, ret;



    if ((ret = ff_alloc_packet2(avctx, avpkt, MAX_PACKET_SIZE)))

        return ret;



    if (s->last_bitrate != avctx->bit_rate) {

        s->mode         = get_wb_bitrate_mode(avctx->bit_rate, avctx);

        s->last_bitrate = avctx->bit_rate;

    }

    size = E_IF_encode(s->state, s->mode, samples, avpkt->data, s->allow_dtx);

    if (size <= 0 || size > MAX_PACKET_SIZE) {

        av_log(avctx, AV_LOG_ERROR, "Error encoding frame\n");

        return AVERROR(EINVAL);

    }



    if (frame->pts != AV_NOPTS_VALUE)

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



    avpkt->size = size;

    *got_packet_ptr = 1;

    return 0;

}

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

                               const AVFrame *frame, int *got_packet_ptr)

{

    AMRWBContext *s = avctx->priv_data;

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

    int size, ret;



    if ((ret = ff_alloc_packet2(avctx, avpkt, MAX_PACKET_SIZE)))

        return ret;



    if (s->last_bitrate != avctx->bit_rate) {

        s->mode         = get_wb_bitrate_mode(avctx->bit_rate, avctx);

        s->last_bitrate = avctx->bit_rate;

    }

    size = E_IF_encode(s->state, s->mode, samples, avpkt->data, s->allow_dtx);

    if (size <= 0 || size > MAX_PACKET_SIZE) {

        av_log(avctx, AV_LOG_ERROR, "Error encoding frame\n");

        return AVERROR(EINVAL);

    }



    if (frame->pts != AV_NOPTS_VALUE)

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



    avpkt->size = size;

    *got_packet_ptr = 1;

    return 0;

}

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

                               const AVFrame *VAR_2, int *VAR_3)

{

    AMRWBContext *s = VAR_0->priv_data;

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

    int VAR_5, VAR_6;



    if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, MAX_PACKET_SIZE)))

        return VAR_6;



    if (s->last_bitrate != VAR_0->bit_rate) {

        s->mode         = get_wb_bitrate_mode(VAR_0->bit_rate, VAR_0);

        s->last_bitrate = VAR_0->bit_rate;

    }

    VAR_5 = E_IF_encode(s->state, s->mode, VAR_4, VAR_1->data, s->allow_dtx);

    if (VAR_5 <= 0 || VAR_5 > MAX_PACKET_SIZE) {

        av_log(VAR_0, AV_LOG_ERROR, "Error encoding VAR_2\n");

        return AVERROR(EINVAL);

    }



    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->VAR_5 = VAR_5;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ AMRWBContext *s = VAR_0->priv_data; const int16_t *VAR_4 = (const int16_t *)VAR_2->data[0]; int VAR_5, VAR_6; if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, MAX_PACKET_SIZE)))
return VAR_6; if (s->last_bitrate != VAR_0->bit_rate) { s->mode         = get_wb_bitrate_mode(VAR_0->bit_rate, VAR_0); s->last_bitrate = VAR_0->bit_rate; } VAR_5 = E_IF_encode(s->state, s->mode, VAR_4, VAR_1->data, s->allow_dtx); if (VAR_5 <= 0 || VAR_5 > MAX_PACKET_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "Error encoding VAR_2\n"); return AVERROR(EINVAL); } 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->VAR_5 = VAR_5; *VAR_3 = 1; return 0; }