FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vp9block.c
Date: 2022-11-28 23:49:43
Exec Total Coverage
Lines: 789 812 97.2%
Branches: 872 930 93.8%

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 "libavutil/avassert.h"
25
26 #include "threadframe.h"
27 #include "vp89_rac.h"
28 #include "vp9.h"
29 #include "vp9data.h"
30 #include "vp9dec.h"
31 #include "vpx_rac.h"
32
33 836875 static av_always_inline void setctx_2d(uint8_t *ptr, int w, int h,
34 ptrdiff_t stride, int v)
35 {
36
4/5
✓ Branch 0 taken 560063 times.
✓ Branch 1 taken 217483 times.
✓ Branch 2 taken 47497 times.
✓ Branch 3 taken 11832 times.
✗ Branch 4 not taken.
836875 switch (w) {
37 600753 case 1:
38 do {
39 600753 *ptr = v;
40 600753 ptr += stride;
41
2/2
✓ Branch 0 taken 40690 times.
✓ Branch 1 taken 560063 times.
600753 } while (--h);
42 560063 break;
43 217483 case 2: {
44 217483 int v16 = v * 0x0101;
45 do {
46 399853 AV_WN16A(ptr, v16);
47 399853 ptr += stride;
48
2/2
✓ Branch 0 taken 182370 times.
✓ Branch 1 taken 217483 times.
399853 } while (--h);
49 217483 break;
50 }
51 47497 case 4: {
52 47497 uint32_t v32 = v * 0x01010101;
53 do {
54 174056 AV_WN32A(ptr, v32);
55 174056 ptr += stride;
56
2/2
✓ Branch 0 taken 126559 times.
✓ Branch 1 taken 47497 times.
174056 } while (--h);
57 47497 break;
58 }
59 11832 case 8: {
60 #if HAVE_FAST_64BIT
61 11832 uint64_t v64 = v * 0x0101010101010101ULL;
62 do {
63 87944 AV_WN64A(ptr, v64);
64 87944 ptr += stride;
65
2/2
✓ Branch 0 taken 76112 times.
✓ Branch 1 taken 11832 times.
87944 } while (--h);
66 #else
67 uint32_t v32 = v * 0x01010101;
68 do {
69 AV_WN32A(ptr, v32);
70 AV_WN32A(ptr + 4, v32);
71 ptr += stride;
72 } while (--h);
73 #endif
74 11832 break;
75 }
76 }
77 836875 }
78
79 794355 static void decode_mode(VP9TileData *td)
80 {
81 static const uint8_t left_ctx[N_BS_SIZES] = {
82 0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
83 };
84 static const uint8_t above_ctx[N_BS_SIZES] = {
85 0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf
86 };
87 static const uint8_t max_tx_for_bl_bp[N_BS_SIZES] = {
88 TX_32X32, TX_32X32, TX_32X32, TX_32X32, TX_16X16, TX_16X16,
89 TX_16X16, TX_8X8, TX_8X8, TX_8X8, TX_4X4, TX_4X4, TX_4X4
90 };
91 794355 const VP9Context *s = td->s;
92 794355 VP9Block *b = td->b;
93 794355 int row = td->row, col = td->col, row7 = td->row7;
94 794355 enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];
95 794355 int bw4 = ff_vp9_bwh_tab[1][b->bs][0], w4 = FFMIN(s->cols - col, bw4);
96 794355 int bh4 = ff_vp9_bwh_tab[1][b->bs][1], h4 = FFMIN(s->rows - row, bh4), y;
97 794355 int have_a = row > 0, have_l = col > td->tile_col_start;
98 int vref, filter_id;
99
100
2/2
✓ Branch 0 taken 550697 times.
✓ Branch 1 taken 243658 times.
794355 if (!s->s.h.segmentation.enabled) {
101 550697 b->seg_id = 0;
102
3/4
✓ Branch 0 taken 234362 times.
✓ Branch 1 taken 9296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234362 times.
243658 } else if (s->s.h.keyframe || s->s.h.intraonly) {
103
1/2
✓ Branch 0 taken 9296 times.
✗ Branch 1 not taken.
18592 b->seg_id = !s->s.h.segmentation.update_map ? 0 :
104 9296 vp89_rac_get_tree(td->c, ff_vp9_segmentation_tree,
105 9296 s->s.h.segmentation.prob);
106
2/2
✓ Branch 0 taken 63275 times.
✓ Branch 1 taken 171087 times.
234362 } else if (!s->s.h.segmentation.update_map ||
107
3/4
✓ Branch 0 taken 63275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56354 times.
✓ Branch 3 taken 6921 times.
126550 (s->s.h.segmentation.temporal &&
108 63275 vpx_rac_get_prob_branchy(td->c,
109 63275 s->s.h.segmentation.pred_prob[s->above_segpred_ctx[col] +
110 63275 td->left_segpred_ctx[row7]]))) {
111
3/4
✓ Branch 0 taken 220485 times.
✓ Branch 1 taken 6956 times.
✓ Branch 2 taken 220485 times.
✗ Branch 3 not taken.
227441 if (!s->s.h.errorres && s->s.frames[REF_FRAME_SEGMAP].segmentation_map) {
112 220485 int pred = 8, x;
113 220485 uint8_t *refsegmap = s->s.frames[REF_FRAME_SEGMAP].segmentation_map;
114
115
1/2
✓ Branch 0 taken 220485 times.
✗ Branch 1 not taken.
220485 if (!s->s.frames[REF_FRAME_SEGMAP].uses_2pass)
116 220485 ff_thread_await_progress(&s->s.frames[REF_FRAME_SEGMAP].tf, row >> 3, 0);
117
2/2
✓ Branch 0 taken 388438 times.
✓ Branch 1 taken 220485 times.
608923 for (y = 0; y < h4; y++) {
118 388438 int idx_base = (y + row) * 8 * s->sb_cols + col;
119
2/2
✓ Branch 0 taken 1178112 times.
✓ Branch 1 taken 388438 times.
1566550 for (x = 0; x < w4; x++)
120 1178112 pred = FFMIN(pred, refsegmap[idx_base + x]);
121 }
122 av_assert1(pred < 8);
123 220485 b->seg_id = pred;
124 } else {
125 6956 b->seg_id = 0;
126 }
127
128 227441 memset(&s->above_segpred_ctx[col], 1, w4);
129 227441 memset(&td->left_segpred_ctx[row7], 1, h4);
130 } else {
131 13842 b->seg_id = vp89_rac_get_tree(td->c, ff_vp9_segmentation_tree,
132 6921 s->s.h.segmentation.prob);
133
134 6921 memset(&s->above_segpred_ctx[col], 0, w4);
135 6921 memset(&td->left_segpred_ctx[row7], 0, h4);
136 }
137
2/2
✓ Branch 0 taken 243658 times.
✓ Branch 1 taken 550697 times.
794355 if (s->s.h.segmentation.enabled &&
138
4/6
✓ Branch 0 taken 171087 times.
✓ Branch 1 taken 72571 times.
✓ Branch 2 taken 171087 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 171087 times.
243658 (s->s.h.segmentation.update_map || s->s.h.keyframe || s->s.h.intraonly)) {
139 72571 setctx_2d(&s->s.frames[CUR_FRAME].segmentation_map[row * 8 * s->sb_cols + col],
140 72571 bw4, bh4, 8 * s->sb_cols, b->seg_id);
141 }
142
143
2/2
✓ Branch 0 taken 243658 times.
✓ Branch 1 taken 550697 times.
1038013 b->skip = s->s.h.segmentation.enabled &&
144
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 242857 times.
243658 s->s.h.segmentation.feat[b->seg_id].skip_enabled;
145
2/2
✓ Branch 0 taken 793554 times.
✓ Branch 1 taken 801 times.
794355 if (!b->skip) {
146 793554 int c = td->left_skip_ctx[row7] + s->above_skip_ctx[col];
147 793554 b->skip = vpx_rac_get_prob(td->c, s->prob.p.skip[c]);
148 793554 td->counts.skip[c][b->skip]++;
149 }
150
151
4/4
✓ Branch 0 taken 564922 times.
✓ Branch 1 taken 229433 times.
✓ Branch 2 taken 2376 times.
✓ Branch 3 taken 562546 times.
794355 if (s->s.h.keyframe || s->s.h.intraonly) {
152 231809 b->intra = 1;
153
4/4
✓ Branch 0 taken 234362 times.
✓ Branch 1 taken 328184 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 233561 times.
562546 } else if (s->s.h.segmentation.enabled && s->s.h.segmentation.feat[b->seg_id].ref_enabled) {
154 801 b->intra = !s->s.h.segmentation.feat[b->seg_id].ref_val;
155 } else {
156 int c, bit;
157
158
4/4
✓ Branch 0 taken 534377 times.
✓ Branch 1 taken 27368 times.
✓ Branch 2 taken 518221 times.
✓ Branch 3 taken 16156 times.
561745 if (have_a && have_l) {
159 518221 c = s->above_intra_ctx[col] + td->left_intra_ctx[row7];
160 518221 c += (c == 2);
161 } else {
162
2/2
✓ Branch 0 taken 16156 times.
✓ Branch 1 taken 27368 times.
70892 c = have_a ? 2 * s->above_intra_ctx[col] :
163
2/2
✓ Branch 0 taken 25556 times.
✓ Branch 1 taken 1812 times.
27368 have_l ? 2 * td->left_intra_ctx[row7] : 0;
164 }
165 561745 bit = vpx_rac_get_prob(td->c, s->prob.p.intra[c]);
166 561745 td->counts.intra[c][bit]++;
167 561745 b->intra = !bit;
168 }
169
170
6/6
✓ Branch 0 taken 530281 times.
✓ Branch 1 taken 264074 times.
✓ Branch 2 taken 137847 times.
✓ Branch 3 taken 392434 times.
✓ Branch 4 taken 375989 times.
✓ Branch 5 taken 25932 times.
1170344 if ((b->intra || !b->skip) && s->s.h.txfmmode == TX_SWITCHABLE) {
171 int c;
172
2/2
✓ Branch 0 taken 352610 times.
✓ Branch 1 taken 23379 times.
375989 if (have_a) {
173
2/2
✓ Branch 0 taken 341878 times.
✓ Branch 1 taken 10732 times.
352610 if (have_l) {
174
2/2
✓ Branch 0 taken 278264 times.
✓ Branch 1 taken 63614 times.
341878 c = (s->above_skip_ctx[col] ? max_tx :
175 278264 s->above_txfm_ctx[col]) +
176
2/2
✓ Branch 0 taken 269489 times.
✓ Branch 1 taken 72389 times.
341878 (td->left_skip_ctx[row7] ? max_tx :
177 341878 td->left_txfm_ctx[row7]) > max_tx;
178 } else {
179
2/2
✓ Branch 0 taken 9081 times.
✓ Branch 1 taken 1651 times.
19813 c = s->above_skip_ctx[col] ? 1 :
180
2/2
✓ Branch 0 taken 4134 times.
✓ Branch 1 taken 4947 times.
9081 (s->above_txfm_ctx[col] * 2 > max_tx);
181 }
182
2/2
✓ Branch 0 taken 22097 times.
✓ Branch 1 taken 1282 times.
23379 } else if (have_l) {
183
2/2
✓ Branch 0 taken 19509 times.
✓ Branch 1 taken 2588 times.
41606 c = td->left_skip_ctx[row7] ? 1 :
184
2/2
✓ Branch 0 taken 6362 times.
✓ Branch 1 taken 13147 times.
19509 (td->left_txfm_ctx[row7] * 2 > max_tx);
185 } else {
186 1282 c = 1;
187 }
188
4/5
✓ Branch 0 taken 10027 times.
✓ Branch 1 taken 49282 times.
✓ Branch 2 taken 199405 times.
✓ Branch 3 taken 117275 times.
✗ Branch 4 not taken.
375989 switch (max_tx) {
189 10027 case TX_32X32:
190 10027 b->tx = vpx_rac_get_prob(td->c, s->prob.p.tx32p[c][0]);
191
2/2
✓ Branch 0 taken 9857 times.
✓ Branch 1 taken 170 times.
10027 if (b->tx) {
192 9857 b->tx += vpx_rac_get_prob(td->c, s->prob.p.tx32p[c][1]);
193
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 1055 times.
9857 if (b->tx == 2)
194 8802 b->tx += vpx_rac_get_prob(td->c, s->prob.p.tx32p[c][2]);
195 }
196 10027 td->counts.tx32p[c][b->tx]++;
197 10027 break;
198 49282 case TX_16X16:
199 49282 b->tx = vpx_rac_get_prob(td->c, s->prob.p.tx16p[c][0]);
200
2/2
✓ Branch 0 taken 46323 times.
✓ Branch 1 taken 2959 times.
49282 if (b->tx)
201 46323 b->tx += vpx_rac_get_prob(td->c, s->prob.p.tx16p[c][1]);
202 49282 td->counts.tx16p[c][b->tx]++;
203 49282 break;
204 199405 case TX_8X8:
205 199405 b->tx = vpx_rac_get_prob(td->c, s->prob.p.tx8p[c]);
206 199405 td->counts.tx8p[c][b->tx]++;
207 199405 break;
208 117275 case TX_4X4:
209 117275 b->tx = TX_4X4;
210 117275 break;
211 }
212 } else {
213 418366 b->tx = FFMIN(max_tx, s->s.h.txfmmode);
214 }
215
216
4/4
✓ Branch 0 taken 564922 times.
✓ Branch 1 taken 229433 times.
✓ Branch 2 taken 2376 times.
✓ Branch 3 taken 562546 times.
794355 if (s->s.h.keyframe || s->s.h.intraonly) {
217 231809 uint8_t *a = &s->above_mode_ctx[col * 2];
218 231809 uint8_t *l = &td->left_mode_ctx[(row7) << 1];
219
220 231809 b->comp = 0;
221
2/2
✓ Branch 0 taken 82094 times.
✓ Branch 1 taken 149715 times.
231809 if (b->bs > BS_8x8) {
222 // FIXME the memory storage intermediates here aren't really
223 // necessary, they're just there to make the code slightly
224 // simpler for now
225 82094 b->mode[0] =
226 164188 a[0] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
227 82094 ff_vp9_default_kf_ymode_probs[a[0]][l[0]]);
228
2/2
✓ Branch 0 taken 58831 times.
✓ Branch 1 taken 23263 times.
82094 if (b->bs != BS_8x4) {
229 117662 b->mode[1] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
230 58831 ff_vp9_default_kf_ymode_probs[a[1]][b->mode[0]]);
231 58831 l[0] =
232 58831 a[1] = b->mode[1];
233 } else {
234 23263 l[0] =
235 23263 a[1] =
236 23263 b->mode[1] = b->mode[0];
237 }
238
2/2
✓ Branch 0 taken 66784 times.
✓ Branch 1 taken 15310 times.
82094 if (b->bs != BS_4x8) {
239 66784 b->mode[2] =
240 133568 a[0] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
241 66784 ff_vp9_default_kf_ymode_probs[a[0]][l[1]]);
242
2/2
✓ Branch 0 taken 43521 times.
✓ Branch 1 taken 23263 times.
66784 if (b->bs != BS_8x4) {
243 87042 b->mode[3] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
244 43521 ff_vp9_default_kf_ymode_probs[a[1]][b->mode[2]]);
245 43521 l[1] =
246 43521 a[1] = b->mode[3];
247 } else {
248 23263 l[1] =
249 23263 a[1] =
250 23263 b->mode[3] = b->mode[2];
251 }
252 } else {
253 15310 b->mode[2] = b->mode[0];
254 15310 l[1] =
255 15310 a[1] =
256 15310 b->mode[3] = b->mode[1];
257 }
258 } else {
259 299430 b->mode[0] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
260 149715 ff_vp9_default_kf_ymode_probs[*a][*l]);
261 149715 b->mode[3] =
262 149715 b->mode[2] =
263 149715 b->mode[1] = b->mode[0];
264 // FIXME this can probably be optimized
265 149715 memset(a, b->mode[0], ff_vp9_bwh_tab[0][b->bs][0]);
266 149715 memset(l, b->mode[0], ff_vp9_bwh_tab[0][b->bs][1]);
267 }
268 231809 b->uvmode = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
269 231809 ff_vp9_default_kf_uvmode_probs[b->mode[3]]);
270
2/2
✓ Branch 0 taken 32265 times.
✓ Branch 1 taken 530281 times.
562546 } else if (b->intra) {
271 32265 b->comp = 0;
272
2/2
✓ Branch 0 taken 1699 times.
✓ Branch 1 taken 30566 times.
32265 if (b->bs > BS_8x8) {
273 3398 b->mode[0] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
274 1699 s->prob.p.y_mode[0]);
275 1699 td->counts.y_mode[0][b->mode[0]]++;
276
2/2
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 491 times.
1699 if (b->bs != BS_8x4) {
277 2416 b->mode[1] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
278 1208 s->prob.p.y_mode[0]);
279 1208 td->counts.y_mode[0][b->mode[1]]++;
280 } else {
281 491 b->mode[1] = b->mode[0];
282 }
283
2/2
✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 507 times.
1699 if (b->bs != BS_4x8) {
284 2384 b->mode[2] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
285 1192 s->prob.p.y_mode[0]);
286 1192 td->counts.y_mode[0][b->mode[2]]++;
287
2/2
✓ Branch 0 taken 701 times.
✓ Branch 1 taken 491 times.
1192 if (b->bs != BS_8x4) {
288 1402 b->mode[3] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
289 701 s->prob.p.y_mode[0]);
290 701 td->counts.y_mode[0][b->mode[3]]++;
291 } else {
292 491 b->mode[3] = b->mode[2];
293 }
294 } else {
295 507 b->mode[2] = b->mode[0];
296 507 b->mode[3] = b->mode[1];
297 }
298 } else {
299 static const uint8_t size_group[10] = {
300 3, 3, 3, 3, 2, 2, 2, 1, 1, 1
301 };
302 30566 int sz = size_group[b->bs];
303
304 61132 b->mode[0] = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
305 30566 s->prob.p.y_mode[sz]);
306 30566 b->mode[1] =
307 30566 b->mode[2] =
308 30566 b->mode[3] = b->mode[0];
309 30566 td->counts.y_mode[sz][b->mode[3]]++;
310 }
311 64530 b->uvmode = vp89_rac_get_tree(td->c, ff_vp9_intramode_tree,
312 32265 s->prob.p.uv_mode[b->mode[3]]);
313 32265 td->counts.uv_mode[b->mode[3]][b->uvmode]++;
314 } else {
315 static const uint8_t inter_mode_ctx_lut[14][14] = {
316 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
317 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
318 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
319 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
320 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
321 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
322 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
323 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
324 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
325 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
326 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
327 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
328 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },
329 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },
330 };
331
332
4/4
✓ Branch 0 taken 219611 times.
✓ Branch 1 taken 310670 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 218810 times.
530281 if (s->s.h.segmentation.enabled && s->s.h.segmentation.feat[b->seg_id].ref_enabled) {
333 av_assert2(s->s.h.segmentation.feat[b->seg_id].ref_val != 0);
334 801 b->comp = 0;
335 801 b->ref[0] = s->s.h.segmentation.feat[b->seg_id].ref_val - 1;
336 } else {
337 // read comp_pred flag
338
2/2
✓ Branch 0 taken 343979 times.
✓ Branch 1 taken 185501 times.
529480 if (s->s.h.comppredmode != PRED_SWITCHABLE) {
339 343979 b->comp = s->s.h.comppredmode == PRED_COMPREF;
340 } else {
341 int c;
342
343 // FIXME add intra as ref=0xff (or -1) to make these easier?
344
2/2
✓ Branch 0 taken 180588 times.
✓ Branch 1 taken 4913 times.
185501 if (have_a) {
345
2/2
✓ Branch 0 taken 177443 times.
✓ Branch 1 taken 3145 times.
180588 if (have_l) {
346
4/4
✓ Branch 0 taken 28396 times.
✓ Branch 1 taken 149047 times.
✓ Branch 2 taken 18565 times.
✓ Branch 3 taken 9831 times.
177443 if (s->above_comp_ctx[col] && td->left_comp_ctx[row7]) {
347 18565 c = 4;
348
2/2
✓ Branch 0 taken 9831 times.
✓ Branch 1 taken 149047 times.
158878 } else if (s->above_comp_ctx[col]) {
349
2/2
✓ Branch 0 taken 9720 times.
✓ Branch 1 taken 111 times.
19551 c = 2 + (td->left_intra_ctx[row7] ||
350
2/2
✓ Branch 0 taken 3853 times.
✓ Branch 1 taken 5867 times.
9720 td->left_ref_ctx[row7] == s->s.h.fixcompref);
351
2/2
✓ Branch 0 taken 8508 times.
✓ Branch 1 taken 140539 times.
149047 } else if (td->left_comp_ctx[row7]) {
352
2/2
✓ Branch 0 taken 8396 times.
✓ Branch 1 taken 112 times.
16904 c = 2 + (s->above_intra_ctx[col] ||
353
2/2
✓ Branch 0 taken 2011 times.
✓ Branch 1 taken 6385 times.
8396 s->above_ref_ctx[col] == s->s.h.fixcompref);
354 } else {
355
2/2
✓ Branch 0 taken 139661 times.
✓ Branch 1 taken 878 times.
420739 c = (!s->above_intra_ctx[col] &&
356
2/2
✓ Branch 0 taken 12783 times.
✓ Branch 1 taken 126878 times.
139661 s->above_ref_ctx[col] == s->s.h.fixcompref) ^
357
2/2
✓ Branch 0 taken 138697 times.
✓ Branch 1 taken 1842 times.
279236 (!td->left_intra_ctx[row7] &&
358
2/2
✓ Branch 0 taken 14376 times.
✓ Branch 1 taken 124321 times.
138697 td->left_ref_ctx[row & 7] == s->s.h.fixcompref);
359 }
360 } else {
361
2/2
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 287 times.
6003 c = s->above_comp_ctx[col] ? 3 :
362
4/4
✓ Branch 0 taken 2793 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 902 times.
✓ Branch 3 taken 1891 times.
2858 (!s->above_intra_ctx[col] && s->above_ref_ctx[col] == s->s.h.fixcompref);
363 }
364
2/2
✓ Branch 0 taken 4595 times.
✓ Branch 1 taken 318 times.
4913 } else if (have_l) {
365
2/2
✓ Branch 0 taken 3934 times.
✓ Branch 1 taken 661 times.
8529 c = td->left_comp_ctx[row7] ? 3 :
366
4/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1036 times.
✓ Branch 3 taken 2872 times.
3934 (!td->left_intra_ctx[row7] && td->left_ref_ctx[row7] == s->s.h.fixcompref);
367 } else {
368 318 c = 1;
369 }
370 185501 b->comp = vpx_rac_get_prob(td->c, s->prob.p.comp[c]);
371 185501 td->counts.comp[c][b->comp]++;
372 }
373
374 // read actual references
375 // FIXME probably cache a few variables here to prevent repetitive
376 // memory accesses below
377
2/2
✓ Branch 0 taken 27251 times.
✓ Branch 1 taken 502229 times.
529480 if (b->comp) { /* two references */
378 27251 int fix_idx = s->s.h.signbias[s->s.h.fixcompref], var_idx = !fix_idx, c, bit;
379
380 27251 b->ref[fix_idx] = s->s.h.fixcompref;
381 // FIXME can this codeblob be replaced by some sort of LUT?
382
2/2
✓ Branch 0 taken 26541 times.
✓ Branch 1 taken 710 times.
27251 if (have_a) {
383
2/2
✓ Branch 0 taken 26239 times.
✓ Branch 1 taken 302 times.
26541 if (have_l) {
384
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 26171 times.
26239 if (s->above_intra_ctx[col]) {
385
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 54 times.
68 if (td->left_intra_ctx[row7]) {
386 14 c = 2;
387 } else {
388
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 7 times.
54 c = 1 + 2 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
389 }
390
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 26084 times.
26171 } else if (td->left_intra_ctx[row7]) {
391
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 21 times.
87 c = 1 + 2 * (s->above_ref_ctx[col] != s->s.h.varcompref[1]);
392 } else {
393 26084 int refl = td->left_ref_ctx[row7], refa = s->above_ref_ctx[col];
394
395
4/4
✓ Branch 0 taken 21688 times.
✓ Branch 1 taken 4396 times.
✓ Branch 2 taken 2446 times.
✓ Branch 3 taken 19242 times.
26084 if (refl == refa && refa == s->s.h.varcompref[1]) {
396 2446 c = 0;
397
4/4
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 18717 times.
✓ Branch 2 taken 2175 times.
✓ Branch 3 taken 2746 times.
23638 } else if (!td->left_comp_ctx[row7] && !s->above_comp_ctx[col]) {
398
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 1455 times.
✓ Branch 2 taken 354 times.
✓ Branch 3 taken 366 times.
2175 if ((refa == s->s.h.fixcompref && refl == s->s.h.varcompref[0]) ||
399
4/4
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 1068 times.
✓ Branch 2 taken 408 times.
✓ Branch 3 taken 333 times.
1809 (refl == s->s.h.fixcompref && refa == s->s.h.varcompref[0])) {
400 774 c = 4;
401 } else {
402
2/2
✓ Branch 0 taken 1088 times.
✓ Branch 1 taken 313 times.
1401 c = (refa == refl) ? 3 : 1;
403 }
404
2/2
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 18717 times.
21463 } else if (!td->left_comp_ctx[row7]) {
405
3/4
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 2296 times.
✓ Branch 2 taken 450 times.
✗ Branch 3 not taken.
2746 if (refa == s->s.h.varcompref[1] && refl != s->s.h.varcompref[1]) {
406 450 c = 1;
407 } else {
408 2296 c = (refl == s->s.h.varcompref[1] &&
409
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 2192 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
2296 refa != s->s.h.varcompref[1]) ? 2 : 4;
410 }
411
2/2
✓ Branch 0 taken 3206 times.
✓ Branch 1 taken 15511 times.
18717 } else if (!s->above_comp_ctx[col]) {
412
3/4
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 2764 times.
✓ Branch 2 taken 442 times.
✗ Branch 3 not taken.
3206 if (refl == s->s.h.varcompref[1] && refa != s->s.h.varcompref[1]) {
413 442 c = 1;
414 } else {
415 2764 c = (refa == s->s.h.varcompref[1] &&
416
3/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 2579 times.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
2764 refl != s->s.h.varcompref[1]) ? 2 : 4;
417 }
418 } else {
419
2/2
✓ Branch 0 taken 14747 times.
✓ Branch 1 taken 764 times.
15511 c = (refl == refa) ? 4 : 2;
420 }
421 }
422 } else {
423
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 301 times.
302 if (s->above_intra_ctx[col]) {
424 1 c = 2;
425
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 171 times.
301 } else if (s->above_comp_ctx[col]) {
426
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 22 times.
130 c = 4 * (s->above_ref_ctx[col] != s->s.h.varcompref[1]);
427 } else {
428
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 15 times.
171 c = 3 * (s->above_ref_ctx[col] != s->s.h.varcompref[1]);
429 }
430 }
431
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 18 times.
710 } else if (have_l) {
432
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 688 times.
692 if (td->left_intra_ctx[row7]) {
433 4 c = 2;
434
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 279 times.
688 } else if (td->left_comp_ctx[row7]) {
435
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 115 times.
409 c = 4 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
436 } else {
437
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 37 times.
279 c = 3 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
438 }
439 } else {
440 18 c = 2;
441 }
442 27251 bit = vpx_rac_get_prob(td->c, s->prob.p.comp_ref[c]);
443 27251 b->ref[var_idx] = s->s.h.varcompref[bit];
444 27251 td->counts.comp_ref[c][bit]++;
445 } else /* single reference */ {
446 int bit, c;
447
448
4/4
✓ Branch 0 taken 477369 times.
✓ Branch 1 taken 24860 times.
✓ Branch 2 taken 465102 times.
✓ Branch 3 taken 12267 times.
502229 if (have_a && !s->above_intra_ctx[col]) {
449
4/4
✓ Branch 0 taken 450365 times.
✓ Branch 1 taken 14737 times.
✓ Branch 2 taken 439902 times.
✓ Branch 3 taken 10463 times.
465102 if (have_l && !td->left_intra_ctx[row7]) {
450
2/2
✓ Branch 0 taken 6259 times.
✓ Branch 1 taken 433643 times.
439902 if (td->left_comp_ctx[row7]) {
451
2/2
✓ Branch 0 taken 1572 times.
✓ Branch 1 taken 4687 times.
6259 if (s->above_comp_ctx[col]) {
452
3/4
✓ Branch 0 taken 1572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 1041 times.
2103 c = 1 + (!s->s.h.fixcompref || !td->left_ref_ctx[row7] ||
453
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 398 times.
531 !s->above_ref_ctx[col]);
454 } else {
455
2/2
✓ Branch 0 taken 2895 times.
✓ Branch 1 taken 1792 times.
9374 c = (3 * !s->above_ref_ctx[col]) +
456
3/4
✓ Branch 0 taken 4687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3764 times.
✓ Branch 3 taken 923 times.
4687 (!s->s.h.fixcompref || !td->left_ref_ctx[row7]);
457 }
458
2/2
✓ Branch 0 taken 6712 times.
✓ Branch 1 taken 426931 times.
433643 } else if (s->above_comp_ctx[col]) {
459
2/2
✓ Branch 0 taken 3113 times.
✓ Branch 1 taken 3599 times.
13424 c = (3 * !td->left_ref_ctx[row7]) +
460
3/4
✓ Branch 0 taken 6712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5576 times.
✓ Branch 3 taken 1136 times.
6712 (!s->s.h.fixcompref || !s->above_ref_ctx[col]);
461 } else {
462
4/4
✓ Branch 0 taken 346061 times.
✓ Branch 1 taken 80870 times.
✓ Branch 2 taken 346928 times.
✓ Branch 3 taken 80003 times.
426931 c = 2 * !td->left_ref_ctx[row7] + 2 * !s->above_ref_ctx[col];
463 }
464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25200 times.
25200 } else if (s->above_intra_ctx[col]) {
465 c = 2;
466
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 24969 times.
25200 } else if (s->above_comp_ctx[col]) {
467
3/4
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 33 times.
231 c = 1 + (!s->s.h.fixcompref || !s->above_ref_ctx[col]);
468 } else {
469
2/2
✓ Branch 0 taken 19539 times.
✓ Branch 1 taken 5430 times.
24969 c = 4 * (!s->above_ref_ctx[col]);
470 }
471
4/4
✓ Branch 0 taken 35150 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 32083 times.
✓ Branch 3 taken 3067 times.
37127 } else if (have_l && !td->left_intra_ctx[row7]) {
472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32083 times.
32083 if (td->left_intra_ctx[row7]) {
473 c = 2;
474
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 31741 times.
32083 } else if (td->left_comp_ctx[row7]) {
475
3/4
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 74 times.
342 c = 1 + (!s->s.h.fixcompref || !td->left_ref_ctx[row7]);
476 } else {
477
2/2
✓ Branch 0 taken 25659 times.
✓ Branch 1 taken 6082 times.
31741 c = 4 * (!td->left_ref_ctx[row7]);
478 }
479 } else {
480 5044 c = 2;
481 }
482 502229 bit = vpx_rac_get_prob(td->c, s->prob.p.single_ref[c][0]);
483 502229 td->counts.single_ref[c][0][bit]++;
484
2/2
✓ Branch 0 taken 401665 times.
✓ Branch 1 taken 100564 times.
502229 if (!bit) {
485 401665 b->ref[0] = 0;
486 } else {
487 // FIXME can this codeblob be replaced by some sort of LUT?
488
2/2
✓ Branch 0 taken 95463 times.
✓ Branch 1 taken 5101 times.
100564 if (have_a) {
489
2/2
✓ Branch 0 taken 92322 times.
✓ Branch 1 taken 3141 times.
95463 if (have_l) {
490
2/2
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 88931 times.
92322 if (td->left_intra_ctx[row7]) {
491
2/2
✓ Branch 0 taken 772 times.
✓ Branch 1 taken 2619 times.
3391 if (s->above_intra_ctx[col]) {
492 772 c = 2;
493
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2569 times.
2619 } else if (s->above_comp_ctx[col]) {
494
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
100 c = 1 + 2 * (s->s.h.fixcompref == 1 ||
495
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 41 times.
50 s->above_ref_ctx[col] == 1);
496
2/2
✓ Branch 0 taken 705 times.
✓ Branch 1 taken 1864 times.
2569 } else if (!s->above_ref_ctx[col]) {
497 705 c = 3;
498 } else {
499
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 339 times.
1864 c = 4 * (s->above_ref_ctx[col] == 1);
500 }
501
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 87009 times.
88931 } else if (s->above_intra_ctx[col]) {
502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1922 times.
1922 if (td->left_intra_ctx[row7]) {
503 c = 2;
504
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1877 times.
1922 } else if (td->left_comp_ctx[row7]) {
505
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
90 c = 1 + 2 * (s->s.h.fixcompref == 1 ||
506
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 39 times.
45 td->left_ref_ctx[row7] == 1);
507
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 1320 times.
1877 } else if (!td->left_ref_ctx[row7]) {
508 557 c = 3;
509 } else {
510
2/2
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 333 times.
1320 c = 4 * (td->left_ref_ctx[row7] == 1);
511 }
512
2/2
✓ Branch 0 taken 4390 times.
✓ Branch 1 taken 82619 times.
87009 } else if (s->above_comp_ctx[col]) {
513
2/2
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 3540 times.
4390 if (td->left_comp_ctx[row7]) {
514
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 121 times.
850 if (td->left_ref_ctx[row7] == s->above_ref_ctx[col]) {
515
1/2
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
1458 c = 3 * (s->s.h.fixcompref == 1 ||
516
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 402 times.
729 td->left_ref_ctx[row7] == 1);
517 } else {
518 121 c = 2;
519 }
520
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 3196 times.
3540 } else if (!td->left_ref_ctx[row7]) {
521
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
688 c = 1 + 2 * (s->s.h.fixcompref == 1 ||
522
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 272 times.
344 s->above_ref_ctx[col] == 1);
523 } else {
524
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 2556 times.
6392 c = 3 * (td->left_ref_ctx[row7] == 1) +
525
3/4
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 767 times.
✓ Branch 3 taken 2429 times.
3196 (s->s.h.fixcompref == 1 || s->above_ref_ctx[col] == 1);
526 }
527
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 80860 times.
82619 } else if (td->left_comp_ctx[row7]) {
528
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1425 times.
1759 if (!s->above_ref_ctx[col]) {
529
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
668 c = 1 + 2 * (s->s.h.fixcompref == 1 ||
530
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 262 times.
334 td->left_ref_ctx[row7] == 1);
531 } else {
532
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 913 times.
2850 c = 3 * (s->above_ref_ctx[col] == 1) +
533
3/4
✓ Branch 0 taken 1425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 569 times.
✓ Branch 3 taken 856 times.
1425 (s->s.h.fixcompref == 1 || td->left_ref_ctx[row7] == 1);
534 }
535
2/2
✓ Branch 0 taken 18227 times.
✓ Branch 1 taken 62633 times.
80860 } else if (!s->above_ref_ctx[col]) {
536
2/2
✓ Branch 0 taken 7518 times.
✓ Branch 1 taken 10709 times.
18227 if (!td->left_ref_ctx[row7]) {
537 7518 c = 3;
538 } else {
539
2/2
✓ Branch 0 taken 7063 times.
✓ Branch 1 taken 3646 times.
10709 c = 4 * (td->left_ref_ctx[row7] == 1);
540 }
541
2/2
✓ Branch 0 taken 9303 times.
✓ Branch 1 taken 53330 times.
62633 } else if (!td->left_ref_ctx[row7]) {
542
2/2
✓ Branch 0 taken 7037 times.
✓ Branch 1 taken 2266 times.
9303 c = 4 * (s->above_ref_ctx[col] == 1);
543 } else {
544
2/2
✓ Branch 0 taken 39270 times.
✓ Branch 1 taken 14060 times.
106660 c = 2 * (td->left_ref_ctx[row7] == 1) +
545
2/2
✓ Branch 0 taken 39279 times.
✓ Branch 1 taken 14051 times.
53330 2 * (s->above_ref_ctx[col] == 1);
546 }
547 } else {
548
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 69 times.
3141 if (s->above_intra_ctx[col] ||
549
4/4
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 698 times.
✓ Branch 3 taken 2269 times.
3072 (!s->above_comp_ctx[col] && !s->above_ref_ctx[col])) {
550 767 c = 2;
551
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 2269 times.
2374 } else if (s->above_comp_ctx[col]) {
552
3/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 89 times.
105 c = 3 * (s->s.h.fixcompref == 1 || s->above_ref_ctx[col] == 1);
553 } else {
554
2/2
✓ Branch 0 taken 1233 times.
✓ Branch 1 taken 1036 times.
2269 c = 4 * (s->above_ref_ctx[col] == 1);
555 }
556 }
557
2/2
✓ Branch 0 taken 4691 times.
✓ Branch 1 taken 410 times.
5101 } else if (have_l) {
558
2/2
✓ Branch 0 taken 4535 times.
✓ Branch 1 taken 156 times.
4691 if (td->left_intra_ctx[row7] ||
559
4/4
✓ Branch 0 taken 4419 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 3583 times.
4535 (!td->left_comp_ctx[row7] && !td->left_ref_ctx[row7])) {
560 992 c = 2;
561
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 3583 times.
3699 } else if (td->left_comp_ctx[row7]) {
562
3/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 63 times.
116 c = 3 * (s->s.h.fixcompref == 1 || td->left_ref_ctx[row7] == 1);
563 } else {
564
2/2
✓ Branch 0 taken 2182 times.
✓ Branch 1 taken 1401 times.
3583 c = 4 * (td->left_ref_ctx[row7] == 1);
565 }
566 } else {
567 410 c = 2;
568 }
569 100564 bit = vpx_rac_get_prob(td->c, s->prob.p.single_ref[c][1]);
570 100564 td->counts.single_ref[c][1][bit]++;
571 100564 b->ref[0] = 1 + bit;
572 }
573 }
574 }
575
576
2/2
✓ Branch 0 taken 480128 times.
✓ Branch 1 taken 50153 times.
530281 if (b->bs <= BS_8x8) {
577
4/4
✓ Branch 0 taken 214276 times.
✓ Branch 1 taken 265852 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 213475 times.
480128 if (s->s.h.segmentation.enabled && s->s.h.segmentation.feat[b->seg_id].skip_enabled) {
578 801 b->mode[0] =
579 801 b->mode[1] =
580 801 b->mode[2] =
581 801 b->mode[3] = ZEROMV;
582 } else {
583 static const uint8_t off[10] = {
584 3, 0, 0, 1, 0, 0, 0, 0, 0, 0
585 };
586
587 // FIXME this needs to use the LUT tables from find_ref_mvs
588 // because not all are -1,0/0,-1
589 479327 int c = inter_mode_ctx_lut[s->above_mode_ctx[col + off[b->bs]]]
590 479327 [td->left_mode_ctx[row7 + off[b->bs]]];
591
592 958654 b->mode[0] = vp89_rac_get_tree(td->c, ff_vp9_inter_mode_tree,
593 479327 s->prob.p.mv_mode[c]);
594 479327 b->mode[1] =
595 479327 b->mode[2] =
596 479327 b->mode[3] = b->mode[0];
597 479327 td->counts.mv_mode[c][b->mode[0] - 10]++;
598 }
599 }
600
601
2/2
✓ Branch 0 taken 428749 times.
✓ Branch 1 taken 101532 times.
530281 if (s->s.h.filtermode == FILTER_SWITCHABLE) {
602 int c;
603
604
4/4
✓ Branch 0 taken 406686 times.
✓ Branch 1 taken 22063 times.
✓ Branch 2 taken 395043 times.
✓ Branch 3 taken 11643 times.
428749 if (have_a && s->above_mode_ctx[col] >= NEARESTMV) {
605
4/4
✓ Branch 0 taken 382156 times.
✓ Branch 1 taken 12887 times.
✓ Branch 2 taken 372640 times.
✓ Branch 3 taken 9516 times.
395043 if (have_l && td->left_mode_ctx[row7] >= NEARESTMV) {
606 372640 c = s->above_filter_ctx[col] == td->left_filter_ctx[row7] ?
607
2/2
✓ Branch 0 taken 317963 times.
✓ Branch 1 taken 54677 times.
372640 td->left_filter_ctx[row7] : 3;
608 } else {
609 22403 c = s->above_filter_ctx[col];
610 }
611
4/4
✓ Branch 0 taken 32231 times.
✓ Branch 1 taken 1475 times.
✓ Branch 2 taken 29288 times.
✓ Branch 3 taken 2943 times.
33706 } else if (have_l && td->left_mode_ctx[row7] >= NEARESTMV) {
612 29288 c = td->left_filter_ctx[row7];
613 } else {
614 4418 c = 3;
615 }
616
617 428749 filter_id = vp89_rac_get_tree(td->c, ff_vp9_filter_tree,
618 428749 s->prob.p.filter[c]);
619 428749 td->counts.filter[c][filter_id]++;
620 428749 b->filter = ff_vp9_filter_lut[filter_id];
621 } else {
622 101532 b->filter = s->s.h.filtermode;
623 }
624
625
2/2
✓ Branch 0 taken 50153 times.
✓ Branch 1 taken 480128 times.
530281 if (b->bs > BS_8x8) {
626 50153 int c = inter_mode_ctx_lut[s->above_mode_ctx[col]][td->left_mode_ctx[row7]];
627
628 100306 b->mode[0] = vp89_rac_get_tree(td->c, ff_vp9_inter_mode_tree,
629 50153 s->prob.p.mv_mode[c]);
630 50153 td->counts.mv_mode[c][b->mode[0] - 10]++;
631 50153 ff_vp9_fill_mv(td, b->mv[0], b->mode[0], 0);
632
633
2/2
✓ Branch 0 taken 32766 times.
✓ Branch 1 taken 17387 times.
50153 if (b->bs != BS_8x4) {
634 65532 b->mode[1] = vp89_rac_get_tree(td->c, ff_vp9_inter_mode_tree,
635 32766 s->prob.p.mv_mode[c]);
636 32766 td->counts.mv_mode[c][b->mode[1] - 10]++;
637 32766 ff_vp9_fill_mv(td, b->mv[1], b->mode[1], 1);
638 } else {
639 17387 b->mode[1] = b->mode[0];
640 17387 AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
641 17387 AV_COPY32(&b->mv[1][1], &b->mv[0][1]);
642 }
643
644
2/2
✓ Branch 0 taken 34426 times.
✓ Branch 1 taken 15727 times.
50153 if (b->bs != BS_4x8) {
645 68852 b->mode[2] = vp89_rac_get_tree(td->c, ff_vp9_inter_mode_tree,
646 34426 s->prob.p.mv_mode[c]);
647 34426 td->counts.mv_mode[c][b->mode[2] - 10]++;
648 34426 ff_vp9_fill_mv(td, b->mv[2], b->mode[2], 2);
649
650
2/2
✓ Branch 0 taken 17039 times.
✓ Branch 1 taken 17387 times.
34426 if (b->bs != BS_8x4) {
651 34078 b->mode[3] = vp89_rac_get_tree(td->c, ff_vp9_inter_mode_tree,
652 17039 s->prob.p.mv_mode[c]);
653 17039 td->counts.mv_mode[c][b->mode[3] - 10]++;
654 17039 ff_vp9_fill_mv(td, b->mv[3], b->mode[3], 3);
655 } else {
656 17387 b->mode[3] = b->mode[2];
657 17387 AV_COPY32(&b->mv[3][0], &b->mv[2][0]);
658 17387 AV_COPY32(&b->mv[3][1], &b->mv[2][1]);
659 }
660 } else {
661 15727 b->mode[2] = b->mode[0];
662 15727 AV_COPY32(&b->mv[2][0], &b->mv[0][0]);
663 15727 AV_COPY32(&b->mv[2][1], &b->mv[0][1]);
664 15727 b->mode[3] = b->mode[1];
665 15727 AV_COPY32(&b->mv[3][0], &b->mv[1][0]);
666 15727 AV_COPY32(&b->mv[3][1], &b->mv[1][1]);
667 }
668 } else {
669 480128 ff_vp9_fill_mv(td, b->mv[0], b->mode[0], -1);
670 480128 AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
671 480128 AV_COPY32(&b->mv[2][0], &b->mv[0][0]);
672 480128 AV_COPY32(&b->mv[3][0], &b->mv[0][0]);
673 480128 AV_COPY32(&b->mv[1][1], &b->mv[0][1]);
674 480128 AV_COPY32(&b->mv[2][1], &b->mv[0][1]);
675 480128 AV_COPY32(&b->mv[3][1], &b->mv[0][1]);
676 }
677
678
2/2
✓ Branch 0 taken 27251 times.
✓ Branch 1 taken 503030 times.
530281 vref = b->ref[b->comp ? s->s.h.signbias[s->s.h.varcompref[0]] : 0];
679 }
680
681 #if HAVE_FAST_64BIT
682 #define SPLAT_CTX(var, val, n) \
683 switch (n) { \
684 case 1: var = val; break; \
685 case 2: AV_WN16A(&var, val * 0x0101); break; \
686 case 4: AV_WN32A(&var, val * 0x01010101); break; \
687 case 8: AV_WN64A(&var, val * 0x0101010101010101ULL); break; \
688 case 16: { \
689 uint64_t v64 = val * 0x0101010101010101ULL; \
690 AV_WN64A( &var, v64); \
691 AV_WN64A(&((uint8_t *) &var)[8], v64); \
692 break; \
693 } \
694 }
695 #else
696 #define SPLAT_CTX(var, val, n) \
697 switch (n) { \
698 case 1: var = val; break; \
699 case 2: AV_WN16A(&var, val * 0x0101); break; \
700 case 4: AV_WN32A(&var, val * 0x01010101); break; \
701 case 8: { \
702 uint32_t v32 = val * 0x01010101; \
703 AV_WN32A( &var, v32); \
704 AV_WN32A(&((uint8_t *) &var)[4], v32); \
705 break; \
706 } \
707 case 16: { \
708 uint32_t v32 = val * 0x01010101; \
709 AV_WN32A( &var, v32); \
710 AV_WN32A(&((uint8_t *) &var)[4], v32); \
711 AV_WN32A(&((uint8_t *) &var)[8], v32); \
712 AV_WN32A(&((uint8_t *) &var)[12], v32); \
713 break; \
714 } \
715 }
716 #endif
717
718
4/5
✓ Branch 0 taken 534276 times.
✓ Branch 1 taken 203216 times.
✓ Branch 2 taken 44207 times.
✓ Branch 3 taken 12656 times.
✗ Branch 4 not taken.
794355 switch (ff_vp9_bwh_tab[1][b->bs][0]) {
719 #define SET_CTXS(perf, dir, off, n) \
720 do { \
721 SPLAT_CTX(perf->dir##_skip_ctx[off], b->skip, n); \
722 SPLAT_CTX(perf->dir##_txfm_ctx[off], b->tx, n); \
723 SPLAT_CTX(perf->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
724 if (!s->s.h.keyframe && !s->s.h.intraonly) { \
725 SPLAT_CTX(perf->dir##_intra_ctx[off], b->intra, n); \
726 SPLAT_CTX(perf->dir##_comp_ctx[off], b->comp, n); \
727 SPLAT_CTX(perf->dir##_mode_ctx[off], b->mode[3], n); \
728 if (!b->intra) { \
729 SPLAT_CTX(perf->dir##_ref_ctx[off], vref, n); \
730 if (s->s.h.filtermode == FILTER_SWITCHABLE) { \
731 SPLAT_CTX(perf->dir##_filter_ctx[off], filter_id, n); \
732 } \
733 } \
734 } \
735 } while (0)
736
7/8
✓ Branch 0 taken 359812 times.
✓ Branch 1 taken 174464 times.
✓ Branch 2 taken 359812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 335457 times.
✓ Branch 5 taken 24355 times.
✓ Branch 6 taken 278211 times.
✓ Branch 7 taken 57246 times.
534276 case 1: SET_CTXS(s, above, col, 1); break;
737
8/8
✓ Branch 0 taken 157412 times.
✓ Branch 1 taken 45804 times.
✓ Branch 2 taken 155036 times.
✓ Branch 3 taken 2376 times.
✓ Branch 4 taken 148082 times.
✓ Branch 5 taken 6954 times.
✓ Branch 6 taken 120586 times.
✓ Branch 7 taken 27496 times.
203216 case 2: SET_CTXS(s, above, col, 2); break;
738
7/8
✓ Branch 0 taken 36364 times.
✓ Branch 1 taken 7843 times.
✓ Branch 2 taken 36364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35466 times.
✓ Branch 5 taken 898 times.
✓ Branch 6 taken 24140 times.
✓ Branch 7 taken 11326 times.
44207 case 4: SET_CTXS(s, above, col, 4); break;
739
7/8
✓ Branch 0 taken 11334 times.
✓ Branch 1 taken 1322 times.
✓ Branch 2 taken 11334 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11276 times.
✓ Branch 5 taken 58 times.
✓ Branch 6 taken 5812 times.
✓ Branch 7 taken 5464 times.
12656 case 8: SET_CTXS(s, above, col, 8); break;
740 }
741
4/5
✓ Branch 0 taken 543284 times.
✓ Branch 1 taken 196725 times.
✓ Branch 2 taken 42548 times.
✓ Branch 3 taken 11798 times.
✗ Branch 4 not taken.
794355 switch (ff_vp9_bwh_tab[1][b->bs][1]) {
742
7/8
✓ Branch 0 taken 362514 times.
✓ Branch 1 taken 180770 times.
✓ Branch 2 taken 362514 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 338685 times.
✓ Branch 5 taken 23829 times.
✓ Branch 6 taken 280926 times.
✓ Branch 7 taken 57759 times.
543284 case 1: SET_CTXS(td, left, row7, 1); break;
743
8/8
✓ Branch 0 taken 156147 times.
✓ Branch 1 taken 40578 times.
✓ Branch 2 taken 153771 times.
✓ Branch 3 taken 2376 times.
✓ Branch 4 taken 146353 times.
✓ Branch 5 taken 7418 times.
✓ Branch 6 taken 119229 times.
✓ Branch 7 taken 27124 times.
196725 case 2: SET_CTXS(td, left, row7, 2); break;
744
7/8
✓ Branch 0 taken 35618 times.
✓ Branch 1 taken 6930 times.
✓ Branch 2 taken 35618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34651 times.
✓ Branch 5 taken 967 times.
✓ Branch 6 taken 23574 times.
✓ Branch 7 taken 11077 times.
42548 case 4: SET_CTXS(td, left, row7, 4); break;
745
7/8
✓ Branch 0 taken 10643 times.
✓ Branch 1 taken 1155 times.
✓ Branch 2 taken 10643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10592 times.
✓ Branch 5 taken 51 times.
✓ Branch 6 taken 5020 times.
✓ Branch 7 taken 5572 times.
11798 case 8: SET_CTXS(td, left, row7, 8); break;
746 }
747 #undef SPLAT_CTX
748 #undef SET_CTXS
749
750
4/4
✓ Branch 0 taken 564922 times.
✓ Branch 1 taken 229433 times.
✓ Branch 2 taken 562546 times.
✓ Branch 3 taken 2376 times.
794355 if (!s->s.h.keyframe && !s->s.h.intraonly) {
751
2/2
✓ Branch 0 taken 51852 times.
✓ Branch 1 taken 510694 times.
562546 if (b->bs > BS_8x8) {
752 51852 int mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
753
754 51852 AV_COPY32(&td->left_mv_ctx[row7 * 2 + 0][0], &b->mv[1][0]);
755 51852 AV_COPY32(&td->left_mv_ctx[row7 * 2 + 0][1], &b->mv[1][1]);
756 51852 AV_WN32A(&td->left_mv_ctx[row7 * 2 + 1][0], mv0);
757 51852 AV_WN32A(&td->left_mv_ctx[row7 * 2 + 1][1], mv1);
758 51852 AV_COPY32(&s->above_mv_ctx[col * 2 + 0][0], &b->mv[2][0]);
759 51852 AV_COPY32(&s->above_mv_ctx[col * 2 + 0][1], &b->mv[2][1]);
760 51852 AV_WN32A(&s->above_mv_ctx[col * 2 + 1][0], mv0);
761 51852 AV_WN32A(&s->above_mv_ctx[col * 2 + 1][1], mv1);
762 } else {
763 510694 int n, mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
764
765
2/2
✓ Branch 0 taken 1707518 times.
✓ Branch 1 taken 510694 times.
2218212 for (n = 0; n < w4 * 2; n++) {
766 1707518 AV_WN32A(&s->above_mv_ctx[col * 2 + n][0], mv0);
767 1707518 AV_WN32A(&s->above_mv_ctx[col * 2 + n][1], mv1);
768 }
769
2/2
✓ Branch 0 taken 1687246 times.
✓ Branch 1 taken 510694 times.
2197940 for (n = 0; n < h4 * 2; n++) {
770 1687246 AV_WN32A(&td->left_mv_ctx[row7 * 2 + n][0], mv0);
771 1687246 AV_WN32A(&td->left_mv_ctx[row7 * 2 + n][1], mv1);
772 }
773 }
774 }
775
776 // FIXME kinda ugly
777
2/2
✓ Branch 0 taken 1198603 times.
✓ Branch 1 taken 794355 times.
1992958 for (y = 0; y < h4; y++) {
778 1198603 int x, o = (row + y) * s->sb_cols * 8 + col;
779 1198603 VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[o];
780
781
2/2
✓ Branch 0 taken 346001 times.
✓ Branch 1 taken 852602 times.
1198603 if (b->intra) {
782
2/2
✓ Branch 0 taken 596906 times.
✓ Branch 1 taken 346001 times.
942907 for (x = 0; x < w4; x++) {
783 596906 mv[x].ref[0] =
784 596906 mv[x].ref[1] = -1;
785 }
786
2/2
✓ Branch 0 taken 52951 times.
✓ Branch 1 taken 799651 times.
852602 } else if (b->comp) {
787
2/2
✓ Branch 0 taken 153979 times.
✓ Branch 1 taken 52951 times.
206930 for (x = 0; x < w4; x++) {
788 153979 mv[x].ref[0] = b->ref[0];
789 153979 mv[x].ref[1] = b->ref[1];
790 153979 AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
791 153979 AV_COPY32(&mv[x].mv[1], &b->mv[3][1]);
792 }
793 } else {
794
2/2
✓ Branch 0 taken 1950526 times.
✓ Branch 1 taken 799651 times.
2750177 for (x = 0; x < w4; x++) {
795 1950526 mv[x].ref[0] = b->ref[0];
796 1950526 mv[x].ref[1] = -1;
797 1950526 AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
798 }
799 }
800 }
801 794355 }
802
803 // FIXME merge cnt/eob arguments?
804 static av_always_inline int
805 2008797 decode_coeffs_b_generic(VPXRangeCoder *c, int16_t *coef, int n_coeffs,
806 int is_tx32x32, int is8bitsperpixel, int bpp, unsigned (*cnt)[6][3],
807 unsigned (*eob)[6][2], const uint8_t (*p)[6][11],
808 int nnz, const int16_t *scan, const int16_t (*nb)[2],
809 const int16_t *band_counts, const int16_t *qmul)
810 {
811 2008797 int i = 0, band = 0, band_left = band_counts[band];
812 2008797 const uint8_t *tp = p[0][nnz];
813 uint8_t cache[1024];
814
815 do {
816 int val, rc;
817
818 10709664 val = vpx_rac_get_prob_branchy(c, tp[0]); // eob
819 10709664 eob[band][nnz][val]++;
820
2/2
✓ Branch 0 taken 1949979 times.
✓ Branch 1 taken 8759685 times.
10709664 if (!val)
821 1949979 break;
822
823 8759685 skip_eob:
824
2/2
✓ Branch 1 taken 8658157 times.
✓ Branch 2 taken 8759685 times.
17417842 if (!vpx_rac_get_prob_branchy(c, tp[1])) { // zero
825 8658157 cnt[band][nnz][0]++;
826
2/2
✓ Branch 0 taken 1199422 times.
✓ Branch 1 taken 7458735 times.
8658157 if (!--band_left)
827 1199422 band_left = band_counts[++band];
828 8658157 cache[scan[i]] = 0;
829 8658157 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
830 8658157 tp = p[band][nnz];
831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8658157 times.
8658157 if (++i == n_coeffs)
832 break; //invalid input; blocks should end with EOB
833 8658157 goto skip_eob;
834 }
835
836 8759685 rc = scan[i];
837
2/2
✓ Branch 1 taken 4990353 times.
✓ Branch 2 taken 3769332 times.
8759685 if (!vpx_rac_get_prob_branchy(c, tp[2])) { // one
838 4990353 cnt[band][nnz][1]++;
839 4990353 val = 1;
840 4990353 cache[rc] = 1;
841 } else {
842 3769332 cnt[band][nnz][2]++;
843
2/2
✓ Branch 1 taken 2500066 times.
✓ Branch 2 taken 1269266 times.
3769332 if (!vpx_rac_get_prob_branchy(c, tp[3])) { // 2, 3, 4
844
2/2
✓ Branch 1 taken 1427065 times.
✓ Branch 2 taken 1073001 times.
2500066 if (!vpx_rac_get_prob_branchy(c, tp[4])) {
845 1427065 cache[rc] = val = 2;
846 } else {
847 1073001 val = 3 + vpx_rac_get_prob(c, tp[5]);
848 1073001 cache[rc] = 3;
849 }
850
2/2
✓ Branch 1 taken 799322 times.
✓ Branch 2 taken 469944 times.
1269266 } else if (!vpx_rac_get_prob_branchy(c, tp[6])) { // cat1/2
851 799322 cache[rc] = 4;
852
2/2
✓ Branch 1 taken 427564 times.
✓ Branch 2 taken 371758 times.
799322 if (!vpx_rac_get_prob_branchy(c, tp[7])) {
853 427564 val = vpx_rac_get_prob(c, 159) + 5;
854 } else {
855 371758 val = (vpx_rac_get_prob(c, 165) << 1) + 7;
856 371758 val += vpx_rac_get_prob(c, 145);
857 }
858 } else { // cat 3-6
859 469944 cache[rc] = 5;
860
2/2
✓ Branch 1 taken 391116 times.
✓ Branch 2 taken 78828 times.
469944 if (!vpx_rac_get_prob_branchy(c, tp[8])) {
861
2/2
✓ Branch 1 taken 252912 times.
✓ Branch 2 taken 138204 times.
391116 if (!vpx_rac_get_prob_branchy(c, tp[9])) {
862 252912 val = 11 + (vpx_rac_get_prob(c, 173) << 2);
863 252912 val += (vpx_rac_get_prob(c, 148) << 1);
864 252912 val += vpx_rac_get_prob(c, 140);
865 } else {
866 138204 val = 19 + (vpx_rac_get_prob(c, 176) << 3);
867 138204 val += (vpx_rac_get_prob(c, 155) << 2);
868 138204 val += (vpx_rac_get_prob(c, 140) << 1);
869 138204 val += vpx_rac_get_prob(c, 135);
870 }
871
2/2
✓ Branch 1 taken 57604 times.
✓ Branch 2 taken 21224 times.
78828 } else if (!vpx_rac_get_prob_branchy(c, tp[10])) {
872 57604 val = (vpx_rac_get_prob(c, 180) << 4) + 35;
873 57604 val += (vpx_rac_get_prob(c, 157) << 3);
874 57604 val += (vpx_rac_get_prob(c, 141) << 2);
875 57604 val += (vpx_rac_get_prob(c, 134) << 1);
876 57604 val += vpx_rac_get_prob(c, 130);
877 } else {
878 21224 val = 67;
879
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 21143 times.
21224 if (!is8bitsperpixel) {
880
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 21 times.
81 if (bpp == 12) {
881 60 val += vpx_rac_get_prob(c, 255) << 17;
882 60 val += vpx_rac_get_prob(c, 255) << 16;
883 }
884 81 val += (vpx_rac_get_prob(c, 255) << 15);
885 81 val += (vpx_rac_get_prob(c, 255) << 14);
886 }
887 21224 val += (vpx_rac_get_prob(c, 254) << 13);
888 21224 val += (vpx_rac_get_prob(c, 254) << 12);
889 21224 val += (vpx_rac_get_prob(c, 254) << 11);
890 21224 val += (vpx_rac_get_prob(c, 252) << 10);
891 21224 val += (vpx_rac_get_prob(c, 249) << 9);
892 21224 val += (vpx_rac_get_prob(c, 243) << 8);
893 21224 val += (vpx_rac_get_prob(c, 230) << 7);
894 21224 val += (vpx_rac_get_prob(c, 196) << 6);
895 21224 val += (vpx_rac_get_prob(c, 177) << 5);
896 21224 val += (vpx_rac_get_prob(c, 153) << 4);
897 21224 val += (vpx_rac_get_prob(c, 140) << 3);
898 21224 val += (vpx_rac_get_prob(c, 133) << 2);
899 21224 val += (vpx_rac_get_prob(c, 130) << 1);
900 21224 val += vpx_rac_get_prob(c, 129);
901 }
902 }
903 }
904 #define STORE_COEF(c, i, v) do { \
905 if (is8bitsperpixel) { \
906 c[i] = v; \
907 } else { \
908 AV_WN32A(&c[i * 2], v); \
909 } \
910 } while (0)
911
2/2
✓ Branch 0 taken 2181998 times.
✓ Branch 1 taken 6577687 times.
8759685 if (!--band_left)
912 2181998 band_left = band_counts[++band];
913
2/2
✓ Branch 0 taken 1366404 times.
✓ Branch 1 taken 7393281 times.
8759685 if (is_tx32x32)
914
10/10
✓ Branch 0 taken 1311420 times.
✓ Branch 1 taken 54984 times.
✓ Branch 3 taken 662969 times.
✓ Branch 4 taken 648451 times.
✓ Branch 5 taken 1299975 times.
✓ Branch 6 taken 11445 times.
✓ Branch 8 taken 26842 times.
✓ Branch 9 taken 28142 times.
✓ Branch 10 taken 54874 times.
✓ Branch 11 taken 110 times.
1366404 STORE_COEF(coef, rc, (int)((vp89_rac_get(c) ? -val : val) * (unsigned)qmul[!!i]) / 2);
915 else
916
10/10
✓ Branch 0 taken 6871870 times.
✓ Branch 1 taken 521411 times.
✓ Branch 3 taken 3445731 times.
✓ Branch 4 taken 3426139 times.
✓ Branch 5 taken 6074311 times.
✓ Branch 6 taken 797559 times.
✓ Branch 8 taken 260973 times.
✓ Branch 9 taken 260438 times.
✓ Branch 10 taken 470514 times.
✓ Branch 11 taken 50897 times.
7393281 STORE_COEF(coef, rc, (vp89_rac_get(c) ? -val : val) * (unsigned)qmul[!!i]);
917 8759685 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
918 8759685 tp = p[band][nnz];
919
2/2
✓ Branch 0 taken 8700867 times.
✓ Branch 1 taken 58818 times.
8759685 } while (++i < n_coeffs);
920
921 2008797 return i;
922 }
923
924 1886053 static int decode_coeffs_b_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
925 unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
926 const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
927 const int16_t (*nb)[2], const int16_t *band_counts,
928 const int16_t *qmul)
929 {
930 1886053 return decode_coeffs_b_generic(td->c, coef, n_coeffs, 0, 1, 8, cnt, eob, p,
931 nnz, scan, nb, band_counts, qmul);
932 }
933
934 13609 static int decode_coeffs_b32_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
935 unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
936 const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
937 const int16_t (*nb)[2], const int16_t *band_counts,
938 const int16_t *qmul)
939 {
940 13609 return decode_coeffs_b_generic(td->c, coef, n_coeffs, 1, 1, 8, cnt, eob, p,
941 nnz, scan, nb, band_counts, qmul);
942 }
943
944 109020 static int decode_coeffs_b_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
945 unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
946 const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
947 const int16_t (*nb)[2], const int16_t *band_counts,
948 const int16_t *qmul)
949 {
950 109020 return decode_coeffs_b_generic(td->c, coef, n_coeffs, 0, 0, td->s->s.h.bpp, cnt, eob, p,
951 nnz, scan, nb, band_counts, qmul);
952 }
953
954 115 static int decode_coeffs_b32_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
955 unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
956 const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
957 const int16_t (*nb)[2], const int16_t *band_counts,
958 const int16_t *qmul)
959 {
960 115 return decode_coeffs_b_generic(td->c, coef, n_coeffs, 1, 0, td->s->s.h.bpp, cnt, eob, p,
961 nnz, scan, nb, band_counts, qmul);
962 }
963
964 369105 static av_always_inline int decode_coeffs(VP9TileData *td, int is8bitsperpixel)
965 {
966 369105 const VP9Context *s = td->s;
967 369105 VP9Block *b = td->b;
968 369105 int row = td->row, col = td->col;
969 369105 const uint8_t (*p)[6][11] = s->prob.coef[b->tx][0 /* y */][!b->intra];
970 369105 unsigned (*c)[6][3] = td->counts.coef[b->tx][0 /* y */][!b->intra];
971 369105 unsigned (*e)[6][2] = td->counts.eob[b->tx][0 /* y */][!b->intra];
972 369105 int w4 = ff_vp9_bwh_tab[1][b->bs][0] << 1, h4 = ff_vp9_bwh_tab[1][b->bs][1] << 1;
973 369105 int end_x = FFMIN(2 * (s->cols - col), w4);
974 369105 int end_y = FFMIN(2 * (s->rows - row), h4);
975 int n, pl, x, y, ret;
976 369105 const int16_t (*qmul)[2] = s->s.h.segmentation.feat[b->seg_id].qmul;
977 369105 int tx = 4 * s->s.h.lossless + b->tx;
978 369105 const int16_t * const *yscans = ff_vp9_scans[tx];
979 369105 const int16_t (* const * ynbs)[2] = ff_vp9_scans_nb[tx];
980 369105 const int16_t *uvscan = ff_vp9_scans[b->uvtx][DCT_DCT];
981 369105 const int16_t (*uvnb)[2] = ff_vp9_scans_nb[b->uvtx][DCT_DCT];
982 369105 uint8_t *a = &s->above_y_nnz_ctx[col * 2];
983 369105 uint8_t *l = &td->left_y_nnz_ctx[(row & 7) << 1];
984 static const int16_t band_counts[4][8] = {
985 { 1, 2, 3, 4, 3, 16 - 13 },
986 { 1, 2, 3, 4, 11, 64 - 21 },
987 { 1, 2, 3, 4, 11, 256 - 21 },
988 { 1, 2, 3, 4, 11, 1024 - 21 },
989 };
990 369105 const int16_t *y_band_counts = band_counts[b->tx];
991 369105 const int16_t *uv_band_counts = band_counts[b->uvtx];
992
2/2
✓ Branch 0 taken 354840 times.
✓ Branch 1 taken 14265 times.
369105 int bytesperpixel = is8bitsperpixel ? 1 : 2;
993 369105 int total_coeff = 0;
994
995 #define MERGE(la, end, step, rd) \
996 for (n = 0; n < end; n += step) \
997 la[n] = !!rd(&la[n])
998 #define MERGE_CTX(step, rd) \
999 do { \
1000 MERGE(l, end_y, step, rd); \
1001 MERGE(a, end_x, step, rd); \
1002 } while (0)
1003
1004 #define DECODE_Y_COEF_LOOP(step, mode_index, v) \
1005 for (n = 0, y = 0; y < end_y; y += step) { \
1006 for (x = 0; x < end_x; x += step, n += step * step) { \
1007 enum TxfmType txtp = ff_vp9_intra_txfm_type[b->mode[mode_index]]; \
1008 ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
1009 (td, td->block + 16 * n * bytesperpixel, 16 * step * step, \
1010 c, e, p, a[x] + l[y], yscans[txtp], \
1011 ynbs[txtp], y_band_counts, qmul[0]); \
1012 a[x] = l[y] = !!ret; \
1013 total_coeff |= !!ret; \
1014 if (step >= 4) { \
1015 AV_WN16A(&td->eob[n], ret); \
1016 } else { \
1017 td->eob[n] = ret; \
1018 } \
1019 } \
1020 }
1021
1022 #define SPLAT(la, end, step, cond) \
1023 if (step == 2) { \
1024 for (n = 1; n < end; n += step) \
1025 la[n] = la[n - 1]; \
1026 } else if (step == 4) { \
1027 if (cond) { \
1028 for (n = 0; n < end; n += step) \
1029 AV_WN32A(&la[n], la[n] * 0x01010101); \
1030 } else { \
1031 for (n = 0; n < end; n += step) \
1032 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
1033 } \
1034 } else /* step == 8 */ { \
1035 if (cond) { \
1036 if (HAVE_FAST_64BIT) { \
1037 for (n = 0; n < end; n += step) \
1038 AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
1039 } else { \
1040 for (n = 0; n < end; n += step) { \
1041 uint32_t v32 = la[n] * 0x01010101; \
1042 AV_WN32A(&la[n], v32); \
1043 AV_WN32A(&la[n + 4], v32); \
1044 } \
1045 } \
1046 } else { \
1047 for (n = 0; n < end; n += step) \
1048 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
1049 } \
1050 }
1051 #define SPLAT_CTX(step) \
1052 do { \
1053 SPLAT(a, end_x, step, end_x == w4); \
1054 SPLAT(l, end_y, step, end_y == h4); \
1055 } while (0)
1056
1057 /* y tokens */
1058
4/5
✓ Branch 0 taken 181055 times.
✓ Branch 1 taken 140799 times.
✓ Branch 2 taken 38650 times.
✓ Branch 3 taken 8601 times.
✗ Branch 4 not taken.
369105 switch (b->tx) {
1059 181055 case TX_4X4:
1060
8/8
✓ Branch 0 taken 479660 times.
✓ Branch 1 taken 344432 times.
✓ Branch 2 taken 782344 times.
✓ Branch 3 taken 41748 times.
✓ Branch 5 taken 824092 times.
✓ Branch 6 taken 381022 times.
✓ Branch 7 taken 381022 times.
✓ Branch 8 taken 181055 times.
1386169 DECODE_Y_COEF_LOOP(1, b->bs > BS_8x8 ? n : 0,);
1061 181055 break;
1062 140799 case TX_8X8:
1063
4/4
✓ Branch 0 taken 167640 times.
✓ Branch 1 taken 140799 times.
✓ Branch 2 taken 170349 times.
✓ Branch 3 taken 140799 times.
478788 MERGE_CTX(2, AV_RN16A);
1064
6/6
✓ Branch 0 taken 229615 times.
✓ Branch 1 taken 5232 times.
✓ Branch 3 taken 234847 times.
✓ Branch 4 taken 167640 times.
✓ Branch 5 taken 167640 times.
✓ Branch 6 taken 140799 times.
543286 DECODE_Y_COEF_LOOP(2, 0,);
1065
4/4
✓ Branch 0 taken 170349 times.
✓ Branch 1 taken 140799 times.
✓ Branch 2 taken 167640 times.
✓ Branch 3 taken 140799 times.
478788 SPLAT_CTX(2);
1066 140799 break;
1067 38650 case TX_16X16:
1068
4/4
✓ Branch 0 taken 40832 times.
✓ Branch 1 taken 38650 times.
✓ Branch 2 taken 41075 times.
✓ Branch 3 taken 38650 times.
120557 MERGE_CTX(4, AV_RN32A);
1069
6/6
✓ Branch 0 taken 43840 times.
✓ Branch 1 taken 438 times.
✓ Branch 3 taken 44278 times.
✓ Branch 4 taken 40832 times.
✓ Branch 5 taken 40832 times.
✓ Branch 6 taken 38650 times.
123760 DECODE_Y_COEF_LOOP(4, 0,);
1070
12/12
✓ Branch 0 taken 38636 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 41061 times.
✓ Branch 3 taken 38636 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 38593 times.
✓ Branch 7 taken 57 times.
✓ Branch 8 taken 40774 times.
✓ Branch 9 taken 38593 times.
✓ Branch 10 taken 58 times.
✓ Branch 11 taken 57 times.
120557 SPLAT_CTX(4);
1071 38650 break;
1072 8601 case TX_32X32:
1073
4/4
✓ Branch 0 taken 9665 times.
✓ Branch 1 taken 8601 times.
✓ Branch 2 taken 9789 times.
✓ Branch 3 taken 8601 times.
28055 MERGE_CTX(8, AV_RN64A);
1074
6/6
✓ Branch 0 taken 11659 times.
✓ Branch 1 taken 69 times.
✓ Branch 3 taken 11728 times.
✓ Branch 4 taken 9665 times.
✓ Branch 5 taken 9665 times.
✓ Branch 6 taken 8601 times.
29994 DECODE_Y_COEF_LOOP(8, 0, 32);
1075
12/12
✓ Branch 0 taken 8593 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 9781 times.
✓ Branch 3 taken 8593 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 8529 times.
✓ Branch 7 taken 72 times.
✓ Branch 8 taken 9591 times.
✓ Branch 9 taken 8529 times.
✓ Branch 10 taken 74 times.
✓ Branch 11 taken 72 times.
28055 SPLAT_CTX(8);
1076 8601 break;
1077 }
1078
1079 #define DECODE_UV_COEF_LOOP(step, v) \
1080 for (n = 0, y = 0; y < end_y; y += step) { \
1081 for (x = 0; x < end_x; x += step, n += step * step) { \
1082 ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
1083 (td, td->uvblock[pl] + 16 * n * bytesperpixel, \
1084 16 * step * step, c, e, p, a[x] + l[y], \
1085 uvscan, uvnb, uv_band_counts, qmul[1]); \
1086 a[x] = l[y] = !!ret; \
1087 total_coeff |= !!ret; \
1088 if (step >= 4) { \
1089 AV_WN16A(&td->uveob[pl][n], ret); \
1090 } else { \
1091 td->uveob[pl][n] = ret; \
1092 } \
1093 } \
1094 }
1095
1096 369105 p = s->prob.coef[b->uvtx][1 /* uv */][!b->intra];
1097 369105 c = td->counts.coef[b->uvtx][1 /* uv */][!b->intra];
1098 369105 e = td->counts.eob[b->uvtx][1 /* uv */][!b->intra];
1099 369105 w4 >>= s->ss_h;
1100 369105 end_x >>= s->ss_h;
1101 369105 h4 >>= s->ss_v;
1102 369105 end_y >>= s->ss_v;
1103
2/2
✓ Branch 0 taken 738210 times.
✓ Branch 1 taken 369105 times.
1107315 for (pl = 0; pl < 2; pl++) {
1104 738210 a = &s->above_uv_nnz_ctx[pl][col << !s->ss_h];
1105 738210 l = &td->left_uv_nnz_ctx[pl][(row & 7) << !s->ss_v];
1106
4/5
✓ Branch 0 taken 612562 times.
✓ Branch 1 taken 105450 times.
✓ Branch 2 taken 18230 times.
✓ Branch 3 taken 1968 times.
✗ Branch 4 not taken.
738210 switch (b->uvtx) {
1107 612562 case TX_4X4:
1108
6/6
✓ Branch 0 taken 683478 times.
✓ Branch 1 taken 57964 times.
✓ Branch 3 taken 741442 times.
✓ Branch 4 taken 662022 times.
✓ Branch 5 taken 662022 times.
✓ Branch 6 taken 612562 times.
2016026 DECODE_UV_COEF_LOOP(1,);
1109 612562 break;
1110 105450 case TX_8X8:
1111
4/4
✓ Branch 0 taken 113522 times.
✓ Branch 1 taken 105450 times.
✓ Branch 2 taken 114542 times.
✓ Branch 3 taken 105450 times.
333514 MERGE_CTX(2, AV_RN16A);
1112
6/6
✓ Branch 0 taken 127498 times.
✓ Branch 1 taken 3300 times.
✓ Branch 3 taken 130798 times.
✓ Branch 4 taken 113522 times.
✓ Branch 5 taken 113522 times.
✓ Branch 6 taken 105450 times.
349770 DECODE_UV_COEF_LOOP(2,);
1113
4/4
✓ Branch 0 taken 114466 times.
✓ Branch 1 taken 105450 times.
✓ Branch 2 taken 113262 times.
✓ Branch 3 taken 105450 times.
333178 SPLAT_CTX(2);
1114 105450 break;
1115 18230 case TX_16X16:
1116
4/4
✓ Branch 0 taken 18702 times.
✓ Branch 1 taken 18230 times.
✓ Branch 2 taken 19114 times.
✓ Branch 3 taken 18230 times.
56046 MERGE_CTX(4, AV_RN32A);
1117
6/6
✓ Branch 0 taken 19278 times.
✓ Branch 1 taken 338 times.
✓ Branch 3 taken 19616 times.
✓ Branch 4 taken 18702 times.
✓ Branch 5 taken 18702 times.
✓ Branch 6 taken 18230 times.
56548 DECODE_UV_COEF_LOOP(4,);
1118
12/12
✓ Branch 0 taken 18214 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 19098 times.
✓ Branch 3 taken 18214 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 18068 times.
✓ Branch 7 taken 162 times.
✓ Branch 8 taken 18540 times.
✓ Branch 9 taken 18068 times.
✓ Branch 10 taken 162 times.
✓ Branch 11 taken 162 times.
56046 SPLAT_CTX(4);
1119 18230 break;
1120 1968 case TX_32X32:
1121
4/4
✓ Branch 0 taken 1978 times.
✓ Branch 1 taken 1968 times.
✓ Branch 2 taken 1984 times.
✓ Branch 3 taken 1968 times.
5930 MERGE_CTX(8, AV_RN64A);
1122
6/6
✓ Branch 0 taken 1950 times.
✓ Branch 1 taken 46 times.
✓ Branch 3 taken 1996 times.
✓ Branch 4 taken 1978 times.
✓ Branch 5 taken 1978 times.
✓ Branch 6 taken 1968 times.
5942 DECODE_UV_COEF_LOOP(8, 32);
1123
9/12
✓ Branch 0 taken 1968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1984 times.
✓ Branch 3 taken 1968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1964 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1974 times.
✓ Branch 9 taken 1964 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
5930 SPLAT_CTX(8);
1124 1968 break;
1125 }
1126 }
1127
1128 369105 return total_coeff;
1129 }
1130
1131 354840 static int decode_coeffs_8bpp(VP9TileData *td)
1132 {
1133 354840 return decode_coeffs(td, 1);
1134 }
1135
1136 14265 static int decode_coeffs_16bpp(VP9TileData *td)
1137 {
1138 14265 return decode_coeffs(td, 0);
1139 }
1140
1141 1518652 static av_always_inline void mask_edges(uint8_t (*mask)[8][4], int ss_h, int ss_v,
1142 int row_and_7, int col_and_7,
1143 int w, int h, int col_end, int row_end,
1144 enum TxfmMode tx, int skip_inter)
1145 {
1146 static const unsigned wide_filter_col_mask[2] = { 0x11, 0x01 };
1147 static const unsigned wide_filter_row_mask[2] = { 0x03, 0x07 };
1148
1149 // FIXME I'm pretty sure all loops can be replaced by a single LUT if
1150 // we make VP9Filter.mask uint64_t (i.e. row/col all single variable)
1151 // and make the LUT 5-indexed (bl, bp, is_uv, tx and row/col), and then
1152 // use row_and_7/col_and_7 as shifts (1*col_and_7+8*row_and_7)
1153
1154 // the intended behaviour of the vp9 loopfilter is to work on 8-pixel
1155 // edges. This means that for UV, we work on two subsampled blocks at
1156 // a time, and we only use the topleft block's mode information to set
1157 // things like block strength. Thus, for any block size smaller than
1158 // 16x16, ignore the odd portion of the block.
1159
4/4
✓ Branch 0 taken 742279 times.
✓ Branch 1 taken 776373 times.
✓ Branch 2 taken 556595 times.
✓ Branch 3 taken 185684 times.
1518652 if (tx == TX_4X4 && (ss_v | ss_h)) {
1160
2/2
✓ Branch 0 taken 508703 times.
✓ Branch 1 taken 47892 times.
556595 if (h == ss_v) {
1161
2/2
✓ Branch 0 taken 252222 times.
✓ Branch 1 taken 256481 times.
508703 if (row_and_7 & 1)
1162 252222 return;
1163
2/2
✓ Branch 0 taken 252221 times.
✓ Branch 1 taken 4260 times.
256481 if (!row_end)
1164 252221 h += 1;
1165 }
1166
2/2
✓ Branch 0 taken 272739 times.
✓ Branch 1 taken 31634 times.
304373 if (w == ss_h) {
1167
2/2
✓ Branch 0 taken 131273 times.
✓ Branch 1 taken 141466 times.
272739 if (col_and_7 & 1)
1168 131273 return;
1169
2/2
✓ Branch 0 taken 131273 times.
✓ Branch 1 taken 10193 times.
141466 if (!col_end)
1170 131273 w += 1;
1171 }
1172 }
1173
1174
4/4
✓ Branch 0 taken 358784 times.
✓ Branch 1 taken 776373 times.
✓ Branch 2 taken 268698 times.
✓ Branch 3 taken 90086 times.
1403855 if (tx == TX_4X4 && !skip_inter) {
1175 268698 int t = 1 << col_and_7, m_col = (t << w) - t, y;
1176 // on 32-px edges, use the 8-px wide loopfilter; else, use 4-px wide
1177 268698 int m_row_8 = m_col & wide_filter_col_mask[ss_h], m_row_4 = m_col - m_row_8;
1178
1179
2/2
✓ Branch 0 taken 372119 times.
✓ Branch 1 taken 268698 times.
640817 for (y = row_and_7; y < h + row_and_7; y++) {
1180
2/2
✓ Branch 0 taken 83465 times.
✓ Branch 1 taken 288654 times.
372119 int col_mask_id = 2 - !(y & wide_filter_row_mask[ss_v]);
1181
1182 372119 mask[0][y][1] |= m_row_8;
1183 372119 mask[0][y][2] |= m_row_4;
1184 // for odd lines, if the odd col is not being filtered,
1185 // skip odd row also:
1186 // .---. <-- a
1187 // | |
1188 // |___| <-- b
1189 // ^ ^
1190 // c d
1191 //
1192 // if a/c are even row/col and b/d are odd, and d is skipped,
1193 // e.g. right edge of size-66x66.webm, then skip b also (bug)
1194
6/6
✓ Branch 0 taken 178794 times.
✓ Branch 1 taken 193325 times.
✓ Branch 2 taken 8637 times.
✓ Branch 3 taken 170157 times.
✓ Branch 4 taken 4224 times.
✓ Branch 5 taken 4413 times.
372119 if ((ss_h & ss_v) && (col_end & 1) && (y & 1)) {
1195 4224 mask[1][y][col_mask_id] |= (t << (w - 1)) - t;
1196 } else {
1197 367895 mask[1][y][col_mask_id] |= m_col;
1198 }
1199
2/2
✓ Branch 0 taken 191159 times.
✓ Branch 1 taken 180960 times.
372119 if (!ss_h)
1200 191159 mask[0][y][3] |= m_col;
1201
2/2
✓ Branch 0 taken 185437 times.
✓ Branch 1 taken 186682 times.
372119 if (!ss_v) {
1202
3/4
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 183271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2166 times.
185437 if (ss_h && (col_end & 1))
1203 mask[1][y][3] |= (t << (w - 1)) - t;
1204 else
1205 185437 mask[1][y][3] |= m_col;
1206 }
1207 }
1208 } else {
1209 866459 int y, t = 1 << col_and_7, m_col = (t << w) - t;
1210
1211
2/2
✓ Branch 0 taken 263173 times.
✓ Branch 1 taken 603286 times.
866459 if (!skip_inter) {
1212 263173 int mask_id = (tx == TX_8X8);
1213 263173 int l2 = tx + ss_h - 1, step1d;
1214 static const unsigned masks[4] = { 0xff, 0x55, 0x11, 0x01 };
1215 263173 int m_row = m_col & masks[l2];
1216
1217 // at odd UV col/row edges tx16/tx32 loopfilter edges, force
1218 // 8wd loopfilter to prevent going off the visible edge.
1219
6/6
✓ Branch 0 taken 60122 times.
✓ Branch 1 taken 203051 times.
✓ Branch 2 taken 9189 times.
✓ Branch 3 taken 50933 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 9181 times.
263181 if (ss_h && tx > TX_8X8 && (w ^ (w - 1)) == 1) {
1220 8 int m_row_16 = ((t << (w - 1)) - t) & masks[l2];
1221 8 int m_row_8 = m_row - m_row_16;
1222
1223
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 8 times.
60 for (y = row_and_7; y < h + row_and_7; y++) {
1224 52 mask[0][y][0] |= m_row_16;
1225 52 mask[0][y][1] |= m_row_8;
1226 }
1227 } else {
1228
2/2
✓ Branch 0 taken 451948 times.
✓ Branch 1 taken 263165 times.
715113 for (y = row_and_7; y < h + row_and_7; y++)
1229 451948 mask[0][y][mask_id] |= m_row;
1230 }
1231
1232 263173 l2 = tx + ss_v - 1;
1233 263173 step1d = 1 << l2;
1234
6/6
✓ Branch 0 taken 60347 times.
✓ Branch 1 taken 202826 times.
✓ Branch 2 taken 9268 times.
✓ Branch 3 taken 51079 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 9189 times.
263173 if (ss_v && tx > TX_8X8 && (h ^ (h - 1)) == 1) {
1235
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 79 times.
156 for (y = row_and_7; y < h + row_and_7 - 1; y += step1d)
1236 77 mask[1][y][0] |= m_col;
1237
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77 times.
79 if (y - row_and_7 == h - 1)
1238 2 mask[1][y][1] |= m_col;
1239 } else {
1240
2/2
✓ Branch 0 taken 295754 times.
✓ Branch 1 taken 263094 times.
558848 for (y = row_and_7; y < h + row_and_7; y += step1d)
1241 295754 mask[1][y][mask_id] |= m_col;
1242 }
1243
2/2
✓ Branch 0 taken 513200 times.
✓ Branch 1 taken 90086 times.
603286 } else if (tx != TX_4X4) {
1244 int mask_id;
1245
1246
4/4
✓ Branch 0 taken 163798 times.
✓ Branch 1 taken 349402 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 163694 times.
513200 mask_id = (tx == TX_8X8) || (h == ss_v);
1247 513200 mask[1][row_and_7][mask_id] |= m_col;
1248
3/4
✓ Branch 0 taken 163798 times.
✓ Branch 1 taken 349402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163798 times.
513200 mask_id = (tx == TX_8X8) || (w == ss_h);
1249
2/2
✓ Branch 0 taken 1028891 times.
✓ Branch 1 taken 513200 times.
1542091 for (y = row_and_7; y < h + row_and_7; y++)
1250 1028891 mask[0][y][mask_id] |= t;
1251 } else {
1252 90086 int t8 = t & wide_filter_col_mask[ss_h], t4 = t - t8;
1253
1254
2/2
✓ Branch 0 taken 165531 times.
✓ Branch 1 taken 90086 times.
255617 for (y = row_and_7; y < h + row_and_7; y++) {
1255 165531 mask[0][y][2] |= t4;
1256 165531 mask[0][y][1] |= t8;
1257 }
1258
4/4
✓ Branch 0 taken 24717 times.
✓ Branch 1 taken 65369 times.
✓ Branch 2 taken 24717 times.
✓ Branch 3 taken 65369 times.
90086 mask[1][row_and_7][2 - !(row_and_7 & wide_filter_row_mask[ss_v])] |= m_col;
1259 }
1260 }
1261 }
1262
1263 794355 void ff_vp9_decode_block(VP9TileData *td, int row, int col,
1264 VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
1265 enum BlockLevel bl, enum BlockPartition bp)
1266 {
1267 794355 const VP9Context *s = td->s;
1268 794355 VP9Block *b = td->b;
1269 794355 enum BlockSize bs = bl * 3 + bp;
1270 794355 int bytesperpixel = s->bytesperpixel;
1271 794355 int w4 = ff_vp9_bwh_tab[1][bs][0], h4 = ff_vp9_bwh_tab[1][bs][1], lvl;
1272 int emu[2];
1273 794355 AVFrame *f = s->s.frames[CUR_FRAME].tf.f;
1274
1275 794355 td->row = row;
1276 794355 td->row7 = row & 7;
1277 794355 td->col = col;
1278 794355 td->col7 = col & 7;
1279
1280 794355 td->min_mv.x = -(128 + col * 64);
1281 794355 td->min_mv.y = -(128 + row * 64);
1282 794355 td->max_mv.x = 128 + (s->cols - col - w4) * 64;
1283 794355 td->max_mv.y = 128 + (s->rows - row - h4) * 64;
1284
1285
1/2
✓ Branch 0 taken 794355 times.
✗ Branch 1 not taken.
794355 if (s->pass < 2) {
1286 794355 b->bs = bs;
1287 794355 b->bl = bl;
1288 794355 b->bp = bp;
1289 794355 decode_mode(td);
1290
4/4
✓ Branch 0 taken 774801 times.
✓ Branch 1 taken 19554 times.
✓ Branch 2 taken 271150 times.
✓ Branch 3 taken 503651 times.
1085059 b->uvtx = b->tx - ((s->ss_h && w4 * 2 == (1 << b->tx)) ||
1291
4/4
✓ Branch 0 taken 277125 times.
✓ Branch 1 taken 13579 times.
✓ Branch 2 taken 53151 times.
✓ Branch 3 taken 223974 times.
290704 (s->ss_v && h4 * 2 == (1 << b->tx)));
1292
1293
2/2
✓ Branch 0 taken 1204 times.
✓ Branch 1 taken 793151 times.
794355 if (td->block_structure) {
1294 1204 td->block_structure[td->nb_block_structure].row = row;
1295 1204 td->block_structure[td->nb_block_structure].col = col;
1296 1204 td->block_structure[td->nb_block_structure].block_size_idx_x = av_log2(w4);
1297 1204 td->block_structure[td->nb_block_structure].block_size_idx_y = av_log2(h4);
1298 1204 td->nb_block_structure++;
1299 }
1300
1301
2/2
✓ Branch 0 taken 369105 times.
✓ Branch 1 taken 425250 times.
794355 if (!b->skip) {
1302 int has_coeffs;
1303
1304
2/2
✓ Branch 0 taken 354840 times.
✓ Branch 1 taken 14265 times.
369105 if (bytesperpixel == 1) {
1305 354840 has_coeffs = decode_coeffs_8bpp(td);
1306 } else {
1307 14265 has_coeffs = decode_coeffs_16bpp(td);
1308 }
1309
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 369105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
369105 if (!has_coeffs && b->bs <= BS_8x8 && !b->intra) {
1310 b->skip = 1;
1311 memset(&s->above_skip_ctx[col], 1, w4);
1312 memset(&td->left_skip_ctx[td->row7], 1, h4);
1313 }
1314 } else {
1315 425250 int row7 = td->row7;
1316
1317 #define SPLAT_ZERO_CTX(v, n) \
1318 switch (n) { \
1319 case 1: v = 0; break; \
1320 case 2: AV_ZERO16(&v); break; \
1321 case 4: AV_ZERO32(&v); break; \
1322 case 8: AV_ZERO64(&v); break; \
1323 case 16: AV_ZERO128(&v); break; \
1324 }
1325 #define SPLAT_ZERO_YUV(dir, var, off, n, dir2) \
1326 do { \
1327 SPLAT_ZERO_CTX(dir##_y_##var[off * 2], n * 2); \
1328 if (s->ss_##dir2) { \
1329 SPLAT_ZERO_CTX(dir##_uv_##var[0][off], n); \
1330 SPLAT_ZERO_CTX(dir##_uv_##var[1][off], n); \
1331 } else { \
1332 SPLAT_ZERO_CTX(dir##_uv_##var[0][off * 2], n * 2); \
1333 SPLAT_ZERO_CTX(dir##_uv_##var[1][off * 2], n * 2); \
1334 } \
1335 } while (0)
1336
1337
4/5
✓ Branch 0 taken 247778 times.
✓ Branch 1 taken 133565 times.
✓ Branch 2 taken 32882 times.
✓ Branch 3 taken 11025 times.
✗ Branch 4 not taken.
425250 switch (w4) {
1338
2/2
✓ Branch 0 taken 243323 times.
✓ Branch 1 taken 4455 times.
491101 case 1: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 1, h); break;
1339
2/2
✓ Branch 0 taken 132050 times.
✓ Branch 1 taken 1515 times.
265615 case 2: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 2, h); break;
1340
2/2
✓ Branch 0 taken 32549 times.
✓ Branch 1 taken 333 times.
65431 case 4: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 4, h); break;
1341
2/2
✓ Branch 1 taken 10948 times.
✓ Branch 2 taken 77 times.
21973 case 8: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 8, h); break;
1342 }
1343
4/5
✓ Branch 0 taken 253051 times.
✓ Branch 1 taken 130229 times.
✓ Branch 2 taken 31641 times.
✓ Branch 3 taken 10329 times.
✗ Branch 4 not taken.
425250 switch (h4) {
1344
2/2
✓ Branch 0 taken 247577 times.
✓ Branch 1 taken 5474 times.
500628 case 1: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 1, v); break;
1345
2/2
✓ Branch 0 taken 128108 times.
✓ Branch 1 taken 2121 times.
258337 case 2: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 2, v); break;
1346
2/2
✓ Branch 0 taken 31333 times.
✓ Branch 1 taken 308 times.
62974 case 4: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 4, v); break;
1347
2/2
✓ Branch 1 taken 10242 times.
✓ Branch 2 taken 87 times.
20571 case 8: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 8, v); break;
1348 }
1349 }
1350
1351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 794355 times.
794355 if (s->pass == 1) {
1352 s->td[0].b++;
1353 s->td[0].block += w4 * h4 * 64 * bytesperpixel;
1354 s->td[0].uvblock[0] += w4 * h4 * 64 * bytesperpixel >> (s->ss_h + s->ss_v);
1355 s->td[0].uvblock[1] += w4 * h4 * 64 * bytesperpixel >> (s->ss_h + s->ss_v);
1356 s->td[0].eob += 4 * w4 * h4;
1357 s->td[0].uveob[0] += 4 * w4 * h4 >> (s->ss_h + s->ss_v);
1358 s->td[0].uveob[1] += 4 * w4 * h4 >> (s->ss_h + s->ss_v);
1359
1360 return;
1361 }
1362 }
1363
1364 // emulated overhangs if the stride of the target buffer can't hold. This
1365 // makes it possible to support emu-edge and so on even if we have large block
1366 // overhangs
1367
1/2
✓ Branch 0 taken 794355 times.
✗ Branch 1 not taken.
1588710 emu[0] = (col + w4) * 8 * bytesperpixel > f->linesize[0] ||
1368
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 (row + h4) > s->rows;
1369
1/2
✓ Branch 0 taken 794355 times.
✗ Branch 1 not taken.
1588710 emu[1] = ((col + w4) * 8 >> s->ss_h) * bytesperpixel > f->linesize[1] ||
1370
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 (row + h4) > s->rows;
1371
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 if (emu[0]) {
1372 2238 td->dst[0] = td->tmp_y;
1373 2238 td->y_stride = 128;
1374 } else {
1375 792117 td->dst[0] = f->data[0] + yoff;
1376 792117 td->y_stride = f->linesize[0];
1377 }
1378
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 if (emu[1]) {
1379 2238 td->dst[1] = td->tmp_uv[0];
1380 2238 td->dst[2] = td->tmp_uv[1];
1381 2238 td->uv_stride = 128;
1382 } else {
1383 792117 td->dst[1] = f->data[1] + uvoff;
1384 792117 td->dst[2] = f->data[2] + uvoff;
1385 792117 td->uv_stride = f->linesize[1];
1386 }
1387
2/2
✓ Branch 0 taken 264074 times.
✓ Branch 1 taken 530281 times.
794355 if (b->intra) {
1388
2/2
✓ Branch 0 taken 5135 times.
✓ Branch 1 taken 258939 times.
264074 if (s->s.h.bpp > 8) {
1389 5135 ff_vp9_intra_recon_16bpp(td, yoff, uvoff);
1390 } else {
1391 258939 ff_vp9_intra_recon_8bpp(td, yoff, uvoff);
1392 }
1393 } else {
1394
2/2
✓ Branch 0 taken 15787 times.
✓ Branch 1 taken 514494 times.
530281 if (s->s.h.bpp > 8) {
1395 15787 ff_vp9_inter_recon_16bpp(td);
1396 } else {
1397 514494 ff_vp9_inter_recon_8bpp(td);
1398 }
1399 }
1400
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 if (emu[0]) {
1401 2238 int w = FFMIN(s->cols - col, w4) * 8, h = FFMIN(s->rows - row, h4) * 8, n, o = 0;
1402
1403
2/2
✓ Branch 0 taken 4227 times.
✓ Branch 1 taken 2238 times.
6465 for (n = 0; o < w; n++) {
1404 4227 int bw = 64 >> n;
1405
1406 av_assert2(n <= 4);
1407
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 1974 times.
4227 if (w & bw) {
1408 2253 s->dsp.mc[n][0][0][0][0](f->data[0] + yoff + o * bytesperpixel, f->linesize[0],
1409 2253 td->tmp_y + o * bytesperpixel, 128, h, 0, 0);
1410 2253 o += bw;
1411 }
1412 }
1413 }
1414
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 792117 times.
794355 if (emu[1]) {
1415 2238 int w = FFMIN(s->cols - col, w4) * 8 >> s->ss_h;
1416 2238 int h = FFMIN(s->rows - row, h4) * 8 >> s->ss_v, n, o = 0;
1417
1418
2/2
✓ Branch 0 taken 4227 times.
✓ Branch 1 taken 2238 times.
6465 for (n = s->ss_h; o < w; n++) {
1419 4227 int bw = 64 >> n;
1420
1421 av_assert2(n <= 4);
1422
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 1974 times.
4227 if (w & bw) {
1423 2253 s->dsp.mc[n][0][0][0][0](f->data[1] + uvoff + o * bytesperpixel, f->linesize[1],
1424 2253 td->tmp_uv[0] + o * bytesperpixel, 128, h, 0, 0);
1425 2253 s->dsp.mc[n][0][0][0][0](f->data[2] + uvoff + o * bytesperpixel, f->linesize[2],
1426 2253 td->tmp_uv[1] + o * bytesperpixel, 128, h, 0, 0);
1427 2253 o += bw;
1428 }
1429 }
1430 }
1431
1432 // pick filter level and find edges to apply filter to
1433
2/2
✓ Branch 0 taken 764395 times.
✓ Branch 1 taken 29960 times.
794355 if (s->s.h.filter.level &&
1434
2/2
✓ Branch 0 taken 522047 times.
✓ Branch 1 taken 242348 times.
764395 (lvl = s->s.h.segmentation.feat[b->seg_id].lflvl[b->intra ? 0 : b->ref[0] + 1]
1435
2/2
✓ Branch 0 taken 764304 times.
✓ Branch 1 taken 91 times.
764395 [b->mode[3] != ZEROMV]) > 0) {
1436 764304 int x_end = FFMIN(s->cols - col, w4), y_end = FFMIN(s->rows - row, h4);
1437
4/4
✓ Branch 0 taken 521956 times.
✓ Branch 1 taken 242348 times.
✓ Branch 2 taken 388677 times.
✓ Branch 3 taken 133279 times.
764304 int skip_inter = !b->intra && b->skip, col7 = td->col7, row7 = td->row7;
1438
1439 764304 setctx_2d(&lflvl->level[row7 * 8 + col7], w4, h4, 8, lvl);
1440 764304 mask_edges(lflvl->mask[0], 0, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
1441
4/4
✓ Branch 0 taken 19535 times.
✓ Branch 1 taken 744769 times.
✓ Branch 2 taken 9579 times.
✓ Branch 3 taken 9956 times.
764304 if (s->ss_h || s->ss_v)
1442 1502355 mask_edges(lflvl->mask[1], s->ss_h, s->ss_v, row7, col7, x_end, y_end,
1443
4/4
✓ Branch 0 taken 372903 times.
✓ Branch 1 taken 381445 times.
✓ Branch 2 taken 17651 times.
✓ Branch 3 taken 355252 times.
754348 s->cols & 1 && col + w4 >= s->cols ? s->cols & 7 : 0,
1444
4/4
✓ Branch 0 taken 181644 times.
✓ Branch 1 taken 572704 times.
✓ Branch 2 taken 6341 times.
✓ Branch 3 taken 175303 times.
754348 s->rows & 1 && row + h4 >= s->rows ? s->rows & 7 : 0,
1445 b->uvtx, skip_inter);
1446 }
1447
1448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 794355 times.
794355 if (s->pass == 2) {
1449 s->td[0].b++;
1450 s->td[0].block += w4 * h4 * 64 * bytesperpixel;
1451 s->td[0].uvblock[0] += w4 * h4 * 64 * bytesperpixel >> (s->ss_v + s->ss_h);
1452 s->td[0].uvblock[1] += w4 * h4 * 64 * bytesperpixel >> (s->ss_v + s->ss_h);
1453 s->td[0].eob += 4 * w4 * h4;
1454 s->td[0].uveob[0] += 4 * w4 * h4 >> (s->ss_v + s->ss_h);
1455 s->td[0].uveob[1] += 4 * w4 * h4 >> (s->ss_v + s->ss_h);
1456 }
1457 }
1458