FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vp9mvs.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 151 151 100.0%
Functions: 4 4 100.0%
Branches: 340 432 78.7%

Line Branch Exec Source
1 /*
2 * VP9 compatible video decoder
3 *
4 * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5 * Copyright (C) 2013 Clément Bœsch <u pkh me>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "progressframe.h"
25 #include "vp89_rac.h"
26 #include "vp9data.h"
27 #include "vp9dec.h"
28 #include "vpx_rac.h"
29
30 612314 static av_always_inline void clamp_mv(VP9mv *dst, const VP9mv *src,
31 VP9TileData *td)
32 {
33 612314 dst->x = av_clip(src->x, td->min_mv.x, td->max_mv.x);
34 612314 dst->y = av_clip(src->y, td->min_mv.y, td->max_mv.y);
35 612314 }
36
37 631778 static void find_ref_mvs(VP9TileData *td,
38 VP9mv *pmv, int ref, int z, int idx, int sb)
39 {
40 static const int8_t mv_ref_blk_off[N_BS_SIZES][8][2] = {
41 [BS_64x64] = { { 3, -1 }, { -1, 3 }, { 4, -1 }, { -1, 4 },
42 { -1, -1 }, { 0, -1 }, { -1, 0 }, { 6, -1 } },
43 [BS_64x32] = { { 0, -1 }, { -1, 0 }, { 4, -1 }, { -1, 2 },
44 { -1, -1 }, { 0, -3 }, { -3, 0 }, { 2, -1 } },
45 [BS_32x64] = { { -1, 0 }, { 0, -1 }, { -1, 4 }, { 2, -1 },
46 { -1, -1 }, { -3, 0 }, { 0, -3 }, { -1, 2 } },
47 [BS_32x32] = { { 1, -1 }, { -1, 1 }, { 2, -1 }, { -1, 2 },
48 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 } },
49 [BS_32x16] = { { 0, -1 }, { -1, 0 }, { 2, -1 }, { -1, -1 },
50 { -1, 1 }, { 0, -3 }, { -3, 0 }, { -3, -3 } },
51 [BS_16x32] = { { -1, 0 }, { 0, -1 }, { -1, 2 }, { -1, -1 },
52 { 1, -1 }, { -3, 0 }, { 0, -3 }, { -3, -3 } },
53 [BS_16x16] = { { 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, 1 },
54 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 } },
55 [BS_16x8] = { { 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, -1 },
56 { 0, -2 }, { -2, 0 }, { -2, -1 }, { -1, -2 } },
57 [BS_8x16] = { { -1, 0 }, { 0, -1 }, { -1, 1 }, { -1, -1 },
58 { -2, 0 }, { 0, -2 }, { -1, -2 }, { -2, -1 } },
59 [BS_8x8] = { { 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
60 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
61 [BS_8x4] = { { 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
62 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
63 [BS_4x8] = { { 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
64 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
65 [BS_4x4] = { { 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
66 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
67 };
68 631778 const VP9Context *s = td->s;
69 631778 VP9Block *b = td->b;
70 631778 int row = td->row, col = td->col, row7 = td->row7;
71 631778 const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
72 #define INVALID_MV 0x80008000U
73 631778 uint32_t mem = INVALID_MV, mem_sub8x8 = INVALID_MV;
74 int i;
75
76 #define RETURN_DIRECT_MV(mv) \
77 do { \
78 uint32_t m = AV_RN32A(&mv); \
79 if (!idx) { \
80 AV_WN32A(pmv, m); \
81 return; \
82 } else if (mem == INVALID_MV) { \
83 mem = m; \
84 } else if (m != mem) { \
85 AV_WN32A(pmv, m); \
86 return; \
87 } \
88 } while (0)
89
90
2/2
✓ Branch 0 taken 72459 times.
✓ Branch 1 taken 559319 times.
631778 if (sb >= 0) {
91
4/4
✓ Branch 0 taken 55376 times.
✓ Branch 1 taken 17083 times.
✓ Branch 2 taken 16646 times.
✓ Branch 3 taken 38730 times.
72459 if (sb == 2 || sb == 1) {
92
3/6
✓ Branch 0 taken 14585 times.
✓ Branch 1 taken 19144 times.
✓ Branch 2 taken 19144 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
33729 RETURN_DIRECT_MV(b->mv[0][z]);
93
2/2
✓ Branch 0 taken 10151 times.
✓ Branch 1 taken 28579 times.
38730 } else if (sb == 3) {
94
3/6
✓ Branch 0 taken 6444 times.
✓ Branch 1 taken 3707 times.
✓ Branch 2 taken 3707 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10151 RETURN_DIRECT_MV(b->mv[2][z]);
95
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3707 times.
✓ Branch 4 taken 3100 times.
✓ Branch 5 taken 607 times.
3707 RETURN_DIRECT_MV(b->mv[1][z]);
96
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
✓ Branch 4 taken 237 times.
✓ Branch 5 taken 370 times.
607 RETURN_DIRECT_MV(b->mv[0][z]);
97 }
98
99 #define RETURN_MV(mv) \
100 do { \
101 if (sb > 0) { \
102 VP9mv tmp; \
103 uint32_t m; \
104 av_assert2(idx == 1); \
105 av_assert2(mem != INVALID_MV); \
106 if (mem_sub8x8 == INVALID_MV) { \
107 clamp_mv(&tmp, &mv, td); \
108 m = AV_RN32A(&tmp); \
109 if (m != mem) { \
110 AV_WN32A(pmv, m); \
111 return; \
112 } \
113 mem_sub8x8 = AV_RN32A(&mv); \
114 } else if (mem_sub8x8 != AV_RN32A(&mv)) { \
115 clamp_mv(&tmp, &mv, td); \
116 m = AV_RN32A(&tmp); \
117 if (m != mem) { \
118 AV_WN32A(pmv, m); \
119 } else { \
120 /* BUG I'm pretty sure this isn't the intention */ \
121 AV_WN32A(pmv, 0); \
122 } \
123 return; \
124 } \
125 } else { \
126 uint32_t m = AV_RN32A(&mv); \
127 if (!idx) { \
128 clamp_mv(pmv, &mv, td); \
129 return; \
130 } else if (mem == INVALID_MV) { \
131 mem = m; \
132 } else if (m != mem) { \
133 clamp_mv(pmv, &mv, td); \
134 return; \
135 } \
136 } \
137 } while (0)
138
139
2/2
✓ Branch 0 taken 37734 times.
✓ Branch 1 taken 10359 times.
48093 if (row > 0) {
140 37734 VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[(row - 1) * s->sb_cols * 8 + col];
141
2/2
✓ Branch 0 taken 33061 times.
✓ Branch 1 taken 4673 times.
37734 if (mv->ref[0] == ref)
142
8/16
✓ Branch 0 taken 12595 times.
✓ Branch 1 taken 20466 times.
✓ Branch 2 taken 12595 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8701 times.
✓ Branch 6 taken 3894 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 12877 times.
✓ Branch 13 taken 7589 times.
✓ Branch 15 taken 7589 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
33061 RETURN_MV(s->above_mv_ctx[2 * col + (sb & 1)][0]);
143
2/2
✓ Branch 0 taken 701 times.
✓ Branch 1 taken 3972 times.
4673 else if (mv->ref[1] == ref)
144
8/16
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 452 times.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 144 times.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 316 times.
✓ Branch 13 taken 136 times.
✓ Branch 15 taken 136 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
701 RETURN_MV(s->above_mv_ctx[2 * col + (sb & 1)][1]);
145 }
146
2/2
✓ Branch 0 taken 25391 times.
✓ Branch 1 taken 664 times.
26055 if (col > td->tile_col_start) {
147 25391 VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[row * s->sb_cols * 8 + col - 1];
148
2/2
✓ Branch 0 taken 22874 times.
✓ Branch 1 taken 2517 times.
25391 if (mv->ref[0] == ref)
149
15/16
✓ Branch 0 taken 9317 times.
✓ Branch 1 taken 13557 times.
✓ Branch 2 taken 5799 times.
✓ Branch 3 taken 3518 times.
✓ Branch 5 taken 5107 times.
✓ Branch 6 taken 692 times.
✓ Branch 7 taken 2994 times.
✓ Branch 8 taken 524 times.
✓ Branch 10 taken 2994 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5464 times.
✓ Branch 13 taken 8093 times.
✓ Branch 15 taken 1038 times.
✓ Branch 16 taken 7055 times.
✓ Branch 17 taken 6544 times.
✓ Branch 18 taken 511 times.
22874 RETURN_MV(td->left_mv_ctx[2 * row7 + (sb >> 1)][0]);
150
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2141 times.
2517 else if (mv->ref[1] == ref)
151
15/16
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 67 times.
✓ Branch 3 taken 90 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 26 times.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 87 times.
✓ Branch 13 taken 132 times.
✓ Branch 15 taken 28 times.
✓ Branch 16 taken 104 times.
✓ Branch 17 taken 84 times.
✓ Branch 18 taken 20 times.
376 RETURN_MV(td->left_mv_ctx[2 * row7 + (sb >> 1)][1]);
152 }
153 5680 i = 2;
154 } else {
155 559319 i = 0;
156 }
157
158 // previously coded MVs in this neighborhood, using same reference frame
159
2/2
✓ Branch 0 taken 967040 times.
✓ Branch 1 taken 22944 times.
989984 for (; i < 8; i++) {
160 967040 int c = p[i][0] + col, r = p[i][1] + row;
161
162
6/6
✓ Branch 0 taken 966706 times.
✓ Branch 1 taken 334 times.
✓ Branch 2 taken 935270 times.
✓ Branch 3 taken 31436 times.
✓ Branch 4 taken 881260 times.
✓ Branch 5 taken 54010 times.
967040 if (c >= td->tile_col_start && c < s->cols &&
163
2/2
✓ Branch 0 taken 881238 times.
✓ Branch 1 taken 22 times.
881260 r >= 0 && r < s->rows) {
164 881238 VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[r * s->sb_cols * 8 + c];
165
166
2/2
✓ Branch 0 taken 651578 times.
✓ Branch 1 taken 229660 times.
881238 if (mv->ref[0] == ref)
167
15/16
✓ Branch 0 taken 3196 times.
✓ Branch 1 taken 648382 times.
✓ Branch 2 taken 313 times.
✓ Branch 3 taken 2883 times.
✓ Branch 5 taken 222 times.
✓ Branch 6 taken 91 times.
✓ Branch 7 taken 1162 times.
✓ Branch 8 taken 1721 times.
✓ Branch 10 taken 1162 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 408685 times.
✓ Branch 13 taken 239697 times.
✓ Branch 15 taken 106665 times.
✓ Branch 16 taken 133032 times.
✓ Branch 17 taken 105077 times.
✓ Branch 18 taken 27955 times.
651578 RETURN_MV(mv->mv[0]);
168
2/2
✓ Branch 0 taken 36406 times.
✓ Branch 1 taken 193254 times.
229660 else if (mv->ref[1] == ref)
169
15/16
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 36230 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 149 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 57 times.
✓ Branch 8 taken 92 times.
✓ Branch 10 taken 57 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 19506 times.
✓ Branch 13 taken 16724 times.
✓ Branch 15 taken 8304 times.
✓ Branch 16 taken 8420 times.
✓ Branch 17 taken 7332 times.
✓ Branch 18 taken 1088 times.
36406 RETURN_MV(mv->mv[1]);
170 }
171 }
172
173 // MV at this position in previous frame, using same reference frame
174
2/2
✓ Branch 0 taken 21888 times.
✓ Branch 1 taken 1056 times.
22944 if (s->s.h.use_last_frame_mvs) {
175 21888 VP9mvrefPair *mv = &s->s.frames[REF_FRAME_MVPAIR].mv[row * s->sb_cols * 8 + col];
176
177
1/2
✓ Branch 0 taken 21888 times.
✗ Branch 1 not taken.
21888 if (!s->s.frames[REF_FRAME_MVPAIR].uses_2pass)
178 21888 ff_progress_frame_await(&s->s.frames[REF_FRAME_MVPAIR].tf, row >> 3);
179
2/2
✓ Branch 0 taken 9555 times.
✓ Branch 1 taken 12333 times.
21888 if (mv->ref[0] == ref)
180
15/16
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 9029 times.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 275 times.
✓ Branch 5 taken 225 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 266 times.
✓ Branch 8 taken 9 times.
✓ Branch 10 taken 266 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5814 times.
✓ Branch 13 taken 3215 times.
✓ Branch 15 taken 378 times.
✓ Branch 16 taken 2837 times.
✓ Branch 17 taken 2728 times.
✓ Branch 18 taken 109 times.
9555 RETURN_MV(mv->mv[0]);
181
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 12030 times.
12333 else if (mv->ref[1] == ref)
182
13/16
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 19 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 19 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 19 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 193 times.
✓ Branch 13 taken 88 times.
✓ Branch 15 taken 20 times.
✓ Branch 16 taken 68 times.
✓ Branch 17 taken 60 times.
✓ Branch 18 taken 8 times.
303 RETURN_MV(mv->mv[1]);
183 }
184
185 #define RETURN_SCALE_MV(mv, scale) \
186 do { \
187 if (scale) { \
188 VP9mv mv_temp = { -mv.x, -mv.y }; \
189 RETURN_MV(mv_temp); \
190 } else { \
191 RETURN_MV(mv); \
192 } \
193 } while (0)
194
195 // previously coded MVs in this neighborhood, using different reference frame
196
2/2
✓ Branch 0 taken 38573 times.
✓ Branch 1 taken 2865 times.
41438 for (i = 0; i < 8; i++) {
197 38573 int c = p[i][0] + col, r = p[i][1] + row;
198
199
8/8
✓ Branch 0 taken 38455 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 30268 times.
✓ Branch 3 taken 8187 times.
✓ Branch 4 taken 23821 times.
✓ Branch 5 taken 6447 times.
✓ Branch 6 taken 23818 times.
✓ Branch 7 taken 3 times.
38573 if (c >= td->tile_col_start && c < s->cols && r >= 0 && r < s->rows) {
200 23818 VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[r * s->sb_cols * 8 + c];
201
202
4/4
✓ Branch 0 taken 19277 times.
✓ Branch 1 taken 4541 times.
✓ Branch 2 taken 12466 times.
✓ Branch 3 taken 6811 times.
23818 if (mv->ref[0] != ref && mv->ref[0] >= 0)
203
32/34
✓ Branch 0 taken 3883 times.
✓ Branch 1 taken 8583 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 3784 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 86 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 37 times.
✓ Branch 12 taken 49 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2248 times.
✓ Branch 15 taken 1536 times.
✓ Branch 17 taken 285 times.
✓ Branch 18 taken 1251 times.
✓ Branch 19 taken 842 times.
✓ Branch 20 taken 409 times.
✓ Branch 22 taken 253 times.
✓ Branch 23 taken 8330 times.
✓ Branch 24 taken 140 times.
✓ Branch 25 taken 113 times.
✓ Branch 27 taken 110 times.
✓ Branch 28 taken 30 times.
✓ Branch 29 taken 92 times.
✓ Branch 30 taken 21 times.
✓ Branch 32 taken 92 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 6062 times.
✓ Branch 35 taken 2268 times.
✓ Branch 37 taken 616 times.
✓ Branch 38 taken 1652 times.
✓ Branch 39 taken 1301 times.
✓ Branch 40 taken 351 times.
12466 RETURN_SCALE_MV(mv->mv[0],
204 s->s.h.signbias[mv->ref[0]] != s->s.h.signbias[ref]);
205
4/4
✓ Branch 0 taken 13025 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 12882 times.
13104 if (mv->ref[1] != ref && mv->ref[1] >= 0 &&
206 // BUG - libvpx has this condition regardless of whether
207 // we used the first ref MV and pre-scaling
208
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 50 times.
143 AV_RN32A(&mv->mv[0]) != AV_RN32A(&mv->mv[1])) {
209
11/34
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 78 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 8 times.
✓ Branch 12 taken 7 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 78 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 78 times.
✓ Branch 19 taken 50 times.
✓ Branch 20 taken 28 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
93 RETURN_SCALE_MV(mv->mv[1], s->s.h.signbias[mv->ref[1]] != s->s.h.signbias[ref]);
210 }
211 }
212 }
213
214 // MV at this position in previous frame, using different reference frame
215
2/2
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 203 times.
2865 if (s->s.h.use_last_frame_mvs) {
216 2662 VP9mvrefPair *mv = &s->s.frames[REF_FRAME_MVPAIR].mv[row * s->sb_cols * 8 + col];
217
218 // no need to await_progress, because we already did that above
219
4/4
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 1499 times.
✓ Branch 3 taken 1041 times.
2662 if (mv->ref[0] != ref && mv->ref[0] >= 0)
220
31/34
✓ Branch 0 taken 664 times.
✓ Branch 1 taken 835 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 18 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 18 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 420 times.
✓ Branch 15 taken 224 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 208 times.
✓ Branch 19 taken 199 times.
✓ Branch 20 taken 9 times.
✓ Branch 22 taken 83 times.
✓ Branch 23 taken 752 times.
✓ Branch 24 taken 42 times.
✓ Branch 25 taken 41 times.
✓ Branch 27 taken 31 times.
✓ Branch 28 taken 11 times.
✓ Branch 29 taken 37 times.
✓ Branch 30 taken 4 times.
✓ Branch 32 taken 37 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 430 times.
✓ Branch 35 taken 322 times.
✓ Branch 37 taken 22 times.
✓ Branch 38 taken 300 times.
✓ Branch 39 taken 284 times.
✓ Branch 40 taken 16 times.
1499 RETURN_SCALE_MV(mv->mv[0], s->s.h.signbias[mv->ref[0]] != s->s.h.signbias[ref]);
221
4/4
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1232 times.
1242 if (mv->ref[1] != ref && mv->ref[1] >= 0 &&
222 // BUG - libvpx has this condition regardless of whether
223 // we used the first ref MV and pre-scaling
224
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 AV_RN32A(&mv->mv[0]) != AV_RN32A(&mv->mv[1])) {
225
6/34
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 5 times.
✓ Branch 20 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
6 RETURN_SCALE_MV(mv->mv[1], s->s.h.signbias[mv->ref[1]] != s->s.h.signbias[ref]);
226 }
227 }
228
229 1440 AV_ZERO32(pmv);
230 1440 clamp_mv(pmv, pmv, td);
231 #undef INVALID_MV
232 #undef RETURN_MV
233 #undef RETURN_SCALE_MV
234 }
235
236 419551 static av_always_inline int read_mv_component(VP9TileData *td, int idx, int hp)
237 {
238 419551 const VP9Context *s = td->s;
239 419551 int bit, sign = vpx_rac_get_prob(td->c, s->prob.p.mv_comp[idx].sign);
240 419551 int n, c = vp89_rac_get_tree(td->c, ff_vp9_mv_class_tree,
241 419551 s->prob.p.mv_comp[idx].classes);
242
243 419551 td->counts.mv_comp[idx].sign[sign]++;
244 419551 td->counts.mv_comp[idx].classes[c]++;
245
2/2
✓ Branch 0 taken 53160 times.
✓ Branch 1 taken 366391 times.
419551 if (c) {
246 int m;
247
248
2/2
✓ Branch 0 taken 102599 times.
✓ Branch 1 taken 53160 times.
155759 for (n = 0, m = 0; m < c; m++) {
249 102599 bit = vpx_rac_get_prob(td->c, s->prob.p.mv_comp[idx].bits[m]);
250 102599 n |= bit << m;
251 102599 td->counts.mv_comp[idx].bits[m][bit]++;
252 }
253 53160 n <<= 3;
254 53160 bit = vp89_rac_get_tree(td->c, ff_vp9_mv_fp_tree,
255 53160 s->prob.p.mv_comp[idx].fp);
256 53160 n |= bit << 1;
257 53160 td->counts.mv_comp[idx].fp[bit]++;
258
2/2
✓ Branch 0 taken 28612 times.
✓ Branch 1 taken 24548 times.
53160 if (hp) {
259 28612 bit = vpx_rac_get_prob(td->c, s->prob.p.mv_comp[idx].hp);
260 28612 td->counts.mv_comp[idx].hp[bit]++;
261 28612 n |= bit;
262 } else {
263 24548 n |= 1;
264 // bug in libvpx - we count for bw entropy purposes even if the
265 // bit wasn't coded
266 24548 td->counts.mv_comp[idx].hp[1]++;
267 }
268 53160 n += 8 << c;
269 } else {
270 366391 n = vpx_rac_get_prob(td->c, s->prob.p.mv_comp[idx].class0);
271 366391 td->counts.mv_comp[idx].class0[n]++;
272 366391 bit = vp89_rac_get_tree(td->c, ff_vp9_mv_fp_tree,
273 366391 s->prob.p.mv_comp[idx].class0_fp[n]);
274 366391 td->counts.mv_comp[idx].class0_fp[n][bit]++;
275 366391 n = (n << 3) | (bit << 1);
276
2/2
✓ Branch 0 taken 191446 times.
✓ Branch 1 taken 174945 times.
366391 if (hp) {
277 191446 bit = vpx_rac_get_prob(td->c, s->prob.p.mv_comp[idx].class0_hp);
278 191446 td->counts.mv_comp[idx].class0_hp[bit]++;
279 191446 n |= bit;
280 } else {
281 174945 n |= 1;
282 // bug in libvpx - we count for bw entropy purposes even if the
283 // bit wasn't coded
284 174945 td->counts.mv_comp[idx].class0_hp[1]++;
285 }
286 }
287
288
2/2
✓ Branch 0 taken 160242 times.
✓ Branch 1 taken 259309 times.
419551 return sign ? -(n + 1) : (n + 1);
289 }
290
291 614512 void ff_vp9_fill_mv(VP9TileData *td, VP9mv *mv, int mode, int sb)
292 {
293 614512 const VP9Context *s = td->s;
294 614512 VP9Block *b = td->b;
295
296
2/2
✓ Branch 0 taken 10953 times.
✓ Branch 1 taken 603559 times.
614512 if (mode == ZEROMV) {
297 10953 AV_ZERO32(&mv[0]);
298 10953 AV_ZERO32(&mv[1]);
299 } else {
300 int hp;
301
302 // FIXME cache this value and reuse for other subblocks
303
2/2
✓ Branch 0 taken 336263 times.
✓ Branch 1 taken 267296 times.
603559 find_ref_mvs(td, &mv[0], b->ref[0], 0, mode == NEARMV,
304 mode == NEWMV ? -1 : sb);
305 // FIXME maybe move this code into find_ref_mvs()
306
4/4
✓ Branch 0 taken 336263 times.
✓ Branch 1 taken 267296 times.
✓ Branch 2 taken 265277 times.
✓ Branch 3 taken 70986 times.
603559 if ((mode == NEWMV || sb == -1) &&
307
2/2
✓ Branch 0 taken 246572 times.
✓ Branch 1 taken 286001 times.
532573 !(hp = s->s.h.highprecisionmvs &&
308
6/6
✓ Branch 0 taken 348501 times.
✓ Branch 1 taken 184072 times.
✓ Branch 2 taken 297220 times.
✓ Branch 3 taken 51281 times.
✓ Branch 4 taken 286001 times.
✓ Branch 5 taken 11219 times.
532573 abs(mv[0].x) < 64 && abs(mv[0].y) < 64)) {
309
2/2
✓ Branch 0 taken 1756 times.
✓ Branch 1 taken 244816 times.
246572 if (mv[0].y & 1) {
310
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 1016 times.
1756 if (mv[0].y < 0)
311 740 mv[0].y++;
312 else
313 1016 mv[0].y--;
314 }
315
2/2
✓ Branch 0 taken 2217 times.
✓ Branch 1 taken 244355 times.
246572 if (mv[0].x & 1) {
316
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 1440 times.
2217 if (mv[0].x < 0)
317 777 mv[0].x++;
318 else
319 1440 mv[0].x--;
320 }
321 }
322
2/2
✓ Branch 0 taken 267296 times.
✓ Branch 1 taken 336263 times.
603559 if (mode == NEWMV) {
323 534592 enum MVJoint j = vp89_rac_get_tree(td->c, ff_vp9_mv_joint_tree,
324 267296 s->prob.p.mv_joint);
325
326 267296 td->counts.mv_joint[j]++;
327
2/2
✓ Branch 0 taken 221232 times.
✓ Branch 1 taken 46064 times.
267296 if (j >= MV_JOINT_V)
328 221232 mv[0].y += read_mv_component(td, 0, hp);
329
2/2
✓ Branch 0 taken 177759 times.
✓ Branch 1 taken 89537 times.
267296 if (j & 1)
330 177759 mv[0].x += read_mv_component(td, 1, hp);
331 }
332
333
2/2
✓ Branch 0 taken 28219 times.
✓ Branch 1 taken 575340 times.
603559 if (b->comp) {
334 // FIXME cache this value and reuse for other subblocks
335
2/2
✓ Branch 0 taken 14781 times.
✓ Branch 1 taken 13438 times.
28219 find_ref_mvs(td, &mv[1], b->ref[1], 1, mode == NEARMV,
336 mode == NEWMV ? -1 : sb);
337
4/4
✓ Branch 0 taken 14781 times.
✓ Branch 1 taken 13438 times.
✓ Branch 2 taken 13308 times.
✓ Branch 3 taken 1473 times.
28219 if ((mode == NEWMV || sb == -1) &&
338
2/2
✓ Branch 0 taken 17991 times.
✓ Branch 1 taken 8755 times.
26746 !(hp = s->s.h.highprecisionmvs &&
339
6/6
✓ Branch 0 taken 9952 times.
✓ Branch 1 taken 16794 times.
✓ Branch 2 taken 8867 times.
✓ Branch 3 taken 1085 times.
✓ Branch 4 taken 8755 times.
✓ Branch 5 taken 112 times.
26746 abs(mv[1].x) < 64 && abs(mv[1].y) < 64)) {
340
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17907 times.
17991 if (mv[1].y & 1) {
341
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 54 times.
84 if (mv[1].y < 0)
342 30 mv[1].y++;
343 else
344 54 mv[1].y--;
345 }
346
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 17922 times.
17991 if (mv[1].x & 1) {
347
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 10 times.
69 if (mv[1].x < 0)
348 59 mv[1].x++;
349 else
350 10 mv[1].x--;
351 }
352 }
353
2/2
✓ Branch 0 taken 13438 times.
✓ Branch 1 taken 14781 times.
28219 if (mode == NEWMV) {
354 26876 enum MVJoint j = vp89_rac_get_tree(td->c, ff_vp9_mv_joint_tree,
355 13438 s->prob.p.mv_joint);
356
357 13438 td->counts.mv_joint[j]++;
358
2/2
✓ Branch 0 taken 10960 times.
✓ Branch 1 taken 2478 times.
13438 if (j >= MV_JOINT_V)
359 10960 mv[1].y += read_mv_component(td, 0, hp);
360
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 3838 times.
13438 if (j & 1)
361 9600 mv[1].x += read_mv_component(td, 1, hp);
362 }
363 }
364 }
365 614512 }
366