static int decode_mb_i(AVSContext *h, int cbp_code) {

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

    int block, pred_mode_uv;

    uint8_t top[18];

    uint8_t *left = NULL;

    uint8_t *d;



    ff_cavs_init_mb(h);



    /* get intra prediction modes from stream */

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

        int nA,nB,predpred;

        int pos = ff_cavs_scan3x3[block];



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

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

        predpred = FFMIN(nA,nB);

        if(predpred == NOT_AVAIL) // if either is not available

            predpred = INTRA_L_LP;

        if(!get_bits1(gb)){

            int rem_mode= get_bits(gb, 2);

            predpred = rem_mode + (rem_mode >= predpred);

        }

        h->pred_mode_Y[pos] = predpred;

    }

    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");

        return -1;

    }

    ff_cavs_modify_mb_i(h, &pred_mode_uv);



    /* get coded block pattern */

    if(h->pic_type == AV_PICTURE_TYPE_I)

        cbp_code = get_ue_golomb(gb);

    if(cbp_code > 63){

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

        return -1;

    }

    h->cbp = cbp_tab[cbp_code][0];

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

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



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

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

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

        ff_cavs_load_intra_pred_luma(h, top, &left, block);

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

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

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

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

    }



    /* chroma intra prediction */

    ff_cavs_load_intra_pred_chroma(h);

    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);

    ff_cavs_filter(h,I_8X8);

    set_mv_intra(h);

    return 0;

}

static int decode_mb_i(AVSContext *h, int cbp_code) {

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

    int block, pred_mode_uv;

    uint8_t top[18];

    uint8_t *left = NULL;

    uint8_t *d;



    ff_cavs_init_mb(h);



    

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

        int nA,nB,predpred;

        int pos = ff_cavs_scan3x3[block];



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

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

        predpred = FFMIN(nA,nB);

        if(predpred == NOT_AVAIL) 

            predpred = INTRA_L_LP;

        if(!get_bits1(gb)){

            int rem_mode= get_bits(gb, 2);

            predpred = rem_mode + (rem_mode >= predpred);

        }

        h->pred_mode_Y[pos] = predpred;

    }

    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");

        return -1;

    }

    ff_cavs_modify_mb_i(h, &pred_mode_uv);



    

    if(h->pic_type == AV_PICTURE_TYPE_I)

        cbp_code = get_ue_golomb(gb);

    if(cbp_code > 63){

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

        return -1;

    }

    h->cbp = cbp_tab[cbp_code][0];

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

        h->qp = (h->qp + get_se_golomb(gb)) & 63; 



    

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

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

        ff_cavs_load_intra_pred_luma(h, top, &left, block);

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

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

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

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

    }



    

    ff_cavs_load_intra_pred_chroma(h);

    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);

    ff_cavs_filter(h,I_8X8);

    set_mv_intra(h);

    return 0;

}

    int block, pred_mode_uv;
static int FUNC_0(AVSContext *VAR_0, int VAR_1) {

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

    int VAR_2, VAR_3;

    uint8_t top[18];

    uint8_t *left = NULL;

    uint8_t *d;



    ff_cavs_init_mb(VAR_0);



    

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

        int VAR_4,VAR_5,VAR_6;

        int VAR_7 = ff_cavs_scan3x3[VAR_2];



        VAR_4 = VAR_0->pred_mode_Y[VAR_7-1];

        VAR_5 = VAR_0->pred_mode_Y[VAR_7-3];

        VAR_6 = FFMIN(VAR_4,VAR_5);

        if(VAR_6 == NOT_AVAIL) 

            VAR_6 = INTRA_L_LP;

        if(!get_bits1(gb)){

            int VAR_8= get_bits(gb, 2);

            VAR_6 = VAR_8 + (VAR_8 >= VAR_6);

        }

        VAR_0->pred_mode_Y[VAR_7] = VAR_6;

    }

    VAR_3 = get_ue_golomb(gb);

    if(VAR_3 > 6) {

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

        return -1;

    }

    ff_cavs_modify_mb_i(VAR_0, &VAR_3);



    

    if(VAR_0->pic_type == AV_PICTURE_TYPE_I)

        VAR_1 = get_ue_golomb(gb);

    if(VAR_1 > 63){

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

        return -1;

    }

    VAR_0->cbp = cbp_tab[VAR_1][0];

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

        VAR_0->qp = (VAR_0->qp + get_se_golomb(gb)) & 63; 



    

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

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

        ff_cavs_load_intra_pred_luma(VAR_0, top, &left, VAR_2);

        VAR_0->intra_pred_l[VAR_0->pred_mode_Y[ff_cavs_scan3x3[VAR_2]]]

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

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

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

    }



    

    ff_cavs_load_intra_pred_chroma(VAR_0);

    VAR_0->intra_pred_c[VAR_3](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_3](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);

    ff_cavs_filter(VAR_0,I_8X8);

    set_mv_intra(VAR_0);

    return 0;

}

static int FUNC_0(AVSContext *VAR_0, int VAR_1) { GetBitContext *gb = &VAR_0->s.gb; int VAR_2, VAR_3; uint8_t top[18]; uint8_t *left = NULL; uint8_t *d; ff_cavs_init_mb(VAR_0); for(VAR_2=0;VAR_2<4;VAR_2++) { int VAR_4,VAR_5,VAR_6; int VAR_7 = ff_cavs_scan3x3[VAR_2]; VAR_4 = VAR_0->pred_mode_Y[VAR_7-1]; VAR_5 = VAR_0->pred_mode_Y[VAR_7-3]; VAR_6 = FFMIN(VAR_4,VAR_5); if(VAR_6 == NOT_AVAIL)
VAR_6 = INTRA_L_LP; if(!get_bits1(gb)){ int VAR_8= get_bits(gb, 2); VAR_6 = VAR_8 + (VAR_8 >= VAR_6); } VAR_0->pred_mode_Y[VAR_7] = VAR_6; } VAR_3 = get_ue_golomb(gb); if(VAR_3 > 6) { av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n"); return -1; } ff_cavs_modify_mb_i(VAR_0, &VAR_3); if(VAR_0->pic_type == AV_PICTURE_TYPE_I)
VAR_1 = get_ue_golomb(gb); if(VAR_1 > 63){ av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal intra cbp\n"); return -1; } VAR_0->cbp = cbp_tab[VAR_1][0]; if(VAR_0->cbp && !VAR_0->qp_fixed)
VAR_0->qp = (VAR_0->qp + get_se_golomb(gb)) & 63; for(VAR_2=0;VAR_2<4;VAR_2++) { d = VAR_0->cy + VAR_0->luma_scan[VAR_2]; ff_cavs_load_intra_pred_luma(VAR_0, top, &left, VAR_2); VAR_0->intra_pred_l[VAR_0->pred_mode_Y[ff_cavs_scan3x3[VAR_2]]]
(d, top, left, VAR_0->l_stride); if(VAR_0->cbp & (1<<VAR_2))
decode_residual_block(VAR_0,gb,ff_cavs_intra_dec,1,VAR_0->qp,d,VAR_0->l_stride); } ff_cavs_load_intra_pred_chroma(VAR_0); VAR_0->intra_pred_c[VAR_3](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_3](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); ff_cavs_filter(VAR_0,I_8X8); set_mv_intra(VAR_0); return 0; }