static int mpeg_field_start(MpegEncContext *s){

    AVCodecContext *avctx= s->avctx;

    Mpeg1Context *s1 = (Mpeg1Context*)s;



    /* start frame decoding */

    if(s->first_field || s->picture_structure==PICT_FRAME){

        if(MPV_frame_start(s, avctx) < 0)

            return -1;



        ff_er_frame_start(s);



        /* first check if we must repeat the frame */

        s->current_picture_ptr->repeat_pict = 0;

        if (s->repeat_first_field) {

            if (s->progressive_sequence) {

                if (s->top_field_first)

                    s->current_picture_ptr->repeat_pict = 4;

                else

                    s->current_picture_ptr->repeat_pict = 2;

            } else if (s->progressive_frame) {

                s->current_picture_ptr->repeat_pict = 1;

            }

        }



        *s->current_picture_ptr->pan_scan= s1->pan_scan;

    }else{ //second field

            int i;



            if(!s->current_picture_ptr){

                av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");

                return -1;

            }



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

                s->current_picture.data[i] = s->current_picture_ptr->data[i];

                if(s->picture_structure == PICT_BOTTOM_FIELD){

                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];

                }

            }

    }

#if CONFIG_MPEG_XVMC_DECODER

// MPV_frame_start will call this function too,

// but we need to call it on every field

    if(s->avctx->xvmc_acceleration)

         ff_xvmc_field_start(s,avctx);

#endif



    return 0;

}

static int mpeg_field_start(MpegEncContext *s){

    AVCodecContext *avctx= s->avctx;

    Mpeg1Context *s1 = (Mpeg1Context*)s;



    

    if(s->first_field || s->picture_structure==PICT_FRAME){

        if(MPV_frame_start(s, avctx) < 0)

            return -1;



        ff_er_frame_start(s);



        

        s->current_picture_ptr->repeat_pict = 0;

        if (s->repeat_first_field) {

            if (s->progressive_sequence) {

                if (s->top_field_first)

                    s->current_picture_ptr->repeat_pict = 4;

                else

                    s->current_picture_ptr->repeat_pict = 2;

            } else if (s->progressive_frame) {

                s->current_picture_ptr->repeat_pict = 1;

            }

        }



        *s->current_picture_ptr->pan_scan= s1->pan_scan;

    }else{ 

            int i;



            if(!s->current_picture_ptr){

                av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");

                return -1;

            }



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

                s->current_picture.data[i] = s->current_picture_ptr->data[i];

                if(s->picture_structure == PICT_BOTTOM_FIELD){

                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];

                }

            }

    }

#if CONFIG_MPEG_XVMC_DECODER





    if(s->avctx->xvmc_acceleration)

         ff_xvmc_field_start(s,avctx);

#endif



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0){

    AVCodecContext *avctx= VAR_0->avctx;

    Mpeg1Context *s1 = (Mpeg1Context*)VAR_0;



    

    if(VAR_0->first_field || VAR_0->picture_structure==PICT_FRAME){

        if(MPV_frame_start(VAR_0, avctx) < 0)

            return -1;



        ff_er_frame_start(VAR_0);



        

        VAR_0->current_picture_ptr->repeat_pict = 0;

        if (VAR_0->repeat_first_field) {

            if (VAR_0->progressive_sequence) {

                if (VAR_0->top_field_first)

                    VAR_0->current_picture_ptr->repeat_pict = 4;

                else

                    VAR_0->current_picture_ptr->repeat_pict = 2;

            } else if (VAR_0->progressive_frame) {

                VAR_0->current_picture_ptr->repeat_pict = 1;

            }

        }



        *VAR_0->current_picture_ptr->pan_scan= s1->pan_scan;

    }else{ 

            int VAR_1;



            if(!VAR_0->current_picture_ptr){

                av_log(VAR_0->avctx, AV_LOG_ERROR, "first field missing\n");

                return -1;

            }



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

                VAR_0->current_picture.data[VAR_1] = VAR_0->current_picture_ptr->data[VAR_1];

                if(VAR_0->picture_structure == PICT_BOTTOM_FIELD){

                    VAR_0->current_picture.data[VAR_1] += VAR_0->current_picture_ptr->linesize[VAR_1];

                }

            }

    }

#if CONFIG_MPEG_XVMC_DECODER





    if(VAR_0->avctx->xvmc_acceleration)

         ff_xvmc_field_start(VAR_0,avctx);

#endif



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0){ AVCodecContext *avctx= VAR_0->avctx; Mpeg1Context *s1 = (Mpeg1Context*)VAR_0; if(VAR_0->first_field || VAR_0->picture_structure==PICT_FRAME){ if(MPV_frame_start(VAR_0, avctx) < 0)
return -1; ff_er_frame_start(VAR_0); VAR_0->current_picture_ptr->repeat_pict = 0; if (VAR_0->repeat_first_field) { if (VAR_0->progressive_sequence) { if (VAR_0->top_field_first)
VAR_0->current_picture_ptr->repeat_pict = 4; else
VAR_0->current_picture_ptr->repeat_pict = 2; } else if (VAR_0->progressive_frame) { VAR_0->current_picture_ptr->repeat_pict = 1; } } *VAR_0->current_picture_ptr->pan_scan= s1->pan_scan; }else{ int VAR_1; if(!VAR_0->current_picture_ptr){ av_log(VAR_0->avctx, AV_LOG_ERROR, "first field missing\n"); return -1; } for(VAR_1=0; VAR_1<4; VAR_1++){ VAR_0->current_picture.data[VAR_1] = VAR_0->current_picture_ptr->data[VAR_1]; if(VAR_0->picture_structure == PICT_BOTTOM_FIELD){ VAR_0->current_picture.data[VAR_1] += VAR_0->current_picture_ptr->linesize[VAR_1]; } } } #if CONFIG_MPEG_XVMC_DECODER
if(VAR_0->avctx->xvmc_acceleration)
ff_xvmc_field_start(VAR_0,avctx); #endif
return 0; }