static void decode_mb_i(AVSContext *h) {

    GetBitContext *gb = &h->s.gb;

    int block, pred_mode_uv;

    uint8_t top[18];

    uint8_t left[18];

    uint8_t *d;



    init_mb(h);



    /* get intra prediction modes from stream */

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

        int nA,nB,predpred;

        int pos = scan3x3[block];



        nA = h->pred_mode_Y[pos-1];

        nB = h->pred_mode_Y[pos-3];

        if((nA == NOT_AVAIL) || (nB == NOT_AVAIL))

            predpred = 2;

        else

            predpred = FFMIN(nA,nB);

        if(get_bits1(gb))

            h->pred_mode_Y[pos] = predpred;

        else {

            h->pred_mode_Y[pos] = get_bits(gb,2);

            if(h->pred_mode_Y[pos] >= predpred)

                h->pred_mode_Y[pos]++;

        }

    }

    pred_mode_uv = get_ue_golomb(gb);

    if(pred_mode_uv > 6) {

        av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n");

        pred_mode_uv = 0;

    }



    /* save pred modes before they get modified */

    h->pred_mode_Y[3] =  h->pred_mode_Y[5];

    h->pred_mode_Y[6] =  h->pred_mode_Y[8];

    h->top_pred_Y[h->mbx*2+0] = h->pred_mode_Y[7];

    h->top_pred_Y[h->mbx*2+1] = h->pred_mode_Y[8];



    /* modify pred modes according to availability of neighbour samples */

    if(!(h->flags & A_AVAIL)) {

        modify_pred(left_modifier_l, &h->pred_mode_Y[4] );

        modify_pred(left_modifier_l, &h->pred_mode_Y[7] );

        modify_pred(left_modifier_c, &pred_mode_uv );

    }

    if(!(h->flags & B_AVAIL)) {

        modify_pred(top_modifier_l, &h->pred_mode_Y[4] );

        modify_pred(top_modifier_l, &h->pred_mode_Y[5] );

        modify_pred(top_modifier_c, &pred_mode_uv );

    }



    /* get coded block pattern */

    if(h->pic_type == FF_I_TYPE)

        h->cbp = cbp_tab[get_ue_golomb(gb)][0];

    if(h->cbp && !h->qp_fixed)

        h->qp += get_se_golomb(gb); //qp_delta



    /* luma intra prediction interleaved with residual decode/transform/add */

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

        d = h->cy + h->luma_scan[block];

        load_intra_pred_luma(h, top, left, block);

        h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]

            (d, top, left, h->l_stride);

        if(h->cbp & (1<<block))

            decode_residual_block(h,gb,intra_2dvlc,1,h->qp,d,h->l_stride);

    }



    /* chroma intra prediction */

    /* extend borders by one pixel */

    h->left_border_u[9] = h->left_border_u[8];

    h->left_border_v[9] = h->left_border_v[8];

    h->top_border_u[h->mbx*10+9] = h->top_border_u[h->mbx*10+8];

    h->top_border_v[h->mbx*10+9] = h->top_border_v[h->mbx*10+8];

    if(h->mbx && h->mby) {

        h->top_border_u[h->mbx*10] = h->left_border_u[0] = h->topleft_border_u;

        h->top_border_v[h->mbx*10] = h->left_border_v[0] = h->topleft_border_v;

    } else {

        h->left_border_u[0] = h->left_border_u[1];

        h->left_border_v[0] = h->left_border_v[1];

        h->top_border_u[h->mbx*10] = h->top_border_u[h->mbx*10+1];

        h->top_border_v[h->mbx*10] = h->top_border_v[h->mbx*10+1];

    }

    h->intra_pred_c[pred_mode_uv](h->cu, &h->top_border_u[h->mbx*10],

                                  h->left_border_u, h->c_stride);

    h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx*10],

                                  h->left_border_v, h->c_stride);



    decode_residual_chroma(h);

    filter_mb(h,I_8X8);



    /* mark motion vectors as intra */

    h->mv[MV_FWD_X0] = intra_mv;

    set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);

    h->mv[MV_BWD_X0] = intra_mv;

    set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);

    if(h->pic_type != FF_B_TYPE)

        *h->col_type = I_8X8;

}

