static int decode_p_mbs(VC9Context *v)

{

    int x, y, current_mb = 0, i; /* MB/Block Position info */

    int skip_mb_bit = 0, cbpcy; /* MB/B skip */

    int hybrid_pred, ac_pred; /* Prediction types */

    int mb_has_coeffs = 1  /* last_flag */, mb_is_intra;

    int dmv_x, dmv_y; /* Differential MV components */

    int mv_mode_bit = 0; /* mv_mode_bit: 1MV=0, 4MV=0 */

    int mqdiff, mquant; /* MB quantization */

    int tt_block; /* MB Transform type */

    static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },

        offset_table[6] = { 0, 1, 3, 7, 15, 31 };

    int k_x, k_y; /* Long MV fixed bitlength */

    int hpel_flag, intra_flag; /* Some MB properties */

    int index, index1; /* LUT indices */

    int val, sign;



    /* Select ttmb table depending on pq */

    if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];

    else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];

    else v->ttmb_vlc = &vc9_ttmb_vlc[2];



    /* Select proper long MV range */

    switch (v->mvrange)

    {

    case 1: k_x = 10; k_y = 9; break;

    case 2: k_x = 12; k_y = 10; break;

    case 3: k_x = 13; k_y = 11; break;

    default: /*case 0 too */ k_x = 9; k_y = 8; break;

    }



    hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL

    k_x -= hpel_flag;

    k_y -= hpel_flag;



    for (y=0; y<v->height_mb; y++)

    {

        for (x=0; x<v->width_mb; x++)

        {

            if (v->mv_type_mb_plane[current_mb])

                mv_mode_bit = get_bits(&v->gb, 1);

            if (0) //skipmb is rawmode

                skip_mb_bit = get_bits(&v->gb, 1);

            if (!mv_mode_bit) /* 1MV mode */

            {

                if (!v->skip_mb_plane[current_mb])

                {

                    GET_MVDATA();



                    /* hybrid mv pred, 8.3.5.3.4 */

                    if (v->mv_mode == MV_PMODE_1MV ||

                        v->mv_mode == MV_PMODE_MIXED_MV)

                        hybrid_pred = get_bits(&v->gb, 1);

                    if (mb_is_intra && !mb_has_coeffs)

                    {

                        GET_MQUANT();

                        ac_pred = get_bits(&v->gb, 1);

                    }

                    else if (mb_has_coeffs)

                    {

                        if (mb_is_intra) ac_pred = get_bits(&v->gb, 1);

                        cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table,

                                         VC9_CBPCY_P_VLC_BITS, 2);

                        GET_MQUANT();

                    }

                    if (!v->ttmbf)

                        v->ttfrm = get_vlc2(&v->gb, v->ttmb_vlc->table,

                                            VC9_TTMB_VLC_BITS, 2);

                    //Decode blocks from that mb wrt cbpcy

                }

                else //Skipped

                {

                    /* hybrid mv pred, 8.3.5.3.4 */

                    if (v->mv_mode == MV_PMODE_1MV ||

                        v->mv_mode == MV_PMODE_MIXED_MV)

                        hybrid_pred = get_bits(&v->gb, 1);

                }

            } //1MV mode

            else //4MV mode

            {

              if (!v->skip_mb_plane[current_mb] /* unskipped MB */)

                {

                    cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table,

                                     VC9_CBPCY_P_VLC_BITS, 2);

                    for (i=0; i<4; i++) //For all 4 Y blocks

                    {

                        if (cbpcy & (1<<6) /* cbpcy set for this block */)

                        {

                            GET_MVDATA();

                        }

                        if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */)

                            hybrid_pred = get_bits(&v->gb, 1);

                        GET_MQUANT();

                        if (mb_is_intra /* One of the 4 blocks is intra */ &&

                            index /* non-zero pred for that block */)

                            ac_pred = get_bits(&v->gb, 1);

                        if (!v->ttmbf)

                            tt_block = get_vlc2(&v->gb, v->ttmb_vlc->table,

                                                VC9_TTMB_VLC_BITS, 2);

            

                        /* TODO: Process blocks wrt cbpcy */

            

                        /* Prepare cbpcy for next block */

                        cbpcy <<= 1;

                    }

                }

                else //Skipped MB

                {

                    for (i=0; i<4; i++) //All 4 Y blocks

                    {

                        if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */)

                            hybrid_pred = get_bits(&v->gb, 1);

                        

                        /* FIXME: do something */

                    }

                }

            }

        }

        current_mb++;

    }

    return 0;

}

