static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)

{

    AVCodecContext *avctx = s->avctx;

    Mpeg1Context *s1      = (Mpeg1Context *) s;



    /* start frame decoding */

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

        AVFrameSideData *pan_scan;



        if (ff_MPV_frame_start(s, avctx) < 0)

            return -1;



        ff_mpeg_er_frame_start(s);



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

        s->current_picture_ptr->f.repeat_pict = 0;

        if (s->repeat_first_field) {

            if (s->progressive_sequence) {

                if (s->top_field_first)

                    s->current_picture_ptr->f.repeat_pict = 4;

                else

                    s->current_picture_ptr->f.repeat_pict = 2;

            } else if (s->progressive_frame) {

                s->current_picture_ptr->f.repeat_pict = 1;

            }

        }



        pan_scan = av_frame_new_side_data(&s->current_picture_ptr->f,

                                          AV_FRAME_DATA_PANSCAN,

                                          sizeof(s1->pan_scan));

        if (!pan_scan)

            return AVERROR(ENOMEM);

        memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan));



        if (s1->a53_caption) {

            AVFrameSideData *sd = av_frame_new_side_data(

                &s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,

                s1->a53_caption_size);

            if (sd)

                memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);

            av_freep(&s1->a53_caption);

        }



        if (s1->has_stereo3d) {

            AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);

            if (!stereo)

                return AVERROR(ENOMEM);



            *stereo = s1->stereo3d;

            s1->has_stereo3d = 0;

        }

        if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))

            ff_thread_finish_setup(avctx);

    } else { // second field

        int i;



        if (!s->current_picture_ptr) {

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

            return -1;

        }



        if (s->avctx->hwaccel &&

            (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {

            if (s->avctx->hwaccel->end_frame(s->avctx) < 0)

                av_log(avctx, AV_LOG_ERROR,

                       "hardware accelerator failed to decode first field\n");

        }



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

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

            if (s->picture_structure == PICT_BOTTOM_FIELD)

                s->current_picture.f.data[i] +=

                    s->current_picture_ptr->f.linesize[i];

        }

    }



    if (avctx->hwaccel) {

        if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)

            return -1;

    }



#if FF_API_XVMC

FF_DISABLE_DEPRECATION_WARNINGS

// MPV_frame_start will call this function too,

// but we need to call it on every field

    if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)

        if (ff_xvmc_field_start(s, avctx) < 0)

            return -1;

FF_ENABLE_DEPRECATION_WARNINGS

#endif /* FF_API_XVMC */



    return 0;

}

static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)

{

    AVCodecContext *avctx = s->avctx;

    Mpeg1Context *s1      = (Mpeg1Context *) s;



    

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

        AVFrameSideData *pan_scan;



        if (ff_MPV_frame_start(s, avctx) < 0)

            return -1;



        ff_mpeg_er_frame_start(s);



        

        s->current_picture_ptr->f.repeat_pict = 0;

        if (s->repeat_first_field) {

            if (s->progressive_sequence) {

                if (s->top_field_first)

                    s->current_picture_ptr->f.repeat_pict = 4;

                else

                    s->current_picture_ptr->f.repeat_pict = 2;

            } else if (s->progressive_frame) {

                s->current_picture_ptr->f.repeat_pict = 1;

            }

        }



        pan_scan = av_frame_new_side_data(&s->current_picture_ptr->f,

                                          AV_FRAME_DATA_PANSCAN,

                                          sizeof(s1->pan_scan));

        if (!pan_scan)

            return AVERROR(ENOMEM);

        memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan));



        if (s1->a53_caption) {

            AVFrameSideData *sd = av_frame_new_side_data(

                &s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,

                s1->a53_caption_size);

            if (sd)

                memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);

            av_freep(&s1->a53_caption);

        }



        if (s1->has_stereo3d) {

            AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);

            if (!stereo)

                return AVERROR(ENOMEM);



            *stereo = s1->stereo3d;

            s1->has_stereo3d = 0;

        }

        if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))

            ff_thread_finish_setup(avctx);

    } else { 

        int i;



        if (!s->current_picture_ptr) {

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

            return -1;

        }



        if (s->avctx->hwaccel &&

            (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {

            if (s->avctx->hwaccel->end_frame(s->avctx) < 0)

                av_log(avctx, AV_LOG_ERROR,

                       "hardware accelerator failed to decode first field\n");

        }



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

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

            if (s->picture_structure == PICT_BOTTOM_FIELD)

                s->current_picture.f.data[i] +=

                    s->current_picture_ptr->f.linesize[i];

        }

    }



    if (avctx->hwaccel) {

        if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)

            return -1;

    }



#if FF_API_XVMC

FF_DISABLE_DEPRECATION_WARNINGS





    if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)

        if (ff_xvmc_field_start(s, avctx) < 0)

            return -1;

FF_ENABLE_DEPRECATION_WARNINGS

#endif 



    return 0;

}

        s->current_picture_ptr->f.repeat_pict = 0;                     s->current_picture_ptr->f.repeat_pict = 4;                     s->current_picture_ptr->f.repeat_pict = 2;                 s->current_picture_ptr->f.repeat_pict = 1;         pan_scan = av_frame_new_side_data(&s->current_picture_ptr->f,                 &s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,             AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);             s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];                 s->current_picture.f.data[i] +=                     s->current_picture_ptr->f.linesize[i];                 s->current_picture.f.data[i] +=                 s->current_picture.f.data[i] +=
