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

                             const AVFrame *frame, int *got_packet_ptr)

{

    AlacEncodeContext *s = avctx->priv_data;

    int out_bytes, max_frame_size, ret;



    s->frame_size = frame->nb_samples;



    if (frame->nb_samples < DEFAULT_FRAME_SIZE)

        max_frame_size = get_max_frame_size(s->frame_size, avctx->channels,

                                            avctx->bits_per_raw_sample);

    else

        max_frame_size = s->max_coded_frame_size;



    if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size)))

        return ret;



    /* use verbatim mode for compression_level 0 */

    if (s->compression_level) {

        s->verbatim   = 0;

        s->extra_bits = avctx->bits_per_raw_sample - 16;

    } else {

        s->verbatim   = 1;

        s->extra_bits = 0;

    }



    out_bytes = write_frame(s, avpkt, frame->extended_data);



    if (out_bytes > max_frame_size) {

        /* frame too large. use verbatim mode */

        s->verbatim = 1;

        s->extra_bits = 0;

        out_bytes = write_frame(s, avpkt, frame->extended_data);

    }



    avpkt->size = out_bytes;

    *got_packet_ptr = 1;

    return 0;

}

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

                             const AVFrame *frame, int *got_packet_ptr)

{

    AlacEncodeContext *s = avctx->priv_data;

    int out_bytes, max_frame_size, ret;



    s->frame_size = frame->nb_samples;



    if (frame->nb_samples < DEFAULT_FRAME_SIZE)

        max_frame_size = get_max_frame_size(s->frame_size, avctx->channels,

                                            avctx->bits_per_raw_sample);

    else

        max_frame_size = s->max_coded_frame_size;



    if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size)))

        return ret;



    

    if (s->compression_level) {

        s->verbatim   = 0;

        s->extra_bits = avctx->bits_per_raw_sample - 16;

    } else {

        s->verbatim   = 1;

        s->extra_bits = 0;

    }



    out_bytes = write_frame(s, avpkt, frame->extended_data);



    if (out_bytes > max_frame_size) {

        

        s->verbatim = 1;

        s->extra_bits = 0;

        out_bytes = write_frame(s, avpkt, frame->extended_data);

    }



    avpkt->size = out_bytes;

    *got_packet_ptr = 1;

    return 0;

}

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

                             const AVFrame *VAR_2, int *VAR_3)

{

    AlacEncodeContext *s = VAR_0->priv_data;

    int VAR_4, VAR_5, VAR_6;



    s->frame_size = VAR_2->nb_samples;



    if (VAR_2->nb_samples < DEFAULT_FRAME_SIZE)

        VAR_5 = get_max_frame_size(s->frame_size, VAR_0->channels,

                                            VAR_0->bits_per_raw_sample);

    else

        VAR_5 = s->max_coded_frame_size;



    if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, 2 * VAR_5)))

        return VAR_6;



    

    if (s->compression_level) {

        s->verbatim   = 0;

        s->extra_bits = VAR_0->bits_per_raw_sample - 16;

    } else {

        s->verbatim   = 1;

        s->extra_bits = 0;

    }



    VAR_4 = write_frame(s, VAR_1, VAR_2->extended_data);



    if (VAR_4 > VAR_5) {

        

        s->verbatim = 1;

        s->extra_bits = 0;

        VAR_4 = write_frame(s, VAR_1, VAR_2->extended_data);

    }



    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)
{ AlacEncodeContext *s = VAR_0->priv_data; int VAR_4, VAR_5, VAR_6; s->frame_size = VAR_2->nb_samples; if (VAR_2->nb_samples < DEFAULT_FRAME_SIZE)
VAR_5 = get_max_frame_size(s->frame_size, VAR_0->channels,
VAR_0->bits_per_raw_sample); else
VAR_5 = s->max_coded_frame_size; if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, 2 * VAR_5)))
return VAR_6; if (s->compression_level) { s->verbatim   = 0; s->extra_bits = VAR_0->bits_per_raw_sample - 16; } else { s->verbatim   = 1; s->extra_bits = 0; } VAR_4 = write_frame(s, VAR_1, VAR_2->extended_data); if (VAR_4 > VAR_5) { s->verbatim = 1; s->extra_bits = 0; VAR_4 = write_frame(s, VAR_1, VAR_2->extended_data); } VAR_1->size = VAR_4; *VAR_3 = 1; return 0; }