static int frame_start(MpegEncContext *s)

{

    int ret;



    /* mark & release old frames */

    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&

        s->last_picture_ptr != s->next_picture_ptr &&

        s->last_picture_ptr->f.buf[0]) {

        ff_mpeg_unref_picture(s, s->last_picture_ptr);

    }



    s->current_picture_ptr->f.pict_type = s->pict_type;

    s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;



    ff_mpeg_unref_picture(s, &s->current_picture);

    if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,

                                   s->current_picture_ptr)) < 0)

        return ret;



    if (s->pict_type != AV_PICTURE_TYPE_B) {

        s->last_picture_ptr = s->next_picture_ptr;

        if (!s->droppable)

            s->next_picture_ptr = s->current_picture_ptr;

    }



    if (s->last_picture_ptr) {

        ff_mpeg_unref_picture(s, &s->last_picture);

        if (s->last_picture_ptr->f.buf[0] &&

            (ret = ff_mpeg_ref_picture(s, &s->last_picture,

                                       s->last_picture_ptr)) < 0)

            return ret;

    }

    if (s->next_picture_ptr) {

        ff_mpeg_unref_picture(s, &s->next_picture);

        if (s->next_picture_ptr->f.buf[0] &&

            (ret = ff_mpeg_ref_picture(s, &s->next_picture,

                                       s->next_picture_ptr)) < 0)

            return ret;

    }



    if (s->picture_structure!= PICT_FRAME) {

        int i;

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

            if (s->picture_structure == PICT_BOTTOM_FIELD) {

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

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

            }

            s->current_picture.f.linesize[i] *= 2;

            s->last_picture.f.linesize[i]    *= 2;

            s->next_picture.f.linesize[i]    *= 2;

        }

    }



    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {

        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;

        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;

    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {

        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;

        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;

    } else {

        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;

        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;

    }



    if (s->dct_error_sum) {

        assert(s->avctx->noise_reduction && s->encoding);

        update_noise_reduction(s);

    }



    return 0;

}

static int frame_start(MpegEncContext *s)

