static int init_er(MpegEncContext *s)

{

    ERContext *er = &s->er;

    int mb_array_size = s->mb_height * s->mb_stride;

    int i;



    er->avctx       = s->avctx;

    er->mecc        = &s->mecc;



    er->mb_index2xy = s->mb_index2xy;

    er->mb_num      = s->mb_num;

    er->mb_width    = s->mb_width;

    er->mb_height   = s->mb_height;

    er->mb_stride   = s->mb_stride;

    er->b8_stride   = s->b8_stride;



    er->er_temp_buffer     = av_malloc(s->mb_height * s->mb_stride);

    er->error_status_table = av_mallocz(mb_array_size);

    if (!er->er_temp_buffer || !er->error_status_table)

        goto fail;



    er->mbskip_table  = s->mbskip_table;

    er->mbintra_table = s->mbintra_table;



    for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++)

        er->dc_val[i] = s->dc_val[i];



    er->decode_mb = mpeg_er_decode_mb;

    er->opaque    = s;



    return 0;

fail:

    av_freep(&er->er_temp_buffer);

    av_freep(&er->error_status_table);

    return AVERROR(ENOMEM);

}

static int init_er(MpegEncContext *s)

{

    ERContext *er = &s->er;

    int mb_array_size = s->mb_height * s->mb_stride;

    int i;



    er->avctx       = s->avctx;

    er->mecc        = &s->mecc;



    er->mb_index2xy = s->mb_index2xy;

    er->mb_num      = s->mb_num;

    er->mb_width    = s->mb_width;

    er->mb_height   = s->mb_height;

    er->mb_stride   = s->mb_stride;

    er->b8_stride   = s->b8_stride;



    er->er_temp_buffer     = av_malloc(s->mb_height * s->mb_stride);

    er->error_status_table = av_mallocz(mb_array_size);

    if (!er->er_temp_buffer || !er->error_status_table)

        goto fail;



    er->mbskip_table  = s->mbskip_table;

    er->mbintra_table = s->mbintra_table;



    for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++)

        er->dc_val[i] = s->dc_val[i];



    er->decode_mb = mpeg_er_decode_mb;

    er->opaque    = s;



    return 0;

fail:

    av_freep(&er->er_temp_buffer);

    av_freep(&er->error_status_table);

    return AVERROR(ENOMEM);

}

static int FUNC_0(MpegEncContext *VAR_0)

{

    ERContext *er = &VAR_0->er;

    int VAR_1 = VAR_0->mb_height * VAR_0->mb_stride;

    int VAR_2;



    er->avctx       = VAR_0->avctx;

    er->mecc        = &VAR_0->mecc;



    er->mb_index2xy = VAR_0->mb_index2xy;

    er->mb_num      = VAR_0->mb_num;

    er->mb_width    = VAR_0->mb_width;

    er->mb_height   = VAR_0->mb_height;

    er->mb_stride   = VAR_0->mb_stride;

    er->b8_stride   = VAR_0->b8_stride;



    er->er_temp_buffer     = av_malloc(VAR_0->mb_height * VAR_0->mb_stride);

    er->error_status_table = av_mallocz(VAR_1);

    if (!er->er_temp_buffer || !er->error_status_table)

        goto fail;



    er->mbskip_table  = VAR_0->mbskip_table;

    er->mbintra_table = VAR_0->mbintra_table;



    for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_0->dc_val); VAR_2++)

        er->dc_val[VAR_2] = VAR_0->dc_val[VAR_2];



    er->decode_mb = mpeg_er_decode_mb;

    er->opaque    = VAR_0;



    return 0;

fail:

    av_freep(&er->er_temp_buffer);

    av_freep(&er->error_status_table);

    return AVERROR(ENOMEM);

}

static int FUNC_0(MpegEncContext *VAR_0)
{ ERContext *er = &VAR_0->er; int VAR_1 = VAR_0->mb_height * VAR_0->mb_stride; int VAR_2; er->avctx       = VAR_0->avctx; er->mecc        = &VAR_0->mecc; er->mb_index2xy = VAR_0->mb_index2xy; er->mb_num      = VAR_0->mb_num; er->mb_width    = VAR_0->mb_width; er->mb_height   = VAR_0->mb_height; er->mb_stride   = VAR_0->mb_stride; er->b8_stride   = VAR_0->b8_stride; er->er_temp_buffer     = av_malloc(VAR_0->mb_height * VAR_0->mb_stride); er->error_status_table = av_mallocz(VAR_1); if (!er->er_temp_buffer || !er->error_status_table)
goto fail; er->mbskip_table  = VAR_0->mbskip_table; er->mbintra_table = VAR_0->mbintra_table; for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_0->dc_val); VAR_2++) er->dc_val[VAR_2] = VAR_0->dc_val[VAR_2]; er->decode_mb = mpeg_er_decode_mb; er->opaque    = VAR_0; return 0; fail:
av_freep(&er->er_temp_buffer); av_freep(&er->error_status_table); return AVERROR(ENOMEM); }