static int rv40_decode_mb_info(RV34DecContext *r)

{

    MpegEncContext *s = &r->s;

    GetBitContext *gb = &s->gb;

    int q, i;

    int prev_type = 0;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int blocks[RV34_MB_TYPES] = {0};

    int count = 0;



    if(!r->s.mb_skip_run)

        r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;



    if(--r->s.mb_skip_run)

         return RV34_MB_SKIP;



    if(r->avail_cache[6-1])

        blocks[r->mb_type[mb_pos - 1]]++;

    if(r->avail_cache[6-4]){

        blocks[r->mb_type[mb_pos - s->mb_stride]]++;

        if(r->avail_cache[6-2])

            blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;

        if(r->avail_cache[6-5])

            blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;

    }



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

        if(blocks[i] > count){

            count = blocks[i];

            prev_type = i;

        }

    }

    if(s->pict_type == AV_PICTURE_TYPE_P){

        prev_type = block_num_to_ptype_vlc_num[prev_type];

        q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);

        if(q < PBTYPE_ESCAPE)

            return q;

        q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n");

    }else{

        prev_type = block_num_to_btype_vlc_num[prev_type];

        q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);

        if(q < PBTYPE_ESCAPE)

            return q;

        q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n");

    }

    return 0;

}

static int rv40_decode_mb_info(RV34DecContext *r)

{

    MpegEncContext *s = &r->s;

    GetBitContext *gb = &s->gb;

    int q, i;

    int prev_type = 0;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int blocks[RV34_MB_TYPES] = {0};

    int count = 0;



    if(!r->s.mb_skip_run)

        r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;



    if(--r->s.mb_skip_run)

         return RV34_MB_SKIP;



    if(r->avail_cache[6-1])

        blocks[r->mb_type[mb_pos - 1]]++;

    if(r->avail_cache[6-4]){

        blocks[r->mb_type[mb_pos - s->mb_stride]]++;

        if(r->avail_cache[6-2])

            blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;

        if(r->avail_cache[6-5])

            blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;

    }



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

        if(blocks[i] > count){

            count = blocks[i];

            prev_type = i;

        }

    }

    if(s->pict_type == AV_PICTURE_TYPE_P){

        prev_type = block_num_to_ptype_vlc_num[prev_type];

        q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);

        if(q < PBTYPE_ESCAPE)

            return q;

        q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n");

    }else{

        prev_type = block_num_to_btype_vlc_num[prev_type];

        q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);

        if(q < PBTYPE_ESCAPE)

            return q;

        q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n");

    }

    return 0;

}

static int FUNC_0(RV34DecContext *VAR_0)

{

    MpegEncContext *s = &VAR_0->s;

    GetBitContext *gb = &s->gb;

    int VAR_1, VAR_2;

    int VAR_3 = 0;

    int VAR_4 = s->mb_x + s->mb_y * s->mb_stride;

    int VAR_5[RV34_MB_TYPES] = {0};

    int VAR_6 = 0;



    if(!VAR_0->s.mb_skip_run)

        VAR_0->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;



    if(--VAR_0->s.mb_skip_run)

         return RV34_MB_SKIP;



    if(VAR_0->avail_cache[6-1])

        VAR_5[VAR_0->mb_type[VAR_4 - 1]]++;

    if(VAR_0->avail_cache[6-4]){

        VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride]]++;

        if(VAR_0->avail_cache[6-2])

            VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride + 1]]++;

        if(VAR_0->avail_cache[6-5])

            VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride - 1]]++;

    }



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

        if(VAR_5[VAR_2] > VAR_6){

            VAR_6 = VAR_5[VAR_2];

            VAR_3 = VAR_2;

        }

    }

    if(s->pict_type == AV_PICTURE_TYPE_P){

        VAR_3 = block_num_to_ptype_vlc_num[VAR_3];

        VAR_1 = get_vlc2(gb, ptype_vlc[VAR_3].table, PTYPE_VLC_BITS, 1);

        if(VAR_1 < PBTYPE_ESCAPE)

            return VAR_1;

        VAR_1 = get_vlc2(gb, ptype_vlc[VAR_3].table, PTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n");

    }else{

        VAR_3 = block_num_to_btype_vlc_num[VAR_3];

        VAR_1 = get_vlc2(gb, btype_vlc[VAR_3].table, BTYPE_VLC_BITS, 1);

        if(VAR_1 < PBTYPE_ESCAPE)

            return VAR_1;

        VAR_1 = get_vlc2(gb, btype_vlc[VAR_3].table, BTYPE_VLC_BITS, 1);

        av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n");

    }

    return 0;

}

static int FUNC_0(RV34DecContext *VAR_0)
{ MpegEncContext *s = &VAR_0->s; GetBitContext *gb = &s->gb; int VAR_1, VAR_2; int VAR_3 = 0; int VAR_4 = s->mb_x + s->mb_y * s->mb_stride; int VAR_5[RV34_MB_TYPES] = {0}; int VAR_6 = 0; if(!VAR_0->s.mb_skip_run)
VAR_0->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1; if(--VAR_0->s.mb_skip_run)
return RV34_MB_SKIP; if(VAR_0->avail_cache[6-1])
VAR_5[VAR_0->mb_type[VAR_4 - 1]]++; if(VAR_0->avail_cache[6-4]){ VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride]]++; if(VAR_0->avail_cache[6-2])
VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride + 1]]++; if(VAR_0->avail_cache[6-5])
VAR_5[VAR_0->mb_type[VAR_4 - s->mb_stride - 1]]++; } for(VAR_2 = 0; VAR_2 < RV34_MB_TYPES; VAR_2++){ if(VAR_5[VAR_2] > VAR_6){ VAR_6 = VAR_5[VAR_2]; VAR_3 = VAR_2; } } if(s->pict_type == AV_PICTURE_TYPE_P){ VAR_3 = block_num_to_ptype_vlc_num[VAR_3]; VAR_1 = get_vlc2(gb, ptype_vlc[VAR_3].table, PTYPE_VLC_BITS, 1); if(VAR_1 < PBTYPE_ESCAPE)
return VAR_1; VAR_1 = get_vlc2(gb, ptype_vlc[VAR_3].table, PTYPE_VLC_BITS, 1); av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n"); }else{ VAR_3 = block_num_to_btype_vlc_num[VAR_3]; VAR_1 = get_vlc2(gb, btype_vlc[VAR_3].table, BTYPE_VLC_BITS, 1); if(VAR_1 < PBTYPE_ESCAPE)
return VAR_1; VAR_1 = get_vlc2(gb, btype_vlc[VAR_3].table, BTYPE_VLC_BITS, 1); av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n"); } return 0; }