FFmpeg coverage


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