int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)

{

    Mpeg4DecContext *ctx = avctx->priv_data;

    MpegEncContext    *s = &ctx->m;



    /* divx 5.01+ bitstream reorder stuff */

    /* Since this clobbers the input buffer and hwaccel codecs still need the

     * data during hwaccel->end_frame we should not do this any earlier */

    if (s->divx_packed) {

        int current_pos     = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);

        int startcode_found = 0;



        if (buf_size - current_pos > 7) {



            int i;

            for (i = current_pos; i < buf_size - 4; i++)



                if (buf[i]     == 0 &&

                    buf[i + 1] == 0 &&

                    buf[i + 2] == 1 &&

                    buf[i + 3] == 0xB6) {

                    startcode_found = !(buf[i + 4] & 0x40);

                    break;

                }

        }



        if (startcode_found) {

            av_fast_malloc(&s->bitstream_buffer,

                           &s->allocated_bitstream_buffer_size,

                           buf_size - current_pos +

                           FF_INPUT_BUFFER_PADDING_SIZE);

            if (!s->bitstream_buffer)

                return AVERROR(ENOMEM);

            memcpy(s->bitstream_buffer, buf + current_pos,

                   buf_size - current_pos);

            s->bitstream_buffer_size = buf_size - current_pos;

        }

    }



    return 0;

}

int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)

{

    Mpeg4DecContext *ctx = avctx->priv_data;

    MpegEncContext    *s = &ctx->m;



    

    



    if (s->divx_packed) {

        int current_pos     = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);

        int startcode_found = 0;



        if (buf_size - current_pos > 7) {



            int i;

            for (i = current_pos; i < buf_size - 4; i++)



                if (buf[i]     == 0 &&

                    buf[i + 1] == 0 &&

                    buf[i + 2] == 1 &&

                    buf[i + 3] == 0xB6) {

                    startcode_found = !(buf[i + 4] & 0x40);

                    break;

                }

        }



        if (startcode_found) {

            av_fast_malloc(&s->bitstream_buffer,

                           &s->allocated_bitstream_buffer_size,

                           buf_size - current_pos +

                           FF_INPUT_BUFFER_PADDING_SIZE);

            if (!s->bitstream_buffer)

                return AVERROR(ENOMEM);

            memcpy(s->bitstream_buffer, buf + current_pos,

                   buf_size - current_pos);

            s->bitstream_buffer_size = buf_size - current_pos;

        }

    }



    return 0;

}

            av_fast_malloc(&s->bitstream_buffer,                            buf_size - current_pos +                            FF_INPUT_BUFFER_PADDING_SIZE);
int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    Mpeg4DecContext *ctx = VAR_0->priv_data;

    MpegEncContext    *s = &ctx->m;



    

    



    if (s->divx_packed) {

        int VAR_3     = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);

        int VAR_4 = 0;



        if (VAR_2 - VAR_3 > 7) {



            int VAR_5;

            for (VAR_5 = VAR_3; VAR_5 < VAR_2 - 4; VAR_5++)



                if (VAR_1[VAR_5]     == 0 &&

                    VAR_1[VAR_5 + 1] == 0 &&

                    VAR_1[VAR_5 + 2] == 1 &&

                    VAR_1[VAR_5 + 3] == 0xB6) {

                    VAR_4 = !(VAR_1[VAR_5 + 4] & 0x40);

                    break;

                }

        }



        if (VAR_4) {

            av_fast_malloc(&s->bitstream_buffer,

                           &s->allocated_bitstream_buffer_size,

                           VAR_2 - VAR_3 +

                           FF_INPUT_BUFFER_PADDING_SIZE);

            if (!s->bitstream_buffer)

                return AVERROR(ENOMEM);

            memcpy(s->bitstream_buffer, VAR_1 + VAR_3,

                   VAR_2 - VAR_3);

            s->bitstream_buffer_size = VAR_2 - VAR_3;

        }

    }



    return 0;

}

int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ Mpeg4DecContext *ctx = VAR_0->priv_data; MpegEncContext    *s = &ctx->m; if (s->divx_packed) { int VAR_3     = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3); int VAR_4 = 0; if (VAR_2 - VAR_3 > 7) { int VAR_5; for (VAR_5 = VAR_3; VAR_5 < VAR_2 - 4; VAR_5++) if (VAR_1[VAR_5]     == 0 &&
VAR_1[VAR_5 + 1] == 0 &&
VAR_1[VAR_5 + 2] == 1 &&
VAR_1[VAR_5 + 3] == 0xB6) { VAR_4 = !(VAR_1[VAR_5 + 4] & 0x40); break; } } if (VAR_4) { av_fast_malloc(&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
VAR_2 - VAR_3 +
FF_INPUT_BUFFER_PADDING_SIZE); if (!s->bitstream_buffer)
return AVERROR(ENOMEM); memcpy(s->bitstream_buffer, VAR_1 + VAR_3,
VAR_2 - VAR_3); s->bitstream_buffer_size = VAR_2 - VAR_3; } } return 0; }