static void decode_mb_i(AVSContext *h) {

    GetBitContext *gb = &h->s.gb;

    int block, pred_mode_uv;

    uint8_t top[18];

    uint8_t left[18];

    uint8_t *d;



    init_mb(h);



    

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

        int nA,nB,predpred;

        int pos = scan3x3[block];



        nA = h->pred_mode_Y[pos-1];

        nB = h->pred_mode_Y[pos-3];

        if((nA == NOT_AVAIL) || (nB == NOT_AVAIL))

            predpred = 2;

        else

            predpred = FFMIN(nA,nB);

        if(get_bits1(gb))

            h->pred_mode_Y[pos] = predpred;

        else {

            h->pred_mode_Y[pos] = get_bits(gb,2);

            if(h->pred_mode_Y[pos] >= predpred)

                h->pred_mode_Y[pos]++;

        }

    }

    pred_mode_uv = get_ue_golomb(gb);

    if(pred_mode_uv > 6) {

        av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n");

        pred_mode_uv = 0;

    }



    

    h->pred_mode_Y[3] =  h->pred_mode_Y[5];

    h->pred_mode_Y[6] =  h->pred_mode_Y[8];

    h->top_pred_Y[h->mbx*2+0] = h->pred_mode_Y[7];

    h->top_pred_Y[h->mbx*2+1] = h->pred_mode_Y[8];



    

    if(!(h->flags & A_AVAIL)) {

        modify_pred(left_modifier_l, &h->pred_mode_Y[4] );

        modify_pred(left_modifier_l, &h->pred_mode_Y[7] );

        modify_pred(left_modifier_c, &pred_mode_uv );

    }

    if(!(h->flags & B_AVAIL)) {

        modify_pred(top_modifier_l, &h->pred_mode_Y[4] );

        modify_pred(top_modifier_l, &h->pred_mode_Y[5] );

        modify_pred(top_modifier_c, &pred_mode_uv );

    }



    

    if(h->pic_type == FF_I_TYPE)

        h->cbp = cbp_tab[get_ue_golomb(gb)][0];

    if(h->cbp && !h->qp_fixed)

        h->qp += get_se_golomb(gb); 



    

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

        d = h->cy + h->luma_scan[block];

        load_intra_pred_luma(h, top, left, block);

        h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]

            (d, top, left, h->l_stride);

        if(h->cbp & (1<<block))

            decode_residual_block(h,gb,intra_2dvlc,1,h->qp,d,h->l_stride);

    }



    

    

    h->left_border_u[9] = h->left_border_u[8];

    h->left_border_v[9] = h->left_border_v[8];

    h->top_border_u[h->mbx*10+9] = h->top_border_u[h->mbx*10+8];

    h->top_border_v[h->mbx*10+9] = h->top_border_v[h->mbx*10+8];

    if(h->mbx && h->mby) {

        h->top_border_u[h->mbx*10] = h->left_border_u[0] = h->topleft_border_u;

        h->top_border_v[h->mbx*10] = h->left_border_v[0] = h->topleft_border_v;

    } else {

        h->left_border_u[0] = h->left_border_u[1];

        h->left_border_v[0] = h->left_border_v[1];

        h->top_border_u[h->mbx*10] = h->top_border_u[h->mbx*10+1];

        h->top_border_v[h->mbx*10] = h->top_border_v[h->mbx*10+1];

    }

    h->intra_pred_c[pred_mode_uv](h->cu, &h->top_border_u[h->mbx*10],

                                  h->left_border_u, h->c_stride);

    h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx*10],

                                  h->left_border_v, h->c_stride);



    decode_residual_chroma(h);

    filter_mb(h,I_8X8);



    

    h->mv[MV_FWD_X0] = intra_mv;

    set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);

    h->mv[MV_BWD_X0] = intra_mv;

    set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);

    if(h->pic_type != FF_B_TYPE)

        *h->col_type = I_8X8;

}

