int ff_h264_alloc_tables(H264Context *h){

    MpegEncContext * const s = &h->s;

    const int big_mb_num= s->mb_stride * (s->mb_height+1);

    int x,y;



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->intra4x4_pred_mode, big_mb_num * 8  * sizeof(uint8_t), fail)



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count    , big_mb_num * 16 * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->slice_table_base  , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->cbp_table, big_mb_num * sizeof(uint16_t), fail)



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->direct_table, 32*big_mb_num * sizeof(uint8_t) , fail);



    memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride)  * sizeof(*h->slice_table_base));

    h->slice_table= h->slice_table_base + s->mb_stride*2 + 1;



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b_xy  , big_mb_num * sizeof(uint32_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b8_xy , big_mb_num * sizeof(uint32_t), fail);

    for(y=0; y<s->mb_height; y++){

        for(x=0; x<s->mb_width; x++){

            const int mb_xy= x + y*s->mb_stride;

            const int b_xy = 4*x + 4*y*h->b_stride;

            const int b8_xy= 2*x + 2*y*h->b8_stride;



            h->mb2b_xy [mb_xy]= b_xy;

            h->mb2b8_xy[mb_xy]= b8_xy;

        }

    }



    s->obmc_scratchpad = NULL;



    if(!h->dequant4_coeff[0])

        init_dequant_tables(h);



    return 0;

fail:

    free_tables(h);

    return -1;

}

int ff_h264_alloc_tables(H264Context *h){

    MpegEncContext * const s = &h->s;

    const int big_mb_num= s->mb_stride * (s->mb_height+1);

    int x,y;



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->intra4x4_pred_mode, big_mb_num * 8  * sizeof(uint8_t), fail)



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count    , big_mb_num * 16 * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->slice_table_base  , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->cbp_table, big_mb_num * sizeof(uint16_t), fail)



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->direct_table, 32*big_mb_num * sizeof(uint8_t) , fail);



    memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride)  * sizeof(*h->slice_table_base));

    h->slice_table= h->slice_table_base + s->mb_stride*2 + 1;



    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b_xy  , big_mb_num * sizeof(uint32_t), fail);

    FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b8_xy , big_mb_num * sizeof(uint32_t), fail);

    for(y=0; y<s->mb_height; y++){

        for(x=0; x<s->mb_width; x++){

            const int mb_xy= x + y*s->mb_stride;

            const int b_xy = 4*x + 4*y*h->b_stride;

            const int b8_xy= 2*x + 2*y*h->b8_stride;



            h->mb2b_xy [mb_xy]= b_xy;

            h->mb2b8_xy[mb_xy]= b8_xy;

        }

    }



    s->obmc_scratchpad = NULL;



    if(!h->dequant4_coeff[0])

        init_dequant_tables(h);



    return 0;

fail:

    free_tables(h);

    return -1;

}

int FUNC_0(H264Context *VAR_0){

    MpegEncContext * const s = &VAR_0->s;

    const int VAR_1= s->mb_stride * (s->mb_height+1);

    int VAR_2,VAR_3;



    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->intra4x4_pred_mode, VAR_1 * 8  * sizeof(uint8_t), fail)



    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->non_zero_count    , VAR_1 * 16 * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->slice_table_base  , (VAR_1+s->mb_stride) * sizeof(*VAR_0->slice_table_base), fail)

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->cbp_table, VAR_1 * sizeof(uint16_t), fail)



    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->chroma_pred_mode_table, VAR_1 * sizeof(uint8_t), fail)

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mvd_table[0], 32*VAR_1 * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mvd_table[1], 32*VAR_1 * sizeof(uint16_t), fail);

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->direct_table, 32*VAR_1 * sizeof(uint8_t) , fail);



    memset(VAR_0->slice_table_base, -1, (VAR_1+s->mb_stride)  * sizeof(*VAR_0->slice_table_base));

    VAR_0->slice_table= VAR_0->slice_table_base + s->mb_stride*2 + 1;



    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mb2b_xy  , VAR_1 * sizeof(uint32_t), fail);

    FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mb2b8_xy , VAR_1 * sizeof(uint32_t), fail);

    for(VAR_3=0; VAR_3<s->mb_height; VAR_3++){

        for(VAR_2=0; VAR_2<s->mb_width; VAR_2++){

            const int mb_xy= VAR_2 + VAR_3*s->mb_stride;

            const int b_xy = 4*VAR_2 + 4*VAR_3*VAR_0->b_stride;

            const int b8_xy= 2*VAR_2 + 2*VAR_3*VAR_0->b8_stride;



            VAR_0->mb2b_xy [mb_xy]= b_xy;

            VAR_0->mb2b8_xy[mb_xy]= b8_xy;

        }

    }



    s->obmc_scratchpad = NULL;



    if(!VAR_0->dequant4_coeff[0])

        init_dequant_tables(VAR_0);



    return 0;

fail:

    free_tables(VAR_0);

    return -1;

}

int FUNC_0(H264Context *VAR_0){ MpegEncContext * const s = &VAR_0->s; const int VAR_1= s->mb_stride * (s->mb_height+1); int VAR_2,VAR_3; FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->intra4x4_pred_mode, VAR_1 * 8  * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->non_zero_count    , VAR_1 * 16 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->slice_table_base  , (VAR_1+s->mb_stride) * sizeof(*VAR_0->slice_table_base), fail)
FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->cbp_table, VAR_1 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->chroma_pred_mode_table, VAR_1 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mvd_table[0], 32*VAR_1 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mvd_table[1], 32*VAR_1 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->direct_table, 32*VAR_1 * sizeof(uint8_t) , fail); memset(VAR_0->slice_table_base, -1, (VAR_1+s->mb_stride)  * sizeof(*VAR_0->slice_table_base)); VAR_0->slice_table= VAR_0->slice_table_base + s->mb_stride*2 + 1; FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mb2b_xy  , VAR_1 * sizeof(uint32_t), fail); FF_ALLOCZ_OR_GOTO(VAR_0->s.avctx, VAR_0->mb2b8_xy , VAR_1 * sizeof(uint32_t), fail); for(VAR_3=0; VAR_3<s->mb_height; VAR_3++){ for(VAR_2=0; VAR_2<s->mb_width; VAR_2++){ const int mb_xy= VAR_2 + VAR_3*s->mb_stride; const int b_xy = 4*VAR_2 + 4*VAR_3*VAR_0->b_stride; const int b8_xy= 2*VAR_2 + 2*VAR_3*VAR_0->b8_stride; VAR_0->mb2b_xy [mb_xy]= b_xy; VAR_0->mb2b8_xy[mb_xy]= b8_xy; } } s->obmc_scratchpad = NULL; if(!VAR_0->dequant4_coeff[0])
init_dequant_tables(VAR_0); return 0; fail:
free_tables(VAR_0); return -1; }