int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)

{

    if(pc->overread){

        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",

                pc->overread, pc->state, next, pc->index, pc->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);

    }



    /* Copy overread bytes from last frame into buffer. */

    for(; pc->overread>0; pc->overread--){

        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];

    }



    /* flush remaining if EOF */

    if(!*buf_size && next == END_NOT_FOUND){

        next= 0;

    }



    pc->last_index= pc->index;



    /* copy into buffer end return */

    if(next == END_NOT_FOUND){

        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!new_buffer)

            return AVERROR(ENOMEM);

        pc->buffer = new_buffer;

        memcpy(&pc->buffer[pc->index], *buf, *buf_size);

        pc->index += *buf_size;

        return -1;

    }



    *buf_size=

    pc->overread_index= pc->index + next;



    /* append to buffer */

    if(pc->index){

        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!new_buffer)

            return AVERROR(ENOMEM);

        pc->buffer = new_buffer;


        memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );

        pc->index = 0;

        *buf= pc->buffer;

    }



    /* store overread bytes */

    for(;next < 0; next++){

        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];

        pc->state64 = (pc->state64<<8) | pc->buffer[pc->last_index + next];

        pc->overread++;

    }



    if(pc->overread){

        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",

                pc->overread, pc->state, next, pc->index, pc->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);

    }



    return 0;

}
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)

{

    if(pc->overread){

        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",

                pc->overread, pc->state, next, pc->index, pc->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);

    }



    

    for(; pc->overread>0; pc->overread--){

        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];

    }



    

    if(!*buf_size && next == END_NOT_FOUND){

        next= 0;

    }



    pc->last_index= pc->index;



    

    if(next == END_NOT_FOUND){

        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!new_buffer)

            return AVERROR(ENOMEM);

        pc->buffer = new_buffer;

        memcpy(&pc->buffer[pc->index], *buf, *buf_size);

        pc->index += *buf_size;

        return -1;

    }



    *buf_size=

    pc->overread_index= pc->index + next;



    

    if(pc->index){

        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!new_buffer)

            return AVERROR(ENOMEM);

        pc->buffer = new_buffer;


        memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );

        pc->index = 0;

        *buf= pc->buffer;

    }



    

    for(;next < 0; next++){

        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];

        pc->state64 = (pc->state64<<8) | pc->buffer[pc->last_index + next];

        pc->overread++;

    }



    if(pc->overread){

        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",

                pc->overread, pc->state, next, pc->index, pc->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);

    }



    return 0;

}
int FUNC_0(ParseContext *VAR_0, int VAR_1, const uint8_t **VAR_2, int *VAR_3)

