void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c,

                      VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9])

{

    int i, x, y, luma_start = 0, luma_ctx = 3;

    int nnz_pred, nnz, nnz_total = 0;

    int segment = mb->segment;

    int block_dc = 0;



    if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {

        nnz_pred = t_nnz[8] + l_nnz[8];



        // decode DC values and do hadamard

        nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0,

                                  nnz_pred, s->qmat[segment].luma_dc_qmul);

        l_nnz[8] = t_nnz[8] = !!nnz;

        if (nnz) {

            nnz_total += nnz;

            block_dc   = 1;

            if (nnz == 1)

                s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc);

            else

                s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc);

        }

        luma_start = 1;

        luma_ctx   = 0;

    }



    // luma blocks

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

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

            nnz_pred = l_nnz[y] + t_nnz[x];

            nnz = decode_block_coeffs(c, td->block[y][x],

                                      s->prob->token[luma_ctx],

                                      luma_start, nnz_pred,

                                      s->qmat[segment].luma_qmul);

            /* nnz+block_dc may be one more than the actual last index,

             * but we don't care */

            td->non_zero_count_cache[y][x] = nnz + block_dc;

            t_nnz[x] = l_nnz[y] = !!nnz;

            nnz_total += nnz;

        }



    // chroma blocks

    // TODO: what to do about dimensions? 2nd dim for luma is x,

    // but for chroma it's (y<<1)|x

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

        for (y = 0; y < 2; y++)

            for (x = 0; x < 2; x++) {

                nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];

                nnz      = decode_block_coeffs(c, td->block[i][(y << 1) + x],

                                               s->prob->token[2],

                                               0, nnz_pred,

                                               s->qmat[segment].chroma_qmul);

                td->non_zero_count_cache[i][(y << 1) + x] = nnz;

                t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;

                nnz_total       += nnz;

            }



    // if there were no coded coeffs despite the macroblock not being marked skip,

    // we MUST not do the inner loop filter and should not do IDCT

    // Since skip isn't used for bitstream prediction, just manually set it.

    if (!nnz_total)

        mb->skip = 1;

}

void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c,

                      VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9])

{

    int i, x, y, luma_start = 0, luma_ctx = 3;

    int nnz_pred, nnz, nnz_total = 0;

    int segment = mb->segment;

    int block_dc = 0;



    if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {

        nnz_pred = t_nnz[8] + l_nnz[8];



        

        nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0,

                                  nnz_pred, s->qmat[segment].luma_dc_qmul);

        l_nnz[8] = t_nnz[8] = !!nnz;

        if (nnz) {

            nnz_total += nnz;

            block_dc   = 1;

            if (nnz == 1)

                s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc);

            else

                s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc);

        }

        luma_start = 1;

        luma_ctx   = 0;

    }



    

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

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

            nnz_pred = l_nnz[y] + t_nnz[x];

            nnz = decode_block_coeffs(c, td->block[y][x],

                                      s->prob->token[luma_ctx],

                                      luma_start, nnz_pred,

                                      s->qmat[segment].luma_qmul);

            



            td->non_zero_count_cache[y][x] = nnz + block_dc;

            t_nnz[x] = l_nnz[y] = !!nnz;

            nnz_total += nnz;

        }



    

    

    

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

        for (y = 0; y < 2; y++)

            for (x = 0; x < 2; x++) {

                nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];

                nnz      = decode_block_coeffs(c, td->block[i][(y << 1) + x],

                                               s->prob->token[2],

                                               0, nnz_pred,

                                               s->qmat[segment].chroma_qmul);

                td->non_zero_count_cache[i][(y << 1) + x] = nnz;

                t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;

                nnz_total       += nnz;

            }



    

    

    

    if (!nnz_total)

        mb->skip = 1;

}

                      VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9])     if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {                                   nnz_pred, s->qmat[segment].luma_dc_qmul);                                       s->qmat[segment].luma_qmul);                 nnz      = decode_block_coeffs(c, td->block[i][(y << 1) + x],                                                s->prob->token[2],                                                0, nnz_pred,                                                s->qmat[segment].chroma_qmul);                 nnz_total       += nnz;
void FUNC_0(VP8Context *VAR_0, VP8ThreadData *VAR_1, VP56RangeCoder *VAR_2,

                      VP8Macroblock *VAR_3, uint8_t VAR_4[9], uint8_t VAR_5[9])