static int decode_p_mbs(VC9Context *v)

{

    int x, y, current_mb = 0, i; 

    int skip_mb_bit = 0, cbpcy; 

    int hybrid_pred, ac_pred; 

    int mb_has_coeffs = 1  , mb_is_intra;

    int dmv_x, dmv_y; 

    int mv_mode_bit = 0; 

    int mqdiff, mquant; 

    int tt_block; 

    static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },

        offset_table[6] = { 0, 1, 3, 7, 15, 31 };

    int k_x, k_y; 

    int hpel_flag, intra_flag; 

    int index, index1; 

    int val, sign;



    

    if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];

    else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];

    else v->ttmb_vlc = &vc9_ttmb_vlc[2];



    

    switch (v->mvrange)

    {

    case 1: k_x = 10; k_y = 9; break;

    case 2: k_x = 12; k_y = 10; break;

    case 3: k_x = 13; k_y = 11; break;

    default:  k_x = 9; k_y = 8; break;

    }



    hpel_flag = v->mv_mode & 1; 

    k_x -= hpel_flag;

    k_y -= hpel_flag;



    for (y=0; y<v->height_mb; y++)

    {

        for (x=0; x<v->width_mb; x++)

        {

            if (v->mv_type_mb_plane[current_mb])

                mv_mode_bit = get_bits(&v->gb, 1);

            if (0) 

                skip_mb_bit = get_bits(&v->gb, 1);

            if (!mv_mode_bit) 

            {

                if (!v->skip_mb_plane[current_mb])

                {

                    GET_MVDATA();



                    

                    if (v->mv_mode == MV_PMODE_1MV ||

                        v->mv_mode == MV_PMODE_MIXED_MV)

                        hybrid_pred = get_bits(&v->gb, 1);

                    if (mb_is_intra && !mb_has_coeffs)

                    {

                        GET_MQUANT();

                        ac_pred = get_bits(&v->gb, 1);

                    }

                    else if (mb_has_coeffs)

                    {

                        if (mb_is_intra) ac_pred = get_bits(&v->gb, 1);

                        cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table,

                                         VC9_CBPCY_P_VLC_BITS, 2);

                        GET_MQUANT();

                    }

                    if (!v->ttmbf)

                        v->ttfrm = get_vlc2(&v->gb, v->ttmb_vlc->table,

                                            VC9_TTMB_VLC_BITS, 2);

                    

                }

                else 

                {

                    

                    if (v->mv_mode == MV_PMODE_1MV ||

                        v->mv_mode == MV_PMODE_MIXED_MV)

                        hybrid_pred = get_bits(&v->gb, 1);

                }

            } 

            else 

            {

              if (!v->skip_mb_plane[current_mb] )

                {

                    cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table,

                                     VC9_CBPCY_P_VLC_BITS, 2);

                    for (i=0; i<4; i++) 

                    {

                        if (cbpcy & (1<<6) )

                        {

                            GET_MVDATA();

                        }

                        if (v->mv_mode == MV_PMODE_MIXED_MV )

                            hybrid_pred = get_bits(&v->gb, 1);

                        GET_MQUANT();

                        if (mb_is_intra  &&

                            index )

                            ac_pred = get_bits(&v->gb, 1);

                        if (!v->ttmbf)

                            tt_block = get_vlc2(&v->gb, v->ttmb_vlc->table,

                                                VC9_TTMB_VLC_BITS, 2);

            

                        

            

                        

                        cbpcy <<= 1;

                    }

                }

                else  MB

                {

                    for (i=0; i<4; i++) 

                    {

                        if (v->mv_mode == MV_PMODE_MIXED_MV )

                            hybrid_pred = get_bits(&v->gb, 1);

                        

                        

                    }

                }

            }

        }

        current_mb++;

    }

    return 0;

}

