FFmpeg coverage


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