FFmpeg coverage


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