static int FUNC_0(VC9Context *VAR_0)

{

    int VAR_1, VAR_2, VAR_3 = 0, VAR_4; 

    int VAR_5 = 0, VAR_6; 

    int VAR_7, VAR_8; 

    int VAR_9 = 1  , VAR_10;

    int VAR_11, VAR_12; 

    int VAR_13 = 0; 

    int VAR_14, VAR_15; 

    int VAR_16; 

    static const int VAR_17[6] = { 0, 2, 3, 4, 5, 8 },

        VAR_18[6] = { 0, 1, 3, 7, 15, 31 };

    int VAR_19, VAR_20; 

    int VAR_21, VAR_22; 

    int VAR_23, VAR_24; 

    int VAR_25, VAR_26;



    

    if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0];

    else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1];

    else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2];



    

    switch (VAR_0->mvrange)

    {

    case 1: VAR_19 = 10; VAR_20 = 9; break;

    case 2: VAR_19 = 12; VAR_20 = 10; break;

    case 3: VAR_19 = 13; VAR_20 = 11; break;

    default:  VAR_19 = 9; VAR_20 = 8; break;

    }



    VAR_21 = VAR_0->mv_mode & 1; 

    VAR_19 -= VAR_21;

    VAR_20 -= VAR_21;



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

    {

        for (VAR_1=0; VAR_1<VAR_0->width_mb; VAR_1++)

        {

            if (VAR_0->mv_type_mb_plane[VAR_3])

                VAR_13 = get_bits(&VAR_0->gb, 1);

            if (0) 

                VAR_5 = get_bits(&VAR_0->gb, 1);

            if (!VAR_13) 

            {

                if (!VAR_0->skip_mb_plane[VAR_3])

                {

                    GET_MVDATA();



                    

                    if (VAR_0->mv_mode == MV_PMODE_1MV ||

                        VAR_0->mv_mode == MV_PMODE_MIXED_MV)

                        VAR_7 = get_bits(&VAR_0->gb, 1);

                    if (VAR_10 && !VAR_9)

                    {

                        GET_MQUANT();

                        VAR_8 = get_bits(&VAR_0->gb, 1);

                    }

                    else if (VAR_9)

                    {

                        if (VAR_10) VAR_8 = get_bits(&VAR_0->gb, 1);

                        VAR_6 = get_vlc2(&VAR_0->gb, VAR_0->cbpcy_vlc->table,

                                         VC9_CBPCY_P_VLC_BITS, 2);

                        GET_MQUANT();

                    }

                    if (!VAR_0->ttmbf)

                        VAR_0->ttfrm = get_vlc2(&VAR_0->gb, VAR_0->ttmb_vlc->table,

                                            VC9_TTMB_VLC_BITS, 2);

                    

                }

                else 

                {

                    

                    if (VAR_0->mv_mode == MV_PMODE_1MV ||

                        VAR_0->mv_mode == MV_PMODE_MIXED_MV)

                        VAR_7 = get_bits(&VAR_0->gb, 1);

                }

            } 

            else 

            {

              if (!VAR_0->skip_mb_plane[VAR_3] )

                {

                    VAR_6 = get_vlc2(&VAR_0->gb, VAR_0->cbpcy_vlc->table,

                                     VC9_CBPCY_P_VLC_BITS, 2);

                    for (VAR_4=0; VAR_4<4; VAR_4++) 

                    {

                        if (VAR_6 & (1<<6) )

                        {

                            GET_MVDATA();

                        }

                        if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )

                            VAR_7 = get_bits(&VAR_0->gb, 1);

                        GET_MQUANT();

                        if (VAR_10  &&

                            VAR_23 )

                            VAR_8 = get_bits(&VAR_0->gb, 1);

                        if (!VAR_0->ttmbf)

                            VAR_16 = get_vlc2(&VAR_0->gb, VAR_0->ttmb_vlc->table,

                                                VC9_TTMB_VLC_BITS, 2);

            

                        

            

                        

                        VAR_6 <<= 1;

                    }

                }

                else  MB

                {

                    for (VAR_4=0; VAR_4<4; VAR_4++) 

                    {

                        if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )

                            VAR_7 = get_bits(&VAR_0->gb, 1);

                        

                        

                    }

                }

            }

        }

        VAR_3++;

    }

    return 0;

}