static int FUNC_0(MpegEncContext *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    AVCodecContext *avctx = VAR_0->avctx;

    Mpeg1Context *s1      = (Mpeg1Context *) VAR_0;



    

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

        AVFrameSideData *pan_scan;



        if (ff_MPV_frame_start(VAR_0, avctx) < 0)

            return -1;



        ff_mpeg_er_frame_start(VAR_0);



        

        VAR_0->current_picture_ptr->f.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->f.repeat_pict = 4;

                else

                    VAR_0->current_picture_ptr->f.repeat_pict = 2;

            } else if (VAR_0->progressive_frame) {

                VAR_0->current_picture_ptr->f.repeat_pict = 1;

            }

        }



        pan_scan = av_frame_new_side_data(&VAR_0->current_picture_ptr->f,

                                          AV_FRAME_DATA_PANSCAN,

                                          sizeof(s1->pan_scan));

        if (!pan_scan)

            return AVERROR(ENOMEM);

        memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan));



        if (s1->a53_caption) {

            AVFrameSideData *sd = av_frame_new_side_data(

                &VAR_0->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,

                s1->a53_caption_size);

            if (sd)

                memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);

            av_freep(&s1->a53_caption);

        }



        if (s1->has_stereo3d) {

            AVStereo3D *stereo = av_stereo3d_create_side_data(&VAR_0->current_picture_ptr->f);

            if (!stereo)

                return AVERROR(ENOMEM);



            *stereo = s1->stereo3d;

            s1->has_stereo3d = 0;

        }

        if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))

            ff_thread_finish_setup(avctx);

    } else { 

        int VAR_3;



        if (!VAR_0->current_picture_ptr) {

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

            return -1;

        }



        if (VAR_0->avctx->hwaccel &&

            (VAR_0->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {

            if (VAR_0->avctx->hwaccel->end_frame(VAR_0->avctx) < 0)

                av_log(avctx, AV_LOG_ERROR,

                       "hardware accelerator failed to decode first field\n");

        }



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

            VAR_0->current_picture.f.data[VAR_3] = VAR_0->current_picture_ptr->f.data[VAR_3];

            if (VAR_0->picture_structure == PICT_BOTTOM_FIELD)

                VAR_0->current_picture.f.data[VAR_3] +=

                    VAR_0->current_picture_ptr->f.linesize[VAR_3];

        }

    }



    if (avctx->hwaccel) {

        if (avctx->hwaccel->start_frame(avctx, VAR_1, VAR_2) < 0)

            return -1;

    }



#if FF_API_XVMC

FF_DISABLE_DEPRECATION_WARNINGS





    if (CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration)

        if (ff_xvmc_field_start(VAR_0, avctx) < 0)

            return -1;

FF_ENABLE_DEPRECATION_WARNINGS

#endif 



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ AVCodecContext *avctx = VAR_0->avctx; Mpeg1Context *s1      = (Mpeg1Context *) VAR_0; if (VAR_0->first_field || VAR_0->picture_structure == PICT_FRAME) { AVFrameSideData *pan_scan; if (ff_MPV_frame_start(VAR_0, avctx) < 0)
return -1; ff_mpeg_er_frame_start(VAR_0); VAR_0->current_picture_ptr->f.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->f.repeat_pict = 4; else
VAR_0->current_picture_ptr->f.repeat_pict = 2; } else if (VAR_0->progressive_frame) { VAR_0->current_picture_ptr->f.repeat_pict = 1; } } pan_scan = av_frame_new_side_data(&VAR_0->current_picture_ptr->f,
AV_FRAME_DATA_PANSCAN,
sizeof(s1->pan_scan)); if (!pan_scan)
return AVERROR(ENOMEM); memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan)); if (s1->a53_caption) { AVFrameSideData *sd = av_frame_new_side_data(
&VAR_0->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
s1->a53_caption_size); if (sd)
memcpy(sd->data, s1->a53_caption, s1->a53_caption_size); av_freep(&s1->a53_caption); } if (s1->has_stereo3d) { AVStereo3D *stereo = av_stereo3d_create_side_data(&VAR_0->current_picture_ptr->f); if (!stereo)
return AVERROR(ENOMEM); *stereo = s1->stereo3d; s1->has_stereo3d = 0; } if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_finish_setup(avctx); } else { int VAR_3; if (!VAR_0->current_picture_ptr) { av_log(VAR_0->avctx, AV_LOG_ERROR, "first field missing\n"); return -1; } if (VAR_0->avctx->hwaccel &&
(VAR_0->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) { if (VAR_0->avctx->hwaccel->end_frame(VAR_0->avctx) < 0)
av_log(avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode first field\n"); } for (VAR_3 = 0; VAR_3 < 4; VAR_3++) { VAR_0->current_picture.f.data[VAR_3] = VAR_0->current_picture_ptr->f.data[VAR_3]; if (VAR_0->picture_structure == PICT_BOTTOM_FIELD)
VAR_0->current_picture.f.data[VAR_3] +=
VAR_0->current_picture_ptr->f.linesize[VAR_3]; } } if (avctx->hwaccel) { if (avctx->hwaccel->start_frame(avctx, VAR_1, VAR_2) < 0)
return -1; } #if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration)
if (ff_xvmc_field_start(VAR_0, avctx) < 0)
return -1; FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0; }