{

    if(VAR_0->overread){

        av_dlog(NULL, "overread %d, state:%X VAR_1:%d index:%d o_index:%d\n",

                VAR_0->overread, VAR_0->state, VAR_1, VAR_0->index, VAR_0->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*VAR_2)[0], (*VAR_2)[1], (*VAR_2)[2], (*VAR_2)[3]);

    }



    

    for(; VAR_0->overread>0; VAR_0->overread--){

        VAR_0->buffer[VAR_0->index++]= VAR_0->buffer[VAR_0->overread_index++];

    }



    

    if(!*VAR_3 && VAR_1 == END_NOT_FOUND){

        VAR_1= 0;

    }



    VAR_0->last_index= VAR_0->index;



    

    if(VAR_1 == END_NOT_FOUND){

        void* VAR_5 = av_fast_realloc(VAR_0->buffer, &VAR_0->buffer_size, (*VAR_3) + VAR_0->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!VAR_5)

            return AVERROR(ENOMEM);

        VAR_0->buffer = VAR_5;

        memcpy(&VAR_0->buffer[VAR_0->index], *VAR_2, *VAR_3);

        VAR_0->index += *VAR_3;

        return -1;

    }



    *VAR_3=

    VAR_0->overread_index= VAR_0->index + VAR_1;



    

    if(VAR_0->index){

        void* VAR_5 = av_fast_realloc(VAR_0->buffer, &VAR_0->buffer_size, VAR_1 + VAR_0->index + FF_INPUT_BUFFER_PADDING_SIZE);



        if(!VAR_5)

            return AVERROR(ENOMEM);

        VAR_0->buffer = VAR_5;


        memcpy(&VAR_0->buffer[VAR_0->index], *VAR_2, VAR_1 + FF_INPUT_BUFFER_PADDING_SIZE );

        VAR_0->index = 0;

        *VAR_2= VAR_0->buffer;

    }



    

    for(;VAR_1 < 0; VAR_1++){

        VAR_0->state = (VAR_0->state<<8) | VAR_0->buffer[VAR_0->last_index + VAR_1];

        VAR_0->state64 = (VAR_0->state64<<8) | VAR_0->buffer[VAR_0->last_index + VAR_1];

        VAR_0->overread++;

    }



    if(VAR_0->overread){

        av_dlog(NULL, "overread %d, state:%X VAR_1:%d index:%d o_index:%d\n",

                VAR_0->overread, VAR_0->state, VAR_1, VAR_0->index, VAR_0->overread_index);

        av_dlog(NULL, "%X %X %X %X\n", (*VAR_2)[0], (*VAR_2)[1],(*VAR_2)[2],(*VAR_2)[3]);

    }



    return 0;

}
int FUNC_0(ParseContext *VAR_0, int VAR_1, const uint8_t **VAR_2, int *VAR_3)
{ if(VAR_0->overread){ av_dlog(NULL, "overread %d, state:%X VAR_1:%d index:%d o_index:%d\n",
VAR_0->overread, VAR_0->state, VAR_1, VAR_0->index, VAR_0->overread_index); av_dlog(NULL, "%X %X %X %X\n", (*VAR_2)[0], (*VAR_2)[1], (*VAR_2)[2], (*VAR_2)[3]); } for(; VAR_0->overread>0; VAR_0->overread--){ VAR_0->buffer[VAR_0->index++]= VAR_0->buffer[VAR_0->overread_index++]; } if(!*VAR_3 && VAR_1 == END_NOT_FOUND){ VAR_1= 0; } VAR_0->last_index= VAR_0->index; if(VAR_1 == END_NOT_FOUND){ void* VAR_5 = av_fast_realloc(VAR_0->buffer, &VAR_0->buffer_size, (*VAR_3) + VAR_0->index + FF_INPUT_BUFFER_PADDING_SIZE); if(!VAR_5)
return AVERROR(ENOMEM); VAR_0->buffer = VAR_5; memcpy(&VAR_0->buffer[VAR_0->index], *VAR_2, *VAR_3); VAR_0->index += *VAR_3; return -1; } *VAR_3=
VAR_0->overread_index= VAR_0->index + VAR_1; if(VAR_0->index){ void* VAR_5 = av_fast_realloc(VAR_0->buffer, &VAR_0->buffer_size, VAR_1 + VAR_0->index + FF_INPUT_BUFFER_PADDING_SIZE); if(!VAR_5)
return AVERROR(ENOMEM); VAR_0->buffer = VAR_5; memcpy(&VAR_0->buffer[VAR_0->index], *VAR_2, VAR_1 + FF_INPUT_BUFFER_PADDING_SIZE ); VAR_0->index = 0; *VAR_2= VAR_0->buffer; } for(;VAR_1 < 0; VAR_1++){ VAR_0->state = (VAR_0->state<<8) | VAR_0->buffer[VAR_0->last_index + VAR_1]; VAR_0->state64 = (VAR_0->state64<<8) | VAR_0->buffer[VAR_0->last_index + VAR_1]; VAR_0->overread++; } if(VAR_0->overread){ av_dlog(NULL, "overread %d, state:%X VAR_1:%d index:%d o_index:%d\n",
VAR_0->overread, VAR_0->state, VAR_1, VAR_0->index, VAR_0->overread_index); av_dlog(NULL, "%X %X %X %X\n", (*VAR_2)[0], (*VAR_2)[1],(*VAR_2)[2],(*VAR_2)[3]); } return 0; }