libavcodec/vp9block.c:613: error: Buffer Overrun L1
  Offset: 4 (⇐ 3 + 1) Size: 4 by call to `ff_vp9_fill_mv`.

libavcodec/vp9block.c:44:1: Parameter `b->mv[*]`
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:613:21: Call
611.                                                   s->prob.p.mv_mode[c]);
612.                     s->counts.mv_mode[c][b->mode[3] - 10]++;
613.                     ff_vp9_fill_mv(s, b->mv[3], b->mode[3], 3);
                         ^
614.                 } else {
615.                     b->mode[3] = b->mode[2];

libavcodec/vp9mvs.c:284:1: <Length trace>
282. }
283. 
284. void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
     ^
285. {
286.     VP9Block *b = s->b;

libavcodec/vp9mvs.c:284:1: Parameter `*mv`
  282. }
  283. 
  284. void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
       ^
  285. {
  286.     VP9Block *b = s->b;

libavcodec/vp9mvs.c:330:44: Array access: Offset: 4 (⇐ 3 + 1) Size: 4 by call to `ff_vp9_fill_mv` 
  328.             if ((mode == NEWMV || sb == -1) &&
  329.                 !(hp = s->highprecisionmvs &&
  330.                   abs(mv[1].x) < 64 && abs(mv[1].y) < 64)) {
                                                  ^
  331.                 if (mv[1].y & 1) {
  332.                     if (mv[1].y < 0)

void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
{
    VP9Block *b = s->b;
    if (mode == ZEROMV) {
        memset(mv, 0, sizeof(*mv) * 2);
    } else {
        int hp;
        find_ref_mvs(s, &mv[0], b->ref[0], 0, mode == NEARMV,
                     mode == NEWMV ? -1 : sb);
        if ((mode == NEWMV || sb == -1) &&
            !(hp = s->highprecisionmvs &&
              abs(mv[0].x) < 64 && abs(mv[0].y) < 64)) {
            if (mv[0].y & 1) {
                if (mv[0].y < 0)
                    mv[0].y++;
                else
                    mv[0].y--;
            }
            if (mv[0].x & 1) {
                if (mv[0].x < 0)
                    mv[0].x++;
                else
                    mv[0].x--;
            }
        }
        if (mode == NEWMV) {
            enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,
                                              s->prob.p.mv_joint);
            s->counts.mv_joint[j]++;
            if (j >= MV_JOINT_V)
                mv[0].y += read_mv_component(s, 0, hp);
            if (j & 1)
                mv[0].x += read_mv_component(s, 1, hp);
        }
        if (b->comp) {
            find_ref_mvs(s, &mv[1], b->ref[1], 1, mode == NEARMV,
                         mode == NEWMV ? -1 : sb);
            if ((mode == NEWMV || sb == -1) &&
                !(hp = s->highprecisionmvs &&
                  abs(mv[1].x) < 64 && abs(mv[1].y) < 64)) {
                if (mv[1].y & 1) {
                    if (mv[1].y < 0)
                        mv[1].y++;
                    else
                        mv[1].y--;
                }
                if (mv[1].x & 1) {
                    if (mv[1].x < 0)
                        mv[1].x++;
                    else
                        mv[1].x--;
                }
            }
            if (mode == NEWMV) {
                enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,
                                                  s->prob.p.mv_joint);
                s->counts.mv_joint[j]++;
                if (j >= MV_JOINT_V)
                    mv[1].y += read_mv_component(s, 0, hp);
                if (j & 1)
                    mv[1].x += read_mv_component(s, 1, hp);
            }
        }
    }
}
['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}', 'void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)\n{\n    VP9Block *b = s->b;\n    if (mode == ZEROMV) {\n        memset(mv, 0, sizeof(*mv) * 2);\n    } else {\n        int hp;\n        find_ref_mvs(s, &mv[0], b->ref[0], 0, mode == NEARMV,\n                     mode == NEWMV ? -1 : sb);\n        if ((mode == NEWMV || sb == -1) &&\n            !(hp = s->highprecisionmvs &&\n              abs(mv[0].x) < 64 && abs(mv[0].y) < 64)) {\n            if (mv[0].y & 1) {\n                if (mv[0].y < 0)\n                    mv[0].y++;\n                else\n                    mv[0].y--;\n            }\n            if (mv[0].x & 1) {\n                if (mv[0].x < 0)\n                    mv[0].x++;\n                else\n                    mv[0].x--;\n            }\n        }\n        if (mode == NEWMV) {\n            enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,\n                                              s->prob.p.mv_joint);\n            s->counts.mv_joint[j]++;\n            if (j >= MV_JOINT_V)\n                mv[0].y += read_mv_component(s, 0, hp);\n            if (j & 1)\n                mv[0].x += read_mv_component(s, 1, hp);\n        }\n        if (b->comp) {\n            find_ref_mvs(s, &mv[1], b->ref[1], 1, mode == NEARMV,\n                         mode == NEWMV ? -1 : sb);\n            if ((mode == NEWMV || sb == -1) &&\n                !(hp = s->highprecisionmvs &&\n                  abs(mv[1].x) < 64 && abs(mv[1].y) < 64)) {\n                if (mv[1].y & 1) {\n                    if (mv[1].y < 0)\n                        mv[1].y++;\n                    else\n                        mv[1].y--;\n                }\n                if (mv[1].x & 1) {\n                    if (mv[1].x < 0)\n                        mv[1].x++;\n                    else\n                        mv[1].x--;\n                }\n            }\n            if (mode == NEWMV) {\n                enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,\n                                                  s->prob.p.mv_joint);\n                s->counts.mv_joint[j]++;\n                if (j >= MV_JOINT_V)\n                    mv[1].y += read_mv_component(s, 0, hp);\n                if (j & 1)\n                    mv[1].x += read_mv_component(s, 1, hp);\n            }\n        }\n    }\n}']