static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){

    ParseContext *pc= &s->parse_context;

    int i;

    uint32_t state;

    

    state= pc->state;

    

    i=0;

    if(!pc->frame_start_found){

        for(i=0; i<buf_size; i++){

            state= (state<<8) | buf[i];

            if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){

                i++;

                pc->frame_start_found=1;

                break;

            }

        }

    }

    

    if(pc->frame_start_found){

        for(; i<buf_size; i++){

            state= (state<<8) | buf[i];

            if((state&0xFFFFFF00) == 0x100){

                if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){

                    pc->frame_start_found=0;

                    pc->state=-1; 

                    return i-3;

                }

            }

        }

    }        

    pc->state= state;

    return -1;

}

static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){

    ParseContext *pc= &s->parse_context;

    int i;

    uint32_t state;

    

    state= pc->state;

    

    i=0;

    if(!pc->frame_start_found){

        for(i=0; i<buf_size; i++){

            state= (state<<8) | buf[i];

            if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){

                i++;

                pc->frame_start_found=1;

                break;

            }

        }

    }

    

    if(pc->frame_start_found){

        for(; i<buf_size; i++){

            state= (state<<8) | buf[i];

            if((state&0xFFFFFF00) == 0x100){

                if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){

                    pc->frame_start_found=0;

                    pc->state=-1; 

                    return i-3;

                }

            }

        }

    }        

    pc->state= state;

    return -1;

}

static int FUNC_0(MpegEncContext *VAR_0, uint8_t *VAR_1, int VAR_2){

    ParseContext *pc= &VAR_0->parse_context;

    int VAR_3;

    uint32_t state;

    

    state= pc->state;

    

    VAR_3=0;

    if(!pc->frame_start_found){

        for(VAR_3=0; VAR_3<VAR_2; VAR_3++){

            state= (state<<8) | VAR_1[VAR_3];

            if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){

                VAR_3++;

                pc->frame_start_found=1;

                break;

            }

        }

    }

    

    if(pc->frame_start_found){

        for(; VAR_3<VAR_2; VAR_3++){

            state= (state<<8) | VAR_1[VAR_3];

            if((state&0xFFFFFF00) == 0x100){

                if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){

                    pc->frame_start_found=0;

                    pc->state=-1; 

                    return VAR_3-3;

                }

            }

        }

    }        

    pc->state= state;

    return -1;

}

static int FUNC_0(MpegEncContext *VAR_0, uint8_t *VAR_1, int VAR_2){ ParseContext *pc= &VAR_0->parse_context; int VAR_3; uint32_t state; state= pc->state; VAR_3=0; if(!pc->frame_start_found){ for(VAR_3=0; VAR_3<VAR_2; VAR_3++){ state= (state<<8) | VAR_1[VAR_3]; if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){ VAR_3++; pc->frame_start_found=1; break; } } } if(pc->frame_start_found){ for(; VAR_3<VAR_2; VAR_3++){ state= (state<<8) | VAR_1[VAR_3]; if((state&0xFFFFFF00) == 0x100){ if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){ pc->frame_start_found=0; pc->state=-1; return VAR_3-3; } } } } pc->state= state; return -1; }