static int FUNC_0(VC9Context *VAR_0)
{ int VAR_1, VAR_2, VAR_3 = 0, VAR_4; int VAR_5 = 0, VAR_6; int VAR_7, VAR_8; int VAR_9 = 1  , VAR_10; int VAR_11, VAR_12; int VAR_13 = 0; int VAR_14, VAR_15; int VAR_16; static const int VAR_17[6] = { 0, 2, 3, 4, 5, 8 }, VAR_18[6] = { 0, 1, 3, 7, 15, 31 }; int VAR_19, VAR_20; int VAR_21, VAR_22; int VAR_23, VAR_24; int VAR_25, VAR_26; if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0]; else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1]; else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2]; switch (VAR_0->mvrange)
{ case 1: VAR_19 = 10; VAR_20 = 9; break; case 2: VAR_19 = 12; VAR_20 = 10; break; case 3: VAR_19 = 13; VAR_20 = 11; break; default:  VAR_19 = 9; VAR_20 = 8; break; } VAR_21 = VAR_0->mv_mode & 1; VAR_19 -= VAR_21; VAR_20 -= VAR_21; for (VAR_2=0; VAR_2<VAR_0->height_mb; VAR_2++) { for (VAR_1=0; VAR_1<VAR_0->width_mb; VAR_1++) { if (VAR_0->mv_type_mb_plane[VAR_3])
VAR_13 = get_bits(&VAR_0->gb, 1); if (0)
VAR_5 = get_bits(&VAR_0->gb, 1); if (!VAR_13)
{ if (!VAR_0->skip_mb_plane[VAR_3])
{ GET_MVDATA(); if (VAR_0->mv_mode == MV_PMODE_1MV ||
VAR_0->mv_mode == MV_PMODE_MIXED_MV)
VAR_7 = get_bits(&VAR_0->gb, 1); if (VAR_10 && !VAR_9)
{ GET_MQUANT(); VAR_8 = get_bits(&VAR_0->gb, 1); } else if (VAR_9)
{ if (VAR_10) VAR_8 = get_bits(&VAR_0->gb, 1); VAR_6 = get_vlc2(&VAR_0->gb, VAR_0->cbpcy_vlc->table,
VC9_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); } if (!VAR_0->ttmbf)
VAR_0->ttfrm = get_vlc2(&VAR_0->gb, VAR_0->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 2); } else
{ if (VAR_0->mv_mode == MV_PMODE_1MV ||
VAR_0->mv_mode == MV_PMODE_MIXED_MV)
VAR_7 = get_bits(&VAR_0->gb, 1); } } else
{ if (!VAR_0->skip_mb_plane[VAR_3] )
{ VAR_6 = get_vlc2(&VAR_0->gb, VAR_0->cbpcy_vlc->table,
VC9_CBPCY_P_VLC_BITS, 2); for (VAR_4=0; VAR_4<4; VAR_4++) { if (VAR_6 & (1<<6) )
{ GET_MVDATA(); } if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )
VAR_7 = get_bits(&VAR_0->gb, 1); GET_MQUANT(); if (VAR_10  &&
VAR_23 )
VAR_8 = get_bits(&VAR_0->gb, 1); if (!VAR_0->ttmbf)
VAR_16 = get_vlc2(&VAR_0->gb, VAR_0->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 2); VAR_6 <<= 1; } } else  MB
{ for (VAR_4=0; VAR_4<4; VAR_4++) { if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )
VAR_7 = get_bits(&VAR_0->gb, 1); } } } } VAR_3++; } return 0; }