static void vp5_parse_coeff(vp56_context_t *s)
{
    vp56_range_coder_t *c = &s->c;
    vp56_model_t *model = s->modelp;
    uint8_t *permute = s->scantable.permutated;
    uint8_t *model1, *model2;
    int coeff, sign, coeff_idx;
    int b, i, cg, idx, ctx, ctx_last;
    int pt = 0;
    for (b=0; b<6; b++) {
        int ct = 1;
        if (b > 3) pt = 1;
        ctx = 6*s->coeff_ctx[vp56_b6to4[b]][0]
              + s->above_blocks[s->above_block_idx[b]].not_null_dc;
        model1 = model->coeff_dccv[pt];
        model2 = model->coeff_dcct[pt][ctx];
        for (coeff_idx=0; coeff_idx<64; ) {
            if (vp56_rac_get_prob(c, model2[0])) {
                if (vp56_rac_get_prob(c, model2[2])) {
                    if (vp56_rac_get_prob(c, model2[3])) {
                        s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 4;
                        idx = vp56_rac_get_tree(c, vp56_pc_tree, model1);
                        sign = vp56_rac_get(c);
                        coeff = vp56_coeff_bias[idx+5];
                        for (i=vp56_coeff_bit_length[idx]; i>=0; i--)
                            coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i;
                    } else {
                        if (vp56_rac_get_prob(c, model2[4])) {
                            coeff = 3 + vp56_rac_get_prob(c, model1[5]);
                            s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 3;
                        } else {
                            coeff = 2;
                            s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 2;
                        }
                        sign = vp56_rac_get(c);
                    }
                    ct = 2;
                } else {
                    ct = 1;
                    s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 1;
                    sign = vp56_rac_get(c);
                    coeff = 1;
                }
                coeff = (coeff ^ -sign) + sign;
                if (coeff_idx)
                    coeff *= s->dequant_ac;
                s->block_coeff[b][permute[coeff_idx]] = coeff;
            } else {
                if (ct && !vp56_rac_get_prob(c, model2[1]))
                    break;
                ct = 0;
                s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 0;
            }
            cg = vp5_coeff_groups[++coeff_idx];
            ctx = s->coeff_ctx[vp56_b6to4[b]][coeff_idx];
            model1 = model->coeff_ract[pt][ct][cg];
            model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
        }
        ctx_last = FFMIN(s->coeff_ctx_last[vp56_b6to4[b]], 24);
        s->coeff_ctx_last[vp56_b6to4[b]] = coeff_idx;
        if (coeff_idx < ctx_last)
            for (i=coeff_idx; i<=ctx_last; i++)
                s->coeff_ctx[vp56_b6to4[b]][i] = 5;
        s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[vp56_b6to4[b]][0];
    }
}
['static void vp5_parse_coeff(vp56_context_t *s)\n{\n    vp56_range_coder_t *c = &s->c;\n    vp56_model_t *model = s->modelp;\n    uint8_t *permute = s->scantable.permutated;\n    uint8_t *model1, *model2;\n    int coeff, sign, coeff_idx;\n    int b, i, cg, idx, ctx, ctx_last;\n    int pt = 0;\n    for (b=0; b<6; b++) {\n        int ct = 1;\n        if (b > 3) pt = 1;\n        ctx = 6*s->coeff_ctx[vp56_b6to4[b]][0]\n              + s->above_blocks[s->above_block_idx[b]].not_null_dc;\n        model1 = model->coeff_dccv[pt];\n        model2 = model->coeff_dcct[pt][ctx];\n        for (coeff_idx=0; coeff_idx<64; ) {\n            if (vp56_rac_get_prob(c, model2[0])) {\n                if (vp56_rac_get_prob(c, model2[2])) {\n                    if (vp56_rac_get_prob(c, model2[3])) {\n                        s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 4;\n                        idx = vp56_rac_get_tree(c, vp56_pc_tree, model1);\n                        sign = vp56_rac_get(c);\n                        coeff = vp56_coeff_bias[idx+5];\n                        for (i=vp56_coeff_bit_length[idx]; i>=0; i--)\n                            coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i;\n                    } else {\n                        if (vp56_rac_get_prob(c, model2[4])) {\n                            coeff = 3 + vp56_rac_get_prob(c, model1[5]);\n                            s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 3;\n                        } else {\n                            coeff = 2;\n                            s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 2;\n                        }\n                        sign = vp56_rac_get(c);\n                    }\n                    ct = 2;\n                } else {\n                    ct = 1;\n                    s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 1;\n                    sign = vp56_rac_get(c);\n                    coeff = 1;\n                }\n                coeff = (coeff ^ -sign) + sign;\n                if (coeff_idx)\n                    coeff *= s->dequant_ac;\n                s->block_coeff[b][permute[coeff_idx]] = coeff;\n            } else {\n                if (ct && !vp56_rac_get_prob(c, model2[1]))\n                    break;\n                ct = 0;\n                s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 0;\n            }\n            cg = vp5_coeff_groups[++coeff_idx];\n            ctx = s->coeff_ctx[vp56_b6to4[b]][coeff_idx];\n            model1 = model->coeff_ract[pt][ct][cg];\n            model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];\n        }\n        ctx_last = FFMIN(s->coeff_ctx_last[vp56_b6to4[b]], 24);\n        s->coeff_ctx_last[vp56_b6to4[b]] = coeff_idx;\n        if (coeff_idx < ctx_last)\n            for (i=coeff_idx; i<=ctx_last; i++)\n                s->coeff_ctx[vp56_b6to4[b]][i] = 5;\n        s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[vp56_b6to4[b]][0];\n    }\n}']