void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,

                    uint8_t *segment, uint8_t *ref, int layout, int is_vp7)

{

    VP56RangeCoder *c = &s->c;

    static const char *vp7_feature_name[] = { "q-index",

                                              "lf-delta",

                                              "partial-golden-update",

                                              "blit-pitch" };

    if (is_vp7) {

        int i;

        *segment = 0;

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

            if (s->feature_enabled[i]) {

                if (vp56_rac_get_prob_branchy(c, s->feature_present_prob[i])) {

                      int index = vp8_rac_get_tree(c, vp7_feature_index_tree,

                                                   s->feature_index_prob[i]);

                      av_log(s->avctx, AV_LOG_WARNING,

                             "Feature %s present in macroblock (value 0x%x)\n",

                             vp7_feature_name[i], s->feature_value[i][index]);

                }

           }

        }

    } else if (s->segmentation.update_map) {

        int bit  = vp56_rac_get_prob(c, s->prob->segmentid[0]);

        *segment = vp56_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit;

    } else if (s->segmentation.enabled)

        *segment = ref ? *ref : *segment;

    mb->segment = *segment;



    mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0;



    if (s->keyframe) {

        mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,

                                    vp8_pred16x16_prob_intra);



        if (mb->mode == MODE_I4x4) {

            decode_intra4x4_modes(s, c, mb, mb_x, 1, layout);

        } else {

            const uint32_t modes = (is_vp7 ? vp7_pred4x4_mode

                                           : vp8_pred4x4_mode)[mb->mode] * 0x01010101u;

            if (s->mb_layout)

                AV_WN32A(mb->intra4x4_pred_mode_top, modes);

            else

                AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);

            AV_WN32A(s->intra4x4_pred_mode_left, modes);

        }



        mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                vp8_pred8x8c_prob_intra);

        mb->ref_frame        = VP56_FRAME_CURRENT;

    } else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {

        // inter MB, 16.2

        if (vp56_rac_get_prob_branchy(c, s->prob->last))

            mb->ref_frame =

                (!is_vp7 && vp56_rac_get_prob(c, s->prob->golden)) ? VP56_FRAME_GOLDEN2 /* altref */

                                                                   : VP56_FRAME_GOLDEN;

        else

            mb->ref_frame = VP56_FRAME_PREVIOUS;

        s->ref_count[mb->ref_frame - 1]++;



        // motion vectors, 16.3

        if (is_vp7)

            vp7_decode_mvs(s, mb, mb_x, mb_y, layout);

        else

            vp8_decode_mvs(s, mb, mb_x, mb_y, layout);

    } else {

        // intra MB, 16.1

        mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);



        if (mb->mode == MODE_I4x4)

            decode_intra4x4_modes(s, c, mb, mb_x, 0, layout);



        mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                s->prob->pred8x8c);

        mb->ref_frame        = VP56_FRAME_CURRENT;

        mb->partitioning     = VP8_SPLITMVMODE_NONE;

        AV_ZERO32(&mb->bmv[0]);

    }

}

void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,

                    uint8_t *segment, uint8_t *ref, int layout, int is_vp7)

{

    VP56RangeCoder *c = &s->c;

    static const char *vp7_feature_name[] = { "q-index",

                                              "lf-delta",

                                              "partial-golden-update",

                                              "blit-pitch" };

    if (is_vp7) {

        int i;

        *segment = 0;

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

            if (s->feature_enabled[i]) {

                if (vp56_rac_get_prob_branchy(c, s->feature_present_prob[i])) {

                      int index = vp8_rac_get_tree(c, vp7_feature_index_tree,

                                                   s->feature_index_prob[i]);

                      av_log(s->avctx, AV_LOG_WARNING,

                             "Feature %s present in macroblock (value 0x%x)\n",

                             vp7_feature_name[i], s->feature_value[i][index]);

                }

           }

        }

    } else if (s->segmentation.update_map) {

        int bit  = vp56_rac_get_prob(c, s->prob->segmentid[0]);

        *segment = vp56_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit;

    } else if (s->segmentation.enabled)

        *segment = ref ? *ref : *segment;

    mb->segment = *segment;



    mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0;



    if (s->keyframe) {

        mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,

                                    vp8_pred16x16_prob_intra);



        if (mb->mode == MODE_I4x4) {

            decode_intra4x4_modes(s, c, mb, mb_x, 1, layout);

        } else {

            const uint32_t modes = (is_vp7 ? vp7_pred4x4_mode

                                           : vp8_pred4x4_mode)[mb->mode] * 0x01010101u;

            if (s->mb_layout)

                AV_WN32A(mb->intra4x4_pred_mode_top, modes);

            else

                AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);

            AV_WN32A(s->intra4x4_pred_mode_left, modes);

        }



        mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                vp8_pred8x8c_prob_intra);

        mb->ref_frame        = VP56_FRAME_CURRENT;

    } else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {

        

        if (vp56_rac_get_prob_branchy(c, s->prob->last))

            mb->ref_frame =

                (!is_vp7 && vp56_rac_get_prob(c, s->prob->golden)) ? VP56_FRAME_GOLDEN2 

                                                                   : VP56_FRAME_GOLDEN;

        else

            mb->ref_frame = VP56_FRAME_PREVIOUS;

        s->ref_count[mb->ref_frame - 1]++;



        

        if (is_vp7)

            vp7_decode_mvs(s, mb, mb_x, mb_y, layout);

        else

            vp8_decode_mvs(s, mb, mb_x, mb_y, layout);

    } else {

        

        mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);



        if (mb->mode == MODE_I4x4)

            decode_intra4x4_modes(s, c, mb, mb_x, 0, layout);



        mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                s->prob->pred8x8c);

        mb->ref_frame        = VP56_FRAME_CURRENT;

        mb->partitioning     = VP8_SPLITMVMODE_NONE;

        AV_ZERO32(&mb->bmv[0]);

    }

}

