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

                             const AVFrame *frame, int *got_packet_ptr)

{

    FaacAudioContext *s = avctx->priv_data;

    int bytes_written, ret;

    int num_samples  = frame ? frame->nb_samples : 0;

    void *samples    = frame ? frame->data[0]    : NULL;



    if ((ret = ff_alloc_packet2(avctx, avpkt, (7 + 768) * avctx->channels))) {

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

        return ret;

    }



    bytes_written = faacEncEncode(s->faac_handle, samples,

                                  num_samples * avctx->channels,

                                  avpkt->data, avpkt->size);

    if (bytes_written < 0) {

        av_log(avctx, AV_LOG_ERROR, "faacEncEncode() error\n");

        return bytes_written;

    }



    /* add current frame to the queue */

    if (frame) {

        if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)

            return ret;

    }



    if (!bytes_written)

        return 0;



    /* Get the next frame pts/duration */

    ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,

                       &avpkt->duration);



    avpkt->size = bytes_written;

    *got_packet_ptr = 1;

    return 0;

}

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

                             const AVFrame *frame, int *got_packet_ptr)

{

    FaacAudioContext *s = avctx->priv_data;

    int bytes_written, ret;

    int num_samples  = frame ? frame->nb_samples : 0;

    void *samples    = frame ? frame->data[0]    : NULL;



    if ((ret = ff_alloc_packet2(avctx, avpkt, (7 + 768) * avctx->channels))) {

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

        return ret;

    }



    bytes_written = faacEncEncode(s->faac_handle, samples,

                                  num_samples * avctx->channels,

                                  avpkt->data, avpkt->size);

    if (bytes_written < 0) {

        av_log(avctx, AV_LOG_ERROR, "faacEncEncode() error\n");

        return bytes_written;

    }



    

    if (frame) {

        if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)

            return ret;

    }



    if (!bytes_written)

        return 0;



    

    ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,

                       &avpkt->duration);



    avpkt->size = bytes_written;

    *got_packet_ptr = 1;

    return 0;

}

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

                             const AVFrame *VAR_2, int *VAR_3)

{

    FaacAudioContext *s = VAR_0->priv_data;

    int VAR_4, VAR_5;

    int VAR_6  = VAR_2 ? VAR_2->nb_samples : 0;

    void *VAR_7    = VAR_2 ? VAR_2->data[0]    : NULL;



    if ((VAR_5 = ff_alloc_packet2(VAR_0, VAR_1, (7 + 768) * VAR_0->channels))) {

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

        return VAR_5;

    }



    VAR_4 = faacEncEncode(s->faac_handle, VAR_7,

                                  VAR_6 * VAR_0->channels,

                                  VAR_1->data, VAR_1->size);

    if (VAR_4 < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "faacEncEncode() error\n");

        return VAR_4;

    }



    

    if (VAR_2) {

        if ((VAR_5 = ff_af_queue_add(&s->afq, VAR_2)) < 0)

            return VAR_5;

    }



    if (!VAR_4)

        return 0;



    

    ff_af_queue_remove(&s->afq, VAR_0->frame_size, &VAR_1->pts,

                       &VAR_1->duration);



    VAR_1->size = VAR_4;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ FaacAudioContext *s = VAR_0->priv_data; int VAR_4, VAR_5; int VAR_6  = VAR_2 ? VAR_2->nb_samples : 0; void *VAR_7    = VAR_2 ? VAR_2->data[0]    : NULL; if ((VAR_5 = ff_alloc_packet2(VAR_0, VAR_1, (7 + 768) * VAR_0->channels))) { av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet\n"); return VAR_5; } VAR_4 = faacEncEncode(s->faac_handle, VAR_7,
VAR_6 * VAR_0->channels,
VAR_1->data, VAR_1->size); if (VAR_4 < 0) { av_log(VAR_0, AV_LOG_ERROR, "faacEncEncode() error\n"); return VAR_4; } if (VAR_2) { if ((VAR_5 = ff_af_queue_add(&s->afq, VAR_2)) < 0)
return VAR_5; } if (!VAR_4)
return 0; ff_af_queue_remove(&s->afq, VAR_0->frame_size, &VAR_1->pts,
&VAR_1->duration); VAR_1->size = VAR_4; *VAR_3 = 1; return 0; }