{

    int VAR_6, VAR_7, VAR_8, VAR_9 = 0, VAR_10 = 3;

    int VAR_11, VAR_12, VAR_13 = 0;

    int VAR_14 = VAR_3->VAR_14;

    int VAR_15 = 0;



    if (VAR_3->mode != MODE_I4x4 && VAR_3->mode != VP8_MVMODE_SPLIT) {

        VAR_11 = VAR_4[8] + VAR_5[8];



        

        VAR_12 = decode_block_coeffs(VAR_2, VAR_1->VAR_15, VAR_0->prob->token[1], 0,

                                  VAR_11, VAR_0->qmat[VAR_14].luma_dc_qmul);

        VAR_5[8] = VAR_4[8] = !!VAR_12;

        if (VAR_12) {

            VAR_13 += VAR_12;

            VAR_15   = 1;

            if (VAR_12 == 1)

                VAR_0->vp8dsp.vp8_luma_dc_wht_dc(VAR_1->block, VAR_1->VAR_15);

            else

                VAR_0->vp8dsp.vp8_luma_dc_wht(VAR_1->block, VAR_1->VAR_15);

        }

        VAR_9 = 1;

        VAR_10   = 0;

    }



    

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

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

            VAR_11 = VAR_5[VAR_8] + VAR_4[VAR_7];

            VAR_12 = decode_block_coeffs(VAR_2, VAR_1->block[VAR_8][VAR_7],

                                      VAR_0->prob->token[VAR_10],

                                      VAR_9, VAR_11,

                                      VAR_0->qmat[VAR_14].luma_qmul);

            



            VAR_1->non_zero_count_cache[VAR_8][VAR_7] = VAR_12 + VAR_15;

            VAR_4[VAR_7] = VAR_5[VAR_8] = !!VAR_12;

            VAR_13 += VAR_12;

        }



    

    

    

    for (VAR_6 = 4; VAR_6 < 6; VAR_6++)

        for (VAR_8 = 0; VAR_8 < 2; VAR_8++)

            for (VAR_7 = 0; VAR_7 < 2; VAR_7++) {

                VAR_11 = VAR_5[VAR_6 + 2 * VAR_8] + VAR_4[VAR_6 + 2 * VAR_7];

                VAR_12      = decode_block_coeffs(VAR_2, VAR_1->block[VAR_6][(VAR_8 << 1) + VAR_7],

                                               VAR_0->prob->token[2],

                                               0, VAR_11,

                                               VAR_0->qmat[VAR_14].chroma_qmul);

                VAR_1->non_zero_count_cache[VAR_6][(VAR_8 << 1) + VAR_7] = VAR_12;

                VAR_4[VAR_6 + 2 * VAR_7] = VAR_5[VAR_6 + 2 * VAR_8] = !!VAR_12;

                VAR_13       += VAR_12;

            }



    

    

    

    if (!VAR_13)

        VAR_3->skip = 1;

}

void FUNC_0(VP8Context *VAR_0, VP8ThreadData *VAR_1, VP56RangeCoder *VAR_2,
VP8Macroblock *VAR_3, uint8_t VAR_4[9], uint8_t VAR_5[9])
{ int VAR_6, VAR_7, VAR_8, VAR_9 = 0, VAR_10 = 3; int VAR_11, VAR_12, VAR_13 = 0; int VAR_14 = VAR_3->VAR_14; int VAR_15 = 0; if (VAR_3->mode != MODE_I4x4 && VAR_3->mode != VP8_MVMODE_SPLIT) { VAR_11 = VAR_4[8] + VAR_5[8]; VAR_12 = decode_block_coeffs(VAR_2, VAR_1->VAR_15, VAR_0->prob->token[1], 0,
VAR_11, VAR_0->qmat[VAR_14].luma_dc_qmul); VAR_5[8] = VAR_4[8] = !!VAR_12; if (VAR_12) { VAR_13 += VAR_12; VAR_15   = 1; if (VAR_12 == 1)
VAR_0->vp8dsp.vp8_luma_dc_wht_dc(VAR_1->block, VAR_1->VAR_15); else
VAR_0->vp8dsp.vp8_luma_dc_wht(VAR_1->block, VAR_1->VAR_15); } VAR_9 = 1; VAR_10   = 0; } for (VAR_8 = 0; VAR_8 < 4; VAR_8++) for (VAR_7 = 0; VAR_7 < 4; VAR_7++) { VAR_11 = VAR_5[VAR_8] + VAR_4[VAR_7]; VAR_12 = decode_block_coeffs(VAR_2, VAR_1->block[VAR_8][VAR_7],
VAR_0->prob->token[VAR_10],
VAR_9, VAR_11,
VAR_0->qmat[VAR_14].luma_qmul); VAR_1->non_zero_count_cache[VAR_8][VAR_7] = VAR_12 + VAR_15; VAR_4[VAR_7] = VAR_5[VAR_8] = !!VAR_12; VAR_13 += VAR_12; } for (VAR_6 = 4; VAR_6 < 6; VAR_6++) for (VAR_8 = 0; VAR_8 < 2; VAR_8++) for (VAR_7 = 0; VAR_7 < 2; VAR_7++) { VAR_11 = VAR_5[VAR_6 + 2 * VAR_8] + VAR_4[VAR_6 + 2 * VAR_7]; VAR_12      = decode_block_coeffs(VAR_2, VAR_1->block[VAR_6][(VAR_8 << 1) + VAR_7],
VAR_0->prob->token[2],
0, VAR_11,
VAR_0->qmat[VAR_14].chroma_qmul); VAR_1->non_zero_count_cache[VAR_6][(VAR_8 << 1) + VAR_7] = VAR_12; VAR_4[VAR_6 + 2 * VAR_7] = VAR_5[VAR_6 + 2 * VAR_8] = !!VAR_12; VAR_13       += VAR_12; } if (!VAR_13)
VAR_3->skip = 1; }