libavcodec/vp9.c:801: error: Buffer Overrun L1
  Offset: 2 Size: 2 by call to `ff_vp9_decode_block`.

libavcodec/vp9.c:784:18: Call
782.     } else if (col + hbs < s->cols) {
783.         if (row + hbs < s->rows) {
784.             bp = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);
                      ^
785.             switch (bp) {
786.             case PARTITION_NONE:

libavcodec/vp56.h:385:1: Parameter `(*tree)[*]`
  383. // how probabilities are associated with decisions is different I think
  384. // well, the new scheme fits in the old but this way has one fewer branches per decision
  385. static av_always_inline
       ^
  386. int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2],
  387.                      const uint8_t *probs)

libavcodec/vp56.h:389:12: Call
  387.                      const uint8_t *probs)
  388. {
  389.     return vp8_rac_get_tree_with_offset(c, tree, probs, 0);
                  ^
  390. }
  391. 

libavcodec/vp56.h:372:1: Parameter `(*tree)[*]`
    370.  * used to save a bit after a 0 token (by disallowing EOB to immediately follow.)
    371.  */
    372. static av_always_inline
         ^
    373. int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2],
    374.                                  const uint8_t *probs, int i)

libavcodec/vp56.h:377:9: Assignment
    375. {
    376.     do {
    377.         i = tree[i][vp56_rac_get_prob(c, probs[i])];
                 ^
    378.     } while (i > 0);
    379. 

libavcodec/vp56.h:380:5: Assignment
    378.     } while (i > 0);
    379. 
    380.     return -i;
             ^
    381. }
    382. 

libavcodec/vp56.h:389:5: Assignment
  387.                      const uint8_t *probs)
  388. {
  389.     return vp8_rac_get_tree_with_offset(c, tree, probs, 0);
           ^
  390. }
  391. 

libavcodec/vp9.c:784:13: Assignment
782.     } else if (col + hbs < s->cols) {
783.         if (row + hbs < s->rows) {
784.             bp = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);
                 ^
785.             switch (bp) {
786.             case PARTITION_NONE:

libavcodec/vp9.c:801:23: Call
799.                 break;
800.             case PARTITION_V:
801.                 ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,
                           ^
802.                                           bl, bp);
803.                 if (!ret) {

libavcodec/vp9block.c:1572:1: Parameter `bp`
  1570. }
  1571. 
  1572. int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
        ^
  1573.                         VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
  1574.                         enum BlockLevel bl, enum BlockPartition bp)

libavcodec/vp9block.c:1596:9: Assignment
  1594.         b->bs = bs;
  1595.         b->bl = bl;
  1596.         b->bp = bp;
                ^
  1597.         decode_mode(s, b);
  1598.         b->uvtx = b->tx - (w4 * 2 == (1 << b->tx) || h4 * 2 == (1 << b->tx));

libavcodec/vp9block.c:1597:9: Call
  1595.         b->bl = bl;
  1596.         b->bp = bp;
  1597.         decode_mode(s, b);
                ^
  1598.         b->uvtx = b->tx - (w4 * 2 == (1 << b->tx) || h4 * 2 == (1 << b->tx));
  1599. 

libavcodec/vp9block.c:44:1: <Offset trace>
42. 
43. // differential forward probability updates
44. static void decode_mode(VP9Context *s, VP9Block *const b)
    ^