{

    int ret;



    

    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&

        s->last_picture_ptr != s->next_picture_ptr &&

        s->last_picture_ptr->f.buf[0]) {

        ff_mpeg_unref_picture(s, s->last_picture_ptr);

    }



    s->current_picture_ptr->f.pict_type = s->pict_type;

    s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;



    ff_mpeg_unref_picture(s, &s->current_picture);

    if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,

                                   s->current_picture_ptr)) < 0)

        return ret;



    if (s->pict_type != AV_PICTURE_TYPE_B) {

        s->last_picture_ptr = s->next_picture_ptr;

        if (!s->droppable)

            s->next_picture_ptr = s->current_picture_ptr;

    }



    if (s->last_picture_ptr) {

        ff_mpeg_unref_picture(s, &s->last_picture);

        if (s->last_picture_ptr->f.buf[0] &&

            (ret = ff_mpeg_ref_picture(s, &s->last_picture,

                                       s->last_picture_ptr)) < 0)

            return ret;

    }

    if (s->next_picture_ptr) {

        ff_mpeg_unref_picture(s, &s->next_picture);

        if (s->next_picture_ptr->f.buf[0] &&

            (ret = ff_mpeg_ref_picture(s, &s->next_picture,

                                       s->next_picture_ptr)) < 0)

            return ret;

    }



    if (s->picture_structure!= PICT_FRAME) {

        int i;

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

            if (s->picture_structure == PICT_BOTTOM_FIELD) {

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

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

            }

            s->current_picture.f.linesize[i] *= 2;

            s->last_picture.f.linesize[i]    *= 2;

            s->next_picture.f.linesize[i]    *= 2;

        }

    }



    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {

        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;

        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;

    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {

        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;

        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;

    } else {

        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;

        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;

    }



    if (s->dct_error_sum) {

        assert(s->avctx->noise_reduction && s->encoding);

        update_noise_reduction(s);

    }



    return 0;

}

                s->current_picture.f.data[i] +=         s->last_picture_ptr->f.buf[0]) {     s->current_picture_ptr->f.pict_type = s->pict_type;     s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;         if (s->last_picture_ptr->f.buf[0] &&         if (s->next_picture_ptr->f.buf[0] &&                 s->current_picture.f.data[i] +=                     s->current_picture.f.linesize[i];             s->current_picture.f.linesize[i] *= 2;             s->last_picture.f.linesize[i]    *= 2;             s->next_picture.f.linesize[i]    *= 2;         s->last_picture_ptr->f.buf[0]) {     s->current_picture_ptr->f.pict_type = s->pict_type;     s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;         if (s->last_picture_ptr->f.buf[0] &&         if (s->next_picture_ptr->f.buf[0] &&                 s->current_picture.f.data[i] +=                     s->current_picture.f.linesize[i];             s->current_picture.f.linesize[i] *= 2;             s->last_picture.f.linesize[i]    *= 2;             s->next_picture.f.linesize[i]    *= 2;
static int FUNC_0(MpegEncContext *VAR_0)

{

    int VAR_1;



    

    if (VAR_0->pict_type != AV_PICTURE_TYPE_B && VAR_0->last_picture_ptr &&

        VAR_0->last_picture_ptr != VAR_0->next_picture_ptr &&

        VAR_0->last_picture_ptr->f.buf[0]) {

        ff_mpeg_unref_picture(VAR_0, VAR_0->last_picture_ptr);

    }



    VAR_0->current_picture_ptr->f.pict_type = VAR_0->pict_type;

    VAR_0->current_picture_ptr->f.key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I;



    ff_mpeg_unref_picture(VAR_0, &VAR_0->current_picture);

    if ((VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->current_picture,

                                   VAR_0->current_picture_ptr)) < 0)

        return VAR_1;



    if (VAR_0->pict_type != AV_PICTURE_TYPE_B) {

        VAR_0->last_picture_ptr = VAR_0->next_picture_ptr;

        if (!VAR_0->droppable)

            VAR_0->next_picture_ptr = VAR_0->current_picture_ptr;

    }



    if (VAR_0->last_picture_ptr) {

        ff_mpeg_unref_picture(VAR_0, &VAR_0->last_picture);

        if (VAR_0->last_picture_ptr->f.buf[0] &&

            (VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->last_picture,

                                       VAR_0->last_picture_ptr)) < 0)

            return VAR_1;

    }

    if (VAR_0->next_picture_ptr) {

        ff_mpeg_unref_picture(VAR_0, &VAR_0->next_picture);

        if (VAR_0->next_picture_ptr->f.buf[0] &&

            (VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->next_picture,

                                       VAR_0->next_picture_ptr)) < 0)

            return VAR_1;

    }



    if (VAR_0->picture_structure!= PICT_FRAME) {

        int VAR_2;

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

            if (VAR_0->picture_structure == PICT_BOTTOM_FIELD) {

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

                    VAR_0->current_picture.f.linesize[VAR_2];

            }

            VAR_0->current_picture.f.linesize[VAR_2] *= 2;

            VAR_0->last_picture.f.linesize[VAR_2]    *= 2;

            VAR_0->next_picture.f.linesize[VAR_2]    *= 2;

        }

    }



    if (VAR_0->mpeg_quant || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {

        VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg2_intra;

        VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg2_inter;

    } else if (VAR_0->out_format == FMT_H263 || VAR_0->out_format == FMT_H261) {

        VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_h263_intra;

        VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_h263_inter;

    } else {

        VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg1_intra;

        VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg1_inter;

    }



    if (VAR_0->dct_error_sum) {

        assert(VAR_0->avctx->noise_reduction && VAR_0->encoding);

        update_noise_reduction(VAR_0);

    }



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0)
{ int VAR_1; if (VAR_0->pict_type != AV_PICTURE_TYPE_B && VAR_0->last_picture_ptr &&
VAR_0->last_picture_ptr != VAR_0->next_picture_ptr &&
VAR_0->last_picture_ptr->f.buf[0]) { ff_mpeg_unref_picture(VAR_0, VAR_0->last_picture_ptr); } VAR_0->current_picture_ptr->f.pict_type = VAR_0->pict_type; VAR_0->current_picture_ptr->f.key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I; ff_mpeg_unref_picture(VAR_0, &VAR_0->current_picture); if ((VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->current_picture,
VAR_0->current_picture_ptr)) < 0)
return VAR_1; if (VAR_0->pict_type != AV_PICTURE_TYPE_B) { VAR_0->last_picture_ptr = VAR_0->next_picture_ptr; if (!VAR_0->droppable)
VAR_0->next_picture_ptr = VAR_0->current_picture_ptr; } if (VAR_0->last_picture_ptr) { ff_mpeg_unref_picture(VAR_0, &VAR_0->last_picture); if (VAR_0->last_picture_ptr->f.buf[0] &&
(VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->last_picture,
VAR_0->last_picture_ptr)) < 0)
return VAR_1; } if (VAR_0->next_picture_ptr) { ff_mpeg_unref_picture(VAR_0, &VAR_0->next_picture); if (VAR_0->next_picture_ptr->f.buf[0] &&
(VAR_1 = ff_mpeg_ref_picture(VAR_0, &VAR_0->next_picture,
VAR_0->next_picture_ptr)) < 0)
return VAR_1; } if (VAR_0->picture_structure!= PICT_FRAME) { int VAR_2; for (VAR_2 = 0; VAR_2 < 4; VAR_2++) { if (VAR_0->picture_structure == PICT_BOTTOM_FIELD) { VAR_0->current_picture.f.data[VAR_2] +=
VAR_0->current_picture.f.linesize[VAR_2]; } VAR_0->current_picture.f.linesize[VAR_2] *= 2; VAR_0->last_picture.f.linesize[VAR_2]    *= 2; VAR_0->next_picture.f.linesize[VAR_2]    *= 2; } } if (VAR_0->mpeg_quant || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) { VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg2_intra; VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg2_inter; } else if (VAR_0->out_format == FMT_H263 || VAR_0->out_format == FMT_H261) { VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_h263_intra; VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_h263_inter; } else { VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg1_intra; VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg1_inter; } if (VAR_0->dct_error_sum) { assert(VAR_0->avctx->noise_reduction && VAR_0->encoding); update_noise_reduction(VAR_0); } return 0; }