void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,             vp8_decode_mvs(s, mb, mb_x, mb_y, layout);
void FUNC_0(VP8Context *VAR_0, VP8Macroblock *VAR_1, int VAR_2, int VAR_3,

                    uint8_t *VAR_4, uint8_t *VAR_5, int VAR_6, int VAR_7)

{

    VP56RangeCoder *c = &VAR_0->c;

    static const char *VAR_8[] = { "q-VAR_10",

                                              "lf-delta",

                                              "partial-golden-update",

                                              "blit-pitch" };

    if (VAR_7) {

        int VAR_9;

        *VAR_4 = 0;

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

            if (VAR_0->feature_enabled[VAR_9]) {

                if (vp56_rac_get_prob_branchy(c, VAR_0->feature_present_prob[VAR_9])) {

                      int VAR_10 = vp8_rac_get_tree(c, vp7_feature_index_tree,

                                                   VAR_0->feature_index_prob[VAR_9]);

                      av_log(VAR_0->avctx, AV_LOG_WARNING,

                             "Feature %VAR_0 present in macroblock (value 0x%x)\n",

                             VAR_8[VAR_9], VAR_0->feature_value[VAR_9][VAR_10]);

                }

           }

        }

    } else if (VAR_0->segmentation.update_map) {

        int VAR_11  = vp56_rac_get_prob(c, VAR_0->prob->segmentid[0]);

        *VAR_4 = vp56_rac_get_prob(c, VAR_0->prob->segmentid[1+VAR_11]) + 2*VAR_11;

    } else if (VAR_0->segmentation.enabled)

        *VAR_4 = VAR_5 ? *VAR_5 : *VAR_4;

    VAR_1->VAR_4 = *VAR_4;



    VAR_1->skip = VAR_0->mbskip_enabled ? vp56_rac_get_prob(c, VAR_0->prob->mbskip) : 0;



    if (VAR_0->keyframe) {

        VAR_1->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,

                                    vp8_pred16x16_prob_intra);



        if (VAR_1->mode == MODE_I4x4) {

            decode_intra4x4_modes(VAR_0, c, VAR_1, VAR_2, 1, VAR_6);

        } else {

            const uint32_t VAR_12 = (VAR_7 ? vp7_pred4x4_mode

                                           : vp8_pred4x4_mode)[VAR_1->mode] * 0x01010101u;

            if (VAR_0->mb_layout)

                AV_WN32A(VAR_1->intra4x4_pred_mode_top, VAR_12);

            else

                AV_WN32A(VAR_0->intra4x4_pred_mode_top + 4 * VAR_2, VAR_12);

            AV_WN32A(VAR_0->intra4x4_pred_mode_left, VAR_12);

        }



        VAR_1->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                vp8_pred8x8c_prob_intra);

        VAR_1->ref_frame        = VP56_FRAME_CURRENT;

    } else if (vp56_rac_get_prob_branchy(c, VAR_0->prob->intra)) {

        

        if (vp56_rac_get_prob_branchy(c, VAR_0->prob->last))

            VAR_1->ref_frame =

                (!VAR_7 && vp56_rac_get_prob(c, VAR_0->prob->golden)) ? VP56_FRAME_GOLDEN2 

                                                                   : VP56_FRAME_GOLDEN;

        else

            VAR_1->ref_frame = VP56_FRAME_PREVIOUS;

        VAR_0->ref_count[VAR_1->ref_frame - 1]++;



        

        if (VAR_7)

            vp7_decode_mvs(VAR_0, VAR_1, VAR_2, VAR_3, VAR_6);

        else

            vp8_decode_mvs(VAR_0, VAR_1, VAR_2, VAR_3, VAR_6);

    } else {

        

        VAR_1->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, VAR_0->prob->pred16x16);



        if (VAR_1->mode == MODE_I4x4)

            decode_intra4x4_modes(VAR_0, c, VAR_1, VAR_2, 0, VAR_6);



        VAR_1->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,

                                                VAR_0->prob->pred8x8c);

        VAR_1->ref_frame        = VP56_FRAME_CURRENT;

        VAR_1->partitioning     = VP8_SPLITMVMODE_NONE;

        AV_ZERO32(&VAR_1->bmv[0]);

    }

}