static void FUNC_0(AVSContext *VAR_0) {

    GetBitContext *gb = &VAR_0->s.gb;

    int VAR_1, VAR_2;

    uint8_t top[18];

    uint8_t left[18];

    uint8_t *d;



    init_mb(VAR_0);



    

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

        int VAR_3,VAR_4,VAR_5;

        int VAR_6 = scan3x3[VAR_1];



        VAR_3 = VAR_0->pred_mode_Y[VAR_6-1];

        VAR_4 = VAR_0->pred_mode_Y[VAR_6-3];

        if((VAR_3 == NOT_AVAIL) || (VAR_4 == NOT_AVAIL))

            VAR_5 = 2;

        else

            VAR_5 = FFMIN(VAR_3,VAR_4);

        if(get_bits1(gb))

            VAR_0->pred_mode_Y[VAR_6] = VAR_5;

        else {

            VAR_0->pred_mode_Y[VAR_6] = get_bits(gb,2);

            if(VAR_0->pred_mode_Y[VAR_6] >= VAR_5)

                VAR_0->pred_mode_Y[VAR_6]++;

        }

    }

    VAR_2 = get_ue_golomb(gb);

    if(VAR_2 > 6) {

        av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n");

        VAR_2 = 0;

    }



    

    VAR_0->pred_mode_Y[3] =  VAR_0->pred_mode_Y[5];

    VAR_0->pred_mode_Y[6] =  VAR_0->pred_mode_Y[8];

    VAR_0->top_pred_Y[VAR_0->mbx*2+0] = VAR_0->pred_mode_Y[7];

    VAR_0->top_pred_Y[VAR_0->mbx*2+1] = VAR_0->pred_mode_Y[8];



    

    if(!(VAR_0->flags & A_AVAIL)) {

        modify_pred(left_modifier_l, &VAR_0->pred_mode_Y[4] );

        modify_pred(left_modifier_l, &VAR_0->pred_mode_Y[7] );

        modify_pred(left_modifier_c, &VAR_2 );

    }

    if(!(VAR_0->flags & B_AVAIL)) {

        modify_pred(top_modifier_l, &VAR_0->pred_mode_Y[4] );

        modify_pred(top_modifier_l, &VAR_0->pred_mode_Y[5] );

        modify_pred(top_modifier_c, &VAR_2 );

    }



    

    if(VAR_0->pic_type == FF_I_TYPE)

        VAR_0->cbp = cbp_tab[get_ue_golomb(gb)][0];

    if(VAR_0->cbp && !VAR_0->qp_fixed)

        VAR_0->qp += get_se_golomb(gb); 



    

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

        d = VAR_0->cy + VAR_0->luma_scan[VAR_1];

        load_intra_pred_luma(VAR_0, top, left, VAR_1);

        VAR_0->intra_pred_l[VAR_0->pred_mode_Y[scan3x3[VAR_1]]]

            (d, top, left, VAR_0->l_stride);

        if(VAR_0->cbp & (1<<VAR_1))

            decode_residual_block(VAR_0,gb,intra_2dvlc,1,VAR_0->qp,d,VAR_0->l_stride);

    }



    

    

    VAR_0->left_border_u[9] = VAR_0->left_border_u[8];

    VAR_0->left_border_v[9] = VAR_0->left_border_v[8];

    VAR_0->top_border_u[VAR_0->mbx*10+9] = VAR_0->top_border_u[VAR_0->mbx*10+8];

    VAR_0->top_border_v[VAR_0->mbx*10+9] = VAR_0->top_border_v[VAR_0->mbx*10+8];

    if(VAR_0->mbx && VAR_0->mby) {

        VAR_0->top_border_u[VAR_0->mbx*10] = VAR_0->left_border_u[0] = VAR_0->topleft_border_u;

        VAR_0->top_border_v[VAR_0->mbx*10] = VAR_0->left_border_v[0] = VAR_0->topleft_border_v;

    } else {

        VAR_0->left_border_u[0] = VAR_0->left_border_u[1];

        VAR_0->left_border_v[0] = VAR_0->left_border_v[1];

        VAR_0->top_border_u[VAR_0->mbx*10] = VAR_0->top_border_u[VAR_0->mbx*10+1];

        VAR_0->top_border_v[VAR_0->mbx*10] = VAR_0->top_border_v[VAR_0->mbx*10+1];

    }

    VAR_0->intra_pred_c[VAR_2](VAR_0->cu, &VAR_0->top_border_u[VAR_0->mbx*10],

                                  VAR_0->left_border_u, VAR_0->c_stride);

    VAR_0->intra_pred_c[VAR_2](VAR_0->cv, &VAR_0->top_border_v[VAR_0->mbx*10],

                                  VAR_0->left_border_v, VAR_0->c_stride);



    decode_residual_chroma(VAR_0);

    filter_mb(VAR_0,I_8X8);



    

    VAR_0->mv[MV_FWD_X0] = intra_mv;

    set_mvs(&VAR_0->mv[MV_FWD_X0], BLK_16X16);

    VAR_0->mv[MV_BWD_X0] = intra_mv;

    set_mvs(&VAR_0->mv[MV_BWD_X0], BLK_16X16);

    if(VAR_0->pic_type != FF_B_TYPE)

        *VAR_0->col_type = I_8X8;

}