45. {
46.     static const uint8_t left_ctx[N_BS_SIZES] = {

libavcodec/vp9block.c:44:1: Parameter `s->signbias[*]`
    42. 
    43. // differential forward probability updates
    44. static void decode_mode(VP9Context *s, VP9Block *const b)
        ^
    45. {
    46.     static const uint8_t left_ctx[N_BS_SIZES] = {

libavcodec/vp9block.c:338:17: Assignment
    336.             // memory accesses below
    337.             if (b->comp) { /* two references */
    338.                 int fix_idx = s->signbias[s->fixcompref], var_idx = !fix_idx, c, bit;
                         ^
    339. 
    340.                 b->ref[fix_idx] = s->fixcompref;

libavcodec/vp9block.c:44:1: <Length trace>
42. 
43. // differential forward probability updates
44. static void decode_mode(VP9Context *s, VP9Block *const b)
    ^
45. {
46.     static const uint8_t left_ctx[N_BS_SIZES] = {

libavcodec/vp9block.c:44:1: Parameter `b->ref[*]`
    42. 
    43. // differential forward probability updates
    44. static void decode_mode(VP9Context *s, VP9Block *const b)
        ^
    45. {
    46.     static const uint8_t left_ctx[N_BS_SIZES] = {

libavcodec/vp9block.c:340:17: Array access: Offset: 2 Size: 2 by call to `ff_vp9_decode_block` 
    338.                 int fix_idx = s->signbias[s->fixcompref], var_idx = !fix_idx, c, bit;
    339. 
    340.                 b->ref[fix_idx] = s->fixcompref;
                         ^
    341.                 // FIXME can this codeblob be replaced by some sort of LUT?
    342.                 if (have_a) {

static void decode_mode(VP9Context *s, VP9Block *const b)
{
    static const uint8_t left_ctx[N_BS_SIZES] = {
        0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
    };
    static const uint8_t above_ctx[N_BS_SIZES] = {
        0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf
    };
    static const uint8_t max_tx_for_bl_bp[N_BS_SIZES] = {
        TX_32X32, TX_32X32, TX_32X32, TX_32X32, TX_16X16, TX_16X16,
        TX_16X16, TX_8X8,   TX_8X8,   TX_8X8,   TX_4X4,   TX_4X4,  TX_4X4
    };
    int row = b->row, col = b->col, row7 = b->row7;
    enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];
    int w4 = FFMIN(s->cols - col, bwh_tab[1][b->bs][0]);
    int h4 = FFMIN(s->rows - row, bwh_tab[1][b->bs][1]);
    int have_a = row > 0, have_l = col > s->tiling.tile_col_start;
    int y;
    if (!s->segmentation.enabled) {
        b->seg_id = 0;
    } else if (s->keyframe || s->intraonly) {
        b->seg_id = s->segmentation.update_map ?
                    vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree, s->prob.seg) : 0;
    } else if (!s->segmentation.update_map ||
               (s->segmentation.temporal &&
                vp56_rac_get_prob_branchy(&s->c,
                                          s->prob.segpred[s->above_segpred_ctx[col] +
                                                          s->left_segpred_ctx[row7]]))) {
        uint8_t *refsegmap = s->frames[LAST_FRAME].segmentation_map;
        int pred = MAX_SEGMENT - 1;
        int x;
        if (!s->last_uses_2pass)
            ff_thread_await_progress(&s->frames[LAST_FRAME].tf, row >> 3, 0);
        for (y = 0; y < h4; y++)
            for (x = 0; x < w4; x++)
                pred = FFMIN(pred,
                             refsegmap[(y + row) * 8 * s->sb_cols + x + col]);
        b->seg_id = pred;
        memset(&s->above_segpred_ctx[col], 1, w4);
        memset(&s->left_segpred_ctx[row7], 1, h4);
    } else {
        b->seg_id = vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree,
                                     s->prob.seg);
        memset(&s->above_segpred_ctx[col], 0, w4);
        memset(&s->left_segpred_ctx[row7], 0, h4);
    }
    if ((s->segmentation.enabled && s->segmentation.update_map) || s->keyframe) {
        uint8_t *segmap = s->frames[CUR_FRAME].segmentation_map;
        for (y = 0; y < h4; y++)
            memset(&segmap[(y + row) * 8 * s->sb_cols + col],
                   b->seg_id, w4);
    }
    b->skip = s->segmentation.enabled &&
              s->segmentation.feat[b->seg_id].skip_enabled;
    if (!b->skip) {
        int c = s->left_skip_ctx[row7] + s->above_skip_ctx[col];
        b->skip = vp56_rac_get_prob(&s->c, s->prob.p.skip[c]);
        s->counts.skip[c][b->skip]++;
    }
    if (s->keyframe || s->intraonly) {
        b->intra = 1;
    } else if (s->segmentation.feat[b->seg_id].ref_enabled) {
        b->intra = !s->segmentation.feat[b->seg_id].ref_val;
    } else {
        int c, bit;
        if (have_a && have_l) {
            c  = s->above_intra_ctx[col] + s->left_intra_ctx[row7];
            c += (c == 2);
        } else {
            c = have_a ? 2 * s->above_intra_ctx[col] :
                have_l ? 2 * s->left_intra_ctx[row7] : 0;
        }
        bit = vp56_rac_get_prob(&s->c, s->prob.p.intra[c]);
        s->counts.intra[c][bit]++;
        b->intra = !bit;
    }
    if ((b->intra || !b->skip) && s->txfmmode == TX_SWITCHABLE) {
        int c;
        if (have_a) {
            if (have_l) {
                c = (s->above_skip_ctx[col] ? max_tx :
                     s->above_txfm_ctx[col]) +
                    (s->left_skip_ctx[row7] ? max_tx :
                     s->left_txfm_ctx[row7]) > max_tx;
            } else {
                c = s->above_skip_ctx[col] ? 1 :
                    (s->above_txfm_ctx[col] * 2 > max_tx);
            }
        } else if (have_l) {
            c = s->left_skip_ctx[row7] ? 1 :
                (s->left_txfm_ctx[row7] * 2 > max_tx);
        } else {
            c = 1;
        }
        switch (max_tx) {
        case TX_32X32:
            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][0]);
            if (b->tx) {
                b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][1]);
                if (b->tx == 2)
                    b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][2]);
            }
            s->counts.tx32p[c][b->tx]++;
            break;
        case TX_16X16:
            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][0]);
            if (b->tx)
                b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][1]);
            s->counts.tx16p[c][b->tx]++;
            break;
        case TX_8X8:
            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx8p[c]);
            s->counts.tx8p[c][b->tx]++;
            break;
        case TX_4X4:
            b->tx = TX_4X4;
            break;
        }
    } else {
        b->tx = FFMIN(max_tx, s->txfmmode);
    }
    if (s->keyframe || s->intraonly) {
        uint8_t *a = &s->above_mode_ctx[col * 2];
        uint8_t *l = &s->left_mode_ctx[(row7) << 1];
        b->comp = 0;
        if (b->bs > BS_8x8) {
            b->mode[0] =
            a[0]       = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                          ff_vp9_default_kf_ymode_probs[a[0]][l[0]]);
            if (b->bs != BS_8x4) {
                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                              ff_vp9_default_kf_ymode_probs[a[1]][b->mode[0]]);
                l[0]       =
                a[1]       = b->mode[1];
            } else {
                l[0]       =
                a[1]       =
                b->mode[1] = b->mode[0];
            }
            if (b->bs != BS_4x8) {
                b->mode[2] =
                a[0]       = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                              ff_vp9_default_kf_ymode_probs[a[0]][l[1]]);
                if (b->bs != BS_8x4) {
                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                                  ff_vp9_default_kf_ymode_probs[a[1]][b->mode[2]]);
                    l[1]       =
                    a[1]       = b->mode[3];
                } else {
                    l[1]       =
                    a[1]       =
                    b->mode[3] = b->mode[2];
                }
            } else {
                b->mode[2] = b->mode[0];
                l[1]       =
                a[1]       =
                b->mode[3] = b->mode[1];
            }
        } else {
            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                          ff_vp9_default_kf_ymode_probs[*a][*l]);
            b->mode[3] =
            b->mode[2] =
            b->mode[1] = b->mode[0];
            memset(a, b->mode[0], bwh_tab[0][b->bs][0]);
            memset(l, b->mode[0], bwh_tab[0][b->bs][1]);
        }
        b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                     ff_vp9_default_kf_uvmode_probs[b->mode[3]]);
    } else if (b->intra) {
        b->comp = 0;
        if (b->bs > BS_8x8) {
            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                          s->prob.p.y_mode[0]);
            s->counts.y_mode[0][b->mode[0]]++;
            if (b->bs != BS_8x4) {
                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                              s->prob.p.y_mode[0]);
                s->counts.y_mode[0][b->mode[1]]++;
            } else {
                b->mode[1] = b->mode[0];
            }
            if (b->bs != BS_4x8) {
                b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                              s->prob.p.y_mode[0]);
                s->counts.y_mode[0][b->mode[2]]++;
                if (b->bs != BS_8x4) {
                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                                  s->prob.p.y_mode[0]);
                    s->counts.y_mode[0][b->mode[3]]++;
                } else {
                    b->mode[3] = b->mode[2];
                }
            } else {
                b->mode[2] = b->mode[0];
                b->mode[3] = b->mode[1];
            }
        } else {
            static const uint8_t size_group[10] = {
                3, 3, 3, 3, 2, 2, 2, 1, 1, 1
            };
            int sz = size_group[b->bs];
            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                          s->prob.p.y_mode[sz]);
            b->mode[1] =
            b->mode[2] =
            b->mode[3] = b->mode[0];
            s->counts.y_mode[sz][b->mode[3]]++;
        }
        b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
                                     s->prob.p.uv_mode[b->mode[3]]);
        s->counts.uv_mode[b->mode[3]][b->uvmode]++;
    } else {
        static const uint8_t inter_mode_ctx_lut[14][14] = {
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },
            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },
        };
        if (s->segmentation.feat[b->seg_id].ref_enabled) {
            av_assert2(s->segmentation.feat[b->seg_id].ref_val != 0);
            b->comp   = 0;
            b->ref[0] = s->segmentation.feat[b->seg_id].ref_val - 1;
        } else {
            if (s->comppredmode != PRED_SWITCHABLE) {
                b->comp = s->comppredmode == PRED_COMPREF;
            } else {
                int c;
                if (have_a) {
                    if (have_l) {
                        if (s->above_comp_ctx[col] && s->left_comp_ctx[row7]) {
                            c = 4;
                        } else if (s->above_comp_ctx[col]) {
                            c = 2 + (s->left_intra_ctx[row7] ||
                                     s->left_ref_ctx[row7] == s->fixcompref);
                        } else if (s->left_comp_ctx[row7]) {
                            c = 2 + (s->above_intra_ctx[col] ||
                                     s->above_ref_ctx[col] == s->fixcompref);
                        } else {
                            c = (!s->above_intra_ctx[col] &&
                                 s->above_ref_ctx[col] == s->fixcompref) ^
                                (!s->left_intra_ctx[row7] &&
                                 s->left_ref_ctx[row & 7] == s->fixcompref);
                        }
                    } else {
                        c = s->above_comp_ctx[col] ? 3 :
                            (!s->above_intra_ctx[col] && s->above_ref_ctx[col] == s->fixcompref);
                    }
                } else if (have_l) {
                    c = s->left_comp_ctx[row7] ? 3 :
                        (!s->left_intra_ctx[row7] && s->left_ref_ctx[row7] == s->fixcompref);
                } else {
                    c = 1;
                }
                b->comp = vp56_rac_get_prob(&s->c, s->prob.p.comp[c]);
                s->counts.comp[c][b->comp]++;
            }
            if (b->comp) {
                int fix_idx = s->signbias[s->fixcompref], var_idx = !fix_idx, c, bit;
                b->ref[fix_idx] = s->fixcompref;
                if (have_a) {
                    if (have_l) {
                        if (s->above_intra_ctx[col]) {
                            if (s->left_intra_ctx[row7]) {
                                c = 2;
                            } else {
                                c = 1 + 2 * (s->left_ref_ctx[row7] != s->varcompref[1]);
                            }
                        } else if (s->left_intra_ctx[row7]) {
                            c = 1 + 2 * (s->above_ref_ctx[col] != s->varcompref[1]);
                        } else {
                            int refl = s->left_ref_ctx[row7], refa = s->above_ref_ctx[col];
                            if (refl == refa && refa == s->varcompref[1]) {
                                c = 0;
                            } else if (!s->left_comp_ctx[row7] && !s->above_comp_ctx[col]) {
                                if ((refa == s->fixcompref && refl == s->varcompref[0]) ||
                                    (refl == s->fixcompref && refa == s->varcompref[0])) {
                                    c = 4;
                                } else {
                                    c = (refa == refl) ? 3 : 1;
                                }
                            } else if (!s->left_comp_ctx[row7]) {
                                if (refa == s->varcompref[1] && refl != s->varcompref[1]) {
                                    c = 1;
                                } else {
                                    c = (refl == s->varcompref[1] &&
                                         refa != s->varcompref[1]) ? 2 : 4;
                                }
                            } else if (!s->above_comp_ctx[col]) {
                                if (refl == s->varcompref[1] && refa != s->varcompref[1]) {
                                    c = 1;
                                } else {
                                    c = (refa == s->varcompref[1] &&
                                         refl != s->varcompref[1]) ? 2 : 4;
                                }
                            } else {
                                c = (refl == refa) ? 4 : 2;
                            }
                        }
                    } else {
                        if (s->above_intra_ctx[col]) {
                            c = 2;
                        } else if (s->above_comp_ctx[col]) {
                            c = 4 * (s->above_ref_ctx[col] != s->varcompref[1]);
                        } else {
                            c = 3 * (s->above_ref_ctx[col] != s->varcompref[1]);
                        }
                    }
                } else if (have_l) {
                    if (s->left_intra_ctx[row7]) {
                        c = 2;
                    } else if (s->left_comp_ctx[row7]) {
                        c = 4 * (s->left_ref_ctx[row7] != s->varcompref[1]);
                    } else {
                        c = 3 * (s->left_ref_ctx[row7] != s->varcompref[1]);
                    }
                } else {
                    c = 2;
                }
                bit = vp56_rac_get_prob(&s->c, s->prob.p.comp_ref[c]);
                b->ref[var_idx] = s->varcompref[bit];
                s->counts.comp_ref[c][bit]++;
            } else {
                int bit, c;
                if (have_a && !s->above_intra_ctx[col]) {
                    if (have_l && !s->left_intra_ctx[row7]) {
                        if (s->left_comp_ctx[row7]) {
                            if (s->above_comp_ctx[col]) {
                                c = 1 + (!s->fixcompref || !s->left_ref_ctx[row7] ||
                                         !s->above_ref_ctx[col]);
                            } else {
                                c = (3 * !s->above_ref_ctx[col]) +
                                    (!s->fixcompref || !s->left_ref_ctx[row7]);
                            }
                        } else if (s->above_comp_ctx[col]) {
                            c = (3 * !s->left_ref_ctx[row7]) +
                                (!s->fixcompref || !s->above_ref_ctx[col]);
                        } else {
                            c = 2 * !s->left_ref_ctx[row7] + 2 * !s->above_ref_ctx[col];
                        }
                    } else if (s->above_intra_ctx[col]) {
                        c = 2;
                    } else if (s->above_comp_ctx[col]) {
                        c = 1 + (!s->fixcompref || !s->above_ref_ctx[col]);
                    } else {
                        c = 4 * (!s->above_ref_ctx[col]);
                    }
                } else if (have_l && !s->left_intra_ctx[row7]) {
                    if (s->left_intra_ctx[row7]) {
                        c = 2;
                    } else if (s->left_comp_ctx[row7]) {
                        c = 1 + (!s->fixcompref || !s->left_ref_ctx[row7]);
                    } else {
                        c = 4 * (!s->left_ref_ctx[row7]);
                    }
                } else {
                    c = 2;
                }
                bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][0]);
                s->counts.single_ref[c][0][bit]++;
                if (!bit) {
                    b->ref[0] = 0;
                } else {
                    if (have_a) {
                        if (have_l) {
                            if (s->left_intra_ctx[row7]) {
                                if (s->above_intra_ctx[col]) {
                                    c = 2;
                                } else if (s->above_comp_ctx[col]) {
                                    c = 1 + 2 * (s->fixcompref == 1 ||
                                                 s->above_ref_ctx[col] == 1);
                                } else if (!s->above_ref_ctx[col]) {
                                    c = 3;
                                } else {
                                    c = 4 * (s->above_ref_ctx[col] == 1);
                                }
                            } else if (s->above_intra_ctx[col]) {
                                if (s->left_intra_ctx[row7]) {
                                    c = 2;
                                } else if (s->left_comp_ctx[row7]) {
                                    c = 1 + 2 * (s->fixcompref == 1 ||
                                                 s->left_ref_ctx[row7] == 1);
                                } else if (!s->left_ref_ctx[row7]) {
                                    c = 3;
                                } else {
                                    c = 4 * (s->left_ref_ctx[row7] == 1);
                                }
                            } else if (s->above_comp_ctx[col]) {
                                if (s->left_comp_ctx[row7]) {
                                    if (s->left_ref_ctx[row7] == s->above_ref_ctx[col]) {
                                        c = 3 * (s->fixcompref == 1 ||
                                                 s->left_ref_ctx[row7] == 1);
                                    } else {
                                        c = 2;
                                    }
                                } else if (!s->left_ref_ctx[row7]) {
                                    c = 1 + 2 * (s->fixcompref == 1 ||
                                                 s->above_ref_ctx[col] == 1);
                                } else {
                                    c = 3 * (s->left_ref_ctx[row7] == 1) +
                                        (s->fixcompref == 1 || s->above_ref_ctx[col] == 1);
                                }
                            } else if (s->left_comp_ctx[row7]) {
                                if (!s->above_ref_ctx[col]) {
                                    c = 1 + 2 * (s->fixcompref == 1 ||
                                                 s->left_ref_ctx[row7] == 1);
                                } else {
                                    c = 3 * (s->above_ref_ctx[col] == 1) +
                                        (s->fixcompref == 1 || s->left_ref_ctx[row7] == 1);
                                }
                            } else if (!s->above_ref_ctx[col]) {
                                if (!s->left_ref_ctx[row7]) {
                                    c = 3;
                                } else {
                                    c = 4 * (s->left_ref_ctx[row7] == 1);
                                }
                            } else if (!s->left_ref_ctx[row7]) {
                                c = 4 * (s->above_ref_ctx[col] == 1);
                            } else {
                                c = 2 * (s->left_ref_ctx[row7] == 1) +
                                    2 * (s->above_ref_ctx[col] == 1);
                            }
                        } else {
                            if (s->above_intra_ctx[col] ||
                                (!s->above_comp_ctx[col] && !s->above_ref_ctx[col])) {
                                c = 2;
                            } else if (s->above_comp_ctx[col]) {
                                c = 3 * (s->fixcompref == 1 || s->above_ref_ctx[col] == 1);
                            } else {
                                c = 4 * (s->above_ref_ctx[col] == 1);
                            }
                        }
                    } else if (have_l) {
                        if (s->left_intra_ctx[row7] ||
                            (!s->left_comp_ctx[row7] && !s->left_ref_ctx[row7])) {
                            c = 2;
                        } else if (s->left_comp_ctx[row7]) {
                            c = 3 * (s->fixcompref == 1 || s->left_ref_ctx[row7] == 1);
                        } else {
                            c = 4 * (s->left_ref_ctx[row7] == 1);
                        }
                    } else {
                        c = 2;
                    }
                    bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][1]);
                    s->counts.single_ref[c][1][bit]++;
                    b->ref[0] = 1 + bit;
                }
            }
        }
        if (b->bs <= BS_8x8) {
            if (s->segmentation.feat[b->seg_id].skip_enabled) {
                b->mode[0] =
                b->mode[1] =
                b->mode[2] =
                b->mode[3] = ZEROMV;
            } else {
                static const uint8_t off[10] = {
                    3, 0, 0, 1, 0, 0, 0, 0, 0, 0
                };
                int c = inter_mode_ctx_lut[s->above_mode_ctx[col + off[b->bs]]]
                                          [s->left_mode_ctx[row7 + off[b->bs]]];
                b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
                                              s->prob.p.mv_mode[c]);
                b->mode[1] =
                b->mode[2] =
                b->mode[3] = b->mode[0];
                s->counts.mv_mode[c][b->mode[0] - 10]++;
            }
        }
        if (s->filtermode == FILTER_SWITCHABLE) {
            int c;
            if (have_a && s->above_mode_ctx[col] >= NEARESTMV) {
                if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {
                    c = s->above_filter_ctx[col] == s->left_filter_ctx[row7] ?
                        s->left_filter_ctx[row7] : 3;
                } else {
                    c = s->above_filter_ctx[col];
                }
            } else if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {
                c = s->left_filter_ctx[row7];
            } else {
                c = 3;
            }
            b->filter = vp8_rac_get_tree(&s->c, ff_vp9_filter_tree,
                                         s->prob.p.filter[c]);
            s->counts.filter[c][b->filter]++;
        } else {
            b->filter = s->filtermode;
        }
        if (b->bs > BS_8x8) {
            int c = inter_mode_ctx_lut[s->above_mode_ctx[col]][s->left_mode_ctx[row7]];
            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
                                          s->prob.p.mv_mode[c]);
            s->counts.mv_mode[c][b->mode[0] - 10]++;
            ff_vp9_fill_mv(s, b->mv[0], b->mode[0], 0);
            if (b->bs != BS_8x4) {
                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
                                              s->prob.p.mv_mode[c]);
                s->counts.mv_mode[c][b->mode[1] - 10]++;
                ff_vp9_fill_mv(s, b->mv[1], b->mode[1], 1);
            } else {
                b->mode[1] = b->mode[0];
                AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
                AV_COPY32(&b->mv[1][1], &b->mv[0][1]);
            }
            if (b->bs != BS_4x8) {
                b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
                                              s->prob.p.mv_mode[c]);
                s->counts.mv_mode[c][b->mode[2] - 10]++;
                ff_vp9_fill_mv(s, b->mv[2], b->mode[2], 2);
                if (b->bs != BS_8x4) {
                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
                                                  s->prob.p.mv_mode[c]);
                    s->counts.mv_mode[c][b->mode[3] - 10]++;
                    ff_vp9_fill_mv(s, b->mv[3], b->mode[3], 3);
                } else {
                    b->mode[3] = b->mode[2];
                    AV_COPY32(&b->mv[3][0], &b->mv[2][0]);
                    AV_COPY32(&b->mv[3][1], &b->mv[2][1]);
                }
            } else {
                b->mode[2] = b->mode[0];
                AV_COPY32(&b->mv[2][0], &b->mv[0][0]);
                AV_COPY32(&b->mv[2][1], &b->mv[0][1]);
                b->mode[3] = b->mode[1];
                AV_COPY32(&b->mv[3][0], &b->mv[1][0]);
                AV_COPY32(&b->mv[3][1], &b->mv[1][1]);
            }
        } else {
            ff_vp9_fill_mv(s, b->mv[0], b->mode[0], -1);
            AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
            AV_COPY32(&b->mv[2][0], &b->mv[0][0]);
            AV_COPY32(&b->mv[3][0], &b->mv[0][0]);
            AV_COPY32(&b->mv[1][1], &b->mv[0][1]);
            AV_COPY32(&b->mv[2][1], &b->mv[0][1]);
            AV_COPY32(&b->mv[3][1], &b->mv[0][1]);
        }
    }
    memset(&s->above_skip_ctx[col], b->skip, w4);
    memset(&s->left_skip_ctx[row7], b->skip, h4);
    memset(&s->above_txfm_ctx[col], b->tx, w4);
    memset(&s->left_txfm_ctx[row7], b->tx, h4);
    memset(&s->above_partition_ctx[col], above_ctx[b->bs], w4);
    memset(&s->left_partition_ctx[row7], left_ctx[b->bs], h4);
    if (!s->keyframe && !s->intraonly) {
        memset(&s->above_intra_ctx[col], b->intra, w4);
        memset(&s->left_intra_ctx[row7], b->intra, h4);
        memset(&s->above_comp_ctx[col], b->comp, w4);
        memset(&s->left_comp_ctx[row7], b->comp, h4);
        memset(&s->above_mode_ctx[col], b->mode[3], w4);
        memset(&s->left_mode_ctx[row7], b->mode[3], h4);
        if (s->filtermode == FILTER_SWITCHABLE && !b->intra) {
            memset(&s->above_filter_ctx[col], b->filter, w4);
            memset(&s->left_filter_ctx[row7], b->filter, h4);
            b->filter = ff_vp9_filter_lut[b->filter];
        }
        if (b->bs > BS_8x8) {
            int mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
            AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][0], &b->mv[1][0]);
            AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][1], &b->mv[1][1]);
            AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][0], mv0);
            AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][1], mv1);
            AV_COPY32(&s->above_mv_ctx[col * 2 + 0][0], &b->mv[2][0]);
            AV_COPY32(&s->above_mv_ctx[col * 2 + 0][1], &b->mv[2][1]);
            AV_WN32A(&s->above_mv_ctx[col * 2 + 1][0], mv0);
            AV_WN32A(&s->above_mv_ctx[col * 2 + 1][1], mv1);
        } else {
            int n, mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
            for (n = 0; n < w4 * 2; n++) {
                AV_WN32A(&s->above_mv_ctx[col * 2 + n][0], mv0);
                AV_WN32A(&s->above_mv_ctx[col * 2 + n][1], mv1);
            }
            for (n = 0; n < h4 * 2; n++) {
                AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][0], mv0);
                AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][1], mv1);
            }
        }
        if (!b->intra) {
            int vref = b->ref[b->comp ? s->signbias[s->varcompref[0]] : 0];
            memset(&s->above_ref_ctx[col], vref, w4);
            memset(&s->left_ref_ctx[row7], vref, h4);
        }
    }
    for (y = 0; y < h4; y++) {
        int x, o = (row + y) * s->sb_cols * 8 + col;
        VP9MVRefPair *mv = &s->frames[CUR_FRAME].mv[o];
        if (b->intra) {
            for (x = 0; x < w4; x++) {
                mv[x].ref[0] =
                mv[x].ref[1] = -1;
            }
        } else if (b->comp) {
            for (x = 0; x < w4; x++) {
                mv[x].ref[0] = b->ref[0];
                mv[x].ref[1] = b->ref[1];
                AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
                AV_COPY32(&mv[x].mv[1], &b->mv[3][1]);
            }
        } else {
            for (x = 0; x < w4; x++) {
                mv[x].ref[0] = b->ref[0];
                mv[x].ref[1] = -1;
                AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
            }
        }
    }
}
['static int decode_subblock(AVCodecContext *avctx, int row, int col,\n                           VP9Filter *lflvl,\n                           ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)\n{\n    VP9Context *s = avctx->priv_data;\n    AVFrame    *f = s->frames[CUR_FRAME].tf.f;\n    int c = ((s->above_partition_ctx[col]       >> (3 - bl)) & 1) |\n            (((s->left_partition_ctx[row & 0x7] >> (3 - bl)) & 1) << 1);\n    int ret;\n    const uint8_t *p = s->keyframe ? ff_vp9_default_kf_partition_probs[bl][c]\n                                   : s->prob.p.partition[bl][c];\n    enum BlockPartition bp;\n    ptrdiff_t hbs = 4 >> bl;\n    if (bl == BL_8X8) {\n        bp  = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);\n        ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);\n    } else if (col + hbs < s->cols) {\n        if (row + hbs < s->rows) {\n            bp = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);\n            switch (bp) {\n            case PARTITION_NONE:\n                ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,\n                                          bl, bp);\n                break;\n            case PARTITION_H:\n                ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,\n                                          bl, bp);\n                if (!ret) {\n                    yoff  += hbs * 8 * f->linesize[0];\n                    uvoff += hbs * 4 * f->linesize[1];\n                    ret    = ff_vp9_decode_block(avctx, row + hbs, col, lflvl,\n                                                 yoff, uvoff, bl, bp);\n                }\n                break;\n            case PARTITION_V:\n                ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,\n                                          bl, bp);\n                if (!ret) {\n                    yoff  += hbs * 8;\n                    uvoff += hbs * 4;\n                    ret    = ff_vp9_decode_block(avctx, row, col + hbs, lflvl,\n                                                 yoff, uvoff, bl, bp);\n                }\n                break;\n            case PARTITION_SPLIT:\n                ret = decode_subblock(avctx, row, col, lflvl,\n                                      yoff, uvoff, bl + 1);\n                if (!ret) {\n                    ret = decode_subblock(avctx, row, col + hbs, lflvl,\n                                          yoff + 8 * hbs, uvoff + 4 * hbs,\n                                          bl + 1);\n                    if (!ret) {\n                        yoff  += hbs * 8 * f->linesize[0];\n                        uvoff += hbs * 4 * f->linesize[1];\n                        ret    = decode_subblock(avctx, row + hbs, col, lflvl,\n                                                 yoff, uvoff, bl + 1);\n                        if (!ret) {\n                            ret = decode_subblock(avctx, row + hbs, col + hbs,\n                                                  lflvl, yoff + 8 * hbs,\n                                                  uvoff + 4 * hbs, bl + 1);\n                        }\n                    }\n                }\n                break;\n            default:\n                av_log(avctx, AV_LOG_ERROR, "Unexpected partition %d.", bp);\n                return AVERROR_INVALIDDATA;\n            }\n        } else if (vp56_rac_get_prob_branchy(&s->c, p[1])) {\n            bp  = PARTITION_SPLIT;\n            ret = decode_subblock(avctx, row, col, lflvl, yoff, uvoff, bl + 1);\n            if (!ret)\n                ret = decode_subblock(avctx, row, col + hbs, lflvl,\n                                      yoff + 8 * hbs, uvoff + 4 * hbs, bl + 1);\n        } else {\n            bp  = PARTITION_H;\n            ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,\n                                      bl, bp);\n        }\n    } else if (row + hbs < s->rows) {\n        if (vp56_rac_get_prob_branchy(&s->c, p[2])) {\n            bp  = PARTITION_SPLIT;\n            ret = decode_subblock(avctx, row, col, lflvl, yoff, uvoff, bl + 1);\n            if (!ret) {\n                yoff  += hbs * 8 * f->linesize[0];\n                uvoff += hbs * 4 * f->linesize[1];\n                ret    = decode_subblock(avctx, row + hbs, col, lflvl,\n                                         yoff, uvoff, bl + 1);\n            }\n        } else {\n            bp  = PARTITION_V;\n            ret = ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff,\n                                      bl, bp);\n        }\n    } else {\n        bp  = PARTITION_SPLIT;\n        ret = decode_subblock(avctx, row, col, lflvl, yoff, uvoff, bl + 1);\n    }\n    s->counts.partition[bl][c][bp]++;\n    return ret;\n}', 'static av_always_inline\nint vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2],\n                     const uint8_t *probs)\n{\n    return vp8_rac_get_tree_with_offset(c, tree, probs, 0);\n}', 'static av_always_inline\nint vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2],\n                                 const uint8_t *probs, int i)\n{\n    do {\n        i = tree[i][vp56_rac_get_prob(c, probs[i])];\n    } while (i > 0);\n    return -i;\n}', 'int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,\n                        VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,\n                        enum BlockLevel bl, enum BlockPartition bp)\n{\n    VP9Context *s = avctx->priv_data;\n    VP9Block *b = s->b;\n    AVFrame *f = s->frames[CUR_FRAME].tf.f;\n    enum BlockSize bs = bl * 3 + bp;\n    int ret, y, w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;\n    int emu[2];\n    b->row  = row;\n    b->row7 = row & 7;\n    b->col  = col;\n    b->col7 = col & 7;\n    s->min_mv.x = -(128 + col * 64);\n    s->min_mv.y = -(128 + row * 64);\n    s->max_mv.x = 128 + (s->cols - col - w4) * 64;\n    s->max_mv.y = 128 + (s->rows - row - h4) * 64;\n    if (s->pass < 2) {\n        b->bs = bs;\n        b->bl = bl;\n        b->bp = bp;\n        decode_mode(s, b);\n        b->uvtx = b->tx - (w4 * 2 == (1 << b->tx) || h4 * 2 == (1 << b->tx));\n        if (!b->skip) {\n            if ((ret = decode_coeffs(avctx)) < 0)\n                return ret;\n        } else {\n            int pl;\n            memset(&s->above_y_nnz_ctx[col * 2], 0, w4 * 2);\n            memset(&s->left_y_nnz_ctx[(row & 7) << 1], 0, h4 * 2);\n            for (pl = 0; pl < 2; pl++) {\n                memset(&s->above_uv_nnz_ctx[pl][col], 0, w4);\n                memset(&s->left_uv_nnz_ctx[pl][row & 7], 0, h4);\n            }\n        }\n        if (s->pass == 1) {\n            s->b++;\n            s->block      += w4 * h4 * 64;\n            s->uvblock[0] += w4 * h4 * 16;\n            s->uvblock[1] += w4 * h4 * 16;\n            s->eob        += w4 * h4 * 4;\n            s->uveob[0]   += w4 * h4;\n            s->uveob[1]   += w4 * h4;\n            return 0;\n        }\n    }\n    emu[0] = (col + w4) * 8 > f->linesize[0] ||\n             (row + h4) > s->rows;\n    emu[1] = (col + w4) * 4 > f->linesize[1] ||\n             (row + h4) > s->rows;\n    if (emu[0]) {\n        b->dst[0]   = s->tmp_y;\n        b->y_stride = 64;\n    } else {\n        b->dst[0]   = f->data[0] + yoff;\n        b->y_stride = f->linesize[0];\n    }\n    if (emu[1]) {\n        b->dst[1]    = s->tmp_uv[0];\n        b->dst[2]    = s->tmp_uv[1];\n        b->uv_stride = 32;\n    } else {\n        b->dst[1]    = f->data[1] + uvoff;\n        b->dst[2]    = f->data[2] + uvoff;\n        b->uv_stride = f->linesize[1];\n    }\n    if (b->intra) {\n        intra_recon(avctx, yoff, uvoff);\n    } else {\n        if ((ret = inter_recon(avctx)) < 0)\n            return ret;\n    }\n    if (emu[0]) {\n        int w = FFMIN(s->cols - col, w4) * 8;\n        int h = FFMIN(s->rows - row, h4) * 8;\n        int n, o = 0;\n        for (n = 0; o < w; n++) {\n            int bw = 64 >> n;\n            av_assert2(n <= 4);\n            if (w & bw) {\n                s->dsp.mc[n][0][0][0][0](f->data[0] + yoff + o,\n                                         s->tmp_y + o,\n                                         f->linesize[0],\n                                         64, h, 0, 0);\n                o += bw;\n            }\n        }\n    }\n    if (emu[1]) {\n        int w = FFMIN(s->cols - col, w4) * 4;\n        int h = FFMIN(s->rows - row, h4) * 4;\n        int n, o = 0;\n        for (n = 1; o < w; n++) {\n            int bw = 64 >> n;\n            av_assert2(n <= 4);\n            if (w & bw) {\n                s->dsp.mc[n][0][0][0][0](f->data[1] + uvoff + o,\n                                         s->tmp_uv[0] + o,\n                                         f->linesize[1],\n                                         32, h, 0, 0);\n                s->dsp.mc[n][0][0][0][0](f->data[2] + uvoff + o,\n                                         s->tmp_uv[1] + o,\n                                         f->linesize[2],\n                                         32, h, 0, 0);\n                o += bw;\n            }\n        }\n    }\n    if (s->filter.level &&\n        (lvl = s->segmentation.feat[b->seg_id].lflvl[b->intra ? 0 : b->ref[0] + 1]\n                                                    [b->mode[3] != ZEROMV]) > 0) {\n        int x_end = FFMIN(s->cols - col, w4);\n        int y_end = FFMIN(s->rows - row, h4);\n        int skip_inter = !b->intra && b->skip;\n        for (y = 0; y < h4; y++)\n            memset(&lflvl->level[((row & 7) + y) * 8 + (col & 7)], lvl, w4);\n        mask_edges(lflvl, 0, row & 7, col & 7, x_end, y_end, 0, 0, b->tx, skip_inter);\n        mask_edges(lflvl, 1, row & 7, col & 7, x_end, y_end,\n                   s->cols & 1 && col + w4 >= s->cols ? s->cols & 7 : 0,\n                   s->rows & 1 && row + h4 >= s->rows ? s->rows & 7 : 0,\n                   b->uvtx, skip_inter);\n        if (!s->filter.lim_lut[lvl]) {\n            int sharp = s->filter.sharpness;\n            int limit = lvl;\n            if (sharp > 0) {\n                limit >>= (sharp + 3) >> 2;\n                limit   = FFMIN(limit, 9 - sharp);\n            }\n            limit = FFMAX(limit, 1);\n            s->filter.lim_lut[lvl]   = limit;\n            s->filter.mblim_lut[lvl] = 2 * (lvl + 2) + limit;\n        }\n    }\n    if (s->pass == 2) {\n        s->b++;\n        s->block      += w4 * h4 * 64;\n        s->uvblock[0] += w4 * h4 * 16;\n        s->uvblock[1] += w4 * h4 * 16;\n        s->eob        += w4 * h4 * 4;\n        s->uveob[0]   += w4 * h4;\n        s->uveob[1]   += w4 * h4;\n    }\n    return 0;\n}', 'static void decode_mode(VP9Context *s, VP9Block *const b)\n{\n    static const uint8_t left_ctx[N_BS_SIZES] = {\n        0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf\n    };\n    static const uint8_t above_ctx[N_BS_SIZES] = {\n        0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf\n    };\n    static const uint8_t max_tx_for_bl_bp[N_BS_SIZES] = {\n        TX_32X32, TX_32X32, TX_32X32, TX_32X32, TX_16X16, TX_16X16,\n        TX_16X16, TX_8X8,   TX_8X8,   TX_8X8,   TX_4X4,   TX_4X4,  TX_4X4\n    };\n    int row = b->row, col = b->col, row7 = b->row7;\n    enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];\n    int w4 = FFMIN(s->cols - col, bwh_tab[1][b->bs][0]);\n    int h4 = FFMIN(s->rows - row, bwh_tab[1][b->bs][1]);\n    int have_a = row > 0, have_l = col > s->tiling.tile_col_start;\n    int y;\n    if (!s->segmentation.enabled) {\n        b->seg_id = 0;\n    } else if (s->keyframe || s->intraonly) {\n        b->seg_id = s->segmentation.update_map ?\n                    vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree, s->prob.seg) : 0;\n    } else if (!s->segmentation.update_map ||\n               (s->segmentation.temporal &&\n                vp56_rac_get_prob_branchy(&s->c,\n                                          s->prob.segpred[s->above_segpred_ctx[col] +\n                                                          s->left_segpred_ctx[row7]]))) {\n        uint8_t *refsegmap = s->frames[LAST_FRAME].segmentation_map;\n        int pred = MAX_SEGMENT - 1;\n        int x;\n        if (!s->last_uses_2pass)\n            ff_thread_await_progress(&s->frames[LAST_FRAME].tf, row >> 3, 0);\n        for (y = 0; y < h4; y++)\n            for (x = 0; x < w4; x++)\n                pred = FFMIN(pred,\n                             refsegmap[(y + row) * 8 * s->sb_cols + x + col]);\n        b->seg_id = pred;\n        memset(&s->above_segpred_ctx[col], 1, w4);\n        memset(&s->left_segpred_ctx[row7], 1, h4);\n    } else {\n        b->seg_id = vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree,\n                                     s->prob.seg);\n        memset(&s->above_segpred_ctx[col], 0, w4);\n        memset(&s->left_segpred_ctx[row7], 0, h4);\n    }\n    if ((s->segmentation.enabled && s->segmentation.update_map) || s->keyframe) {\n        uint8_t *segmap = s->frames[CUR_FRAME].segmentation_map;\n        for (y = 0; y < h4; y++)\n            memset(&segmap[(y + row) * 8 * s->sb_cols + col],\n                   b->seg_id, w4);\n    }\n    b->skip = s->segmentation.enabled &&\n              s->segmentation.feat[b->seg_id].skip_enabled;\n    if (!b->skip) {\n        int c = s->left_skip_ctx[row7] + s->above_skip_ctx[col];\n        b->skip = vp56_rac_get_prob(&s->c, s->prob.p.skip[c]);\n        s->counts.skip[c][b->skip]++;\n    }\n    if (s->keyframe || s->intraonly) {\n        b->intra = 1;\n    } else if (s->segmentation.feat[b->seg_id].ref_enabled) {\n        b->intra = !s->segmentation.feat[b->seg_id].ref_val;\n    } else {\n        int c, bit;\n        if (have_a && have_l) {\n            c  = s->above_intra_ctx[col] + s->left_intra_ctx[row7];\n            c += (c == 2);\n        } else {\n            c = have_a ? 2 * s->above_intra_ctx[col] :\n                have_l ? 2 * s->left_intra_ctx[row7] : 0;\n        }\n        bit = vp56_rac_get_prob(&s->c, s->prob.p.intra[c]);\n        s->counts.intra[c][bit]++;\n        b->intra = !bit;\n    }\n    if ((b->intra || !b->skip) && s->txfmmode == TX_SWITCHABLE) {\n        int c;\n        if (have_a) {\n            if (have_l) {\n                c = (s->above_skip_ctx[col] ? max_tx :\n                     s->above_txfm_ctx[col]) +\n                    (s->left_skip_ctx[row7] ? max_tx :\n                     s->left_txfm_ctx[row7]) > max_tx;\n            } else {\n                c = s->above_skip_ctx[col] ? 1 :\n                    (s->above_txfm_ctx[col] * 2 > max_tx);\n            }\n        } else if (have_l) {\n            c = s->left_skip_ctx[row7] ? 1 :\n                (s->left_txfm_ctx[row7] * 2 > max_tx);\n        } else {\n            c = 1;\n        }\n        switch (max_tx) {\n        case TX_32X32:\n            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][0]);\n            if (b->tx) {\n                b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][1]);\n                if (b->tx == 2)\n                    b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][2]);\n            }\n            s->counts.tx32p[c][b->tx]++;\n            break;\n        case TX_16X16:\n            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][0]);\n            if (b->tx)\n                b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][1]);\n            s->counts.tx16p[c][b->tx]++;\n            break;\n        case TX_8X8:\n            b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx8p[c]);\n            s->counts.tx8p[c][b->tx]++;\n            break;\n        case TX_4X4:\n            b->tx = TX_4X4;\n            break;\n        }\n    } else {\n        b->tx = FFMIN(max_tx, s->txfmmode);\n    }\n    if (s->keyframe || s->intraonly) {\n        uint8_t *a = &s->above_mode_ctx[col * 2];\n        uint8_t *l = &s->left_mode_ctx[(row7) << 1];\n        b->comp = 0;\n        if (b->bs > BS_8x8) {\n            b->mode[0] =\n            a[0]       = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                          ff_vp9_default_kf_ymode_probs[a[0]][l[0]]);\n            if (b->bs != BS_8x4) {\n                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                              ff_vp9_default_kf_ymode_probs[a[1]][b->mode[0]]);\n                l[0]       =\n                a[1]       = b->mode[1];\n            } else {\n                l[0]       =\n                a[1]       =\n                b->mode[1] = b->mode[0];\n            }\n            if (b->bs != BS_4x8) {\n                b->mode[2] =\n                a[0]       = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                              ff_vp9_default_kf_ymode_probs[a[0]][l[1]]);\n                if (b->bs != BS_8x4) {\n                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                                  ff_vp9_default_kf_ymode_probs[a[1]][b->mode[2]]);\n                    l[1]       =\n                    a[1]       = b->mode[3];\n                } else {\n                    l[1]       =\n                    a[1]       =\n                    b->mode[3] = b->mode[2];\n                }\n            } else {\n                b->mode[2] = b->mode[0];\n                l[1]       =\n                a[1]       =\n                b->mode[3] = b->mode[1];\n            }\n        } else {\n            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                          ff_vp9_default_kf_ymode_probs[*a][*l]);\n            b->mode[3] =\n            b->mode[2] =\n            b->mode[1] = b->mode[0];\n            memset(a, b->mode[0], bwh_tab[0][b->bs][0]);\n            memset(l, b->mode[0], bwh_tab[0][b->bs][1]);\n        }\n        b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                     ff_vp9_default_kf_uvmode_probs[b->mode[3]]);\n    } else if (b->intra) {\n        b->comp = 0;\n        if (b->bs > BS_8x8) {\n            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                          s->prob.p.y_mode[0]);\n            s->counts.y_mode[0][b->mode[0]]++;\n            if (b->bs != BS_8x4) {\n                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                              s->prob.p.y_mode[0]);\n                s->counts.y_mode[0][b->mode[1]]++;\n            } else {\n                b->mode[1] = b->mode[0];\n            }\n            if (b->bs != BS_4x8) {\n                b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                              s->prob.p.y_mode[0]);\n                s->counts.y_mode[0][b->mode[2]]++;\n                if (b->bs != BS_8x4) {\n                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                                  s->prob.p.y_mode[0]);\n                    s->counts.y_mode[0][b->mode[3]]++;\n                } else {\n                    b->mode[3] = b->mode[2];\n                }\n            } else {\n                b->mode[2] = b->mode[0];\n                b->mode[3] = b->mode[1];\n            }\n        } else {\n            static const uint8_t size_group[10] = {\n                3, 3, 3, 3, 2, 2, 2, 1, 1, 1\n            };\n            int sz = size_group[b->bs];\n            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                          s->prob.p.y_mode[sz]);\n            b->mode[1] =\n            b->mode[2] =\n            b->mode[3] = b->mode[0];\n            s->counts.y_mode[sz][b->mode[3]]++;\n        }\n        b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,\n                                     s->prob.p.uv_mode[b->mode[3]]);\n        s->counts.uv_mode[b->mode[3]][b->uvmode]++;\n    } else {\n        static const uint8_t inter_mode_ctx_lut[14][14] = {\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },\n            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },\n            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },\n            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },\n            { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },\n        };\n        if (s->segmentation.feat[b->seg_id].ref_enabled) {\n            av_assert2(s->segmentation.feat[b->seg_id].ref_val != 0);\n            b->comp   = 0;\n            b->ref[0] = s->segmentation.feat[b->seg_id].ref_val - 1;\n        } else {\n            if (s->comppredmode != PRED_SWITCHABLE) {\n                b->comp = s->comppredmode == PRED_COMPREF;\n            } else {\n                int c;\n                if (have_a) {\n                    if (have_l) {\n                        if (s->above_comp_ctx[col] && s->left_comp_ctx[row7]) {\n                            c = 4;\n                        } else if (s->above_comp_ctx[col]) {\n                            c = 2 + (s->left_intra_ctx[row7] ||\n                                     s->left_ref_ctx[row7] == s->fixcompref);\n                        } else if (s->left_comp_ctx[row7]) {\n                            c = 2 + (s->above_intra_ctx[col] ||\n                                     s->above_ref_ctx[col] == s->fixcompref);\n                        } else {\n                            c = (!s->above_intra_ctx[col] &&\n                                 s->above_ref_ctx[col] == s->fixcompref) ^\n                                (!s->left_intra_ctx[row7] &&\n                                 s->left_ref_ctx[row & 7] == s->fixcompref);\n                        }\n                    } else {\n                        c = s->above_comp_ctx[col] ? 3 :\n                            (!s->above_intra_ctx[col] && s->above_ref_ctx[col] == s->fixcompref);\n                    }\n                } else if (have_l) {\n                    c = s->left_comp_ctx[row7] ? 3 :\n                        (!s->left_intra_ctx[row7] && s->left_ref_ctx[row7] == s->fixcompref);\n                } else {\n                    c = 1;\n                }\n                b->comp = vp56_rac_get_prob(&s->c, s->prob.p.comp[c]);\n                s->counts.comp[c][b->comp]++;\n            }\n            if (b->comp) {\n                int fix_idx = s->signbias[s->fixcompref], var_idx = !fix_idx, c, bit;\n                b->ref[fix_idx] = s->fixcompref;\n                if (have_a) {\n                    if (have_l) {\n                        if (s->above_intra_ctx[col]) {\n                            if (s->left_intra_ctx[row7]) {\n                                c = 2;\n                            } else {\n                                c = 1 + 2 * (s->left_ref_ctx[row7] != s->varcompref[1]);\n                            }\n                        } else if (s->left_intra_ctx[row7]) {\n                            c = 1 + 2 * (s->above_ref_ctx[col] != s->varcompref[1]);\n                        } else {\n                            int refl = s->left_ref_ctx[row7], refa = s->above_ref_ctx[col];\n                            if (refl == refa && refa == s->varcompref[1]) {\n                                c = 0;\n                            } else if (!s->left_comp_ctx[row7] && !s->above_comp_ctx[col]) {\n                                if ((refa == s->fixcompref && refl == s->varcompref[0]) ||\n                                    (refl == s->fixcompref && refa == s->varcompref[0])) {\n                                    c = 4;\n                                } else {\n                                    c = (refa == refl) ? 3 : 1;\n                                }\n                            } else if (!s->left_comp_ctx[row7]) {\n                                if (refa == s->varcompref[1] && refl != s->varcompref[1]) {\n                                    c = 1;\n                                } else {\n                                    c = (refl == s->varcompref[1] &&\n                                         refa != s->varcompref[1]) ? 2 : 4;\n                                }\n                            } else if (!s->above_comp_ctx[col]) {\n                                if (refl == s->varcompref[1] && refa != s->varcompref[1]) {\n                                    c = 1;\n                                } else {\n                                    c = (refa == s->varcompref[1] &&\n                                         refl != s->varcompref[1]) ? 2 : 4;\n                                }\n                            } else {\n                                c = (refl == refa) ? 4 : 2;\n                            }\n                        }\n                    } else {\n                        if (s->above_intra_ctx[col]) {\n                            c = 2;\n                        } else if (s->above_comp_ctx[col]) {\n                            c = 4 * (s->above_ref_ctx[col] != s->varcompref[1]);\n                        } else {\n                            c = 3 * (s->above_ref_ctx[col] != s->varcompref[1]);\n                        }\n                    }\n                } else if (have_l) {\n                    if (s->left_intra_ctx[row7]) {\n                        c = 2;\n                    } else if (s->left_comp_ctx[row7]) {\n                        c = 4 * (s->left_ref_ctx[row7] != s->varcompref[1]);\n                    } else {\n                        c = 3 * (s->left_ref_ctx[row7] != s->varcompref[1]);\n                    }\n                } else {\n                    c = 2;\n                }\n                bit = vp56_rac_get_prob(&s->c, s->prob.p.comp_ref[c]);\n                b->ref[var_idx] = s->varcompref[bit];\n                s->counts.comp_ref[c][bit]++;\n            } else {\n                int bit, c;\n                if (have_a && !s->above_intra_ctx[col]) {\n                    if (have_l && !s->left_intra_ctx[row7]) {\n                        if (s->left_comp_ctx[row7]) {\n                            if (s->above_comp_ctx[col]) {\n                                c = 1 + (!s->fixcompref || !s->left_ref_ctx[row7] ||\n                                         !s->above_ref_ctx[col]);\n                            } else {\n                                c = (3 * !s->above_ref_ctx[col]) +\n                                    (!s->fixcompref || !s->left_ref_ctx[row7]);\n                            }\n                        } else if (s->above_comp_ctx[col]) {\n                            c = (3 * !s->left_ref_ctx[row7]) +\n                                (!s->fixcompref || !s->above_ref_ctx[col]);\n                        } else {\n                            c = 2 * !s->left_ref_ctx[row7] + 2 * !s->above_ref_ctx[col];\n                        }\n                    } else if (s->above_intra_ctx[col]) {\n                        c = 2;\n                    } else if (s->above_comp_ctx[col]) {\n                        c = 1 + (!s->fixcompref || !s->above_ref_ctx[col]);\n                    } else {\n                        c = 4 * (!s->above_ref_ctx[col]);\n                    }\n                } else if (have_l && !s->left_intra_ctx[row7]) {\n                    if (s->left_intra_ctx[row7]) {\n                        c = 2;\n                    } else if (s->left_comp_ctx[row7]) {\n                        c = 1 + (!s->fixcompref || !s->left_ref_ctx[row7]);\n                    } else {\n                        c = 4 * (!s->left_ref_ctx[row7]);\n                    }\n                } else {\n                    c = 2;\n                }\n                bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][0]);\n                s->counts.single_ref[c][0][bit]++;\n                if (!bit) {\n                    b->ref[0] = 0;\n                } else {\n                    if (have_a) {\n                        if (have_l) {\n                            if (s->left_intra_ctx[row7]) {\n                                if (s->above_intra_ctx[col]) {\n                                    c = 2;\n                                } else if (s->above_comp_ctx[col]) {\n                                    c = 1 + 2 * (s->fixcompref == 1 ||\n                                                 s->above_ref_ctx[col] == 1);\n                                } else if (!s->above_ref_ctx[col]) {\n                                    c = 3;\n                                } else {\n                                    c = 4 * (s->above_ref_ctx[col] == 1);\n                                }\n                            } else if (s->above_intra_ctx[col]) {\n                                if (s->left_intra_ctx[row7]) {\n                                    c = 2;\n                                } else if (s->left_comp_ctx[row7]) {\n                                    c = 1 + 2 * (s->fixcompref == 1 ||\n                                                 s->left_ref_ctx[row7] == 1);\n                                } else if (!s->left_ref_ctx[row7]) {\n                                    c = 3;\n                                } else {\n                                    c = 4 * (s->left_ref_ctx[row7] == 1);\n                                }\n                            } else if (s->above_comp_ctx[col]) {\n                                if (s->left_comp_ctx[row7]) {\n                                    if (s->left_ref_ctx[row7] == s->above_ref_ctx[col]) {\n                                        c = 3 * (s->fixcompref == 1 ||\n                                                 s->left_ref_ctx[row7] == 1);\n                                    } else {\n                                        c = 2;\n                                    }\n                                } else if (!s->left_ref_ctx[row7]) {\n                                    c = 1 + 2 * (s->fixcompref == 1 ||\n                                                 s->above_ref_ctx[col] == 1);\n                                } else {\n                                    c = 3 * (s->left_ref_ctx[row7] == 1) +\n                                        (s->fixcompref == 1 || s->above_ref_ctx[col] == 1);\n                                }\n                            } else if (s->left_comp_ctx[row7]) {\n                                if (!s->above_ref_ctx[col]) {\n                                    c = 1 + 2 * (s->fixcompref == 1 ||\n                                                 s->left_ref_ctx[row7] == 1);\n                                } else {\n                                    c = 3 * (s->above_ref_ctx[col] == 1) +\n                                        (s->fixcompref == 1 || s->left_ref_ctx[row7] == 1);\n                                }\n                            } else if (!s->above_ref_ctx[col]) {\n                                if (!s->left_ref_ctx[row7]) {\n                                    c = 3;\n                                } else {\n                                    c = 4 * (s->left_ref_ctx[row7] == 1);\n                                }\n                            } else if (!s->left_ref_ctx[row7]) {\n                                c = 4 * (s->above_ref_ctx[col] == 1);\n                            } else {\n                                c = 2 * (s->left_ref_ctx[row7] == 1) +\n                                    2 * (s->above_ref_ctx[col] == 1);\n                            }\n                        } else {\n                            if (s->above_intra_ctx[col] ||\n                                (!s->above_comp_ctx[col] && !s->above_ref_ctx[col])) {\n                                c = 2;\n                            } else if (s->above_comp_ctx[col]) {\n                                c = 3 * (s->fixcompref == 1 || s->above_ref_ctx[col] == 1);\n                            } else {\n                                c = 4 * (s->above_ref_ctx[col] == 1);\n                            }\n                        }\n                    } else if (have_l) {\n                        if (s->left_intra_ctx[row7] ||\n                            (!s->left_comp_ctx[row7] && !s->left_ref_ctx[row7])) {\n                            c = 2;\n                        } else if (s->left_comp_ctx[row7]) {\n                            c = 3 * (s->fixcompref == 1 || s->left_ref_ctx[row7] == 1);\n                        } else {\n                            c = 4 * (s->left_ref_ctx[row7] == 1);\n                        }\n                    } else {\n                        c = 2;\n                    }\n                    bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][1]);\n                    s->counts.single_ref[c][1][bit]++;\n                    b->ref[0] = 1 + bit;\n                }\n            }\n        }\n        if (b->bs <= BS_8x8) {\n            if (s->segmentation.feat[b->seg_id].skip_enabled) {\n                b->mode[0] =\n                b->mode[1] =\n                b->mode[2] =\n                b->mode[3] = ZEROMV;\n            } else {\n                static const uint8_t off[10] = {\n                    3, 0, 0, 1, 0, 0, 0, 0, 0, 0\n                };\n                int c = inter_mode_ctx_lut[s->above_mode_ctx[col + off[b->bs]]]\n                                          [s->left_mode_ctx[row7 + off[b->bs]]];\n                b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,\n                                              s->prob.p.mv_mode[c]);\n                b->mode[1] =\n                b->mode[2] =\n                b->mode[3] = b->mode[0];\n                s->counts.mv_mode[c][b->mode[0] - 10]++;\n            }\n        }\n        if (s->filtermode == FILTER_SWITCHABLE) {\n            int c;\n            if (have_a && s->above_mode_ctx[col] >= NEARESTMV) {\n                if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {\n                    c = s->above_filter_ctx[col] == s->left_filter_ctx[row7] ?\n                        s->left_filter_ctx[row7] : 3;\n                } else {\n                    c = s->above_filter_ctx[col];\n                }\n            } else if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {\n                c = s->left_filter_ctx[row7];\n            } else {\n                c = 3;\n            }\n            b->filter = vp8_rac_get_tree(&s->c, ff_vp9_filter_tree,\n                                         s->prob.p.filter[c]);\n            s->counts.filter[c][b->filter]++;\n        } else {\n            b->filter = s->filtermode;\n        }\n        if (b->bs > BS_8x8) {\n            int c = inter_mode_ctx_lut[s->above_mode_ctx[col]][s->left_mode_ctx[row7]];\n            b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,\n                                          s->prob.p.mv_mode[c]);\n            s->counts.mv_mode[c][b->mode[0] - 10]++;\n            ff_vp9_fill_mv(s, b->mv[0], b->mode[0], 0);\n            if (b->bs != BS_8x4) {\n                b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,\n                                              s->prob.p.mv_mode[c]);\n                s->counts.mv_mode[c][b->mode[1] - 10]++;\n                ff_vp9_fill_mv(s, b->mv[1], b->mode[1], 1);\n            } else {\n                b->mode[1] = b->mode[0];\n                AV_COPY32(&b->mv[1][0], &b->mv[0][0]);\n                AV_COPY32(&b->mv[1][1], &b->mv[0][1]);\n            }\n            if (b->bs != BS_4x8) {\n                b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,\n                                              s->prob.p.mv_mode[c]);\n                s->counts.mv_mode[c][b->mode[2] - 10]++;\n                ff_vp9_fill_mv(s, b->mv[2], b->mode[2], 2);\n                if (b->bs != BS_8x4) {\n                    b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,\n                                                  s->prob.p.mv_mode[c]);\n                    s->counts.mv_mode[c][b->mode[3] - 10]++;\n                    ff_vp9_fill_mv(s, b->mv[3], b->mode[3], 3);\n                } else {\n                    b->mode[3] = b->mode[2];\n                    AV_COPY32(&b->mv[3][0], &b->mv[2][0]);\n                    AV_COPY32(&b->mv[3][1], &b->mv[2][1]);\n                }\n            } else {\n                b->mode[2] = b->mode[0];\n                AV_COPY32(&b->mv[2][0], &b->mv[0][0]);\n                AV_COPY32(&b->mv[2][1], &b->mv[0][1]);\n                b->mode[3] = b->mode[1];\n                AV_COPY32(&b->mv[3][0], &b->mv[1][0]);\n                AV_COPY32(&b->mv[3][1], &b->mv[1][1]);\n            }\n        } else {\n            ff_vp9_fill_mv(s, b->mv[0], b->mode[0], -1);\n            AV_COPY32(&b->mv[1][0], &b->mv[0][0]);\n            AV_COPY32(&b->mv[2][0], &b->mv[0][0]);\n            AV_COPY32(&b->mv[3][0], &b->mv[0][0]);\n            AV_COPY32(&b->mv[1][1], &b->mv[0][1]);\n            AV_COPY32(&b->mv[2][1], &b->mv[0][1]);\n            AV_COPY32(&b->mv[3][1], &b->mv[0][1]);\n        }\n    }\n    memset(&s->above_skip_ctx[col], b->skip, w4);\n    memset(&s->left_skip_ctx[row7], b->skip, h4);\n    memset(&s->above_txfm_ctx[col], b->tx, w4);\n    memset(&s->left_txfm_ctx[row7], b->tx, h4);\n    memset(&s->above_partition_ctx[col], above_ctx[b->bs], w4);\n    memset(&s->left_partition_ctx[row7], left_ctx[b->bs], h4);\n    if (!s->keyframe && !s->intraonly) {\n        memset(&s->above_intra_ctx[col], b->intra, w4);\n        memset(&s->left_intra_ctx[row7], b->intra, h4);\n        memset(&s->above_comp_ctx[col], b->comp, w4);\n        memset(&s->left_comp_ctx[row7], b->comp, h4);\n        memset(&s->above_mode_ctx[col], b->mode[3], w4);\n        memset(&s->left_mode_ctx[row7], b->mode[3], h4);\n        if (s->filtermode == FILTER_SWITCHABLE && !b->intra) {\n            memset(&s->above_filter_ctx[col], b->filter, w4);\n            memset(&s->left_filter_ctx[row7], b->filter, h4);\n            b->filter = ff_vp9_filter_lut[b->filter];\n        }\n        if (b->bs > BS_8x8) {\n            int mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);\n            AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][0], &b->mv[1][0]);\n            AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][1], &b->mv[1][1]);\n            AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][0], mv0);\n            AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][1], mv1);\n            AV_COPY32(&s->above_mv_ctx[col * 2 + 0][0], &b->mv[2][0]);\n            AV_COPY32(&s->above_mv_ctx[col * 2 + 0][1], &b->mv[2][1]);\n            AV_WN32A(&s->above_mv_ctx[col * 2 + 1][0], mv0);\n            AV_WN32A(&s->above_mv_ctx[col * 2 + 1][1], mv1);\n        } else {\n            int n, mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);\n            for (n = 0; n < w4 * 2; n++) {\n                AV_WN32A(&s->above_mv_ctx[col * 2 + n][0], mv0);\n                AV_WN32A(&s->above_mv_ctx[col * 2 + n][1], mv1);\n            }\n            for (n = 0; n < h4 * 2; n++) {\n                AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][0], mv0);\n                AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][1], mv1);\n            }\n        }\n        if (!b->intra) {\n            int vref = b->ref[b->comp ? s->signbias[s->varcompref[0]] : 0];\n            memset(&s->above_ref_ctx[col], vref, w4);\n            memset(&s->left_ref_ctx[row7], vref, h4);\n        }\n    }\n    for (y = 0; y < h4; y++) {\n        int x, o = (row + y) * s->sb_cols * 8 + col;\n        VP9MVRefPair *mv = &s->frames[CUR_FRAME].mv[o];\n        if (b->intra) {\n            for (x = 0; x < w4; x++) {\n                mv[x].ref[0] =\n                mv[x].ref[1] = -1;\n            }\n        } else if (b->comp) {\n            for (x = 0; x < w4; x++) {\n                mv[x].ref[0] = b->ref[0];\n                mv[x].ref[1] = b->ref[1];\n                AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);\n                AV_COPY32(&mv[x].mv[1], &b->mv[3][1]);\n            }\n        } else {\n            for (x = 0; x < w4; x++) {\n                mv[x].ref[0] = b->ref[0];\n                mv[x].ref[1] = -1;\n                AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);\n            }\n        }\n    }\n}']