void FUNC_0(VP8Context *VAR_0, VP8Macroblock *VAR_1, int VAR_2, int VAR_3,
uint8_t *VAR_4, uint8_t *VAR_5, int VAR_6, int VAR_7)
{ VP56RangeCoder *c = &VAR_0->c; static const char *VAR_8[] = { "q-VAR_10", "lf-delta",
"partial-golden-update",
"blit-pitch" }; if (VAR_7) { int VAR_9; *VAR_4 = 0; for (VAR_9 = 0; VAR_9 < 4; VAR_9++) { if (VAR_0->feature_enabled[VAR_9]) { if (vp56_rac_get_prob_branchy(c, VAR_0->feature_present_prob[VAR_9])) { int VAR_10 = vp8_rac_get_tree(c, vp7_feature_index_tree,
VAR_0->feature_index_prob[VAR_9]); av_log(VAR_0->avctx, AV_LOG_WARNING,
"Feature %VAR_0 present in macroblock (value 0x%x)\n",
VAR_8[VAR_9], VAR_0->feature_value[VAR_9][VAR_10]); } } } } else if (VAR_0->segmentation.update_map) { int VAR_11  = vp56_rac_get_prob(c, VAR_0->prob->segmentid[0]); *VAR_4 = vp56_rac_get_prob(c, VAR_0->prob->segmentid[1+VAR_11]) + 2*VAR_11; } else if (VAR_0->segmentation.enabled) *VAR_4 = VAR_5 ? *VAR_5 : *VAR_4; VAR_1->VAR_4 = *VAR_4; VAR_1->skip = VAR_0->mbskip_enabled ? vp56_rac_get_prob(c, VAR_0->prob->mbskip) : 0; if (VAR_0->keyframe) { VAR_1->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,
vp8_pred16x16_prob_intra); if (VAR_1->mode == MODE_I4x4) { decode_intra4x4_modes(VAR_0, c, VAR_1, VAR_2, 1, VAR_6); } else { const uint32_t VAR_12 = (VAR_7 ? vp7_pred4x4_mode
: vp8_pred4x4_mode)[VAR_1->mode] * 0x01010101u; if (VAR_0->mb_layout)
AV_WN32A(VAR_1->intra4x4_pred_mode_top, VAR_12); else
AV_WN32A(VAR_0->intra4x4_pred_mode_top + 4 * VAR_2, VAR_12); AV_WN32A(VAR_0->intra4x4_pred_mode_left, VAR_12); } VAR_1->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
vp8_pred8x8c_prob_intra); VAR_1->ref_frame        = VP56_FRAME_CURRENT; } else if (vp56_rac_get_prob_branchy(c, VAR_0->prob->intra)) { if (vp56_rac_get_prob_branchy(c, VAR_0->prob->last))
VAR_1->ref_frame =
(!VAR_7 && vp56_rac_get_prob(c, VAR_0->prob->golden)) ? VP56_FRAME_GOLDEN2
: VP56_FRAME_GOLDEN; else
VAR_1->ref_frame = VP56_FRAME_PREVIOUS; VAR_0->ref_count[VAR_1->ref_frame - 1]++; if (VAR_7)
vp7_decode_mvs(VAR_0, VAR_1, VAR_2, VAR_3, VAR_6); else
vp8_decode_mvs(VAR_0, VAR_1, VAR_2, VAR_3, VAR_6); } else { VAR_1->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, VAR_0->prob->pred16x16); if (VAR_1->mode == MODE_I4x4)
decode_intra4x4_modes(VAR_0, c, VAR_1, VAR_2, 0, VAR_6); VAR_1->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
VAR_0->prob->pred8x8c); VAR_1->ref_frame        = VP56_FRAME_CURRENT; VAR_1->partitioning     = VP8_SPLITMVMODE_NONE; AV_ZERO32(&VAR_1->bmv[0]); } }