static void FUNC_0(AVSContext *VAR_0) { GetBitContext *gb = &VAR_0->s.gb; int VAR_1, VAR_2; uint8_t top[18]; uint8_t left[18]; uint8_t *d; init_mb(VAR_0); for(VAR_1=0;VAR_1<4;VAR_1++) { int VAR_3,VAR_4,VAR_5; int VAR_6 = scan3x3[VAR_1]; VAR_3 = VAR_0->pred_mode_Y[VAR_6-1]; VAR_4 = VAR_0->pred_mode_Y[VAR_6-3]; if((VAR_3 == NOT_AVAIL) || (VAR_4 == NOT_AVAIL))
VAR_5 = 2; else
VAR_5 = FFMIN(VAR_3,VAR_4); if(get_bits1(gb))
VAR_0->pred_mode_Y[VAR_6] = VAR_5; else { VAR_0->pred_mode_Y[VAR_6] = get_bits(gb,2); if(VAR_0->pred_mode_Y[VAR_6] >= VAR_5)
VAR_0->pred_mode_Y[VAR_6]++; } } VAR_2 = get_ue_golomb(gb); if(VAR_2 > 6) { av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n"); VAR_2 = 0; } VAR_0->pred_mode_Y[3] =  VAR_0->pred_mode_Y[5]; VAR_0->pred_mode_Y[6] =  VAR_0->pred_mode_Y[8]; VAR_0->top_pred_Y[VAR_0->mbx*2+0] = VAR_0->pred_mode_Y[7]; VAR_0->top_pred_Y[VAR_0->mbx*2+1] = VAR_0->pred_mode_Y[8]; if(!(VAR_0->flags & A_AVAIL)) { modify_pred(left_modifier_l, &VAR_0->pred_mode_Y[4] ); modify_pred(left_modifier_l, &VAR_0->pred_mode_Y[7] ); modify_pred(left_modifier_c, &VAR_2 ); } if(!(VAR_0->flags & B_AVAIL)) { modify_pred(top_modifier_l, &VAR_0->pred_mode_Y[4] ); modify_pred(top_modifier_l, &VAR_0->pred_mode_Y[5] ); modify_pred(top_modifier_c, &VAR_2 ); } if(VAR_0->pic_type == FF_I_TYPE)
VAR_0->cbp = cbp_tab[get_ue_golomb(gb)][0]; if(VAR_0->cbp && !VAR_0->qp_fixed)
VAR_0->qp += get_se_golomb(gb); for(VAR_1=0;VAR_1<4;VAR_1++) { d = VAR_0->cy + VAR_0->luma_scan[VAR_1]; load_intra_pred_luma(VAR_0, top, left, VAR_1); VAR_0->intra_pred_l[VAR_0->pred_mode_Y[scan3x3[VAR_1]]]
(d, top, left, VAR_0->l_stride); if(VAR_0->cbp & (1<<VAR_1))
decode_residual_block(VAR_0,gb,intra_2dvlc,1,VAR_0->qp,d,VAR_0->l_stride); } VAR_0->left_border_u[9] = VAR_0->left_border_u[8]; VAR_0->left_border_v[9] = VAR_0->left_border_v[8]; VAR_0->top_border_u[VAR_0->mbx*10+9] = VAR_0->top_border_u[VAR_0->mbx*10+8]; VAR_0->top_border_v[VAR_0->mbx*10+9] = VAR_0->top_border_v[VAR_0->mbx*10+8]; if(VAR_0->mbx && VAR_0->mby) { VAR_0->top_border_u[VAR_0->mbx*10] = VAR_0->left_border_u[0] = VAR_0->topleft_border_u; VAR_0->top_border_v[VAR_0->mbx*10] = VAR_0->left_border_v[0] = VAR_0->topleft_border_v; } else { VAR_0->left_border_u[0] = VAR_0->left_border_u[1]; VAR_0->left_border_v[0] = VAR_0->left_border_v[1]; VAR_0->top_border_u[VAR_0->mbx*10] = VAR_0->top_border_u[VAR_0->mbx*10+1]; VAR_0->top_border_v[VAR_0->mbx*10] = VAR_0->top_border_v[VAR_0->mbx*10+1]; } VAR_0->intra_pred_c[VAR_2](VAR_0->cu, &VAR_0->top_border_u[VAR_0->mbx*10],
VAR_0->left_border_u, VAR_0->c_stride); VAR_0->intra_pred_c[VAR_2](VAR_0->cv, &VAR_0->top_border_v[VAR_0->mbx*10],
VAR_0->left_border_v, VAR_0->c_stride); decode_residual_chroma(VAR_0); filter_mb(VAR_0,I_8X8); VAR_0->mv[MV_FWD_X0] = intra_mv; set_mvs(&VAR_0->mv[MV_FWD_X0], BLK_16X16); VAR_0->mv[MV_BWD_X0] = intra_mv; set_mvs(&VAR_0->mv[MV_BWD_X0], BLK_16X16); if(VAR_0->pic_type != FF_B_TYPE)
*VAR_0->col_type = I_8X8; }