/work/dav1d/src/recon_tmpl.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2018-2021, VideoLAN and dav1d authors |
3 | | * Copyright © 2018, Two Orioles, LLC |
4 | | * All rights reserved. |
5 | | * |
6 | | * Redistribution and use in source and binary forms, with or without |
7 | | * modification, are permitted provided that the following conditions are met: |
8 | | * |
9 | | * 1. Redistributions of source code must retain the above copyright notice, this |
10 | | * list of conditions and the following disclaimer. |
11 | | * |
12 | | * 2. Redistributions in binary form must reproduce the above copyright notice, |
13 | | * this list of conditions and the following disclaimer in the documentation |
14 | | * and/or other materials provided with the distribution. |
15 | | * |
16 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
20 | | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | | */ |
27 | | |
28 | | #include "config.h" |
29 | | |
30 | | #include <string.h> |
31 | | #include <stdio.h> |
32 | | |
33 | | #include "common/attributes.h" |
34 | | #include "common/bitdepth.h" |
35 | | #include "common/dump.h" |
36 | | #include "common/frame.h" |
37 | | #include "common/intops.h" |
38 | | |
39 | | #include "src/cdef_apply.h" |
40 | | #include "src/ctx.h" |
41 | | #include "src/ipred_prepare.h" |
42 | | #include "src/lf_apply.h" |
43 | | #include "src/lr_apply.h" |
44 | | #include "src/recon.h" |
45 | | #include "src/scan.h" |
46 | | #include "src/tables.h" |
47 | | #include "src/wedge.h" |
48 | | |
49 | 883k | static inline unsigned read_golomb(MsacContext *const msac) { |
50 | 883k | int len = 0; |
51 | 883k | unsigned val = 1; |
52 | | |
53 | 1.55M | while (!dav1d_msac_decode_bool_equi(msac) && len < 32) len++; |
54 | 1.55M | while (len--) val = (val << 1) + dav1d_msac_decode_bool_equi(msac); |
55 | | |
56 | 883k | return val - 1; |
57 | 883k | } |
58 | | |
59 | | static inline unsigned get_skip_ctx(const TxfmInfo *const t_dim, |
60 | | const enum BlockSize bs, |
61 | | const uint8_t *const a, |
62 | | const uint8_t *const l, |
63 | | const int chroma, |
64 | | const enum Dav1dPixelLayout layout) |
65 | 7.91M | { |
66 | 7.91M | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; |
67 | | |
68 | 7.91M | if (chroma) { |
69 | 4.38M | const int ss_ver = layout == DAV1D_PIXEL_LAYOUT_I420; |
70 | 4.38M | const int ss_hor = layout != DAV1D_PIXEL_LAYOUT_I444; |
71 | 4.38M | const int not_one_blk = b_dim[2] - (!!b_dim[2] && ss_hor) > t_dim->lw || |
72 | 2.59M | b_dim[3] - (!!b_dim[3] && ss_ver) > t_dim->lh; |
73 | 4.38M | unsigned ca, cl; |
74 | | |
75 | 4.38M | #define MERGE_CTX(dir, type, no_val) \ |
76 | 8.76M | c##dir = *(const type *) dir != no_val; \ |
77 | 8.76M | break |
78 | | |
79 | 4.38M | switch (t_dim->lw) { |
80 | | /* For some reason the MSVC CRT _wassert() function is not flagged as |
81 | | * __declspec(noreturn), so when using those headers the compiler will |
82 | | * expect execution to continue after an assertion has been triggered |
83 | | * and will therefore complain about the use of uninitialized variables |
84 | | * when compiled in debug mode if we put the default case at the end. */ |
85 | 0 | default: assert(0); /* fall-through */ |
86 | 1.62M | case TX_4X4: MERGE_CTX(a, uint8_t, 0x40); |
87 | 820k | case TX_8X8: MERGE_CTX(a, uint16_t, 0x4040); |
88 | 641k | case TX_16X16: MERGE_CTX(a, uint32_t, 0x40404040U); |
89 | 1.29M | case TX_32X32: MERGE_CTX(a, uint64_t, 0x4040404040404040ULL); |
90 | 4.38M | } |
91 | 4.38M | switch (t_dim->lh) { |
92 | 0 | default: assert(0); /* fall-through */ |
93 | 1.82M | case TX_4X4: MERGE_CTX(l, uint8_t, 0x40); |
94 | 811k | case TX_8X8: MERGE_CTX(l, uint16_t, 0x4040); |
95 | 500k | case TX_16X16: MERGE_CTX(l, uint32_t, 0x40404040U); |
96 | 1.24M | case TX_32X32: MERGE_CTX(l, uint64_t, 0x4040404040404040ULL); |
97 | 4.38M | } |
98 | 4.38M | #undef MERGE_CTX |
99 | | |
100 | 4.38M | return 7 + not_one_blk * 3 + ca + cl; |
101 | 4.38M | } else if (b_dim[2] == t_dim->lw && b_dim[3] == t_dim->lh) { |
102 | 1.30M | return 0; |
103 | 2.22M | } else { |
104 | 2.22M | unsigned la, ll; |
105 | | |
106 | 2.22M | #define MERGE_CTX(dir, type, tx) \ |
107 | 4.47M | if (tx == TX_64X64) { \ |
108 | 341k | uint64_t tmp = *(const uint64_t *) dir; \ |
109 | 341k | tmp |= *(const uint64_t *) &dir[8]; \ |
110 | 341k | l##dir = (unsigned) (tmp >> 32) | (unsigned) tmp; \ |
111 | 341k | } else \ |
112 | 4.47M | l##dir = *(const type *) dir; \ |
113 | 4.47M | if (tx == TX_32X32) l##dir |= *(const type *) &dir[sizeof(type)]; \ |
114 | 4.47M | if (tx >= TX_16X16) l##dir |= l##dir >> 16; \ |
115 | 4.47M | if (tx >= TX_8X8) l##dir |= l##dir >> 8; \ |
116 | 4.47M | break |
117 | | |
118 | 2.22M | switch (t_dim->lw) { |
119 | 0 | default: assert(0); /* fall-through */ |
120 | 1.20M | case TX_4X4: MERGE_CTX(a, uint8_t, TX_4X4); |
121 | 473k | case TX_8X8: MERGE_CTX(a, uint16_t, TX_8X8); |
122 | 353k | case TX_16X16: MERGE_CTX(a, uint32_t, TX_16X16); |
123 | 29.8k | case TX_32X32: MERGE_CTX(a, uint32_t, TX_32X32); |
124 | 170k | case TX_64X64: MERGE_CTX(a, uint32_t, TX_64X64); |
125 | 2.22M | } |
126 | 2.23M | switch (t_dim->lh) { |
127 | 0 | default: assert(0); /* fall-through */ |
128 | 1.22M | case TX_4X4: MERGE_CTX(l, uint8_t, TX_4X4); |
129 | 460k | case TX_8X8: MERGE_CTX(l, uint16_t, TX_8X8); |
130 | 352k | case TX_16X16: MERGE_CTX(l, uint32_t, TX_16X16); |
131 | 30.1k | case TX_32X32: MERGE_CTX(l, uint32_t, TX_32X32); |
132 | 170k | case TX_64X64: MERGE_CTX(l, uint32_t, TX_64X64); |
133 | 2.23M | } |
134 | 2.23M | #undef MERGE_CTX |
135 | | |
136 | 2.23M | return dav1d_skip_ctx[umin(la & 0x3F, 4)][umin(ll & 0x3F, 4)]; |
137 | 2.23M | } |
138 | 7.91M | } |
139 | | |
140 | | static inline unsigned get_dc_sign_ctx(const int /*enum RectTxfmSize*/ tx, |
141 | | const uint8_t *const a, |
142 | | const uint8_t *const l) |
143 | 3.34M | { |
144 | 3.34M | uint64_t mask = 0xC0C0C0C0C0C0C0C0ULL, mul = 0x0101010101010101ULL; |
145 | 3.34M | int s; |
146 | | |
147 | 3.34M | #if ARCH_X86_64 && defined(__GNUC__) |
148 | | /* Coerce compilers into producing better code. For some reason |
149 | | * every x86-64 compiler is awful at handling 64-bit constants. */ |
150 | 3.34M | __asm__("" : "+r"(mask), "+r"(mul)); |
151 | 3.34M | #endif |
152 | | |
153 | 3.34M | switch(tx) { |
154 | 0 | default: assert(0); /* fall-through */ |
155 | 1.29M | case TX_4X4: { |
156 | 1.29M | int t = *(const uint8_t *) a >> 6; |
157 | 1.29M | t += *(const uint8_t *) l >> 6; |
158 | 1.29M | s = t - 1 - 1; |
159 | 1.29M | break; |
160 | 0 | } |
161 | 352k | case TX_8X8: { |
162 | 352k | uint32_t t = *(const uint16_t *) a & (uint32_t) mask; |
163 | 352k | t += *(const uint16_t *) l & (uint32_t) mask; |
164 | 352k | t *= 0x04040404U; |
165 | 352k | s = (int) (t >> 24) - 2 - 2; |
166 | 352k | break; |
167 | 0 | } |
168 | 257k | case TX_16X16: { |
169 | 257k | uint32_t t = (*(const uint32_t *) a & (uint32_t) mask) >> 6; |
170 | 257k | t += (*(const uint32_t *) l & (uint32_t) mask) >> 6; |
171 | 257k | t *= (uint32_t) mul; |
172 | 257k | s = (int) (t >> 24) - 4 - 4; |
173 | 257k | break; |
174 | 0 | } |
175 | 375k | case TX_32X32: { |
176 | 375k | uint64_t t = (*(const uint64_t *) a & mask) >> 6; |
177 | 375k | t += (*(const uint64_t *) l & mask) >> 6; |
178 | 375k | t *= mul; |
179 | 375k | s = (int) (t >> 56) - 8 - 8; |
180 | 375k | break; |
181 | 0 | } |
182 | 144k | case TX_64X64: { |
183 | 144k | uint64_t t = (*(const uint64_t *) &a[0] & mask) >> 6; |
184 | 144k | t += (*(const uint64_t *) &a[8] & mask) >> 6; |
185 | 144k | t += (*(const uint64_t *) &l[0] & mask) >> 6; |
186 | 144k | t += (*(const uint64_t *) &l[8] & mask) >> 6; |
187 | 144k | t *= mul; |
188 | 144k | s = (int) (t >> 56) - 16 - 16; |
189 | 144k | break; |
190 | 0 | } |
191 | 98.4k | case RTX_4X8: { |
192 | 98.4k | uint32_t t = *(const uint8_t *) a & (uint32_t) mask; |
193 | 98.4k | t += *(const uint16_t *) l & (uint32_t) mask; |
194 | 98.4k | t *= 0x04040404U; |
195 | 98.4k | s = (int) (t >> 24) - 1 - 2; |
196 | 98.4k | break; |
197 | 0 | } |
198 | 154k | case RTX_8X4: { |
199 | 154k | uint32_t t = *(const uint16_t *) a & (uint32_t) mask; |
200 | 154k | t += *(const uint8_t *) l & (uint32_t) mask; |
201 | 154k | t *= 0x04040404U; |
202 | 154k | s = (int) (t >> 24) - 2 - 1; |
203 | 154k | break; |
204 | 0 | } |
205 | 87.6k | case RTX_8X16: { |
206 | 87.6k | uint32_t t = *(const uint16_t *) a & (uint32_t) mask; |
207 | 87.6k | t += *(const uint32_t *) l & (uint32_t) mask; |
208 | 87.6k | t = (t >> 6) * (uint32_t) mul; |
209 | 87.6k | s = (int) (t >> 24) - 2 - 4; |
210 | 87.6k | break; |
211 | 0 | } |
212 | 165k | case RTX_16X8: { |
213 | 165k | uint32_t t = *(const uint32_t *) a & (uint32_t) mask; |
214 | 165k | t += *(const uint16_t *) l & (uint32_t) mask; |
215 | 165k | t = (t >> 6) * (uint32_t) mul; |
216 | 165k | s = (int) (t >> 24) - 4 - 2; |
217 | 165k | break; |
218 | 0 | } |
219 | 57.0k | case RTX_16X32: { |
220 | 57.0k | uint64_t t = *(const uint32_t *) a & (uint32_t) mask; |
221 | 57.0k | t += *(const uint64_t *) l & mask; |
222 | 57.0k | t = (t >> 6) * mul; |
223 | 57.0k | s = (int) (t >> 56) - 4 - 8; |
224 | 57.0k | break; |
225 | 0 | } |
226 | 87.0k | case RTX_32X16: { |
227 | 87.0k | uint64_t t = *(const uint64_t *) a & mask; |
228 | 87.0k | t += *(const uint32_t *) l & (uint32_t) mask; |
229 | 87.0k | t = (t >> 6) * mul; |
230 | 87.0k | s = (int) (t >> 56) - 8 - 4; |
231 | 87.0k | break; |
232 | 0 | } |
233 | 35.9k | case RTX_32X64: { |
234 | 35.9k | uint64_t t = (*(const uint64_t *) &a[0] & mask) >> 6; |
235 | 35.9k | t += (*(const uint64_t *) &l[0] & mask) >> 6; |
236 | 35.9k | t += (*(const uint64_t *) &l[8] & mask) >> 6; |
237 | 35.9k | t *= mul; |
238 | 35.9k | s = (int) (t >> 56) - 8 - 16; |
239 | 35.9k | break; |
240 | 0 | } |
241 | 32.1k | case RTX_64X32: { |
242 | 32.1k | uint64_t t = (*(const uint64_t *) &a[0] & mask) >> 6; |
243 | 32.1k | t += (*(const uint64_t *) &a[8] & mask) >> 6; |
244 | 32.1k | t += (*(const uint64_t *) &l[0] & mask) >> 6; |
245 | 32.1k | t *= mul; |
246 | 32.1k | s = (int) (t >> 56) - 16 - 8; |
247 | 32.1k | break; |
248 | 0 | } |
249 | 44.3k | case RTX_4X16: { |
250 | 44.3k | uint32_t t = *(const uint8_t *) a & (uint32_t) mask; |
251 | 44.3k | t += *(const uint32_t *) l & (uint32_t) mask; |
252 | 44.3k | t = (t >> 6) * (uint32_t) mul; |
253 | 44.3k | s = (int) (t >> 24) - 1 - 4; |
254 | 44.3k | break; |
255 | 0 | } |
256 | 84.9k | case RTX_16X4: { |
257 | 84.9k | uint32_t t = *(const uint32_t *) a & (uint32_t) mask; |
258 | 84.9k | t += *(const uint8_t *) l & (uint32_t) mask; |
259 | 84.9k | t = (t >> 6) * (uint32_t) mul; |
260 | 84.9k | s = (int) (t >> 24) - 4 - 1; |
261 | 84.9k | break; |
262 | 0 | } |
263 | 26.5k | case RTX_8X32: { |
264 | 26.5k | uint64_t t = *(const uint16_t *) a & (uint32_t) mask; |
265 | 26.5k | t += *(const uint64_t *) l & mask; |
266 | 26.5k | t = (t >> 6) * mul; |
267 | 26.5k | s = (int) (t >> 56) - 2 - 8; |
268 | 26.5k | break; |
269 | 0 | } |
270 | 38.8k | case RTX_32X8: { |
271 | 38.8k | uint64_t t = *(const uint64_t *) a & mask; |
272 | 38.8k | t += *(const uint16_t *) l & (uint32_t) mask; |
273 | 38.8k | t = (t >> 6) * mul; |
274 | 38.8k | s = (int) (t >> 56) - 8 - 2; |
275 | 38.8k | break; |
276 | 0 | } |
277 | 7.09k | case RTX_16X64: { |
278 | 7.09k | uint64_t t = *(const uint32_t *) a & (uint32_t) mask; |
279 | 7.09k | t += *(const uint64_t *) &l[0] & mask; |
280 | 7.09k | t = (t >> 6) + ((*(const uint64_t *) &l[8] & mask) >> 6); |
281 | 7.09k | t *= mul; |
282 | 7.09k | s = (int) (t >> 56) - 4 - 16; |
283 | 7.09k | break; |
284 | 0 | } |
285 | 7.06k | case RTX_64X16: { |
286 | 7.06k | uint64_t t = *(const uint64_t *) &a[0] & mask; |
287 | 7.06k | t += *(const uint32_t *) l & (uint32_t) mask; |
288 | 7.06k | t = (t >> 6) + ((*(const uint64_t *) &a[8] & mask) >> 6); |
289 | 7.06k | t *= mul; |
290 | 7.06k | s = (int) (t >> 56) - 16 - 4; |
291 | 7.06k | break; |
292 | 0 | } |
293 | 3.34M | } |
294 | | |
295 | 3.34M | return (s != 0) + (s > 0); |
296 | 3.34M | } |
297 | | |
298 | | static inline unsigned get_lo_ctx(const uint8_t *const levels, |
299 | | const enum TxClass tx_class, |
300 | | unsigned *const hi_mag, |
301 | | const uint8_t (*const ctx_offsets)[5], |
302 | | const unsigned x, const unsigned y, |
303 | | const ptrdiff_t stride) |
304 | 68.2M | { |
305 | 68.2M | unsigned mag = levels[0 * stride + 1] + levels[1 * stride + 0]; |
306 | 68.2M | unsigned offset; |
307 | 68.2M | if (tx_class == TX_CLASS_2D) { |
308 | 64.6M | mag += levels[1 * stride + 1]; |
309 | 64.6M | *hi_mag = mag; |
310 | 64.6M | mag += levels[0 * stride + 2] + levels[2 * stride + 0]; |
311 | 64.6M | offset = ctx_offsets[umin(y, 4)][umin(x, 4)]; |
312 | 64.6M | } else { |
313 | 3.64M | mag += levels[0 * stride + 2]; |
314 | 3.64M | *hi_mag = mag; |
315 | 3.64M | mag += levels[0 * stride + 3] + levels[0 * stride + 4]; |
316 | 3.64M | offset = 26 + (y > 1 ? 10 : y * 5); |
317 | 3.64M | } |
318 | 68.2M | return offset + (mag > 512 ? 4 : (mag + 64) >> 7); |
319 | 68.2M | } |
320 | | |
321 | | static int decode_coefs(Dav1dTaskContext *const t, |
322 | | uint8_t *const a, uint8_t *const l, |
323 | | const enum RectTxfmSize tx, const enum BlockSize bs, |
324 | | const Av1Block *const b, const int intra, |
325 | | const int plane, coef *cf, |
326 | | enum TxfmType *const txtp, uint8_t *res_ctx) |
327 | 7.91M | { |
328 | 7.91M | Dav1dTileState *const ts = t->ts; |
329 | 7.91M | const int chroma = !!plane; |
330 | 7.91M | const Dav1dFrameContext *const f = t->f; |
331 | 7.91M | const int lossless = f->frame_hdr->segmentation.lossless[b->seg_id]; |
332 | 7.91M | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[tx]; |
333 | 7.91M | const int dbg = DEBUG_BLOCK_INFO && plane && 0; |
334 | | |
335 | 7.91M | if (dbg) |
336 | 0 | printf("Start: r=%d\n", ts->msac.rng); |
337 | | |
338 | | // does this block have any non-zero coefficients |
339 | 7.91M | const int sctx = get_skip_ctx(t_dim, bs, a, l, chroma, f->cur.p.layout); |
340 | 7.91M | const int all_skip = dav1d_msac_decode_bool_adapt(&ts->msac, |
341 | 7.91M | ts->cdf.coef.skip[t_dim->ctx][sctx]); |
342 | 7.91M | if (dbg) |
343 | 0 | printf("Post-non-zero[%d][%d][%d]: r=%d\n", |
344 | 0 | t_dim->ctx, sctx, all_skip, ts->msac.rng); |
345 | 7.91M | if (all_skip) { |
346 | 3.95M | *res_ctx = 0x40; |
347 | 3.95M | *txtp = lossless * WHT_WHT; /* lossless ? WHT_WHT : DCT_DCT */ |
348 | 3.95M | return -1; |
349 | 3.95M | } |
350 | | |
351 | | // transform type (chroma: derived, luma: explicitly coded) |
352 | 3.95M | if (lossless) { |
353 | 1.16M | assert(t_dim->max == TX_4X4); |
354 | 1.16M | *txtp = WHT_WHT; |
355 | 2.78M | } else if (t_dim->max + intra >= TX_64X64) { |
356 | 835k | *txtp = DCT_DCT; |
357 | 1.95M | } else if (chroma) { |
358 | | // inferred from either the luma txtp (inter) or a LUT (intra) |
359 | 511k | *txtp = intra ? dav1d_txtp_from_uvmode[b->uv_mode] : |
360 | 511k | get_uv_inter_txtp(t_dim, *txtp); |
361 | 1.44M | } else if (!f->frame_hdr->segmentation.qidx[b->seg_id]) { |
362 | | // In libaom, lossless is checked by a literal qidx == 0, but not all |
363 | | // such blocks are actually lossless. The remainder gets an implicit |
364 | | // transform type (for luma) |
365 | 18.7k | *txtp = DCT_DCT; |
366 | 1.42M | } else { |
367 | 1.42M | unsigned idx; |
368 | 1.42M | if (intra) { |
369 | 1.17M | const enum IntraPredMode y_mode_nofilt = b->y_mode == FILTER_PRED ? |
370 | 988k | dav1d_filter_mode_to_y_mode[b->y_angle] : b->y_mode; |
371 | 1.17M | if (f->frame_hdr->reduced_txtp_set || t_dim->min == TX_16X16) { |
372 | 450k | idx = dav1d_msac_decode_symbol_adapt8(&ts->msac, |
373 | 450k | ts->cdf.m.txtp_intra2[t_dim->min][y_mode_nofilt], 4); |
374 | 450k | *txtp = dav1d_tx_types_per_set[idx + 0]; |
375 | 722k | } else { |
376 | 722k | idx = dav1d_msac_decode_symbol_adapt8(&ts->msac, |
377 | 722k | ts->cdf.m.txtp_intra1[t_dim->min][y_mode_nofilt], 6); |
378 | 722k | *txtp = dav1d_tx_types_per_set[idx + 5]; |
379 | 722k | } |
380 | 1.17M | if (dbg) |
381 | 0 | printf("Post-txtp-intra[%d->%d][%d][%d->%d]: r=%d\n", |
382 | 0 | tx, t_dim->min, y_mode_nofilt, idx, *txtp, ts->msac.rng); |
383 | 1.17M | } else { |
384 | 248k | if (f->frame_hdr->reduced_txtp_set || t_dim->max == TX_32X32) { |
385 | 71.3k | idx = dav1d_msac_decode_bool_adapt(&ts->msac, |
386 | 71.3k | ts->cdf.m.txtp_inter3[t_dim->min]); |
387 | 71.3k | *txtp = (idx - 1) & IDTX; /* idx ? DCT_DCT : IDTX */ |
388 | 177k | } else if (t_dim->min == TX_16X16) { |
389 | 19.0k | idx = dav1d_msac_decode_symbol_adapt16(&ts->msac, |
390 | 19.0k | ts->cdf.m.txtp_inter2, 11); |
391 | 19.0k | *txtp = dav1d_tx_types_per_set[idx + 12]; |
392 | 158k | } else { |
393 | 158k | idx = dav1d_msac_decode_symbol_adapt16(&ts->msac, |
394 | 158k | ts->cdf.m.txtp_inter1[t_dim->min], 15); |
395 | 158k | *txtp = dav1d_tx_types_per_set[idx + 24]; |
396 | 158k | } |
397 | 248k | if (dbg) |
398 | 0 | printf("Post-txtp-inter[%d->%d][%d->%d]: r=%d\n", |
399 | 0 | tx, t_dim->min, idx, *txtp, ts->msac.rng); |
400 | 248k | } |
401 | 1.42M | } |
402 | | |
403 | | // find end-of-block (eob) |
404 | 3.95M | int eob; |
405 | 3.95M | const int slw = imin(t_dim->lw, TX_32X32), slh = imin(t_dim->lh, TX_32X32); |
406 | 3.95M | const int tx2dszctx = slw + slh; |
407 | 3.95M | const enum TxClass tx_class = dav1d_tx_type_class[*txtp]; |
408 | 3.95M | const int is_1d = tx_class != TX_CLASS_2D; |
409 | 3.95M | switch (tx2dszctx) { |
410 | 0 | #define case_sz(sz, bin, ns, is_1d) \ |
411 | 3.96M | case sz: { \ |
412 | 3.96M | uint16_t *const eob_bin_cdf = ts->cdf.coef.eob_bin_##bin[chroma]is_1d; \ |
413 | 3.96M | eob = dav1d_msac_decode_symbol_adapt##ns(&ts->msac, eob_bin_cdf, 4 + sz); \ |
414 | 3.96M | break; \ |
415 | 3.96M | } |
416 | 1.49M | case_sz(0, 16, 8, [is_1d]); |
417 | 325k | case_sz(1, 32, 8, [is_1d]); |
418 | 614k | case_sz(2, 64, 8, [is_1d]); |
419 | 325k | case_sz(3, 128, 8, [is_1d]); |
420 | 399k | case_sz(4, 256, 16, [is_1d]); |
421 | 181k | case_sz(5, 512, 16, ); |
422 | 620k | case_sz(6, 1024, 16, ); |
423 | 3.95M | #undef case_sz |
424 | 3.95M | } |
425 | 3.95M | if (dbg) |
426 | 0 | printf("Post-eob_bin_%d[%d][%d][%d]: r=%d\n", |
427 | 0 | 16 << tx2dszctx, chroma, is_1d, eob, ts->msac.rng); |
428 | 3.95M | if (eob > 1) { |
429 | 2.48M | const int eob_bin = eob - 2; |
430 | 2.48M | uint16_t *const eob_hi_bit_cdf = |
431 | 2.48M | ts->cdf.coef.eob_hi_bit[t_dim->ctx][chroma][eob_bin]; |
432 | 2.48M | const int eob_hi_bit = dav1d_msac_decode_bool_adapt(&ts->msac, eob_hi_bit_cdf); |
433 | 2.48M | if (dbg) |
434 | 0 | printf("Post-eob_hi_bit[%d][%d][%d][%d]: r=%d\n", |
435 | 0 | t_dim->ctx, chroma, eob_bin, eob_hi_bit, ts->msac.rng); |
436 | 2.48M | eob = ((eob_hi_bit | 2) << eob_bin) | dav1d_msac_decode_bools(&ts->msac, eob_bin); |
437 | 2.48M | if (dbg) |
438 | 0 | printf("Post-eob[%d]: r=%d\n", eob, ts->msac.rng); |
439 | 2.48M | } |
440 | 3.95M | assert(eob >= 0); |
441 | | |
442 | | // base tokens |
443 | 3.95M | uint16_t (*const eob_cdf)[4] = ts->cdf.coef.eob_base_tok[t_dim->ctx][chroma]; |
444 | 3.95M | uint16_t (*const hi_cdf)[4] = ts->cdf.coef.br_tok[imin(t_dim->ctx, 3)][chroma]; |
445 | 3.95M | unsigned rc, dc_tok; |
446 | | |
447 | 3.95M | if (eob) { |
448 | 2.62M | uint16_t (*const lo_cdf)[4] = ts->cdf.coef.base_tok[t_dim->ctx][chroma]; |
449 | 2.62M | uint8_t *const levels = t->scratch.levels; // bits 0-5: tok, 6-7: lo_tok |
450 | | |
451 | | /* eob */ |
452 | 2.62M | unsigned ctx = 1 + (eob > 2 << tx2dszctx) + (eob > 4 << tx2dszctx); |
453 | 2.62M | int eob_tok = dav1d_msac_decode_symbol_adapt4(&ts->msac, eob_cdf[ctx], 2); |
454 | 2.62M | int tok = eob_tok + 1; |
455 | 2.62M | int level_tok = tok * 0x41; |
456 | 2.62M | unsigned mag; |
457 | | |
458 | 2.62M | #define DECODE_COEFS_CLASS(tx_class) \ |
459 | 2.62M | unsigned x, y; \ |
460 | 2.62M | uint8_t *level; \ |
461 | 2.62M | if (tx_class == TX_CLASS_2D) \ |
462 | 2.62M | rc = scan[eob], x = rc >> shift, y = rc & mask; \ |
463 | 2.62M | else if (tx_class == TX_CLASS_H) \ |
464 | | /* Transposing reduces the stride and padding requirements */ \ |
465 | 176k | x = eob & mask, y = eob >> shift, rc = eob; \ |
466 | 176k | else /* tx_class == TX_CLASS_V */ \ |
467 | 176k | x = eob & mask, y = eob >> shift, rc = (x << shift2) | y; \ |
468 | 2.62M | if (dbg) \ |
469 | 2.62M | printf("Post-lo_tok[%d][%d][%d][%d=%d=%d]: r=%d\n", \ |
470 | 0 | t_dim->ctx, chroma, ctx, eob, rc, tok, ts->msac.rng); \ |
471 | 2.62M | if (eob_tok == 2) { \ |
472 | 65.9k | ctx = (tx_class == TX_CLASS_2D ? (x | y) > 1 : y != 0) ? 14 : 7; \ |
473 | 65.9k | tok = dav1d_msac_decode_hi_tok(&ts->msac, hi_cdf[ctx]); \ |
474 | 65.9k | level_tok = tok + (3 << 6); \ |
475 | 65.9k | if (dbg) \ |
476 | 65.9k | printf("Post-hi_tok[%d][%d][%d][%d=%d=%d]: r=%d\n", \ |
477 | 0 | imin(t_dim->ctx, 3), chroma, ctx, eob, rc, tok, \ |
478 | 0 | ts->msac.rng); \ |
479 | 65.9k | } \ |
480 | 2.62M | cf[rc] = tok << 11; \ |
481 | 2.62M | if (tx_class == TX_CLASS_2D) \ |
482 | 2.62M | level = levels + rc; \ |
483 | 2.62M | else \ |
484 | 2.62M | level = levels + x * stride + y; \ |
485 | 2.62M | *level = (uint8_t) level_tok; \ |
486 | 70.7M | for (int i = eob - 1; i > 0; i--) { /* ac */ \ |
487 | 68.1M | unsigned rc_i; \ |
488 | 68.1M | if (tx_class == TX_CLASS_2D) \ |
489 | 68.1M | rc_i = scan[i], x = rc_i >> shift, y = rc_i & mask; \ |
490 | 68.1M | else if (tx_class == TX_CLASS_H) \ |
491 | 3.55M | x = i & mask, y = i >> shift, rc_i = i; \ |
492 | 3.55M | else /* tx_class == TX_CLASS_V */ \ |
493 | 3.55M | x = i & mask, y = i >> shift, rc_i = (x << shift2) | y; \ |
494 | 68.1M | assert(x < 32 && y < 32); \ |
495 | 68.1M | if (tx_class == TX_CLASS_2D) \ |
496 | 68.1M | level = levels + rc_i; \ |
497 | 68.1M | else \ |
498 | 68.1M | level = levels + x * stride + y; \ |
499 | 68.1M | ctx = get_lo_ctx(level, tx_class, &mag, lo_ctx_offsets, x, y, stride); \ |
500 | 68.1M | if (tx_class == TX_CLASS_2D) \ |
501 | 68.1M | y |= x; \ |
502 | 68.1M | tok = dav1d_msac_decode_symbol_adapt4(&ts->msac, lo_cdf[ctx], 3); \ |
503 | 68.1M | if (dbg) \ |
504 | 68.1M | printf("Post-lo_tok[%d][%d][%d][%d=%d=%d]: r=%d\n", \ |
505 | 0 | t_dim->ctx, chroma, ctx, i, rc_i, tok, ts->msac.rng); \ |
506 | 68.1M | if (tok == 3) { \ |
507 | 5.45M | mag &= 63; \ |
508 | 5.45M | ctx = (y > (tx_class == TX_CLASS_2D) ? 14 : 7) + \ |
509 | 5.45M | (mag > 12 ? 6 : (mag + 1) >> 1); \ |
510 | 5.45M | tok = dav1d_msac_decode_hi_tok(&ts->msac, hi_cdf[ctx]); \ |
511 | 5.45M | if (dbg) \ |
512 | 5.45M | printf("Post-hi_tok[%d][%d][%d][%d=%d=%d]: r=%d\n", \ |
513 | 0 | imin(t_dim->ctx, 3), chroma, ctx, i, rc_i, tok, \ |
514 | 0 | ts->msac.rng); \ |
515 | 5.45M | *level = (uint8_t) (tok + (3 << 6)); \ |
516 | 5.45M | cf[rc_i] = (tok << 11) | rc; \ |
517 | 5.45M | rc = rc_i; \ |
518 | 62.6M | } else { \ |
519 | | /* 0x1 for tok, 0x7ff as bitmask for rc, 0x41 for level_tok */ \ |
520 | 62.6M | tok *= 0x17ff41; \ |
521 | 62.6M | *level = (uint8_t) tok; \ |
522 | | /* tok ? (tok << 11) | rc : 0 */ \ |
523 | 62.6M | tok = (tok >> 9) & (rc + ~0x7ffu); \ |
524 | 62.6M | if (tok) rc = rc_i; \ |
525 | 62.6M | cf[rc_i] = tok; \ |
526 | 62.6M | } \ |
527 | 68.1M | } \ |
528 | | /* dc */ \ |
529 | 2.62M | ctx = (tx_class == TX_CLASS_2D) ? 0 : \ |
530 | 2.62M | get_lo_ctx(levels, tx_class, &mag, lo_ctx_offsets, 0, 0, stride); \ |
531 | 2.62M | dc_tok = dav1d_msac_decode_symbol_adapt4(&ts->msac, lo_cdf[ctx], 3); \ |
532 | 2.62M | if (dbg) \ |
533 | 2.62M | printf("Post-dc_lo_tok[%d][%d][%d][%d]: r=%d\n", \ |
534 | 0 | t_dim->ctx, chroma, ctx, dc_tok, ts->msac.rng); \ |
535 | 2.62M | if (dc_tok == 3) { \ |
536 | 998k | if (tx_class == TX_CLASS_2D) \ |
537 | 998k | mag = levels[0 * stride + 1] + levels[1 * stride + 0] + \ |
538 | 979k | levels[1 * stride + 1]; \ |
539 | 998k | mag &= 63; \ |
540 | 998k | ctx = mag > 12 ? 6 : (mag + 1) >> 1; \ |
541 | 998k | dc_tok = dav1d_msac_decode_hi_tok(&ts->msac, hi_cdf[ctx]); \ |
542 | 998k | if (dbg) \ |
543 | 998k | printf("Post-dc_hi_tok[%d][%d][0][%d]: r=%d\n", \ |
544 | 0 | imin(t_dim->ctx, 3), chroma, dc_tok, ts->msac.rng); \ |
545 | 998k | } \ |
546 | 2.62M | break |
547 | | |
548 | 2.62M | const uint16_t *scan; |
549 | 2.62M | switch (tx_class) { |
550 | 2.44M | case TX_CLASS_2D: { |
551 | 2.44M | const unsigned nonsquare_tx = tx >= RTX_4X8; |
552 | 2.44M | const uint8_t (*const lo_ctx_offsets)[5] = |
553 | 2.44M | dav1d_lo_ctx_offsets[nonsquare_tx + (tx & nonsquare_tx)]; |
554 | 2.44M | scan = dav1d_scans[tx]; |
555 | 2.44M | const ptrdiff_t stride = 4 << slh; |
556 | 2.44M | const unsigned shift = slh + 2, shift2 = 0; |
557 | 2.44M | const unsigned mask = (4 << slh) - 1; |
558 | 2.44M | memset(levels, 0, stride * ((4 << slw) + 2)); |
559 | 2.44M | DECODE_COEFS_CLASS(TX_CLASS_2D); |
560 | 2.44M | } |
561 | 114k | case TX_CLASS_H: { |
562 | 114k | const uint8_t (*const lo_ctx_offsets)[5] = NULL; |
563 | 114k | const ptrdiff_t stride = 16; |
564 | 114k | const unsigned shift = slh + 2, shift2 = 0; |
565 | 114k | const unsigned mask = (4 << slh) - 1; |
566 | 114k | memset(levels, 0, stride * ((4 << slh) + 2)); |
567 | 114k | DECODE_COEFS_CLASS(TX_CLASS_H); |
568 | 114k | } |
569 | 61.9k | case TX_CLASS_V: { |
570 | 61.9k | const uint8_t (*const lo_ctx_offsets)[5] = NULL; |
571 | 61.9k | const ptrdiff_t stride = 16; |
572 | 61.9k | const unsigned shift = slw + 2, shift2 = slh + 2; |
573 | 61.9k | const unsigned mask = (4 << slw) - 1; |
574 | 61.9k | memset(levels, 0, stride * ((4 << slw) + 2)); |
575 | 61.9k | DECODE_COEFS_CLASS(TX_CLASS_V); |
576 | 61.9k | } |
577 | 0 | #undef DECODE_COEFS_CLASS |
578 | 0 | default: assert(0); |
579 | 2.62M | } |
580 | 2.62M | } else { // dc-only |
581 | 1.33M | int tok_br = dav1d_msac_decode_symbol_adapt4(&ts->msac, eob_cdf[0], 2); |
582 | 1.33M | dc_tok = 1 + tok_br; |
583 | 1.33M | if (dbg) |
584 | 0 | printf("Post-dc_lo_tok[%d][%d][%d][%d]: r=%d\n", |
585 | 0 | t_dim->ctx, chroma, 0, dc_tok, ts->msac.rng); |
586 | 1.33M | if (tok_br == 2) { |
587 | 48.0k | dc_tok = dav1d_msac_decode_hi_tok(&ts->msac, hi_cdf[0]); |
588 | 48.0k | if (dbg) |
589 | 0 | printf("Post-dc_hi_tok[%d][%d][0][%d]: r=%d\n", |
590 | 0 | imin(t_dim->ctx, 3), chroma, dc_tok, ts->msac.rng); |
591 | 48.0k | } |
592 | 1.33M | rc = 0; |
593 | 1.33M | } |
594 | | |
595 | | // residual and sign |
596 | 3.95M | const uint16_t *const dq_tbl = ts->dq[b->seg_id][plane]; |
597 | 3.95M | const uint8_t *const qm_tbl = *txtp < IDTX ? f->qm[tx][plane] : NULL; |
598 | 3.95M | const int dq_shift = imax(0, t_dim->ctx - 2); |
599 | 3.95M | const int cf_max = ~(~127U << (BITDEPTH == 8 ? 8 : f->cur.p.bpc)); |
600 | 3.95M | unsigned cul_level, dc_sign_level; |
601 | | |
602 | 3.95M | if (!dc_tok) { |
603 | 611k | cul_level = 0; |
604 | 611k | dc_sign_level = 1 << 6; |
605 | 611k | if (qm_tbl) goto ac_qm; |
606 | 420k | goto ac_noqm; |
607 | 611k | } |
608 | | |
609 | 3.34M | const int dc_sign_ctx = get_dc_sign_ctx(tx, a, l); |
610 | 3.34M | uint16_t *const dc_sign_cdf = ts->cdf.coef.dc_sign[chroma][dc_sign_ctx]; |
611 | 3.34M | const int dc_sign = dav1d_msac_decode_bool_adapt(&ts->msac, dc_sign_cdf); |
612 | 3.34M | if (dbg) |
613 | 0 | printf("Post-dc_sign[%d][%d][%d]: r=%d\n", |
614 | 0 | chroma, dc_sign_ctx, dc_sign, ts->msac.rng); |
615 | | |
616 | 3.34M | int dc_dq = dq_tbl[0]; |
617 | 3.34M | dc_sign_level = (dc_sign - 1) & (2 << 6); |
618 | | |
619 | 3.34M | if (qm_tbl) { |
620 | 1.13M | dc_dq = (dc_dq * qm_tbl[0] + 16) >> 5; |
621 | | |
622 | 1.13M | if (dc_tok == 15) { |
623 | 35.5k | dc_tok = read_golomb(&ts->msac) + 15; |
624 | 35.5k | if (dbg) |
625 | 0 | printf("Post-dc_residual[%d->%d]: r=%d\n", |
626 | 0 | dc_tok - 15, dc_tok, ts->msac.rng); |
627 | | |
628 | 35.5k | dc_tok &= 0xfffff; |
629 | 35.5k | dc_dq = (dc_dq * dc_tok) & 0xffffff; |
630 | 1.09M | } else { |
631 | 1.09M | dc_dq *= dc_tok; |
632 | 1.09M | assert(dc_dq <= 0xffffff); |
633 | 1.09M | } |
634 | 1.13M | cul_level = dc_tok; |
635 | 1.13M | dc_dq >>= dq_shift; |
636 | 1.13M | dc_dq = umin(dc_dq, cf_max + dc_sign); |
637 | 1.13M | cf[0] = (coef) (dc_sign ? -dc_dq : dc_dq); |
638 | | |
639 | 1.55M | if (rc) ac_qm: { |
640 | 1.55M | const unsigned ac_dq = dq_tbl[1]; |
641 | 11.7M | do { |
642 | 11.7M | const int sign = dav1d_msac_decode_bool_equi(&ts->msac); |
643 | 11.7M | if (dbg) |
644 | 0 | printf("Post-sign[%d=%d]: r=%d\n", rc, sign, ts->msac.rng); |
645 | 11.7M | const unsigned rc_tok = cf[rc]; |
646 | 11.7M | unsigned tok, dq = (ac_dq * qm_tbl[rc] + 16) >> 5; |
647 | 11.7M | int dq_sat; |
648 | | |
649 | 11.7M | if (rc_tok >= (15 << 11)) { |
650 | 424k | tok = read_golomb(&ts->msac) + 15; |
651 | 424k | if (dbg) |
652 | 0 | printf("Post-residual[%d=%d->%d]: r=%d\n", |
653 | 0 | rc, tok - 15, tok, ts->msac.rng); |
654 | | |
655 | 424k | tok &= 0xfffff; |
656 | 424k | dq = (dq * tok) & 0xffffff; |
657 | 11.3M | } else { |
658 | 11.3M | tok = rc_tok >> 11; |
659 | 11.3M | dq *= tok; |
660 | 11.3M | assert(dq <= 0xffffff); |
661 | 11.3M | } |
662 | 11.7M | cul_level += tok; |
663 | 11.7M | dq >>= dq_shift; |
664 | 11.7M | dq_sat = umin(dq, cf_max + sign); |
665 | 11.7M | cf[rc] = (coef) (sign ? -dq_sat : dq_sat); |
666 | | |
667 | 11.7M | rc = rc_tok & 0x3ff; |
668 | 11.7M | } while (rc); |
669 | 1.55M | } |
670 | 2.21M | } else { |
671 | | // non-qmatrix is the common case and allows for additional optimizations |
672 | 2.21M | if (dc_tok == 15) { |
673 | 85.1k | dc_tok = read_golomb(&ts->msac) + 15; |
674 | 85.1k | if (dbg) |
675 | 0 | printf("Post-dc_residual[%d->%d]: r=%d\n", |
676 | 0 | dc_tok - 15, dc_tok, ts->msac.rng); |
677 | | |
678 | 85.1k | dc_tok &= 0xfffff; |
679 | 85.1k | dc_dq = ((dc_dq * dc_tok) & 0xffffff) >> dq_shift; |
680 | 85.1k | dc_dq = umin(dc_dq, cf_max + dc_sign); |
681 | 2.12M | } else { |
682 | 2.12M | dc_dq = ((dc_dq * dc_tok) >> dq_shift); |
683 | 2.12M | assert(dc_dq <= cf_max); |
684 | 2.12M | } |
685 | 2.21M | cul_level = dc_tok; |
686 | 2.21M | cf[0] = (coef) (dc_sign ? -dc_dq : dc_dq); |
687 | | |
688 | 3.07M | if (rc) ac_noqm: { |
689 | 3.07M | const unsigned ac_dq = dq_tbl[1]; |
690 | 15.3M | do { |
691 | 15.3M | const int sign = dav1d_msac_decode_bool_equi(&ts->msac); |
692 | 15.3M | if (dbg) |
693 | 0 | printf("Post-sign[%d=%d]: r=%d\n", rc, sign, ts->msac.rng); |
694 | 15.3M | const unsigned rc_tok = cf[rc]; |
695 | 15.3M | unsigned tok; |
696 | 15.3M | int dq; |
697 | | |
698 | | // residual |
699 | 15.3M | if (rc_tok >= (15 << 11)) { |
700 | 338k | tok = read_golomb(&ts->msac) + 15; |
701 | 338k | if (dbg) |
702 | 0 | printf("Post-residual[%d=%d->%d]: r=%d\n", |
703 | 0 | rc, tok - 15, tok, ts->msac.rng); |
704 | | |
705 | | // coefficient parsing, see 5.11.39 |
706 | 338k | tok &= 0xfffff; |
707 | | |
708 | | // dequant, see 7.12.3 |
709 | 338k | dq = ((ac_dq * tok) & 0xffffff) >> dq_shift; |
710 | 338k | dq = umin(dq, cf_max + sign); |
711 | 15.0M | } else { |
712 | | // cannot exceed cf_max, so we can avoid the clipping |
713 | 15.0M | tok = rc_tok >> 11; |
714 | 15.0M | dq = ((ac_dq * tok) >> dq_shift); |
715 | 15.0M | assert(dq <= cf_max); |
716 | 15.0M | } |
717 | 15.3M | cul_level += tok; |
718 | 15.3M | cf[rc] = (coef) (sign ? -dq : dq); |
719 | | |
720 | 15.3M | rc = rc_tok & 0x3ff; // next non-zero rc, zero if eob |
721 | 15.3M | } while (rc); |
722 | 3.07M | } |
723 | 2.21M | } |
724 | | |
725 | | // context |
726 | 3.95M | *res_ctx = umin(cul_level, 63) | dc_sign_level; |
727 | | |
728 | 3.95M | return eob; |
729 | 3.34M | } |
730 | | |
731 | | static void read_coef_tree(Dav1dTaskContext *const t, |
732 | | const enum BlockSize bs, const Av1Block *const b, |
733 | | const enum RectTxfmSize ytx, const int depth, |
734 | | const uint16_t *const tx_split, |
735 | | const int x_off, const int y_off, pixel *dst) |
736 | 995k | { |
737 | 995k | const Dav1dFrameContext *const f = t->f; |
738 | 995k | Dav1dTileState *const ts = t->ts; |
739 | 995k | const Dav1dDSPContext *const dsp = f->dsp; |
740 | 995k | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[ytx]; |
741 | 995k | const int txw = t_dim->w, txh = t_dim->h; |
742 | | |
743 | | /* y_off can be larger than 3 since lossless blocks use TX_4X4 but can't |
744 | | * be splitted. Aviods an undefined left shift. */ |
745 | 995k | if (depth < 2 && tx_split[depth] && |
746 | 79.0k | tx_split[depth] & (1 << (y_off * 4 + x_off))) |
747 | 60.7k | { |
748 | 60.7k | const enum RectTxfmSize sub = t_dim->sub; |
749 | 60.7k | const TxfmInfo *const sub_t_dim = &dav1d_txfm_dimensions[sub]; |
750 | 60.7k | const int txsw = sub_t_dim->w, txsh = sub_t_dim->h; |
751 | | |
752 | 60.7k | read_coef_tree(t, bs, b, sub, depth + 1, tx_split, |
753 | 60.7k | x_off * 2 + 0, y_off * 2 + 0, dst); |
754 | 60.7k | t->bx += txsw; |
755 | 60.7k | if (txw >= txh && t->bx < f->bw) |
756 | 44.7k | read_coef_tree(t, bs, b, sub, depth + 1, tx_split, x_off * 2 + 1, |
757 | 44.7k | y_off * 2 + 0, dst ? &dst[4 * txsw] : NULL); |
758 | 60.7k | t->bx -= txsw; |
759 | 60.7k | t->by += txsh; |
760 | 60.7k | if (txh >= txw && t->by < f->bh) { |
761 | 41.6k | if (dst) |
762 | 11.4k | dst += 4 * txsh * PXSTRIDE(f->cur.stride[0]); |
763 | 41.6k | read_coef_tree(t, bs, b, sub, depth + 1, tx_split, |
764 | 41.6k | x_off * 2 + 0, y_off * 2 + 1, dst); |
765 | 41.6k | t->bx += txsw; |
766 | 41.6k | if (txw >= txh && t->bx < f->bw) |
767 | 26.2k | read_coef_tree(t, bs, b, sub, depth + 1, tx_split, x_off * 2 + 1, |
768 | 26.2k | y_off * 2 + 1, dst ? &dst[4 * txsw] : NULL); |
769 | 41.6k | t->bx -= txsw; |
770 | 41.6k | } |
771 | 60.7k | t->by -= txsh; |
772 | 934k | } else { |
773 | 934k | const int bx4 = t->bx & 31, by4 = t->by & 31; |
774 | 934k | enum TxfmType txtp; |
775 | 934k | uint8_t cf_ctx; |
776 | 934k | int eob; |
777 | 934k | coef *cf; |
778 | | |
779 | 934k | if (t->frame_thread.pass) { |
780 | 934k | const int p = t->frame_thread.pass & 1; |
781 | 934k | assert(ts->frame_thread[p].cf); |
782 | 934k | cf = ts->frame_thread[p].cf; |
783 | 934k | ts->frame_thread[p].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; |
784 | 18.4E | } else { |
785 | 18.4E | cf = bitfn(t->cf); |
786 | 18.4E | } |
787 | 934k | if (t->frame_thread.pass != 2) { |
788 | 654k | eob = decode_coefs(t, &t->a->lcoef[bx4], &t->l.lcoef[by4], |
789 | 654k | ytx, bs, b, 0, 0, cf, &txtp, &cf_ctx); |
790 | 654k | if (DEBUG_BLOCK_INFO) |
791 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", |
792 | 0 | ytx, txtp, eob, ts->msac.rng); |
793 | 654k | dav1d_memset_likely_pow2(&t->a->lcoef[bx4], cf_ctx, imin(txw, f->bw - t->bx)); |
794 | 654k | dav1d_memset_likely_pow2(&t->l.lcoef[by4], cf_ctx, imin(txh, f->bh - t->by)); |
795 | 654k | #define set_ctx(rep_macro) \ |
796 | 2.32M | for (int y = 0; y < txh; y++) { \ |
797 | 1.66M | rep_macro(txtp_map, 0, txtp); \ |
798 | 1.66M | txtp_map += 32; \ |
799 | 1.66M | } |
800 | 654k | uint8_t *txtp_map = &t->scratch.txtp_map[by4 * 32 + bx4]; |
801 | 654k | case_set_upto16(t_dim->lw); |
802 | 654k | #undef set_ctx |
803 | 654k | if (t->frame_thread.pass == 1) |
804 | 654k | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; |
805 | 654k | } else { |
806 | 279k | const int cbi = *ts->frame_thread[0].cbi++; |
807 | 279k | eob = cbi >> 5; |
808 | 279k | txtp = cbi & 0x1f; |
809 | 279k | } |
810 | 934k | if (!(t->frame_thread.pass & 1)) { |
811 | 279k | assert(dst); |
812 | 279k | if (eob >= 0) { |
813 | 161k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
814 | 0 | coef_dump(cf, imin(t_dim->h, 8) * 4, imin(t_dim->w, 8) * 4, 3, "dq"); |
815 | 161k | dsp->itx.itxfm_add[ytx][txtp](dst, f->cur.stride[0], cf, eob |
816 | 161k | HIGHBD_CALL_SUFFIX); |
817 | 161k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
818 | 0 | hex_dump(dst, f->cur.stride[0], t_dim->w * 4, t_dim->h * 4, "recon"); |
819 | 161k | } |
820 | 279k | } |
821 | 934k | } |
822 | 995k | } |
823 | | |
824 | | void bytefn(dav1d_read_coef_blocks)(Dav1dTaskContext *const t, |
825 | | const enum BlockSize bs, const Av1Block *const b) |
826 | 3.98M | { |
827 | 3.98M | const Dav1dFrameContext *const f = t->f; |
828 | 3.98M | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
829 | 3.98M | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
830 | 3.98M | const int bx4 = t->bx & 31, by4 = t->by & 31; |
831 | 3.98M | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; |
832 | 3.98M | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; |
833 | 3.98M | const int bw4 = b_dim[0], bh4 = b_dim[1]; |
834 | 3.98M | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; |
835 | 3.98M | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && |
836 | 3.69M | (bw4 > ss_hor || t->bx & 1) && |
837 | 3.43M | (bh4 > ss_ver || t->by & 1); |
838 | | |
839 | 3.98M | if (b->skip) { |
840 | 2.35M | BlockContext *const a = t->a; |
841 | 2.35M | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); |
842 | 2.35M | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); |
843 | 2.35M | if (has_chroma) { |
844 | 1.86M | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; |
845 | 1.86M | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; |
846 | 1.86M | memset_cw(&a->ccoef[0][cbx4], 0x40); |
847 | 1.86M | memset_cw(&a->ccoef[1][cbx4], 0x40); |
848 | 1.86M | memset_ch(&t->l.ccoef[0][cby4], 0x40); |
849 | 1.86M | memset_ch(&t->l.ccoef[1][cby4], 0x40); |
850 | 1.86M | } |
851 | 2.35M | return; |
852 | 2.35M | } |
853 | | |
854 | 1.63M | Dav1dTileState *const ts = t->ts; |
855 | 1.63M | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); |
856 | 1.63M | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; |
857 | 1.63M | assert(t->frame_thread.pass == 1); |
858 | 1.63M | assert(!b->skip); |
859 | 1.63M | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; |
860 | 1.63M | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->intra ? b->tx : b->max_ytx]; |
861 | 1.63M | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; |
862 | | |
863 | 3.31M | for (int init_y = 0; init_y < h4; init_y += 16) { |
864 | 1.68M | const int sub_h4 = imin(h4, 16 + init_y); |
865 | 3.44M | for (int init_x = 0; init_x < w4; init_x += 16) { |
866 | 1.75M | const int sub_w4 = imin(w4, init_x + 16); |
867 | 1.75M | int y_off = !!init_y, y, x; |
868 | 3.87M | for (y = init_y, t->by += init_y; y < sub_h4; |
869 | 2.11M | y += t_dim->h, t->by += t_dim->h, y_off++) |
870 | 2.11M | { |
871 | 2.11M | int x_off = !!init_x; |
872 | 5.57M | for (x = init_x, t->bx += init_x; x < sub_w4; |
873 | 3.45M | x += t_dim->w, t->bx += t_dim->w, x_off++) |
874 | 3.45M | { |
875 | 3.45M | if (!b->intra) { |
876 | 571k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, |
877 | 571k | x_off, y_off, NULL); |
878 | 2.88M | } else { |
879 | 2.88M | uint8_t cf_ctx = 0x40; |
880 | 2.88M | enum TxfmType txtp; |
881 | 2.88M | const int eob = |
882 | 2.88M | decode_coefs(t, &t->a->lcoef[bx4 + x], |
883 | 2.88M | &t->l.lcoef[by4 + y], b->tx, bs, b, 1, |
884 | 2.88M | 0, ts->frame_thread[1].cf, &txtp, &cf_ctx); |
885 | 2.88M | if (DEBUG_BLOCK_INFO) |
886 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", |
887 | 0 | b->tx, txtp, eob, ts->msac.rng); |
888 | 2.88M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; |
889 | 2.88M | ts->frame_thread[1].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; |
890 | 2.88M | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); |
891 | 2.88M | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); |
892 | 2.88M | } |
893 | 3.45M | } |
894 | 2.11M | t->bx -= x; |
895 | 2.11M | } |
896 | 1.75M | t->by -= y; |
897 | | |
898 | 1.75M | if (!has_chroma) continue; |
899 | | |
900 | 1.46M | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); |
901 | 1.46M | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); |
902 | 4.38M | for (int pl = 0; pl < 2; pl++) { |
903 | 6.26M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; |
904 | 3.33M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) |
905 | 3.33M | { |
906 | 7.72M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; |
907 | 4.38M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) |
908 | 4.38M | { |
909 | 4.38M | uint8_t cf_ctx = 0x40; |
910 | 4.38M | enum TxfmType txtp; |
911 | 4.38M | if (!b->intra) |
912 | 731k | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + |
913 | 731k | bx4 + (x << ss_hor)]; |
914 | 4.38M | const int eob = |
915 | 4.38M | decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], |
916 | 4.38M | &t->l.ccoef[pl][cby4 + y], b->uvtx, bs, |
917 | 4.38M | b, b->intra, 1 + pl, ts->frame_thread[1].cf, |
918 | 4.38M | &txtp, &cf_ctx); |
919 | 4.38M | if (DEBUG_BLOCK_INFO) |
920 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," |
921 | 0 | "txtp=%d,eob=%d]: r=%d\n", |
922 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); |
923 | 4.38M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; |
924 | 4.38M | ts->frame_thread[1].cf += uv_t_dim->w * uv_t_dim->h * 16; |
925 | 4.38M | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); |
926 | 4.38M | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); |
927 | 4.38M | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); |
928 | 4.38M | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); |
929 | 4.38M | } |
930 | 3.33M | t->bx -= x << ss_hor; |
931 | 3.33M | } |
932 | 2.92M | t->by -= y << ss_ver; |
933 | 2.92M | } |
934 | 1.46M | } |
935 | 1.68M | } |
936 | 1.63M | } dav1d_read_coef_blocks_8bpc Line | Count | Source | 826 | 2.00M | { | 827 | 2.00M | const Dav1dFrameContext *const f = t->f; | 828 | 2.00M | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 829 | 2.00M | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 830 | 2.00M | const int bx4 = t->bx & 31, by4 = t->by & 31; | 831 | 2.00M | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 832 | 2.00M | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 833 | 2.00M | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 834 | 2.00M | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; | 835 | 2.00M | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 836 | 1.86M | (bw4 > ss_hor || t->bx & 1) && | 837 | 1.72M | (bh4 > ss_ver || t->by & 1); | 838 | | | 839 | 2.00M | if (b->skip) { | 840 | 1.23M | BlockContext *const a = t->a; | 841 | 1.23M | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); | 842 | 1.23M | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); | 843 | 1.23M | if (has_chroma) { | 844 | 978k | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; | 845 | 978k | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; | 846 | 978k | memset_cw(&a->ccoef[0][cbx4], 0x40); | 847 | 978k | memset_cw(&a->ccoef[1][cbx4], 0x40); | 848 | 978k | memset_ch(&t->l.ccoef[0][cby4], 0x40); | 849 | 978k | memset_ch(&t->l.ccoef[1][cby4], 0x40); | 850 | 978k | } | 851 | 1.23M | return; | 852 | 1.23M | } | 853 | | | 854 | 766k | Dav1dTileState *const ts = t->ts; | 855 | 766k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 856 | 766k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 857 | 766k | assert(t->frame_thread.pass == 1); | 858 | 766k | assert(!b->skip); | 859 | 766k | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; | 860 | 766k | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->intra ? b->tx : b->max_ytx]; | 861 | 766k | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; | 862 | | | 863 | 1.55M | for (int init_y = 0; init_y < h4; init_y += 16) { | 864 | 790k | const int sub_h4 = imin(h4, 16 + init_y); | 865 | 1.61M | for (int init_x = 0; init_x < w4; init_x += 16) { | 866 | 820k | const int sub_w4 = imin(w4, init_x + 16); | 867 | 820k | int y_off = !!init_y, y, x; | 868 | 1.80M | for (y = init_y, t->by += init_y; y < sub_h4; | 869 | 989k | y += t_dim->h, t->by += t_dim->h, y_off++) | 870 | 989k | { | 871 | 989k | int x_off = !!init_x; | 872 | 2.65M | for (x = init_x, t->bx += init_x; x < sub_w4; | 873 | 1.66M | x += t_dim->w, t->bx += t_dim->w, x_off++) | 874 | 1.66M | { | 875 | 1.66M | if (!b->intra) { | 876 | 389k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, | 877 | 389k | x_off, y_off, NULL); | 878 | 1.27M | } else { | 879 | 1.27M | uint8_t cf_ctx = 0x40; | 880 | 1.27M | enum TxfmType txtp; | 881 | 1.27M | const int eob = | 882 | 1.27M | decode_coefs(t, &t->a->lcoef[bx4 + x], | 883 | 1.27M | &t->l.lcoef[by4 + y], b->tx, bs, b, 1, | 884 | 1.27M | 0, ts->frame_thread[1].cf, &txtp, &cf_ctx); | 885 | 1.27M | if (DEBUG_BLOCK_INFO) | 886 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", | 887 | 0 | b->tx, txtp, eob, ts->msac.rng); | 888 | 1.27M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; | 889 | 1.27M | ts->frame_thread[1].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; | 890 | 1.27M | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); | 891 | 1.27M | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); | 892 | 1.27M | } | 893 | 1.66M | } | 894 | 989k | t->bx -= x; | 895 | 989k | } | 896 | 820k | t->by -= y; | 897 | | | 898 | 820k | if (!has_chroma) continue; | 899 | | | 900 | 680k | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); | 901 | 680k | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); | 902 | 2.03M | for (int pl = 0; pl < 2; pl++) { | 903 | 2.93M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; | 904 | 1.57M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) | 905 | 1.57M | { | 906 | 3.74M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; | 907 | 2.17M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) | 908 | 2.17M | { | 909 | 2.17M | uint8_t cf_ctx = 0x40; | 910 | 2.17M | enum TxfmType txtp; | 911 | 2.17M | if (!b->intra) | 912 | 485k | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + | 913 | 485k | bx4 + (x << ss_hor)]; | 914 | 2.17M | const int eob = | 915 | 2.17M | decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 916 | 2.17M | &t->l.ccoef[pl][cby4 + y], b->uvtx, bs, | 917 | 2.17M | b, b->intra, 1 + pl, ts->frame_thread[1].cf, | 918 | 2.17M | &txtp, &cf_ctx); | 919 | 2.17M | if (DEBUG_BLOCK_INFO) | 920 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 921 | 0 | "txtp=%d,eob=%d]: r=%d\n", | 922 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); | 923 | 2.17M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; | 924 | 2.17M | ts->frame_thread[1].cf += uv_t_dim->w * uv_t_dim->h * 16; | 925 | 2.17M | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 926 | 2.17M | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); | 927 | 2.17M | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 928 | 2.17M | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 929 | 2.17M | } | 930 | 1.57M | t->bx -= x << ss_hor; | 931 | 1.57M | } | 932 | 1.35M | t->by -= y << ss_ver; | 933 | 1.35M | } | 934 | 680k | } | 935 | 790k | } | 936 | 766k | } |
dav1d_read_coef_blocks_16bpc Line | Count | Source | 826 | 1.98M | { | 827 | 1.98M | const Dav1dFrameContext *const f = t->f; | 828 | 1.98M | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 829 | 1.98M | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 830 | 1.98M | const int bx4 = t->bx & 31, by4 = t->by & 31; | 831 | 1.98M | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 832 | 1.98M | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 833 | 1.98M | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 834 | 1.98M | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; | 835 | 1.98M | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 836 | 1.82M | (bw4 > ss_hor || t->bx & 1) && | 837 | 1.71M | (bh4 > ss_ver || t->by & 1); | 838 | | | 839 | 1.98M | if (b->skip) { | 840 | 1.11M | BlockContext *const a = t->a; | 841 | 1.11M | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); | 842 | 1.11M | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); | 843 | 1.11M | if (has_chroma) { | 844 | 889k | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; | 845 | 889k | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; | 846 | 889k | memset_cw(&a->ccoef[0][cbx4], 0x40); | 847 | 889k | memset_cw(&a->ccoef[1][cbx4], 0x40); | 848 | 889k | memset_ch(&t->l.ccoef[0][cby4], 0x40); | 849 | 889k | memset_ch(&t->l.ccoef[1][cby4], 0x40); | 850 | 889k | } | 851 | 1.11M | return; | 852 | 1.11M | } | 853 | | | 854 | 865k | Dav1dTileState *const ts = t->ts; | 855 | 865k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 856 | 865k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 857 | 865k | assert(t->frame_thread.pass == 1); | 858 | 865k | assert(!b->skip); | 859 | 865k | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; | 860 | 865k | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->intra ? b->tx : b->max_ytx]; | 861 | 865k | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; | 862 | | | 863 | 1.76M | for (int init_y = 0; init_y < h4; init_y += 16) { | 864 | 895k | const int sub_h4 = imin(h4, 16 + init_y); | 865 | 1.83M | for (int init_x = 0; init_x < w4; init_x += 16) { | 866 | 938k | const int sub_w4 = imin(w4, init_x + 16); | 867 | 938k | int y_off = !!init_y, y, x; | 868 | 2.06M | for (y = init_y, t->by += init_y; y < sub_h4; | 869 | 1.12M | y += t_dim->h, t->by += t_dim->h, y_off++) | 870 | 1.12M | { | 871 | 1.12M | int x_off = !!init_x; | 872 | 2.91M | for (x = init_x, t->bx += init_x; x < sub_w4; | 873 | 1.79M | x += t_dim->w, t->bx += t_dim->w, x_off++) | 874 | 1.79M | { | 875 | 1.79M | if (!b->intra) { | 876 | 182k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, | 877 | 182k | x_off, y_off, NULL); | 878 | 1.60M | } else { | 879 | 1.60M | uint8_t cf_ctx = 0x40; | 880 | 1.60M | enum TxfmType txtp; | 881 | 1.60M | const int eob = | 882 | 1.60M | decode_coefs(t, &t->a->lcoef[bx4 + x], | 883 | 1.60M | &t->l.lcoef[by4 + y], b->tx, bs, b, 1, | 884 | 1.60M | 0, ts->frame_thread[1].cf, &txtp, &cf_ctx); | 885 | 1.60M | if (DEBUG_BLOCK_INFO) | 886 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", | 887 | 0 | b->tx, txtp, eob, ts->msac.rng); | 888 | 1.60M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; | 889 | 1.60M | ts->frame_thread[1].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; | 890 | 1.60M | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); | 891 | 1.60M | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); | 892 | 1.60M | } | 893 | 1.79M | } | 894 | 1.12M | t->bx -= x; | 895 | 1.12M | } | 896 | 938k | t->by -= y; | 897 | | | 898 | 938k | if (!has_chroma) continue; | 899 | | | 900 | 783k | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); | 901 | 783k | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); | 902 | 2.34M | for (int pl = 0; pl < 2; pl++) { | 903 | 3.33M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; | 904 | 1.76M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) | 905 | 1.76M | { | 906 | 3.97M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; | 907 | 2.20M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) | 908 | 2.20M | { | 909 | 2.20M | uint8_t cf_ctx = 0x40; | 910 | 2.20M | enum TxfmType txtp; | 911 | 2.20M | if (!b->intra) | 912 | 245k | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + | 913 | 245k | bx4 + (x << ss_hor)]; | 914 | 2.20M | const int eob = | 915 | 2.20M | decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 916 | 2.20M | &t->l.ccoef[pl][cby4 + y], b->uvtx, bs, | 917 | 2.20M | b, b->intra, 1 + pl, ts->frame_thread[1].cf, | 918 | 2.20M | &txtp, &cf_ctx); | 919 | 2.20M | if (DEBUG_BLOCK_INFO) | 920 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 921 | 0 | "txtp=%d,eob=%d]: r=%d\n", | 922 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); | 923 | 2.20M | *ts->frame_thread[1].cbi++ = eob * (1 << 5) + txtp; | 924 | 2.20M | ts->frame_thread[1].cf += uv_t_dim->w * uv_t_dim->h * 16; | 925 | 2.20M | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 926 | 2.20M | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); | 927 | 2.20M | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 928 | 2.20M | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 929 | 2.20M | } | 930 | 1.76M | t->bx -= x << ss_hor; | 931 | 1.76M | } | 932 | 1.56M | t->by -= y << ss_ver; | 933 | 1.56M | } | 934 | 783k | } | 935 | 895k | } | 936 | 865k | } |
|
937 | | |
938 | | static int mc(Dav1dTaskContext *const t, |
939 | | pixel *const dst8, int16_t *const dst16, const ptrdiff_t dst_stride, |
940 | | const int bw4, const int bh4, |
941 | | const int bx, const int by, const int pl, |
942 | | const mv mv, const Dav1dThreadPicture *const refp, const int refidx, |
943 | | const enum Filter2d filter_2d) |
944 | 977k | { |
945 | 977k | assert((dst8 != NULL) ^ (dst16 != NULL)); |
946 | 977k | const Dav1dFrameContext *const f = t->f; |
947 | 977k | const int ss_ver = !!pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
948 | 977k | const int ss_hor = !!pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
949 | 977k | const int h_mul = 4 >> ss_hor, v_mul = 4 >> ss_ver; |
950 | 977k | const int mvx = mv.x, mvy = mv.y; |
951 | 977k | const int mx = mvx & (15 >> !ss_hor), my = mvy & (15 >> !ss_ver); |
952 | 977k | ptrdiff_t ref_stride = refp->p.stride[!!pl]; |
953 | 977k | const pixel *ref; |
954 | | |
955 | 977k | if (refp->p.p.w == f->cur.p.w && refp->p.p.h == f->cur.p.h) { |
956 | 777k | const int dx = bx * h_mul + (mvx >> (3 + ss_hor)); |
957 | 777k | const int dy = by * v_mul + (mvy >> (3 + ss_ver)); |
958 | 777k | int w, h; |
959 | | |
960 | 777k | if (refp->p.data[0] != f->cur.data[0]) { // i.e. not for intrabc |
961 | 512k | w = (f->cur.p.w + ss_hor) >> ss_hor; |
962 | 512k | h = (f->cur.p.h + ss_ver) >> ss_ver; |
963 | 512k | } else { |
964 | 265k | w = f->bw * 4 >> ss_hor; |
965 | 265k | h = f->bh * 4 >> ss_ver; |
966 | 265k | } |
967 | 777k | if (dx < !!mx * 3 || dy < !!my * 3 || |
968 | 665k | dx + bw4 * h_mul + !!mx * 4 > w || |
969 | 525k | dy + bh4 * v_mul + !!my * 4 > h) |
970 | 346k | { |
971 | 346k | pixel *const emu_edge_buf = bitfn(t->scratch.emu_edge); |
972 | 346k | f->dsp->mc.emu_edge(bw4 * h_mul + !!mx * 7, bh4 * v_mul + !!my * 7, |
973 | 346k | w, h, dx - !!mx * 3, dy - !!my * 3, |
974 | 346k | emu_edge_buf, 192 * sizeof(pixel), |
975 | 346k | refp->p.data[pl], ref_stride); |
976 | 346k | ref = &emu_edge_buf[192 * !!my * 3 + !!mx * 3]; |
977 | 346k | ref_stride = 192 * sizeof(pixel); |
978 | 431k | } else { |
979 | 431k | ref = ((pixel *) refp->p.data[pl]) + PXSTRIDE(ref_stride) * dy + dx; |
980 | 431k | } |
981 | | |
982 | 777k | if (dst8 != NULL) { |
983 | 701k | f->dsp->mc.mc[filter_2d](dst8, dst_stride, ref, ref_stride, bw4 * h_mul, |
984 | 701k | bh4 * v_mul, mx << !ss_hor, my << !ss_ver |
985 | 701k | HIGHBD_CALL_SUFFIX); |
986 | 701k | } else { |
987 | 76.7k | f->dsp->mc.mct[filter_2d](dst16, ref, ref_stride, bw4 * h_mul, |
988 | 76.7k | bh4 * v_mul, mx << !ss_hor, my << !ss_ver |
989 | 76.7k | HIGHBD_CALL_SUFFIX); |
990 | 76.7k | } |
991 | 777k | } else { |
992 | 199k | assert(refp != &f->sr_cur); |
993 | | |
994 | 199k | const int orig_pos_y = (by * v_mul << 4) + mvy * (1 << !ss_ver); |
995 | 199k | const int orig_pos_x = (bx * h_mul << 4) + mvx * (1 << !ss_hor); |
996 | 398k | #define scale_mv(res, val, scale) do { \ |
997 | 398k | const int64_t tmp = (int64_t)(val) * scale + (scale - 0x4000) * 8; \ |
998 | 398k | res = apply_sign64((int) ((llabs(tmp) + 128) >> 8), tmp) + 32; \ |
999 | 398k | } while (0) |
1000 | 199k | int pos_y, pos_x; |
1001 | 199k | scale_mv(pos_x, orig_pos_x, f->svc[refidx][0].scale); |
1002 | 199k | scale_mv(pos_y, orig_pos_y, f->svc[refidx][1].scale); |
1003 | 199k | #undef scale_mv |
1004 | 199k | const int left = pos_x >> 10; |
1005 | 199k | const int top = pos_y >> 10; |
1006 | 199k | const int right = |
1007 | 199k | ((pos_x + (bw4 * h_mul - 1) * f->svc[refidx][0].step) >> 10) + 1; |
1008 | 199k | const int bottom = |
1009 | 199k | ((pos_y + (bh4 * v_mul - 1) * f->svc[refidx][1].step) >> 10) + 1; |
1010 | | |
1011 | 199k | if (DEBUG_BLOCK_INFO) |
1012 | 0 | printf("Off %dx%d [%d,%d,%d], size %dx%d [%d,%d]\n", |
1013 | 0 | left, top, orig_pos_x, f->svc[refidx][0].scale, refidx, |
1014 | 0 | right-left, bottom-top, |
1015 | 0 | f->svc[refidx][0].step, f->svc[refidx][1].step); |
1016 | | |
1017 | 199k | const int w = (refp->p.p.w + ss_hor) >> ss_hor; |
1018 | 199k | const int h = (refp->p.p.h + ss_ver) >> ss_ver; |
1019 | 199k | if (left < 3 || top < 3 || right + 4 > w || bottom + 4 > h) { |
1020 | 187k | pixel *const emu_edge_buf = bitfn(t->scratch.emu_edge); |
1021 | 187k | f->dsp->mc.emu_edge(right - left + 7, bottom - top + 7, |
1022 | 187k | w, h, left - 3, top - 3, |
1023 | 187k | emu_edge_buf, 320 * sizeof(pixel), |
1024 | 187k | refp->p.data[pl], ref_stride); |
1025 | 187k | ref = &emu_edge_buf[320 * 3 + 3]; |
1026 | 187k | ref_stride = 320 * sizeof(pixel); |
1027 | 187k | if (DEBUG_BLOCK_INFO) printf("Emu\n"); |
1028 | 187k | } else { |
1029 | 11.3k | ref = ((pixel *) refp->p.data[pl]) + PXSTRIDE(ref_stride) * top + left; |
1030 | 11.3k | } |
1031 | | |
1032 | 199k | if (dst8 != NULL) { |
1033 | 151k | f->dsp->mc.mc_scaled[filter_2d](dst8, dst_stride, ref, ref_stride, |
1034 | 151k | bw4 * h_mul, bh4 * v_mul, |
1035 | 151k | pos_x & 0x3ff, pos_y & 0x3ff, |
1036 | 151k | f->svc[refidx][0].step, |
1037 | 151k | f->svc[refidx][1].step |
1038 | 151k | HIGHBD_CALL_SUFFIX); |
1039 | 151k | } else { |
1040 | 47.7k | f->dsp->mc.mct_scaled[filter_2d](dst16, ref, ref_stride, |
1041 | 47.7k | bw4 * h_mul, bh4 * v_mul, |
1042 | 47.7k | pos_x & 0x3ff, pos_y & 0x3ff, |
1043 | 47.7k | f->svc[refidx][0].step, |
1044 | 47.7k | f->svc[refidx][1].step |
1045 | 47.7k | HIGHBD_CALL_SUFFIX); |
1046 | 47.7k | } |
1047 | 199k | } |
1048 | | |
1049 | 977k | return 0; |
1050 | 977k | } |
1051 | | |
1052 | | static int obmc(Dav1dTaskContext *const t, |
1053 | | pixel *const dst, const ptrdiff_t dst_stride, |
1054 | | const uint8_t *const b_dim, const int pl, |
1055 | | const int bx4, const int by4, const int w4, const int h4) |
1056 | 85.9k | { |
1057 | 85.9k | assert(!(t->bx & 1) && !(t->by & 1)); |
1058 | 85.9k | const Dav1dFrameContext *const f = t->f; |
1059 | 85.9k | /*const*/ refmvs_block **r = &t->rt.r[(t->by & 31) + 5]; |
1060 | 85.9k | pixel *const lap = bitfn(t->scratch.lap); |
1061 | 85.9k | const int ss_ver = !!pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
1062 | 85.9k | const int ss_hor = !!pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
1063 | 85.9k | const int h_mul = 4 >> ss_hor, v_mul = 4 >> ss_ver; |
1064 | 85.9k | int res; |
1065 | | |
1066 | 85.9k | if (t->by > t->ts->tiling.row_start && |
1067 | 72.2k | (!pl || b_dim[0] * h_mul + b_dim[1] * v_mul >= 16)) |
1068 | 67.6k | { |
1069 | 142k | for (int i = 0, x = 0; x < w4 && i < imin(b_dim[2], 4); ) { |
1070 | | // only odd blocks are considered for overlap handling, hence +1 |
1071 | 74.6k | const refmvs_block *const a_r = &r[-1][t->bx + x + 1]; |
1072 | 74.6k | const uint8_t *const a_b_dim = dav1d_block_dimensions[a_r->bs]; |
1073 | 74.6k | const int step4 = iclip(a_b_dim[0], 2, 16); |
1074 | | |
1075 | 74.6k | if (a_r->ref.ref[0] > 0) { |
1076 | 74.1k | const int ow4 = imin(step4, b_dim[0]); |
1077 | 74.1k | const int oh4 = imin(b_dim[1], 16) >> 1; |
1078 | 74.1k | res = mc(t, lap, NULL, ow4 * h_mul * sizeof(pixel), ow4, (oh4 * 3 + 3) >> 2, |
1079 | 74.1k | t->bx + x, t->by, pl, a_r->mv.mv[0], |
1080 | 74.1k | &f->refp[a_r->ref.ref[0] - 1], a_r->ref.ref[0] - 1, |
1081 | 74.1k | dav1d_filter_2d[t->a->filter[1][bx4 + x + 1]][t->a->filter[0][bx4 + x + 1]]); |
1082 | 74.1k | if (res) return res; |
1083 | 74.1k | f->dsp->mc.blend_h(&dst[x * h_mul], dst_stride, lap, |
1084 | 74.1k | h_mul * ow4, v_mul * oh4); |
1085 | 74.1k | i++; |
1086 | 74.1k | } |
1087 | 74.6k | x += step4; |
1088 | 74.6k | } |
1089 | 67.6k | } |
1090 | | |
1091 | 85.9k | if (t->bx > t->ts->tiling.col_start) |
1092 | 143k | for (int i = 0, y = 0; y < h4 && i < imin(b_dim[3], 4); ) { |
1093 | | // only odd blocks are considered for overlap handling, hence +1 |
1094 | 74.1k | const refmvs_block *const l_r = &r[y + 1][t->bx - 1]; |
1095 | 74.1k | const uint8_t *const l_b_dim = dav1d_block_dimensions[l_r->bs]; |
1096 | 74.1k | const int step4 = iclip(l_b_dim[1], 2, 16); |
1097 | | |
1098 | 74.1k | if (l_r->ref.ref[0] > 0) { |
1099 | 73.6k | const int ow4 = imin(b_dim[0], 16) >> 1; |
1100 | 73.6k | const int oh4 = imin(step4, b_dim[1]); |
1101 | 73.6k | res = mc(t, lap, NULL, h_mul * ow4 * sizeof(pixel), ow4, oh4, |
1102 | 73.6k | t->bx, t->by + y, pl, l_r->mv.mv[0], |
1103 | 73.6k | &f->refp[l_r->ref.ref[0] - 1], l_r->ref.ref[0] - 1, |
1104 | 73.6k | dav1d_filter_2d[t->l.filter[1][by4 + y + 1]][t->l.filter[0][by4 + y + 1]]); |
1105 | 73.6k | if (res) return res; |
1106 | 73.6k | f->dsp->mc.blend_v(&dst[y * v_mul * PXSTRIDE(dst_stride)], |
1107 | 73.6k | dst_stride, lap, h_mul * ow4, v_mul * oh4); |
1108 | 73.6k | i++; |
1109 | 73.6k | } |
1110 | 74.1k | y += step4; |
1111 | 74.1k | } |
1112 | 85.9k | return 0; |
1113 | 85.9k | } |
1114 | | |
1115 | | static int warp_affine(Dav1dTaskContext *const t, |
1116 | | pixel *dst8, int16_t *dst16, const ptrdiff_t dstride, |
1117 | | const uint8_t *const b_dim, const int pl, |
1118 | | const Dav1dThreadPicture *const refp, |
1119 | | const Dav1dWarpedMotionParams *const wmp) |
1120 | 26.9k | { |
1121 | 26.9k | assert((dst8 != NULL) ^ (dst16 != NULL)); |
1122 | 26.9k | const Dav1dFrameContext *const f = t->f; |
1123 | 26.9k | const Dav1dDSPContext *const dsp = f->dsp; |
1124 | 26.9k | const int ss_ver = !!pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
1125 | 26.9k | const int ss_hor = !!pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
1126 | 26.9k | const int h_mul = 4 >> ss_hor, v_mul = 4 >> ss_ver; |
1127 | 26.9k | assert(!((b_dim[0] * h_mul) & 7) && !((b_dim[1] * v_mul) & 7)); |
1128 | 26.9k | const int32_t *const mat = wmp->matrix; |
1129 | 26.9k | const int width = (refp->p.p.w + ss_hor) >> ss_hor; |
1130 | 26.9k | const int height = (refp->p.p.h + ss_ver) >> ss_ver; |
1131 | | |
1132 | 91.3k | for (int y = 0; y < b_dim[1] * v_mul; y += 8) { |
1133 | 64.3k | const int src_y = t->by * 4 + ((y + 4) << ss_ver); |
1134 | 64.3k | const int64_t mat3_y = (int64_t) mat[3] * src_y + mat[0]; |
1135 | 64.3k | const int64_t mat5_y = (int64_t) mat[5] * src_y + mat[1]; |
1136 | 367k | for (int x = 0; x < b_dim[0] * h_mul; x += 8) { |
1137 | | // calculate transformation relative to center of 8x8 block in |
1138 | | // luma pixel units |
1139 | 303k | const int src_x = t->bx * 4 + ((x + 4) << ss_hor); |
1140 | 303k | const int64_t mvx = ((int64_t) mat[2] * src_x + mat3_y) >> ss_hor; |
1141 | 303k | const int64_t mvy = ((int64_t) mat[4] * src_x + mat5_y) >> ss_ver; |
1142 | | |
1143 | 303k | const int dx = (int) (mvx >> 16) - 4; |
1144 | 303k | const int mx = (((int) mvx & 0xffff) - wmp->u.p.alpha * 4 - |
1145 | 303k | wmp->u.p.beta * 7) & ~0x3f; |
1146 | 303k | const int dy = (int) (mvy >> 16) - 4; |
1147 | 303k | const int my = (((int) mvy & 0xffff) - wmp->u.p.gamma * 4 - |
1148 | 303k | wmp->u.p.delta * 4) & ~0x3f; |
1149 | | |
1150 | 303k | const pixel *ref_ptr; |
1151 | 303k | ptrdiff_t ref_stride = refp->p.stride[!!pl]; |
1152 | | |
1153 | 303k | if (dx < 3 || dx + 8 + 4 > width || dy < 3 || dy + 8 + 4 > height) { |
1154 | 223k | pixel *const emu_edge_buf = bitfn(t->scratch.emu_edge); |
1155 | 223k | f->dsp->mc.emu_edge(15, 15, width, height, dx - 3, dy - 3, |
1156 | 223k | emu_edge_buf, 32 * sizeof(pixel), |
1157 | 223k | refp->p.data[pl], ref_stride); |
1158 | 223k | ref_ptr = &emu_edge_buf[32 * 3 + 3]; |
1159 | 223k | ref_stride = 32 * sizeof(pixel); |
1160 | 223k | } else { |
1161 | 79.8k | ref_ptr = ((pixel *) refp->p.data[pl]) + PXSTRIDE(ref_stride) * dy + dx; |
1162 | 79.8k | } |
1163 | 303k | if (dst16 != NULL) |
1164 | 52.7k | dsp->mc.warp8x8t(&dst16[x], dstride, ref_ptr, ref_stride, |
1165 | 52.7k | wmp->u.abcd, mx, my HIGHBD_CALL_SUFFIX); |
1166 | 250k | else |
1167 | 250k | dsp->mc.warp8x8(&dst8[x], dstride, ref_ptr, ref_stride, |
1168 | 250k | wmp->u.abcd, mx, my HIGHBD_CALL_SUFFIX); |
1169 | 303k | } |
1170 | 64.3k | if (dst8) dst8 += 8 * PXSTRIDE(dstride); |
1171 | 13.9k | else dst16 += 8 * dstride; |
1172 | 64.3k | } |
1173 | 26.9k | return 0; |
1174 | 26.9k | } |
1175 | | |
1176 | | void bytefn(dav1d_recon_b_intra)(Dav1dTaskContext *const t, const enum BlockSize bs, |
1177 | | const enum EdgeFlags intra_edge_flags, |
1178 | | const Av1Block *const b) |
1179 | 1.67M | { |
1180 | 1.67M | Dav1dTileState *const ts = t->ts; |
1181 | 1.67M | const Dav1dFrameContext *const f = t->f; |
1182 | 1.67M | const Dav1dDSPContext *const dsp = f->dsp; |
1183 | 1.67M | const int bx4 = t->bx & 31, by4 = t->by & 31; |
1184 | 1.67M | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
1185 | 1.67M | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
1186 | 1.67M | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; |
1187 | 1.67M | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; |
1188 | 1.67M | const int bw4 = b_dim[0], bh4 = b_dim[1]; |
1189 | 1.67M | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); |
1190 | 1.67M | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; |
1191 | 1.67M | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && |
1192 | 1.58M | (bw4 > ss_hor || t->bx & 1) && |
1193 | 1.49M | (bh4 > ss_ver || t->by & 1); |
1194 | 1.67M | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->tx]; |
1195 | 1.67M | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; |
1196 | | |
1197 | | // coefficient coding |
1198 | 1.67M | pixel *const edge = bitfn(t->scratch.edge) + 128; |
1199 | 1.67M | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; |
1200 | | |
1201 | 1.67M | const int intra_edge_filter_flag = f->seq_hdr->intra_edge_filter << 10; |
1202 | | |
1203 | 3.41M | for (int init_y = 0; init_y < h4; init_y += 16) { |
1204 | 1.73M | const int sub_h4 = imin(h4, 16 + init_y); |
1205 | 1.73M | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); |
1206 | 3.54M | for (int init_x = 0; init_x < w4; init_x += 16) { |
1207 | 1.81M | if (b->pal_sz[0]) { |
1208 | 8.42k | pixel *dst = ((pixel *) f->cur.data[0]) + |
1209 | 8.42k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); |
1210 | 8.42k | const uint8_t *pal_idx; |
1211 | 8.42k | if (t->frame_thread.pass) { |
1212 | 8.42k | const int p = t->frame_thread.pass & 1; |
1213 | 8.42k | assert(ts->frame_thread[p].pal_idx); |
1214 | 8.42k | pal_idx = ts->frame_thread[p].pal_idx; |
1215 | 8.42k | ts->frame_thread[p].pal_idx += bw4 * bh4 * 8; |
1216 | 8.42k | } else { |
1217 | 0 | pal_idx = t->scratch.pal_idx_y; |
1218 | 0 | } |
1219 | 8.42k | const pixel *const pal = t->frame_thread.pass ? |
1220 | 8.42k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
1221 | 8.42k | ((t->bx >> 1) + (t->by & 1))][0] : |
1222 | 8.42k | bytefn(t->scratch.pal)[0]; |
1223 | 8.42k | f->dsp->ipred.pal_pred(dst, f->cur.stride[0], pal, |
1224 | 8.42k | pal_idx, bw4 * 4, bh4 * 4); |
1225 | 8.42k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1226 | 0 | hex_dump(dst, PXSTRIDE(f->cur.stride[0]), |
1227 | 0 | bw4 * 4, bh4 * 4, "y-pal-pred"); |
1228 | 8.42k | } |
1229 | | |
1230 | 1.81M | const int intra_flags = (sm_flag(t->a, bx4) | |
1231 | 1.81M | sm_flag(&t->l, by4) | |
1232 | 1.81M | intra_edge_filter_flag); |
1233 | 1.81M | const int sb_has_tr = init_x + 16 < w4 ? 1 : init_y ? 0 : |
1234 | 1.73M | intra_edge_flags & EDGE_I444_TOP_HAS_RIGHT; |
1235 | 1.81M | const int sb_has_bl = init_x ? 0 : init_y + 16 < h4 ? 1 : |
1236 | 1.73M | intra_edge_flags & EDGE_I444_LEFT_HAS_BOTTOM; |
1237 | 1.81M | int y, x; |
1238 | 1.81M | const int sub_w4 = imin(w4, init_x + 16); |
1239 | 4.10M | for (y = init_y, t->by += init_y; y < sub_h4; |
1240 | 2.29M | y += t_dim->h, t->by += t_dim->h) |
1241 | 2.29M | { |
1242 | 2.29M | pixel *dst = ((pixel *) f->cur.data[0]) + |
1243 | 2.29M | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + |
1244 | 2.29M | t->bx + init_x); |
1245 | 7.07M | for (x = init_x, t->bx += init_x; x < sub_w4; |
1246 | 4.78M | x += t_dim->w, t->bx += t_dim->w) |
1247 | 4.77M | { |
1248 | 4.77M | if (b->pal_sz[0]) goto skip_y_pred; |
1249 | | |
1250 | 4.76M | int angle = b->y_angle; |
1251 | 4.76M | const enum EdgeFlags edge_flags = |
1252 | 4.76M | (((y > init_y || !sb_has_tr) && (x + t_dim->w >= sub_w4)) ? |
1253 | 3.75M | 0 : EDGE_I444_TOP_HAS_RIGHT) | |
1254 | 4.76M | ((x > init_x || (!sb_has_bl && y + t_dim->h >= sub_h4)) ? |
1255 | 3.47M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); |
1256 | 4.76M | const pixel *top_sb_edge = NULL; |
1257 | 4.76M | if (!(t->by & (f->sb_step - 1))) { |
1258 | 827k | top_sb_edge = f->ipred_edge[0]; |
1259 | 827k | const int sby = t->by >> f->sb_shift; |
1260 | 827k | top_sb_edge += f->sb128w * 128 * (sby - 1); |
1261 | 827k | } |
1262 | 4.76M | const enum IntraPredMode m = |
1263 | 4.76M | bytefn(dav1d_prepare_intra_edges)(t->bx, |
1264 | 4.76M | t->bx > ts->tiling.col_start, |
1265 | 4.76M | t->by, |
1266 | 4.76M | t->by > ts->tiling.row_start, |
1267 | 4.76M | ts->tiling.col_end, |
1268 | 4.76M | ts->tiling.row_end, |
1269 | 4.76M | edge_flags, dst, |
1270 | 4.76M | f->cur.stride[0], top_sb_edge, |
1271 | 4.76M | b->y_mode, &angle, |
1272 | 4.76M | t_dim->w, t_dim->h, |
1273 | 4.76M | f->seq_hdr->intra_edge_filter, |
1274 | 4.76M | edge HIGHBD_CALL_SUFFIX); |
1275 | 4.76M | dsp->ipred.intra_pred[m](dst, f->cur.stride[0], edge, |
1276 | 4.76M | t_dim->w * 4, t_dim->h * 4, |
1277 | 4.76M | angle | intra_flags, |
1278 | 4.76M | 4 * f->bw - 4 * t->bx, |
1279 | 4.76M | 4 * f->bh - 4 * t->by |
1280 | 4.76M | HIGHBD_CALL_SUFFIX); |
1281 | | |
1282 | 4.76M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { |
1283 | 0 | hex_dump(edge - t_dim->h * 4, t_dim->h * 4, |
1284 | 0 | t_dim->h * 4, 2, "l"); |
1285 | 0 | hex_dump(edge, 0, 1, 1, "tl"); |
1286 | 0 | hex_dump(edge + 1, t_dim->w * 4, |
1287 | 0 | t_dim->w * 4, 2, "t"); |
1288 | 0 | hex_dump(dst, f->cur.stride[0], |
1289 | 0 | t_dim->w * 4, t_dim->h * 4, "y-intra-pred"); |
1290 | 0 | } |
1291 | | |
1292 | 4.78M | skip_y_pred: {} |
1293 | 4.78M | if (!b->skip) { |
1294 | 1.20M | coef *cf; |
1295 | 1.20M | int eob; |
1296 | 1.20M | enum TxfmType txtp; |
1297 | 1.20M | if (t->frame_thread.pass) { |
1298 | 1.20M | const int p = t->frame_thread.pass & 1; |
1299 | 1.20M | const int cbi = *ts->frame_thread[p].cbi++; |
1300 | 1.20M | cf = ts->frame_thread[p].cf; |
1301 | 1.20M | ts->frame_thread[p].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; |
1302 | 1.20M | eob = cbi >> 5; |
1303 | 1.20M | txtp = cbi & 0x1f; |
1304 | 1.20M | } else { |
1305 | 0 | uint8_t cf_ctx; |
1306 | 0 | cf = bitfn(t->cf); |
1307 | 0 | eob = decode_coefs(t, &t->a->lcoef[bx4 + x], |
1308 | 0 | &t->l.lcoef[by4 + y], b->tx, bs, |
1309 | 0 | b, 1, 0, cf, &txtp, &cf_ctx); |
1310 | 0 | if (DEBUG_BLOCK_INFO) |
1311 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", |
1312 | 0 | b->tx, txtp, eob, ts->msac.rng); |
1313 | 0 | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); |
1314 | 0 | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); |
1315 | 0 | } |
1316 | 1.20M | if (eob >= 0) { |
1317 | 836k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1318 | 0 | coef_dump(cf, imin(t_dim->h, 8) * 4, |
1319 | 0 | imin(t_dim->w, 8) * 4, 3, "dq"); |
1320 | 836k | dsp->itx.itxfm_add[b->tx] |
1321 | 836k | [txtp](dst, |
1322 | 836k | f->cur.stride[0], |
1323 | 836k | cf, eob HIGHBD_CALL_SUFFIX); |
1324 | 836k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1325 | 0 | hex_dump(dst, f->cur.stride[0], |
1326 | 0 | t_dim->w * 4, t_dim->h * 4, "recon"); |
1327 | 836k | } |
1328 | 3.58M | } else if (!t->frame_thread.pass) { |
1329 | 0 | dav1d_memset_pow2[t_dim->lw](&t->a->lcoef[bx4 + x], 0x40); |
1330 | 0 | dav1d_memset_pow2[t_dim->lh](&t->l.lcoef[by4 + y], 0x40); |
1331 | 0 | } |
1332 | 4.78M | dst += 4 * t_dim->w; |
1333 | 4.78M | } |
1334 | 2.29M | t->bx -= x; |
1335 | 2.29M | } |
1336 | 1.81M | t->by -= y; |
1337 | | |
1338 | 1.81M | if (!has_chroma) continue; |
1339 | | |
1340 | 1.50M | const ptrdiff_t stride = f->cur.stride[1]; |
1341 | | |
1342 | 1.50M | if (b->uv_mode == CFL_PRED) { |
1343 | 331k | assert(!init_x && !init_y); |
1344 | | |
1345 | 331k | int16_t *const ac = t->scratch.ac; |
1346 | 331k | pixel *y_src = ((pixel *) f->cur.data[0]) + 4 * (t->bx & ~ss_hor) + |
1347 | 331k | 4 * (t->by & ~ss_ver) * PXSTRIDE(f->cur.stride[0]); |
1348 | 331k | const ptrdiff_t uv_off = 4 * ((t->bx >> ss_hor) + |
1349 | 331k | (t->by >> ss_ver) * PXSTRIDE(stride)); |
1350 | 331k | pixel *const uv_dst[2] = { ((pixel *) f->cur.data[1]) + uv_off, |
1351 | 331k | ((pixel *) f->cur.data[2]) + uv_off }; |
1352 | | |
1353 | 331k | const int furthest_r = |
1354 | 331k | ((cw4 << ss_hor) + t_dim->w - 1) & ~(t_dim->w - 1); |
1355 | 331k | const int furthest_b = |
1356 | 331k | ((ch4 << ss_ver) + t_dim->h - 1) & ~(t_dim->h - 1); |
1357 | 331k | dsp->ipred.cfl_ac[f->cur.p.layout - 1](ac, y_src, f->cur.stride[0], |
1358 | 331k | cbw4 - (furthest_r >> ss_hor), |
1359 | 331k | cbh4 - (furthest_b >> ss_ver), |
1360 | 331k | cbw4 * 4, cbh4 * 4); |
1361 | 995k | for (int pl = 0; pl < 2; pl++) { |
1362 | 663k | if (!b->cfl_alpha[pl]) continue; |
1363 | 556k | int angle = 0; |
1364 | 556k | const pixel *top_sb_edge = NULL; |
1365 | 556k | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { |
1366 | 134k | top_sb_edge = f->ipred_edge[pl + 1]; |
1367 | 134k | const int sby = t->by >> f->sb_shift; |
1368 | 134k | top_sb_edge += f->sb128w * 128 * (sby - 1); |
1369 | 134k | } |
1370 | 556k | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; |
1371 | 556k | const int xstart = ts->tiling.col_start >> ss_hor; |
1372 | 556k | const int ystart = ts->tiling.row_start >> ss_ver; |
1373 | 556k | const enum IntraPredMode m = |
1374 | 556k | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, |
1375 | 556k | ypos, ypos > ystart, |
1376 | 556k | ts->tiling.col_end >> ss_hor, |
1377 | 556k | ts->tiling.row_end >> ss_ver, |
1378 | 556k | 0, uv_dst[pl], stride, |
1379 | 556k | top_sb_edge, DC_PRED, &angle, |
1380 | 556k | uv_t_dim->w, uv_t_dim->h, 0, |
1381 | 556k | edge HIGHBD_CALL_SUFFIX); |
1382 | 556k | dsp->ipred.cfl_pred[m](uv_dst[pl], stride, edge, |
1383 | 556k | uv_t_dim->w * 4, |
1384 | 556k | uv_t_dim->h * 4, |
1385 | 556k | ac, b->cfl_alpha[pl] |
1386 | 556k | HIGHBD_CALL_SUFFIX); |
1387 | 556k | } |
1388 | 331k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { |
1389 | 0 | ac_dump(ac, 4*cbw4, 4*cbh4, "ac"); |
1390 | 0 | hex_dump(uv_dst[0], stride, cbw4 * 4, cbh4 * 4, "u-cfl-pred"); |
1391 | 0 | hex_dump(uv_dst[1], stride, cbw4 * 4, cbh4 * 4, "v-cfl-pred"); |
1392 | 0 | } |
1393 | 1.17M | } else if (b->pal_sz[1]) { |
1394 | 3.92k | const ptrdiff_t uv_dstoff = 4 * ((t->bx >> ss_hor) + |
1395 | 3.92k | (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); |
1396 | 3.92k | const pixel (*pal)[8]; |
1397 | 3.92k | const uint8_t *pal_idx; |
1398 | 3.92k | if (t->frame_thread.pass) { |
1399 | 3.92k | const int p = t->frame_thread.pass & 1; |
1400 | 3.92k | assert(ts->frame_thread[p].pal_idx); |
1401 | 3.92k | pal = f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
1402 | 3.92k | ((t->bx >> 1) + (t->by & 1))]; |
1403 | 3.92k | pal_idx = ts->frame_thread[p].pal_idx; |
1404 | 3.92k | ts->frame_thread[p].pal_idx += cbw4 * cbh4 * 8; |
1405 | 3.92k | } else { |
1406 | 0 | pal = bytefn(t->scratch.pal); |
1407 | 0 | pal_idx = t->scratch.pal_idx_uv; |
1408 | 0 | } |
1409 | | |
1410 | 3.92k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[1]) + uv_dstoff, |
1411 | 3.92k | f->cur.stride[1], pal[1], |
1412 | 3.92k | pal_idx, cbw4 * 4, cbh4 * 4); |
1413 | 3.92k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[2]) + uv_dstoff, |
1414 | 3.92k | f->cur.stride[1], pal[2], |
1415 | 3.92k | pal_idx, cbw4 * 4, cbh4 * 4); |
1416 | 3.92k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { |
1417 | 0 | hex_dump(((pixel *) f->cur.data[1]) + uv_dstoff, |
1418 | 0 | PXSTRIDE(f->cur.stride[1]), |
1419 | 0 | cbw4 * 4, cbh4 * 4, "u-pal-pred"); |
1420 | 0 | hex_dump(((pixel *) f->cur.data[2]) + uv_dstoff, |
1421 | 0 | PXSTRIDE(f->cur.stride[1]), |
1422 | 0 | cbw4 * 4, cbh4 * 4, "v-pal-pred"); |
1423 | 0 | } |
1424 | 3.92k | } |
1425 | | |
1426 | 1.50M | const int sm_uv_fl = sm_uv_flag(t->a, cbx4) | |
1427 | 1.50M | sm_uv_flag(&t->l, cby4); |
1428 | 1.50M | const int uv_sb_has_tr = |
1429 | 1.50M | ((init_x + 16) >> ss_hor) < cw4 ? 1 : init_y ? 0 : |
1430 | 1.45M | intra_edge_flags & (EDGE_I420_TOP_HAS_RIGHT >> (f->cur.p.layout - 1)); |
1431 | 1.50M | const int uv_sb_has_bl = |
1432 | 1.50M | init_x ? 0 : ((init_y + 16) >> ss_ver) < ch4 ? 1 : |
1433 | 1.45M | intra_edge_flags & (EDGE_I420_LEFT_HAS_BOTTOM >> (f->cur.p.layout - 1)); |
1434 | 1.50M | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); |
1435 | 4.50M | for (int pl = 0; pl < 2; pl++) { |
1436 | 6.43M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; |
1437 | 3.43M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) |
1438 | 3.42M | { |
1439 | 3.42M | pixel *dst = ((pixel *) f->cur.data[1 + pl]) + |
1440 | 3.42M | 4 * ((t->by >> ss_ver) * PXSTRIDE(stride) + |
1441 | 3.42M | ((t->bx + init_x) >> ss_hor)); |
1442 | 7.72M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; |
1443 | 4.29M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) |
1444 | 4.29M | { |
1445 | 4.29M | if ((b->uv_mode == CFL_PRED && b->cfl_alpha[pl]) || |
1446 | 3.73M | b->pal_sz[1]) |
1447 | 566k | { |
1448 | 566k | goto skip_uv_pred; |
1449 | 566k | } |
1450 | | |
1451 | 3.72M | int angle = b->uv_angle; |
1452 | | // this probably looks weird because we're using |
1453 | | // luma flags in a chroma loop, but that's because |
1454 | | // prepare_intra_edges() expects luma flags as input |
1455 | 3.72M | const enum EdgeFlags edge_flags = |
1456 | 3.72M | (((y > (init_y >> ss_ver) || !uv_sb_has_tr) && |
1457 | 1.75M | (x + uv_t_dim->w >= sub_cw4)) ? |
1458 | 2.62M | 0 : EDGE_I444_TOP_HAS_RIGHT) | |
1459 | 3.72M | ((x > (init_x >> ss_hor) || |
1460 | 2.86M | (!uv_sb_has_bl && y + uv_t_dim->h >= sub_ch4)) ? |
1461 | 2.24M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); |
1462 | 3.72M | const pixel *top_sb_edge = NULL; |
1463 | 3.72M | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { |
1464 | 1.11M | top_sb_edge = f->ipred_edge[1 + pl]; |
1465 | 1.11M | const int sby = t->by >> f->sb_shift; |
1466 | 1.11M | top_sb_edge += f->sb128w * 128 * (sby - 1); |
1467 | 1.11M | } |
1468 | 3.72M | const enum IntraPredMode uv_mode = |
1469 | 3.72M | b->uv_mode == CFL_PRED ? DC_PRED : b->uv_mode; |
1470 | 3.72M | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; |
1471 | 3.72M | const int xstart = ts->tiling.col_start >> ss_hor; |
1472 | 3.72M | const int ystart = ts->tiling.row_start >> ss_ver; |
1473 | 3.72M | const enum IntraPredMode m = |
1474 | 3.72M | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, |
1475 | 3.72M | ypos, ypos > ystart, |
1476 | 3.72M | ts->tiling.col_end >> ss_hor, |
1477 | 3.72M | ts->tiling.row_end >> ss_ver, |
1478 | 3.72M | edge_flags, dst, stride, |
1479 | 3.72M | top_sb_edge, uv_mode, |
1480 | 3.72M | &angle, uv_t_dim->w, |
1481 | 3.72M | uv_t_dim->h, |
1482 | 3.72M | f->seq_hdr->intra_edge_filter, |
1483 | 3.72M | edge HIGHBD_CALL_SUFFIX); |
1484 | 3.72M | angle |= intra_edge_filter_flag; |
1485 | 3.72M | dsp->ipred.intra_pred[m](dst, stride, edge, |
1486 | 3.72M | uv_t_dim->w * 4, |
1487 | 3.72M | uv_t_dim->h * 4, |
1488 | 3.72M | angle | sm_uv_fl, |
1489 | 3.72M | (4 * f->bw + ss_hor - |
1490 | 3.72M | 4 * (t->bx & ~ss_hor)) >> ss_hor, |
1491 | 3.72M | (4 * f->bh + ss_ver - |
1492 | 3.72M | 4 * (t->by & ~ss_ver)) >> ss_ver |
1493 | 3.72M | HIGHBD_CALL_SUFFIX); |
1494 | 3.72M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { |
1495 | 0 | hex_dump(edge - uv_t_dim->h * 4, uv_t_dim->h * 4, |
1496 | 0 | uv_t_dim->h * 4, 2, "l"); |
1497 | 0 | hex_dump(edge, 0, 1, 1, "tl"); |
1498 | 0 | hex_dump(edge + 1, uv_t_dim->w * 4, |
1499 | 0 | uv_t_dim->w * 4, 2, "t"); |
1500 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, |
1501 | 0 | uv_t_dim->h * 4, pl ? "v-intra-pred" : "u-intra-pred"); |
1502 | 0 | } |
1503 | | |
1504 | 4.29M | skip_uv_pred: {} |
1505 | 4.29M | if (!b->skip) { |
1506 | 1.56M | enum TxfmType txtp; |
1507 | 1.56M | int eob; |
1508 | 1.56M | coef *cf; |
1509 | 1.56M | if (t->frame_thread.pass) { |
1510 | 1.56M | const int p = t->frame_thread.pass & 1; |
1511 | 1.56M | const int cbi = *ts->frame_thread[p].cbi++; |
1512 | 1.56M | cf = ts->frame_thread[p].cf; |
1513 | 1.56M | ts->frame_thread[p].cf += uv_t_dim->w * uv_t_dim->h * 16; |
1514 | 1.56M | eob = cbi >> 5; |
1515 | 1.56M | txtp = cbi & 0x1f; |
1516 | 18.4E | } else { |
1517 | 18.4E | uint8_t cf_ctx; |
1518 | 18.4E | cf = bitfn(t->cf); |
1519 | 18.4E | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], |
1520 | 18.4E | &t->l.ccoef[pl][cby4 + y], |
1521 | 18.4E | b->uvtx, bs, b, 1, 1 + pl, cf, |
1522 | 18.4E | &txtp, &cf_ctx); |
1523 | 18.4E | if (DEBUG_BLOCK_INFO) |
1524 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," |
1525 | 0 | "txtp=%d,eob=%d]: r=%d [x=%d,cbx4=%d]\n", |
1526 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng, x, cbx4); |
1527 | 18.4E | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); |
1528 | 18.4E | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); |
1529 | 18.4E | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); |
1530 | 18.4E | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); |
1531 | 18.4E | } |
1532 | 1.56M | if (eob >= 0) { |
1533 | 584k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1534 | 0 | coef_dump(cf, uv_t_dim->h * 4, |
1535 | 0 | uv_t_dim->w * 4, 3, "dq"); |
1536 | 584k | dsp->itx.itxfm_add[b->uvtx] |
1537 | 584k | [txtp](dst, stride, |
1538 | 584k | cf, eob HIGHBD_CALL_SUFFIX); |
1539 | 584k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1540 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, |
1541 | 0 | uv_t_dim->h * 4, "recon"); |
1542 | 584k | } |
1543 | 2.73M | } else if (!t->frame_thread.pass) { |
1544 | 0 | dav1d_memset_pow2[uv_t_dim->lw](&t->a->ccoef[pl][cbx4 + x], 0x40); |
1545 | 0 | dav1d_memset_pow2[uv_t_dim->lh](&t->l.ccoef[pl][cby4 + y], 0x40); |
1546 | 0 | } |
1547 | 4.29M | dst += uv_t_dim->w * 4; |
1548 | 4.29M | } |
1549 | 3.43M | t->bx -= x << ss_hor; |
1550 | 3.43M | } |
1551 | 3.00M | t->by -= y << ss_ver; |
1552 | 3.00M | } |
1553 | 1.50M | } |
1554 | 1.73M | } |
1555 | 1.67M | } Line | Count | Source | 1179 | 839k | { | 1180 | 839k | Dav1dTileState *const ts = t->ts; | 1181 | 839k | const Dav1dFrameContext *const f = t->f; | 1182 | 839k | const Dav1dDSPContext *const dsp = f->dsp; | 1183 | 839k | const int bx4 = t->bx & 31, by4 = t->by & 31; | 1184 | 839k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1185 | 839k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 1186 | 839k | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 1187 | 839k | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 1188 | 839k | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 1189 | 839k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 1190 | 839k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 1191 | 839k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 1192 | 807k | (bw4 > ss_hor || t->bx & 1) && | 1193 | 758k | (bh4 > ss_ver || t->by & 1); | 1194 | 839k | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->tx]; | 1195 | 839k | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; | 1196 | | | 1197 | | // coefficient coding | 1198 | 839k | pixel *const edge = bitfn(t->scratch.edge) + 128; | 1199 | 839k | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; | 1200 | | | 1201 | 839k | const int intra_edge_filter_flag = f->seq_hdr->intra_edge_filter << 10; | 1202 | | | 1203 | 1.71M | for (int init_y = 0; init_y < h4; init_y += 16) { | 1204 | 863k | const int sub_h4 = imin(h4, 16 + init_y); | 1205 | 863k | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); | 1206 | 1.76M | for (int init_x = 0; init_x < w4; init_x += 16) { | 1207 | 896k | if (b->pal_sz[0]) { | 1208 | 4.54k | pixel *dst = ((pixel *) f->cur.data[0]) + | 1209 | 4.54k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); | 1210 | 4.54k | const uint8_t *pal_idx; | 1211 | 4.54k | if (t->frame_thread.pass) { | 1212 | 4.54k | const int p = t->frame_thread.pass & 1; | 1213 | 4.54k | assert(ts->frame_thread[p].pal_idx); | 1214 | 4.54k | pal_idx = ts->frame_thread[p].pal_idx; | 1215 | 4.54k | ts->frame_thread[p].pal_idx += bw4 * bh4 * 8; | 1216 | 4.54k | } else { | 1217 | 0 | pal_idx = t->scratch.pal_idx_y; | 1218 | 0 | } | 1219 | 4.54k | const pixel *const pal = t->frame_thread.pass ? | 1220 | 4.54k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 1221 | 4.54k | ((t->bx >> 1) + (t->by & 1))][0] : | 1222 | 4.54k | bytefn(t->scratch.pal)[0]; | 1223 | 4.54k | f->dsp->ipred.pal_pred(dst, f->cur.stride[0], pal, | 1224 | 4.54k | pal_idx, bw4 * 4, bh4 * 4); | 1225 | 4.54k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1226 | 0 | hex_dump(dst, PXSTRIDE(f->cur.stride[0]), | 1227 | 0 | bw4 * 4, bh4 * 4, "y-pal-pred"); | 1228 | 4.54k | } | 1229 | | | 1230 | 896k | const int intra_flags = (sm_flag(t->a, bx4) | | 1231 | 896k | sm_flag(&t->l, by4) | | 1232 | 896k | intra_edge_filter_flag); | 1233 | 896k | const int sb_has_tr = init_x + 16 < w4 ? 1 : init_y ? 0 : | 1234 | 863k | intra_edge_flags & EDGE_I444_TOP_HAS_RIGHT; | 1235 | 896k | const int sb_has_bl = init_x ? 0 : init_y + 16 < h4 ? 1 : | 1236 | 863k | intra_edge_flags & EDGE_I444_LEFT_HAS_BOTTOM; | 1237 | 896k | int y, x; | 1238 | 896k | const int sub_w4 = imin(w4, init_x + 16); | 1239 | 2.00M | for (y = init_y, t->by += init_y; y < sub_h4; | 1240 | 1.10M | y += t_dim->h, t->by += t_dim->h) | 1241 | 1.10M | { | 1242 | 1.10M | pixel *dst = ((pixel *) f->cur.data[0]) + | 1243 | 1.10M | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + | 1244 | 1.10M | t->bx + init_x); | 1245 | 3.00M | for (x = init_x, t->bx += init_x; x < sub_w4; | 1246 | 1.89M | x += t_dim->w, t->bx += t_dim->w) | 1247 | 1.89M | { | 1248 | 1.89M | if (b->pal_sz[0]) goto skip_y_pred; | 1249 | | | 1250 | 1.88M | int angle = b->y_angle; | 1251 | 1.88M | const enum EdgeFlags edge_flags = | 1252 | 1.88M | (((y > init_y || !sb_has_tr) && (x + t_dim->w >= sub_w4)) ? | 1253 | 1.41M | 0 : EDGE_I444_TOP_HAS_RIGHT) | | 1254 | 1.88M | ((x > init_x || (!sb_has_bl && y + t_dim->h >= sub_h4)) ? | 1255 | 1.28M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); | 1256 | 1.88M | const pixel *top_sb_edge = NULL; | 1257 | 1.88M | if (!(t->by & (f->sb_step - 1))) { | 1258 | 386k | top_sb_edge = f->ipred_edge[0]; | 1259 | 386k | const int sby = t->by >> f->sb_shift; | 1260 | 386k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1261 | 386k | } | 1262 | 1.88M | const enum IntraPredMode m = | 1263 | 1.88M | bytefn(dav1d_prepare_intra_edges)(t->bx, | 1264 | 1.88M | t->bx > ts->tiling.col_start, | 1265 | 1.88M | t->by, | 1266 | 1.88M | t->by > ts->tiling.row_start, | 1267 | 1.88M | ts->tiling.col_end, | 1268 | 1.88M | ts->tiling.row_end, | 1269 | 1.88M | edge_flags, dst, | 1270 | 1.88M | f->cur.stride[0], top_sb_edge, | 1271 | 1.88M | b->y_mode, &angle, | 1272 | 1.88M | t_dim->w, t_dim->h, | 1273 | 1.88M | f->seq_hdr->intra_edge_filter, | 1274 | 1.88M | edge HIGHBD_CALL_SUFFIX); | 1275 | 1.88M | dsp->ipred.intra_pred[m](dst, f->cur.stride[0], edge, | 1276 | 1.88M | t_dim->w * 4, t_dim->h * 4, | 1277 | 1.88M | angle | intra_flags, | 1278 | 1.88M | 4 * f->bw - 4 * t->bx, | 1279 | 1.88M | 4 * f->bh - 4 * t->by | 1280 | 1.88M | HIGHBD_CALL_SUFFIX); | 1281 | | | 1282 | 1.88M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1283 | 0 | hex_dump(edge - t_dim->h * 4, t_dim->h * 4, | 1284 | 0 | t_dim->h * 4, 2, "l"); | 1285 | 0 | hex_dump(edge, 0, 1, 1, "tl"); | 1286 | 0 | hex_dump(edge + 1, t_dim->w * 4, | 1287 | 0 | t_dim->w * 4, 2, "t"); | 1288 | 0 | hex_dump(dst, f->cur.stride[0], | 1289 | 0 | t_dim->w * 4, t_dim->h * 4, "y-intra-pred"); | 1290 | 0 | } | 1291 | | | 1292 | 1.89M | skip_y_pred: {} | 1293 | 1.89M | if (!b->skip) { | 1294 | 521k | coef *cf; | 1295 | 521k | int eob; | 1296 | 521k | enum TxfmType txtp; | 1297 | 521k | if (t->frame_thread.pass) { | 1298 | 521k | const int p = t->frame_thread.pass & 1; | 1299 | 521k | const int cbi = *ts->frame_thread[p].cbi++; | 1300 | 521k | cf = ts->frame_thread[p].cf; | 1301 | 521k | ts->frame_thread[p].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; | 1302 | 521k | eob = cbi >> 5; | 1303 | 521k | txtp = cbi & 0x1f; | 1304 | 521k | } else { | 1305 | 0 | uint8_t cf_ctx; | 1306 | 0 | cf = bitfn(t->cf); | 1307 | 0 | eob = decode_coefs(t, &t->a->lcoef[bx4 + x], | 1308 | 0 | &t->l.lcoef[by4 + y], b->tx, bs, | 1309 | 0 | b, 1, 0, cf, &txtp, &cf_ctx); | 1310 | 0 | if (DEBUG_BLOCK_INFO) | 1311 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", | 1312 | 0 | b->tx, txtp, eob, ts->msac.rng); | 1313 | 0 | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); | 1314 | 0 | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); | 1315 | 0 | } | 1316 | 521k | if (eob >= 0) { | 1317 | 370k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1318 | 0 | coef_dump(cf, imin(t_dim->h, 8) * 4, | 1319 | 0 | imin(t_dim->w, 8) * 4, 3, "dq"); | 1320 | 370k | dsp->itx.itxfm_add[b->tx] | 1321 | 370k | [txtp](dst, | 1322 | 370k | f->cur.stride[0], | 1323 | 370k | cf, eob HIGHBD_CALL_SUFFIX); | 1324 | 370k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1325 | 0 | hex_dump(dst, f->cur.stride[0], | 1326 | 0 | t_dim->w * 4, t_dim->h * 4, "recon"); | 1327 | 370k | } | 1328 | 1.37M | } else if (!t->frame_thread.pass) { | 1329 | 0 | dav1d_memset_pow2[t_dim->lw](&t->a->lcoef[bx4 + x], 0x40); | 1330 | 0 | dav1d_memset_pow2[t_dim->lh](&t->l.lcoef[by4 + y], 0x40); | 1331 | 0 | } | 1332 | 1.89M | dst += 4 * t_dim->w; | 1333 | 1.89M | } | 1334 | 1.10M | t->bx -= x; | 1335 | 1.10M | } | 1336 | 902k | t->by -= y; | 1337 | | | 1338 | 902k | if (!has_chroma) continue; | 1339 | | | 1340 | 760k | const ptrdiff_t stride = f->cur.stride[1]; | 1341 | | | 1342 | 760k | if (b->uv_mode == CFL_PRED) { | 1343 | 174k | assert(!init_x && !init_y); | 1344 | | | 1345 | 174k | int16_t *const ac = t->scratch.ac; | 1346 | 174k | pixel *y_src = ((pixel *) f->cur.data[0]) + 4 * (t->bx & ~ss_hor) + | 1347 | 174k | 4 * (t->by & ~ss_ver) * PXSTRIDE(f->cur.stride[0]); | 1348 | 174k | const ptrdiff_t uv_off = 4 * ((t->bx >> ss_hor) + | 1349 | 174k | (t->by >> ss_ver) * PXSTRIDE(stride)); | 1350 | 174k | pixel *const uv_dst[2] = { ((pixel *) f->cur.data[1]) + uv_off, | 1351 | 174k | ((pixel *) f->cur.data[2]) + uv_off }; | 1352 | | | 1353 | 174k | const int furthest_r = | 1354 | 174k | ((cw4 << ss_hor) + t_dim->w - 1) & ~(t_dim->w - 1); | 1355 | 174k | const int furthest_b = | 1356 | 174k | ((ch4 << ss_ver) + t_dim->h - 1) & ~(t_dim->h - 1); | 1357 | 174k | dsp->ipred.cfl_ac[f->cur.p.layout - 1](ac, y_src, f->cur.stride[0], | 1358 | 174k | cbw4 - (furthest_r >> ss_hor), | 1359 | 174k | cbh4 - (furthest_b >> ss_ver), | 1360 | 174k | cbw4 * 4, cbh4 * 4); | 1361 | 522k | for (int pl = 0; pl < 2; pl++) { | 1362 | 348k | if (!b->cfl_alpha[pl]) continue; | 1363 | 296k | int angle = 0; | 1364 | 296k | const pixel *top_sb_edge = NULL; | 1365 | 296k | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { | 1366 | 71.2k | top_sb_edge = f->ipred_edge[pl + 1]; | 1367 | 71.2k | const int sby = t->by >> f->sb_shift; | 1368 | 71.2k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1369 | 71.2k | } | 1370 | 296k | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; | 1371 | 296k | const int xstart = ts->tiling.col_start >> ss_hor; | 1372 | 296k | const int ystart = ts->tiling.row_start >> ss_ver; | 1373 | 296k | const enum IntraPredMode m = | 1374 | 296k | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, | 1375 | 296k | ypos, ypos > ystart, | 1376 | 296k | ts->tiling.col_end >> ss_hor, | 1377 | 296k | ts->tiling.row_end >> ss_ver, | 1378 | 296k | 0, uv_dst[pl], stride, | 1379 | 296k | top_sb_edge, DC_PRED, &angle, | 1380 | 296k | uv_t_dim->w, uv_t_dim->h, 0, | 1381 | 296k | edge HIGHBD_CALL_SUFFIX); | 1382 | 296k | dsp->ipred.cfl_pred[m](uv_dst[pl], stride, edge, | 1383 | 296k | uv_t_dim->w * 4, | 1384 | 296k | uv_t_dim->h * 4, | 1385 | 296k | ac, b->cfl_alpha[pl] | 1386 | 296k | HIGHBD_CALL_SUFFIX); | 1387 | 296k | } | 1388 | 174k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1389 | 0 | ac_dump(ac, 4*cbw4, 4*cbh4, "ac"); | 1390 | 0 | hex_dump(uv_dst[0], stride, cbw4 * 4, cbh4 * 4, "u-cfl-pred"); | 1391 | 0 | hex_dump(uv_dst[1], stride, cbw4 * 4, cbh4 * 4, "v-cfl-pred"); | 1392 | 0 | } | 1393 | 586k | } else if (b->pal_sz[1]) { | 1394 | 2.61k | const ptrdiff_t uv_dstoff = 4 * ((t->bx >> ss_hor) + | 1395 | 2.61k | (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); | 1396 | 2.61k | const pixel (*pal)[8]; | 1397 | 2.61k | const uint8_t *pal_idx; | 1398 | 2.61k | if (t->frame_thread.pass) { | 1399 | 2.61k | const int p = t->frame_thread.pass & 1; | 1400 | 2.61k | assert(ts->frame_thread[p].pal_idx); | 1401 | 2.61k | pal = f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 1402 | 2.61k | ((t->bx >> 1) + (t->by & 1))]; | 1403 | 2.61k | pal_idx = ts->frame_thread[p].pal_idx; | 1404 | 2.61k | ts->frame_thread[p].pal_idx += cbw4 * cbh4 * 8; | 1405 | 2.61k | } else { | 1406 | 0 | pal = bytefn(t->scratch.pal); | 1407 | 0 | pal_idx = t->scratch.pal_idx_uv; | 1408 | 0 | } | 1409 | | | 1410 | 2.61k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[1]) + uv_dstoff, | 1411 | 2.61k | f->cur.stride[1], pal[1], | 1412 | 2.61k | pal_idx, cbw4 * 4, cbh4 * 4); | 1413 | 2.61k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[2]) + uv_dstoff, | 1414 | 2.61k | f->cur.stride[1], pal[2], | 1415 | 2.61k | pal_idx, cbw4 * 4, cbh4 * 4); | 1416 | 2.61k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1417 | 0 | hex_dump(((pixel *) f->cur.data[1]) + uv_dstoff, | 1418 | 0 | PXSTRIDE(f->cur.stride[1]), | 1419 | 0 | cbw4 * 4, cbh4 * 4, "u-pal-pred"); | 1420 | 0 | hex_dump(((pixel *) f->cur.data[2]) + uv_dstoff, | 1421 | 0 | PXSTRIDE(f->cur.stride[1]), | 1422 | 0 | cbw4 * 4, cbh4 * 4, "v-pal-pred"); | 1423 | 0 | } | 1424 | 2.61k | } | 1425 | | | 1426 | 760k | const int sm_uv_fl = sm_uv_flag(t->a, cbx4) | | 1427 | 760k | sm_uv_flag(&t->l, cby4); | 1428 | 760k | const int uv_sb_has_tr = | 1429 | 760k | ((init_x + 16) >> ss_hor) < cw4 ? 1 : init_y ? 0 : | 1430 | 734k | intra_edge_flags & (EDGE_I420_TOP_HAS_RIGHT >> (f->cur.p.layout - 1)); | 1431 | 760k | const int uv_sb_has_bl = | 1432 | 760k | init_x ? 0 : ((init_y + 16) >> ss_ver) < ch4 ? 1 : | 1433 | 734k | intra_edge_flags & (EDGE_I420_LEFT_HAS_BOTTOM >> (f->cur.p.layout - 1)); | 1434 | 760k | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); | 1435 | 2.26M | for (int pl = 0; pl < 2; pl++) { | 1436 | 3.25M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; | 1437 | 1.74M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) | 1438 | 1.74M | { | 1439 | 1.74M | pixel *dst = ((pixel *) f->cur.data[1 + pl]) + | 1440 | 1.74M | 4 * ((t->by >> ss_ver) * PXSTRIDE(stride) + | 1441 | 1.74M | ((t->bx + init_x) >> ss_hor)); | 1442 | 3.98M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; | 1443 | 2.24M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) | 1444 | 2.24M | { | 1445 | 2.24M | if ((b->uv_mode == CFL_PRED && b->cfl_alpha[pl]) || | 1446 | 1.94M | b->pal_sz[1]) | 1447 | 304k | { | 1448 | 304k | goto skip_uv_pred; | 1449 | 304k | } | 1450 | | | 1451 | 1.93M | int angle = b->uv_angle; | 1452 | | // this probably looks weird because we're using | 1453 | | // luma flags in a chroma loop, but that's because | 1454 | | // prepare_intra_edges() expects luma flags as input | 1455 | 1.93M | const enum EdgeFlags edge_flags = | 1456 | 1.93M | (((y > (init_y >> ss_ver) || !uv_sb_has_tr) && | 1457 | 959k | (x + uv_t_dim->w >= sub_cw4)) ? | 1458 | 1.37M | 0 : EDGE_I444_TOP_HAS_RIGHT) | | 1459 | 1.93M | ((x > (init_x >> ss_hor) || | 1460 | 1.44M | (!uv_sb_has_bl && y + uv_t_dim->h >= sub_ch4)) ? | 1461 | 1.18M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); | 1462 | 1.93M | const pixel *top_sb_edge = NULL; | 1463 | 1.93M | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { | 1464 | 565k | top_sb_edge = f->ipred_edge[1 + pl]; | 1465 | 565k | const int sby = t->by >> f->sb_shift; | 1466 | 565k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1467 | 565k | } | 1468 | 1.93M | const enum IntraPredMode uv_mode = | 1469 | 1.93M | b->uv_mode == CFL_PRED ? DC_PRED : b->uv_mode; | 1470 | 1.93M | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; | 1471 | 1.93M | const int xstart = ts->tiling.col_start >> ss_hor; | 1472 | 1.93M | const int ystart = ts->tiling.row_start >> ss_ver; | 1473 | 1.93M | const enum IntraPredMode m = | 1474 | 1.93M | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, | 1475 | 1.93M | ypos, ypos > ystart, | 1476 | 1.93M | ts->tiling.col_end >> ss_hor, | 1477 | 1.93M | ts->tiling.row_end >> ss_ver, | 1478 | 1.93M | edge_flags, dst, stride, | 1479 | 1.93M | top_sb_edge, uv_mode, | 1480 | 1.93M | &angle, uv_t_dim->w, | 1481 | 1.93M | uv_t_dim->h, | 1482 | 1.93M | f->seq_hdr->intra_edge_filter, | 1483 | 1.93M | edge HIGHBD_CALL_SUFFIX); | 1484 | 1.93M | angle |= intra_edge_filter_flag; | 1485 | 1.93M | dsp->ipred.intra_pred[m](dst, stride, edge, | 1486 | 1.93M | uv_t_dim->w * 4, | 1487 | 1.93M | uv_t_dim->h * 4, | 1488 | 1.93M | angle | sm_uv_fl, | 1489 | 1.93M | (4 * f->bw + ss_hor - | 1490 | 1.93M | 4 * (t->bx & ~ss_hor)) >> ss_hor, | 1491 | 1.93M | (4 * f->bh + ss_ver - | 1492 | 1.93M | 4 * (t->by & ~ss_ver)) >> ss_ver | 1493 | 1.93M | HIGHBD_CALL_SUFFIX); | 1494 | 1.93M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1495 | 0 | hex_dump(edge - uv_t_dim->h * 4, uv_t_dim->h * 4, | 1496 | 0 | uv_t_dim->h * 4, 2, "l"); | 1497 | 0 | hex_dump(edge, 0, 1, 1, "tl"); | 1498 | 0 | hex_dump(edge + 1, uv_t_dim->w * 4, | 1499 | 0 | uv_t_dim->w * 4, 2, "t"); | 1500 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, | 1501 | 0 | uv_t_dim->h * 4, pl ? "v-intra-pred" : "u-intra-pred"); | 1502 | 0 | } | 1503 | | | 1504 | 2.24M | skip_uv_pred: {} | 1505 | 2.24M | if (!b->skip) { | 1506 | 713k | enum TxfmType txtp; | 1507 | 713k | int eob; | 1508 | 713k | coef *cf; | 1509 | 713k | if (t->frame_thread.pass) { | 1510 | 713k | const int p = t->frame_thread.pass & 1; | 1511 | 713k | const int cbi = *ts->frame_thread[p].cbi++; | 1512 | 713k | cf = ts->frame_thread[p].cf; | 1513 | 713k | ts->frame_thread[p].cf += uv_t_dim->w * uv_t_dim->h * 16; | 1514 | 713k | eob = cbi >> 5; | 1515 | 713k | txtp = cbi & 0x1f; | 1516 | 18.4E | } else { | 1517 | 18.4E | uint8_t cf_ctx; | 1518 | 18.4E | cf = bitfn(t->cf); | 1519 | 18.4E | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 1520 | 18.4E | &t->l.ccoef[pl][cby4 + y], | 1521 | 18.4E | b->uvtx, bs, b, 1, 1 + pl, cf, | 1522 | 18.4E | &txtp, &cf_ctx); | 1523 | 18.4E | if (DEBUG_BLOCK_INFO) | 1524 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 1525 | 0 | "txtp=%d,eob=%d]: r=%d [x=%d,cbx4=%d]\n", | 1526 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng, x, cbx4); | 1527 | 18.4E | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 1528 | 18.4E | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); | 1529 | 18.4E | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 1530 | 18.4E | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 1531 | 18.4E | } | 1532 | 713k | if (eob >= 0) { | 1533 | 308k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1534 | 0 | coef_dump(cf, uv_t_dim->h * 4, | 1535 | 0 | uv_t_dim->w * 4, 3, "dq"); | 1536 | 308k | dsp->itx.itxfm_add[b->uvtx] | 1537 | 308k | [txtp](dst, stride, | 1538 | 308k | cf, eob HIGHBD_CALL_SUFFIX); | 1539 | 308k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1540 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, | 1541 | 0 | uv_t_dim->h * 4, "recon"); | 1542 | 308k | } | 1543 | 1.53M | } else if (!t->frame_thread.pass) { | 1544 | 0 | dav1d_memset_pow2[uv_t_dim->lw](&t->a->ccoef[pl][cbx4 + x], 0x40); | 1545 | 0 | dav1d_memset_pow2[uv_t_dim->lh](&t->l.ccoef[pl][cby4 + y], 0x40); | 1546 | 0 | } | 1547 | 2.24M | dst += uv_t_dim->w * 4; | 1548 | 2.24M | } | 1549 | 1.74M | t->bx -= x << ss_hor; | 1550 | 1.74M | } | 1551 | 1.50M | t->by -= y << ss_ver; | 1552 | 1.50M | } | 1553 | 760k | } | 1554 | 863k | } | 1555 | 839k | } |
dav1d_recon_b_intra_16bpc Line | Count | Source | 1179 | 836k | { | 1180 | 836k | Dav1dTileState *const ts = t->ts; | 1181 | 836k | const Dav1dFrameContext *const f = t->f; | 1182 | 836k | const Dav1dDSPContext *const dsp = f->dsp; | 1183 | 836k | const int bx4 = t->bx & 31, by4 = t->by & 31; | 1184 | 836k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1185 | 836k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 1186 | 836k | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 1187 | 836k | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 1188 | 836k | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 1189 | 836k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 1190 | 836k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 1191 | 836k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 1192 | 774k | (bw4 > ss_hor || t->bx & 1) && | 1193 | 734k | (bh4 > ss_ver || t->by & 1); | 1194 | 836k | const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[b->tx]; | 1195 | 836k | const TxfmInfo *const uv_t_dim = &dav1d_txfm_dimensions[b->uvtx]; | 1196 | | | 1197 | | // coefficient coding | 1198 | 836k | pixel *const edge = bitfn(t->scratch.edge) + 128; | 1199 | 836k | const int cbw4 = (bw4 + ss_hor) >> ss_hor, cbh4 = (bh4 + ss_ver) >> ss_ver; | 1200 | | | 1201 | 836k | const int intra_edge_filter_flag = f->seq_hdr->intra_edge_filter << 10; | 1202 | | | 1203 | 1.70M | for (int init_y = 0; init_y < h4; init_y += 16) { | 1204 | 868k | const int sub_h4 = imin(h4, 16 + init_y); | 1205 | 868k | const int sub_ch4 = imin(ch4, (init_y + 16) >> ss_ver); | 1206 | 1.78M | for (int init_x = 0; init_x < w4; init_x += 16) { | 1207 | 913k | if (b->pal_sz[0]) { | 1208 | 3.88k | pixel *dst = ((pixel *) f->cur.data[0]) + | 1209 | 3.88k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); | 1210 | 3.88k | const uint8_t *pal_idx; | 1211 | 3.88k | if (t->frame_thread.pass) { | 1212 | 3.88k | const int p = t->frame_thread.pass & 1; | 1213 | 3.88k | assert(ts->frame_thread[p].pal_idx); | 1214 | 3.88k | pal_idx = ts->frame_thread[p].pal_idx; | 1215 | 3.88k | ts->frame_thread[p].pal_idx += bw4 * bh4 * 8; | 1216 | 3.88k | } else { | 1217 | 0 | pal_idx = t->scratch.pal_idx_y; | 1218 | 0 | } | 1219 | 3.88k | const pixel *const pal = t->frame_thread.pass ? | 1220 | 3.88k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 1221 | 3.88k | ((t->bx >> 1) + (t->by & 1))][0] : | 1222 | 3.88k | bytefn(t->scratch.pal)[0]; | 1223 | 3.88k | f->dsp->ipred.pal_pred(dst, f->cur.stride[0], pal, | 1224 | 3.88k | pal_idx, bw4 * 4, bh4 * 4); | 1225 | 3.88k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1226 | 0 | hex_dump(dst, PXSTRIDE(f->cur.stride[0]), | 1227 | 0 | bw4 * 4, bh4 * 4, "y-pal-pred"); | 1228 | 3.88k | } | 1229 | | | 1230 | 913k | const int intra_flags = (sm_flag(t->a, bx4) | | 1231 | 913k | sm_flag(&t->l, by4) | | 1232 | 913k | intra_edge_filter_flag); | 1233 | 913k | const int sb_has_tr = init_x + 16 < w4 ? 1 : init_y ? 0 : | 1234 | 868k | intra_edge_flags & EDGE_I444_TOP_HAS_RIGHT; | 1235 | 913k | const int sb_has_bl = init_x ? 0 : init_y + 16 < h4 ? 1 : | 1236 | 868k | intra_edge_flags & EDGE_I444_LEFT_HAS_BOTTOM; | 1237 | 913k | int y, x; | 1238 | 913k | const int sub_w4 = imin(w4, init_x + 16); | 1239 | 2.10M | for (y = init_y, t->by += init_y; y < sub_h4; | 1240 | 1.18M | y += t_dim->h, t->by += t_dim->h) | 1241 | 1.18M | { | 1242 | 1.18M | pixel *dst = ((pixel *) f->cur.data[0]) + | 1243 | 1.18M | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + | 1244 | 1.18M | t->bx + init_x); | 1245 | 4.07M | for (x = init_x, t->bx += init_x; x < sub_w4; | 1246 | 2.88M | x += t_dim->w, t->bx += t_dim->w) | 1247 | 2.88M | { | 1248 | 2.88M | if (b->pal_sz[0]) goto skip_y_pred; | 1249 | | | 1250 | 2.87M | int angle = b->y_angle; | 1251 | 2.87M | const enum EdgeFlags edge_flags = | 1252 | 2.87M | (((y > init_y || !sb_has_tr) && (x + t_dim->w >= sub_w4)) ? | 1253 | 2.33M | 0 : EDGE_I444_TOP_HAS_RIGHT) | | 1254 | 2.87M | ((x > init_x || (!sb_has_bl && y + t_dim->h >= sub_h4)) ? | 1255 | 2.18M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); | 1256 | 2.87M | const pixel *top_sb_edge = NULL; | 1257 | 2.87M | if (!(t->by & (f->sb_step - 1))) { | 1258 | 441k | top_sb_edge = f->ipred_edge[0]; | 1259 | 441k | const int sby = t->by >> f->sb_shift; | 1260 | 441k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1261 | 441k | } | 1262 | 2.87M | const enum IntraPredMode m = | 1263 | 2.87M | bytefn(dav1d_prepare_intra_edges)(t->bx, | 1264 | 2.87M | t->bx > ts->tiling.col_start, | 1265 | 2.87M | t->by, | 1266 | 2.87M | t->by > ts->tiling.row_start, | 1267 | 2.87M | ts->tiling.col_end, | 1268 | 2.87M | ts->tiling.row_end, | 1269 | 2.87M | edge_flags, dst, | 1270 | 2.87M | f->cur.stride[0], top_sb_edge, | 1271 | 2.87M | b->y_mode, &angle, | 1272 | 2.87M | t_dim->w, t_dim->h, | 1273 | 2.87M | f->seq_hdr->intra_edge_filter, | 1274 | 2.87M | edge HIGHBD_CALL_SUFFIX); | 1275 | 2.87M | dsp->ipred.intra_pred[m](dst, f->cur.stride[0], edge, | 1276 | 2.87M | t_dim->w * 4, t_dim->h * 4, | 1277 | 2.87M | angle | intra_flags, | 1278 | 2.87M | 4 * f->bw - 4 * t->bx, | 1279 | 2.87M | 4 * f->bh - 4 * t->by | 1280 | 2.87M | HIGHBD_CALL_SUFFIX); | 1281 | | | 1282 | 2.87M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1283 | 0 | hex_dump(edge - t_dim->h * 4, t_dim->h * 4, | 1284 | 0 | t_dim->h * 4, 2, "l"); | 1285 | 0 | hex_dump(edge, 0, 1, 1, "tl"); | 1286 | 0 | hex_dump(edge + 1, t_dim->w * 4, | 1287 | 0 | t_dim->w * 4, 2, "t"); | 1288 | 0 | hex_dump(dst, f->cur.stride[0], | 1289 | 0 | t_dim->w * 4, t_dim->h * 4, "y-intra-pred"); | 1290 | 0 | } | 1291 | | | 1292 | 2.88M | skip_y_pred: {} | 1293 | 2.88M | if (!b->skip) { | 1294 | 680k | coef *cf; | 1295 | 680k | int eob; | 1296 | 680k | enum TxfmType txtp; | 1297 | 680k | if (t->frame_thread.pass) { | 1298 | 680k | const int p = t->frame_thread.pass & 1; | 1299 | 680k | const int cbi = *ts->frame_thread[p].cbi++; | 1300 | 680k | cf = ts->frame_thread[p].cf; | 1301 | 680k | ts->frame_thread[p].cf += imin(t_dim->w, 8) * imin(t_dim->h, 8) * 16; | 1302 | 680k | eob = cbi >> 5; | 1303 | 680k | txtp = cbi & 0x1f; | 1304 | 680k | } else { | 1305 | 0 | uint8_t cf_ctx; | 1306 | 0 | cf = bitfn(t->cf); | 1307 | 0 | eob = decode_coefs(t, &t->a->lcoef[bx4 + x], | 1308 | 0 | &t->l.lcoef[by4 + y], b->tx, bs, | 1309 | 0 | b, 1, 0, cf, &txtp, &cf_ctx); | 1310 | 0 | if (DEBUG_BLOCK_INFO) | 1311 | 0 | printf("Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n", | 1312 | 0 | b->tx, txtp, eob, ts->msac.rng); | 1313 | 0 | dav1d_memset_likely_pow2(&t->a->lcoef[bx4 + x], cf_ctx, imin(t_dim->w, f->bw - t->bx)); | 1314 | 0 | dav1d_memset_likely_pow2(&t->l.lcoef[by4 + y], cf_ctx, imin(t_dim->h, f->bh - t->by)); | 1315 | 0 | } | 1316 | 680k | if (eob >= 0) { | 1317 | 465k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1318 | 0 | coef_dump(cf, imin(t_dim->h, 8) * 4, | 1319 | 0 | imin(t_dim->w, 8) * 4, 3, "dq"); | 1320 | 465k | dsp->itx.itxfm_add[b->tx] | 1321 | 465k | [txtp](dst, | 1322 | 465k | f->cur.stride[0], | 1323 | 465k | cf, eob HIGHBD_CALL_SUFFIX); | 1324 | 465k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1325 | 0 | hex_dump(dst, f->cur.stride[0], | 1326 | 0 | t_dim->w * 4, t_dim->h * 4, "recon"); | 1327 | 465k | } | 1328 | 2.20M | } else if (!t->frame_thread.pass) { | 1329 | 0 | dav1d_memset_pow2[t_dim->lw](&t->a->lcoef[bx4 + x], 0x40); | 1330 | 0 | dav1d_memset_pow2[t_dim->lh](&t->l.lcoef[by4 + y], 0x40); | 1331 | 0 | } | 1332 | 2.88M | dst += 4 * t_dim->w; | 1333 | 2.88M | } | 1334 | 1.18M | t->bx -= x; | 1335 | 1.18M | } | 1336 | 913k | t->by -= y; | 1337 | | | 1338 | 913k | if (!has_chroma) continue; | 1339 | | | 1340 | 746k | const ptrdiff_t stride = f->cur.stride[1]; | 1341 | | | 1342 | 746k | if (b->uv_mode == CFL_PRED) { | 1343 | 157k | assert(!init_x && !init_y); | 1344 | | | 1345 | 157k | int16_t *const ac = t->scratch.ac; | 1346 | 157k | pixel *y_src = ((pixel *) f->cur.data[0]) + 4 * (t->bx & ~ss_hor) + | 1347 | 157k | 4 * (t->by & ~ss_ver) * PXSTRIDE(f->cur.stride[0]); | 1348 | 157k | const ptrdiff_t uv_off = 4 * ((t->bx >> ss_hor) + | 1349 | 157k | (t->by >> ss_ver) * PXSTRIDE(stride)); | 1350 | 157k | pixel *const uv_dst[2] = { ((pixel *) f->cur.data[1]) + uv_off, | 1351 | 157k | ((pixel *) f->cur.data[2]) + uv_off }; | 1352 | | | 1353 | 157k | const int furthest_r = | 1354 | 157k | ((cw4 << ss_hor) + t_dim->w - 1) & ~(t_dim->w - 1); | 1355 | 157k | const int furthest_b = | 1356 | 157k | ((ch4 << ss_ver) + t_dim->h - 1) & ~(t_dim->h - 1); | 1357 | 157k | dsp->ipred.cfl_ac[f->cur.p.layout - 1](ac, y_src, f->cur.stride[0], | 1358 | 157k | cbw4 - (furthest_r >> ss_hor), | 1359 | 157k | cbh4 - (furthest_b >> ss_ver), | 1360 | 157k | cbw4 * 4, cbh4 * 4); | 1361 | 472k | for (int pl = 0; pl < 2; pl++) { | 1362 | 315k | if (!b->cfl_alpha[pl]) continue; | 1363 | 259k | int angle = 0; | 1364 | 259k | const pixel *top_sb_edge = NULL; | 1365 | 259k | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { | 1366 | 62.9k | top_sb_edge = f->ipred_edge[pl + 1]; | 1367 | 62.9k | const int sby = t->by >> f->sb_shift; | 1368 | 62.9k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1369 | 62.9k | } | 1370 | 259k | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; | 1371 | 259k | const int xstart = ts->tiling.col_start >> ss_hor; | 1372 | 259k | const int ystart = ts->tiling.row_start >> ss_ver; | 1373 | 259k | const enum IntraPredMode m = | 1374 | 259k | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, | 1375 | 259k | ypos, ypos > ystart, | 1376 | 259k | ts->tiling.col_end >> ss_hor, | 1377 | 259k | ts->tiling.row_end >> ss_ver, | 1378 | 259k | 0, uv_dst[pl], stride, | 1379 | 259k | top_sb_edge, DC_PRED, &angle, | 1380 | 259k | uv_t_dim->w, uv_t_dim->h, 0, | 1381 | 259k | edge HIGHBD_CALL_SUFFIX); | 1382 | 259k | dsp->ipred.cfl_pred[m](uv_dst[pl], stride, edge, | 1383 | 259k | uv_t_dim->w * 4, | 1384 | 259k | uv_t_dim->h * 4, | 1385 | 259k | ac, b->cfl_alpha[pl] | 1386 | 259k | HIGHBD_CALL_SUFFIX); | 1387 | 259k | } | 1388 | 157k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1389 | 0 | ac_dump(ac, 4*cbw4, 4*cbh4, "ac"); | 1390 | 0 | hex_dump(uv_dst[0], stride, cbw4 * 4, cbh4 * 4, "u-cfl-pred"); | 1391 | 0 | hex_dump(uv_dst[1], stride, cbw4 * 4, cbh4 * 4, "v-cfl-pred"); | 1392 | 0 | } | 1393 | 588k | } else if (b->pal_sz[1]) { | 1394 | 1.31k | const ptrdiff_t uv_dstoff = 4 * ((t->bx >> ss_hor) + | 1395 | 1.31k | (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); | 1396 | 1.31k | const pixel (*pal)[8]; | 1397 | 1.31k | const uint8_t *pal_idx; | 1398 | 1.31k | if (t->frame_thread.pass) { | 1399 | 1.31k | const int p = t->frame_thread.pass & 1; | 1400 | 1.31k | assert(ts->frame_thread[p].pal_idx); | 1401 | 1.31k | pal = f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 1402 | 1.31k | ((t->bx >> 1) + (t->by & 1))]; | 1403 | 1.31k | pal_idx = ts->frame_thread[p].pal_idx; | 1404 | 1.31k | ts->frame_thread[p].pal_idx += cbw4 * cbh4 * 8; | 1405 | 1.31k | } else { | 1406 | 0 | pal = bytefn(t->scratch.pal); | 1407 | 0 | pal_idx = t->scratch.pal_idx_uv; | 1408 | 0 | } | 1409 | | | 1410 | 1.31k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[1]) + uv_dstoff, | 1411 | 1.31k | f->cur.stride[1], pal[1], | 1412 | 1.31k | pal_idx, cbw4 * 4, cbh4 * 4); | 1413 | 1.31k | f->dsp->ipred.pal_pred(((pixel *) f->cur.data[2]) + uv_dstoff, | 1414 | 1.31k | f->cur.stride[1], pal[2], | 1415 | 1.31k | pal_idx, cbw4 * 4, cbh4 * 4); | 1416 | 1.31k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1417 | 0 | hex_dump(((pixel *) f->cur.data[1]) + uv_dstoff, | 1418 | 0 | PXSTRIDE(f->cur.stride[1]), | 1419 | 0 | cbw4 * 4, cbh4 * 4, "u-pal-pred"); | 1420 | 0 | hex_dump(((pixel *) f->cur.data[2]) + uv_dstoff, | 1421 | 0 | PXSTRIDE(f->cur.stride[1]), | 1422 | 0 | cbw4 * 4, cbh4 * 4, "v-pal-pred"); | 1423 | 0 | } | 1424 | 1.31k | } | 1425 | | | 1426 | 746k | const int sm_uv_fl = sm_uv_flag(t->a, cbx4) | | 1427 | 746k | sm_uv_flag(&t->l, cby4); | 1428 | 746k | const int uv_sb_has_tr = | 1429 | 746k | ((init_x + 16) >> ss_hor) < cw4 ? 1 : init_y ? 0 : | 1430 | 717k | intra_edge_flags & (EDGE_I420_TOP_HAS_RIGHT >> (f->cur.p.layout - 1)); | 1431 | 746k | const int uv_sb_has_bl = | 1432 | 746k | init_x ? 0 : ((init_y + 16) >> ss_ver) < ch4 ? 1 : | 1433 | 717k | intra_edge_flags & (EDGE_I420_LEFT_HAS_BOTTOM >> (f->cur.p.layout - 1)); | 1434 | 746k | const int sub_cw4 = imin(cw4, (init_x + 16) >> ss_hor); | 1435 | 2.23M | for (int pl = 0; pl < 2; pl++) { | 1436 | 3.17M | for (y = init_y >> ss_ver, t->by += init_y; y < sub_ch4; | 1437 | 1.68M | y += uv_t_dim->h, t->by += uv_t_dim->h << ss_ver) | 1438 | 1.68M | { | 1439 | 1.68M | pixel *dst = ((pixel *) f->cur.data[1 + pl]) + | 1440 | 1.68M | 4 * ((t->by >> ss_ver) * PXSTRIDE(stride) + | 1441 | 1.68M | ((t->bx + init_x) >> ss_hor)); | 1442 | 3.73M | for (x = init_x >> ss_hor, t->bx += init_x; x < sub_cw4; | 1443 | 2.05M | x += uv_t_dim->w, t->bx += uv_t_dim->w << ss_hor) | 1444 | 2.05M | { | 1445 | 2.05M | if ((b->uv_mode == CFL_PRED && b->cfl_alpha[pl]) || | 1446 | 1.79M | b->pal_sz[1]) | 1447 | 262k | { | 1448 | 262k | goto skip_uv_pred; | 1449 | 262k | } | 1450 | | | 1451 | 1.78M | int angle = b->uv_angle; | 1452 | | // this probably looks weird because we're using | 1453 | | // luma flags in a chroma loop, but that's because | 1454 | | // prepare_intra_edges() expects luma flags as input | 1455 | 1.78M | const enum EdgeFlags edge_flags = | 1456 | 1.78M | (((y > (init_y >> ss_ver) || !uv_sb_has_tr) && | 1457 | 798k | (x + uv_t_dim->w >= sub_cw4)) ? | 1458 | 1.24M | 0 : EDGE_I444_TOP_HAS_RIGHT) | | 1459 | 1.78M | ((x > (init_x >> ss_hor) || | 1460 | 1.42M | (!uv_sb_has_bl && y + uv_t_dim->h >= sub_ch4)) ? | 1461 | 1.05M | 0 : EDGE_I444_LEFT_HAS_BOTTOM); | 1462 | 1.78M | const pixel *top_sb_edge = NULL; | 1463 | 1.78M | if (!((t->by & ~ss_ver) & (f->sb_step - 1))) { | 1464 | 551k | top_sb_edge = f->ipred_edge[1 + pl]; | 1465 | 551k | const int sby = t->by >> f->sb_shift; | 1466 | 551k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1467 | 551k | } | 1468 | 1.78M | const enum IntraPredMode uv_mode = | 1469 | 1.78M | b->uv_mode == CFL_PRED ? DC_PRED : b->uv_mode; | 1470 | 1.78M | const int xpos = t->bx >> ss_hor, ypos = t->by >> ss_ver; | 1471 | 1.78M | const int xstart = ts->tiling.col_start >> ss_hor; | 1472 | 1.78M | const int ystart = ts->tiling.row_start >> ss_ver; | 1473 | 1.78M | const enum IntraPredMode m = | 1474 | 1.78M | bytefn(dav1d_prepare_intra_edges)(xpos, xpos > xstart, | 1475 | 1.78M | ypos, ypos > ystart, | 1476 | 1.78M | ts->tiling.col_end >> ss_hor, | 1477 | 1.78M | ts->tiling.row_end >> ss_ver, | 1478 | 1.78M | edge_flags, dst, stride, | 1479 | 1.78M | top_sb_edge, uv_mode, | 1480 | 1.78M | &angle, uv_t_dim->w, | 1481 | 1.78M | uv_t_dim->h, | 1482 | 1.78M | f->seq_hdr->intra_edge_filter, | 1483 | 1.78M | edge HIGHBD_CALL_SUFFIX); | 1484 | 1.78M | angle |= intra_edge_filter_flag; | 1485 | 1.78M | dsp->ipred.intra_pred[m](dst, stride, edge, | 1486 | 1.78M | uv_t_dim->w * 4, | 1487 | 1.78M | uv_t_dim->h * 4, | 1488 | 1.78M | angle | sm_uv_fl, | 1489 | 1.78M | (4 * f->bw + ss_hor - | 1490 | 1.78M | 4 * (t->bx & ~ss_hor)) >> ss_hor, | 1491 | 1.78M | (4 * f->bh + ss_ver - | 1492 | 1.78M | 4 * (t->by & ~ss_ver)) >> ss_ver | 1493 | 1.78M | HIGHBD_CALL_SUFFIX); | 1494 | 1.78M | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1495 | 0 | hex_dump(edge - uv_t_dim->h * 4, uv_t_dim->h * 4, | 1496 | 0 | uv_t_dim->h * 4, 2, "l"); | 1497 | 0 | hex_dump(edge, 0, 1, 1, "tl"); | 1498 | 0 | hex_dump(edge + 1, uv_t_dim->w * 4, | 1499 | 0 | uv_t_dim->w * 4, 2, "t"); | 1500 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, | 1501 | 0 | uv_t_dim->h * 4, pl ? "v-intra-pred" : "u-intra-pred"); | 1502 | 0 | } | 1503 | | | 1504 | 2.05M | skip_uv_pred: {} | 1505 | 2.05M | if (!b->skip) { | 1506 | 851k | enum TxfmType txtp; | 1507 | 851k | int eob; | 1508 | 851k | coef *cf; | 1509 | 851k | if (t->frame_thread.pass) { | 1510 | 851k | const int p = t->frame_thread.pass & 1; | 1511 | 851k | const int cbi = *ts->frame_thread[p].cbi++; | 1512 | 851k | cf = ts->frame_thread[p].cf; | 1513 | 851k | ts->frame_thread[p].cf += uv_t_dim->w * uv_t_dim->h * 16; | 1514 | 851k | eob = cbi >> 5; | 1515 | 851k | txtp = cbi & 0x1f; | 1516 | 18.4E | } else { | 1517 | 18.4E | uint8_t cf_ctx; | 1518 | 18.4E | cf = bitfn(t->cf); | 1519 | 18.4E | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 1520 | 18.4E | &t->l.ccoef[pl][cby4 + y], | 1521 | 18.4E | b->uvtx, bs, b, 1, 1 + pl, cf, | 1522 | 18.4E | &txtp, &cf_ctx); | 1523 | 18.4E | if (DEBUG_BLOCK_INFO) | 1524 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 1525 | 0 | "txtp=%d,eob=%d]: r=%d [x=%d,cbx4=%d]\n", | 1526 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng, x, cbx4); | 1527 | 18.4E | int ctw = imin(uv_t_dim->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 1528 | 18.4E | int cth = imin(uv_t_dim->h, (f->bh - t->by + ss_ver) >> ss_ver); | 1529 | 18.4E | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 1530 | 18.4E | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 1531 | 18.4E | } | 1532 | 851k | if (eob >= 0) { | 1533 | 275k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1534 | 0 | coef_dump(cf, uv_t_dim->h * 4, | 1535 | 0 | uv_t_dim->w * 4, 3, "dq"); | 1536 | 275k | dsp->itx.itxfm_add[b->uvtx] | 1537 | 275k | [txtp](dst, stride, | 1538 | 275k | cf, eob HIGHBD_CALL_SUFFIX); | 1539 | 275k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1540 | 0 | hex_dump(dst, stride, uv_t_dim->w * 4, | 1541 | 0 | uv_t_dim->h * 4, "recon"); | 1542 | 275k | } | 1543 | 1.20M | } else if (!t->frame_thread.pass) { | 1544 | 0 | dav1d_memset_pow2[uv_t_dim->lw](&t->a->ccoef[pl][cbx4 + x], 0x40); | 1545 | 0 | dav1d_memset_pow2[uv_t_dim->lh](&t->l.ccoef[pl][cby4 + y], 0x40); | 1546 | 0 | } | 1547 | 2.05M | dst += uv_t_dim->w * 4; | 1548 | 2.05M | } | 1549 | 1.68M | t->bx -= x << ss_hor; | 1550 | 1.68M | } | 1551 | 1.49M | t->by -= y << ss_ver; | 1552 | 1.49M | } | 1553 | 746k | } | 1554 | 868k | } | 1555 | 836k | } |
|
1556 | | |
1557 | | int bytefn(dav1d_recon_b_inter)(Dav1dTaskContext *const t, const enum BlockSize bs, |
1558 | | const Av1Block *const b) |
1559 | 291k | { |
1560 | 291k | Dav1dTileState *const ts = t->ts; |
1561 | 291k | const Dav1dFrameContext *const f = t->f; |
1562 | 291k | const Dav1dDSPContext *const dsp = f->dsp; |
1563 | 291k | const int bx4 = t->bx & 31, by4 = t->by & 31; |
1564 | 291k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
1565 | 291k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
1566 | 291k | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; |
1567 | 291k | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; |
1568 | 291k | const int bw4 = b_dim[0], bh4 = b_dim[1]; |
1569 | 291k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); |
1570 | 291k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && |
1571 | 256k | (bw4 > ss_hor || t->bx & 1) && |
1572 | 247k | (bh4 > ss_ver || t->by & 1); |
1573 | 291k | const int chr_layout_idx = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I400 ? 0 : |
1574 | 291k | DAV1D_PIXEL_LAYOUT_I444 - f->cur.p.layout; |
1575 | 291k | int res; |
1576 | | |
1577 | | // prediction |
1578 | 291k | const int cbh4 = (bh4 + ss_ver) >> ss_ver, cbw4 = (bw4 + ss_hor) >> ss_hor; |
1579 | 291k | pixel *dst = ((pixel *) f->cur.data[0]) + |
1580 | 291k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); |
1581 | 291k | const ptrdiff_t uvdstoff = |
1582 | 291k | 4 * ((t->bx >> ss_hor) + (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); |
1583 | 291k | if (IS_KEY_OR_INTRA(f->frame_hdr)) { |
1584 | | // intrabc |
1585 | 97.3k | assert(!f->frame_hdr->super_res.enabled); |
1586 | 97.3k | res = mc(t, dst, NULL, f->cur.stride[0], bw4, bh4, t->bx, t->by, 0, |
1587 | 97.3k | b->mv[0], &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); |
1588 | 97.3k | if (res) return res; |
1589 | 252k | if (has_chroma) for (int pl = 1; pl < 3; pl++) { |
1590 | 168k | res = mc(t, ((pixel *)f->cur.data[pl]) + uvdstoff, NULL, f->cur.stride[1], |
1591 | 168k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), |
1592 | 168k | t->bx & ~ss_hor, t->by & ~ss_ver, pl, b->mv[0], |
1593 | 168k | &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); |
1594 | 168k | if (res) return res; |
1595 | 168k | } |
1596 | 194k | } else if (b->comp_type == COMP_INTER_NONE) { |
1597 | 167k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[0]]; |
1598 | 167k | const enum Filter2d filter_2d = b->filter2d; |
1599 | | |
1600 | 167k | if (imin(bw4, bh4) > 1 && |
1601 | 106k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || |
1602 | 102k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) |
1603 | 7.02k | { |
1604 | 7.02k | res = warp_affine(t, dst, NULL, f->cur.stride[0], b_dim, 0, refp, |
1605 | 7.02k | b->motion_mode == MM_WARP ? &t->warpmv : |
1606 | 7.02k | &f->frame_hdr->gmv[b->ref[0]]); |
1607 | 7.02k | if (res) return res; |
1608 | 160k | } else { |
1609 | 160k | res = mc(t, dst, NULL, f->cur.stride[0], |
1610 | 160k | bw4, bh4, t->bx, t->by, 0, b->mv[0], refp, b->ref[0], filter_2d); |
1611 | 160k | if (res) return res; |
1612 | 160k | if (b->motion_mode == MM_OBMC) { |
1613 | 30.4k | res = obmc(t, dst, f->cur.stride[0], b_dim, 0, bx4, by4, w4, h4); |
1614 | 30.4k | if (res) return res; |
1615 | 30.4k | } |
1616 | 160k | } |
1617 | 167k | if (b->interintra_type) { |
1618 | 5.20k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; |
1619 | 5.20k | enum IntraPredMode m = b->interintra_mode == II_SMOOTH_PRED ? |
1620 | 4.29k | SMOOTH_PRED : b->interintra_mode; |
1621 | 5.20k | pixel *const tmp = bitfn(t->scratch.interintra); |
1622 | 5.20k | int angle = 0; |
1623 | 5.20k | const pixel *top_sb_edge = NULL; |
1624 | 5.20k | if (!(t->by & (f->sb_step - 1))) { |
1625 | 2.77k | top_sb_edge = f->ipred_edge[0]; |
1626 | 2.77k | const int sby = t->by >> f->sb_shift; |
1627 | 2.77k | top_sb_edge += f->sb128w * 128 * (sby - 1); |
1628 | 2.77k | } |
1629 | 5.20k | m = bytefn(dav1d_prepare_intra_edges)(t->bx, t->bx > ts->tiling.col_start, |
1630 | 5.20k | t->by, t->by > ts->tiling.row_start, |
1631 | 5.20k | ts->tiling.col_end, ts->tiling.row_end, |
1632 | 5.20k | 0, dst, f->cur.stride[0], top_sb_edge, |
1633 | 5.20k | m, &angle, bw4, bh4, 0, tl_edge |
1634 | 5.20k | HIGHBD_CALL_SUFFIX); |
1635 | 5.20k | dsp->ipred.intra_pred[m](tmp, 4 * bw4 * sizeof(pixel), |
1636 | 5.20k | tl_edge, bw4 * 4, bh4 * 4, 0, 0, 0 |
1637 | 5.20k | HIGHBD_CALL_SUFFIX); |
1638 | 5.20k | dsp->mc.blend(dst, f->cur.stride[0], tmp, |
1639 | 5.20k | bw4 * 4, bh4 * 4, II_MASK(0, bs, b)); |
1640 | 5.20k | } |
1641 | | |
1642 | 167k | if (!has_chroma) goto skip_inter_chroma_pred; |
1643 | | |
1644 | | // sub8x8 derivation |
1645 | 136k | int is_sub8x8 = bw4 == ss_hor || bh4 == ss_ver; |
1646 | 136k | refmvs_block *const *r; |
1647 | 136k | if (is_sub8x8) { |
1648 | 6.09k | assert(ss_hor == 1); |
1649 | 6.09k | r = &t->rt.r[(t->by & 31) + 5]; |
1650 | 6.09k | if (bw4 == 1) is_sub8x8 &= r[0][t->bx - 1].ref.ref[0] > 0; |
1651 | 6.09k | if (bh4 == ss_ver) is_sub8x8 &= r[-1][t->bx].ref.ref[0] > 0; |
1652 | 6.09k | if (bw4 == 1 && bh4 == ss_ver) |
1653 | 1.79k | is_sub8x8 &= r[-1][t->bx - 1].ref.ref[0] > 0; |
1654 | 6.09k | } |
1655 | | |
1656 | | // chroma prediction |
1657 | 136k | if (is_sub8x8) { |
1658 | 6.02k | assert(ss_hor == 1); |
1659 | 6.02k | ptrdiff_t h_off = 0, v_off = 0; |
1660 | 6.02k | if (bw4 == 1 && bh4 == ss_ver) { |
1661 | 5.27k | for (int pl = 0; pl < 2; pl++) { |
1662 | 3.51k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, |
1663 | 3.51k | NULL, f->cur.stride[1], |
1664 | 3.51k | bw4, bh4, t->bx - 1, t->by - 1, 1 + pl, |
1665 | 3.51k | r[-1][t->bx - 1].mv.mv[0], |
1666 | 3.51k | &f->refp[r[-1][t->bx - 1].ref.ref[0] - 1], |
1667 | 3.51k | r[-1][t->bx - 1].ref.ref[0] - 1, |
1668 | 3.51k | t->frame_thread.pass != 2 ? t->tl_4x4_filter : |
1669 | 3.51k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx - 1].filter2d); |
1670 | 3.51k | if (res) return res; |
1671 | 3.51k | } |
1672 | 1.75k | v_off = 2 * PXSTRIDE(f->cur.stride[1]); |
1673 | 1.75k | h_off = 2; |
1674 | 1.75k | } |
1675 | 6.02k | if (bw4 == 1) { |
1676 | 3.71k | const enum Filter2d left_filter_2d = |
1677 | 3.71k | dav1d_filter_2d[t->l.filter[1][by4]][t->l.filter[0][by4]]; |
1678 | 11.1k | for (int pl = 0; pl < 2; pl++) { |
1679 | 7.42k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + v_off, NULL, |
1680 | 7.42k | f->cur.stride[1], bw4, bh4, t->bx - 1, |
1681 | 7.42k | t->by, 1 + pl, r[0][t->bx - 1].mv.mv[0], |
1682 | 7.42k | &f->refp[r[0][t->bx - 1].ref.ref[0] - 1], |
1683 | 7.42k | r[0][t->bx - 1].ref.ref[0] - 1, |
1684 | 7.42k | t->frame_thread.pass != 2 ? left_filter_2d : |
1685 | 7.42k | f->frame_thread.b[(t->by * f->b4_stride) + t->bx - 1].filter2d); |
1686 | 7.42k | if (res) return res; |
1687 | 7.42k | } |
1688 | 3.71k | h_off = 2; |
1689 | 3.71k | } |
1690 | 6.02k | if (bh4 == ss_ver) { |
1691 | 4.06k | const enum Filter2d top_filter_2d = |
1692 | 4.06k | dav1d_filter_2d[t->a->filter[1][bx4]][t->a->filter[0][bx4]]; |
1693 | 12.2k | for (int pl = 0; pl < 2; pl++) { |
1694 | 8.13k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off, NULL, |
1695 | 8.13k | f->cur.stride[1], bw4, bh4, t->bx, t->by - 1, |
1696 | 8.13k | 1 + pl, r[-1][t->bx].mv.mv[0], |
1697 | 8.13k | &f->refp[r[-1][t->bx].ref.ref[0] - 1], |
1698 | 8.13k | r[-1][t->bx].ref.ref[0] - 1, |
1699 | 8.13k | t->frame_thread.pass != 2 ? top_filter_2d : |
1700 | 8.13k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx].filter2d); |
1701 | 8.13k | if (res) return res; |
1702 | 8.13k | } |
1703 | 4.06k | v_off = 2 * PXSTRIDE(f->cur.stride[1]); |
1704 | 4.06k | } |
1705 | 18.0k | for (int pl = 0; pl < 2; pl++) { |
1706 | 12.0k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off + v_off, NULL, f->cur.stride[1], |
1707 | 12.0k | bw4, bh4, t->bx, t->by, 1 + pl, b->mv[0], |
1708 | 12.0k | refp, b->ref[0], filter_2d); |
1709 | 12.0k | if (res) return res; |
1710 | 12.0k | } |
1711 | 130k | } else { |
1712 | 130k | if (imin(cbw4, cbh4) > 1 && |
1713 | 80.5k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || |
1714 | 76.5k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) |
1715 | 6.58k | { |
1716 | 19.7k | for (int pl = 0; pl < 2; pl++) { |
1717 | 13.1k | res = warp_affine(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, NULL, |
1718 | 13.1k | f->cur.stride[1], b_dim, 1 + pl, refp, |
1719 | 13.1k | b->motion_mode == MM_WARP ? &t->warpmv : |
1720 | 13.1k | &f->frame_hdr->gmv[b->ref[0]]); |
1721 | 13.1k | if (res) return res; |
1722 | 13.1k | } |
1723 | 123k | } else { |
1724 | 371k | for (int pl = 0; pl < 2; pl++) { |
1725 | 247k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, |
1726 | 247k | NULL, f->cur.stride[1], |
1727 | 247k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), |
1728 | 247k | t->bx & ~ss_hor, t->by & ~ss_ver, |
1729 | 247k | 1 + pl, b->mv[0], refp, b->ref[0], filter_2d); |
1730 | 247k | if (res) return res; |
1731 | 247k | if (b->motion_mode == MM_OBMC) { |
1732 | 55.4k | res = obmc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, |
1733 | 55.4k | f->cur.stride[1], b_dim, 1 + pl, bx4, by4, w4, h4); |
1734 | 55.4k | if (res) return res; |
1735 | 55.4k | } |
1736 | 247k | } |
1737 | 123k | } |
1738 | 130k | if (b->interintra_type) { |
1739 | | // FIXME for 8x32 with 4:2:2 subsampling, this probably does |
1740 | | // the wrong thing since it will select 4x16, not 4x32, as a |
1741 | | // transform size... |
1742 | 3.97k | const uint8_t *const ii_mask = II_MASK(chr_layout_idx, bs, b); |
1743 | | |
1744 | 11.9k | for (int pl = 0; pl < 2; pl++) { |
1745 | 7.94k | pixel *const tmp = bitfn(t->scratch.interintra); |
1746 | 7.94k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; |
1747 | 7.94k | enum IntraPredMode m = |
1748 | 7.94k | b->interintra_mode == II_SMOOTH_PRED ? |
1749 | 6.69k | SMOOTH_PRED : b->interintra_mode; |
1750 | 7.94k | int angle = 0; |
1751 | 7.94k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; |
1752 | 7.94k | const pixel *top_sb_edge = NULL; |
1753 | 7.94k | if (!(t->by & (f->sb_step - 1))) { |
1754 | 4.21k | top_sb_edge = f->ipred_edge[pl + 1]; |
1755 | 4.21k | const int sby = t->by >> f->sb_shift; |
1756 | 4.21k | top_sb_edge += f->sb128w * 128 * (sby - 1); |
1757 | 4.21k | } |
1758 | 7.94k | m = bytefn(dav1d_prepare_intra_edges)(t->bx >> ss_hor, |
1759 | 7.94k | (t->bx >> ss_hor) > |
1760 | 7.94k | (ts->tiling.col_start >> ss_hor), |
1761 | 7.94k | t->by >> ss_ver, |
1762 | 7.94k | (t->by >> ss_ver) > |
1763 | 7.94k | (ts->tiling.row_start >> ss_ver), |
1764 | 7.94k | ts->tiling.col_end >> ss_hor, |
1765 | 7.94k | ts->tiling.row_end >> ss_ver, |
1766 | 7.94k | 0, uvdst, f->cur.stride[1], |
1767 | 7.94k | top_sb_edge, m, |
1768 | 7.94k | &angle, cbw4, cbh4, 0, tl_edge |
1769 | 7.94k | HIGHBD_CALL_SUFFIX); |
1770 | 7.94k | dsp->ipred.intra_pred[m](tmp, cbw4 * 4 * sizeof(pixel), |
1771 | 7.94k | tl_edge, cbw4 * 4, cbh4 * 4, 0, 0, 0 |
1772 | 7.94k | HIGHBD_CALL_SUFFIX); |
1773 | 7.94k | dsp->mc.blend(uvdst, f->cur.stride[1], tmp, |
1774 | 7.94k | cbw4 * 4, cbh4 * 4, ii_mask); |
1775 | 7.94k | } |
1776 | 3.97k | } |
1777 | 130k | } |
1778 | | |
1779 | 167k | skip_inter_chroma_pred: {} |
1780 | 167k | t->tl_4x4_filter = filter_2d; |
1781 | 167k | } else { |
1782 | 27.2k | const enum Filter2d filter_2d = b->filter2d; |
1783 | | // Maximum super block size is 128x128 |
1784 | 27.2k | int16_t (*tmp)[128 * 128] = t->scratch.compinter; |
1785 | 27.2k | int jnt_weight; |
1786 | 27.2k | uint8_t *const seg_mask = t->scratch.seg_mask; |
1787 | 27.2k | const uint8_t *mask; |
1788 | | |
1789 | 81.6k | for (int i = 0; i < 2; i++) { |
1790 | 54.4k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; |
1791 | | |
1792 | 54.4k | if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) { |
1793 | 2.47k | res = warp_affine(t, NULL, tmp[i], bw4 * 4, b_dim, 0, refp, |
1794 | 2.47k | &f->frame_hdr->gmv[b->ref[i]]); |
1795 | 2.47k | if (res) return res; |
1796 | 51.9k | } else { |
1797 | 51.9k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, 0, |
1798 | 51.9k | b->mv[i], refp, b->ref[i], filter_2d); |
1799 | 51.9k | if (res) return res; |
1800 | 51.9k | } |
1801 | 54.4k | } |
1802 | 27.2k | switch (b->comp_type) { |
1803 | 20.0k | case COMP_INTER_AVG: |
1804 | 20.0k | dsp->mc.avg(dst, f->cur.stride[0], tmp[0], tmp[1], |
1805 | 20.0k | bw4 * 4, bh4 * 4 HIGHBD_CALL_SUFFIX); |
1806 | 20.0k | break; |
1807 | 2.46k | case COMP_INTER_WEIGHTED_AVG: |
1808 | 2.46k | jnt_weight = f->jnt_weights[b->ref[0]][b->ref[1]]; |
1809 | 2.46k | dsp->mc.w_avg(dst, f->cur.stride[0], tmp[0], tmp[1], |
1810 | 2.46k | bw4 * 4, bh4 * 4, jnt_weight HIGHBD_CALL_SUFFIX); |
1811 | 2.46k | break; |
1812 | 3.31k | case COMP_INTER_SEG: |
1813 | 3.31k | dsp->mc.w_mask[chr_layout_idx](dst, f->cur.stride[0], |
1814 | 3.31k | tmp[b->mask_sign], tmp[!b->mask_sign], |
1815 | 3.31k | bw4 * 4, bh4 * 4, seg_mask, |
1816 | 3.31k | b->mask_sign HIGHBD_CALL_SUFFIX); |
1817 | 3.31k | mask = seg_mask; |
1818 | 3.31k | break; |
1819 | 1.39k | case COMP_INTER_WEDGE: |
1820 | 1.39k | mask = WEDGE_MASK(0, bs, 0, b->wedge_idx); |
1821 | 1.39k | dsp->mc.mask(dst, f->cur.stride[0], |
1822 | 1.39k | tmp[b->mask_sign], tmp[!b->mask_sign], |
1823 | 1.39k | bw4 * 4, bh4 * 4, mask HIGHBD_CALL_SUFFIX); |
1824 | 1.39k | if (has_chroma) |
1825 | 955 | mask = WEDGE_MASK(chr_layout_idx, bs, b->mask_sign, b->wedge_idx); |
1826 | 1.39k | break; |
1827 | 27.2k | } |
1828 | | |
1829 | | // chroma |
1830 | 57.6k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { |
1831 | 115k | for (int i = 0; i < 2; i++) { |
1832 | 76.8k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; |
1833 | 76.8k | if (b->inter_mode == GLOBALMV_GLOBALMV && |
1834 | 13.1k | imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]]) |
1835 | 4.27k | { |
1836 | 4.27k | res = warp_affine(t, NULL, tmp[i], bw4 * 4 >> ss_hor, |
1837 | 4.27k | b_dim, 1 + pl, |
1838 | 4.27k | refp, &f->frame_hdr->gmv[b->ref[i]]); |
1839 | 4.27k | if (res) return res; |
1840 | 72.5k | } else { |
1841 | 72.5k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, |
1842 | 72.5k | 1 + pl, b->mv[i], refp, b->ref[i], filter_2d); |
1843 | 72.5k | if (res) return res; |
1844 | 72.5k | } |
1845 | 76.8k | } |
1846 | 38.4k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; |
1847 | 38.4k | switch (b->comp_type) { |
1848 | 29.1k | case COMP_INTER_AVG: |
1849 | 29.1k | dsp->mc.avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], |
1850 | 29.1k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver |
1851 | 29.1k | HIGHBD_CALL_SUFFIX); |
1852 | 29.1k | break; |
1853 | 3.15k | case COMP_INTER_WEIGHTED_AVG: |
1854 | 3.15k | dsp->mc.w_avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], |
1855 | 3.15k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, jnt_weight |
1856 | 3.15k | HIGHBD_CALL_SUFFIX); |
1857 | 3.15k | break; |
1858 | 1.91k | case COMP_INTER_WEDGE: |
1859 | 6.09k | case COMP_INTER_SEG: |
1860 | 6.09k | dsp->mc.mask(uvdst, f->cur.stride[1], |
1861 | 6.09k | tmp[b->mask_sign], tmp[!b->mask_sign], |
1862 | 6.09k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, mask |
1863 | 6.09k | HIGHBD_CALL_SUFFIX); |
1864 | 6.09k | break; |
1865 | 38.4k | } |
1866 | 38.4k | } |
1867 | 27.2k | } |
1868 | | |
1869 | 292k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { |
1870 | 0 | hex_dump(dst, f->cur.stride[0], b_dim[0] * 4, b_dim[1] * 4, "y-pred"); |
1871 | 0 | if (has_chroma) { |
1872 | 0 | hex_dump(&((pixel *) f->cur.data[1])[uvdstoff], f->cur.stride[1], |
1873 | 0 | cbw4 * 4, cbh4 * 4, "u-pred"); |
1874 | 0 | hex_dump(&((pixel *) f->cur.data[2])[uvdstoff], f->cur.stride[1], |
1875 | 0 | cbw4 * 4, cbh4 * 4, "v-pred"); |
1876 | 0 | } |
1877 | 0 | } |
1878 | | |
1879 | 292k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; |
1880 | | |
1881 | 292k | if (b->skip) { |
1882 | | // reset coef contexts |
1883 | 152k | BlockContext *const a = t->a; |
1884 | 152k | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); |
1885 | 152k | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); |
1886 | 152k | if (has_chroma) { |
1887 | 129k | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; |
1888 | 129k | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; |
1889 | 129k | memset_cw(&a->ccoef[0][cbx4], 0x40); |
1890 | 129k | memset_cw(&a->ccoef[1][cbx4], 0x40); |
1891 | 129k | memset_ch(&t->l.ccoef[0][cby4], 0x40); |
1892 | 129k | memset_ch(&t->l.ccoef[1][cby4], 0x40); |
1893 | 129k | } |
1894 | 152k | return 0; |
1895 | 152k | } |
1896 | | |
1897 | 139k | const TxfmInfo *const uvtx = &dav1d_txfm_dimensions[b->uvtx]; |
1898 | 139k | const TxfmInfo *const ytx = &dav1d_txfm_dimensions[b->max_ytx]; |
1899 | 139k | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; |
1900 | | |
1901 | 288k | for (int init_y = 0; init_y < bh4; init_y += 16) { |
1902 | 300k | for (int init_x = 0; init_x < bw4; init_x += 16) { |
1903 | | // coefficient coding & inverse transforms |
1904 | 151k | int y_off = !!init_y, y; |
1905 | 151k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * init_y; |
1906 | 322k | for (y = init_y, t->by += init_y; y < imin(h4, init_y + 16); |
1907 | 171k | y += ytx->h, y_off++) |
1908 | 171k | { |
1909 | 171k | int x, x_off = !!init_x; |
1910 | 422k | for (x = init_x, t->bx += init_x; x < imin(w4, init_x + 16); |
1911 | 250k | x += ytx->w, x_off++) |
1912 | 250k | { |
1913 | 250k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, |
1914 | 250k | x_off, y_off, &dst[x * 4]); |
1915 | 250k | t->bx += ytx->w; |
1916 | 250k | } |
1917 | 171k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * ytx->h; |
1918 | 171k | t->bx -= x; |
1919 | 171k | t->by += ytx->h; |
1920 | 171k | } |
1921 | 151k | dst -= PXSTRIDE(f->cur.stride[0]) * 4 * y; |
1922 | 151k | t->by -= y; |
1923 | | |
1924 | | // chroma coefs and inverse transform |
1925 | 358k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { |
1926 | 239k | pixel *uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff + |
1927 | 239k | (PXSTRIDE(f->cur.stride[1]) * init_y * 4 >> ss_ver); |
1928 | 239k | for (y = init_y >> ss_ver, t->by += init_y; |
1929 | 531k | y < imin(ch4, (init_y + 16) >> ss_ver); y += uvtx->h) |
1930 | 291k | { |
1931 | 291k | int x; |
1932 | 291k | for (x = init_x >> ss_hor, t->bx += init_x; |
1933 | 738k | x < imin(cw4, (init_x + 16) >> ss_hor); x += uvtx->w) |
1934 | 446k | { |
1935 | 446k | coef *cf; |
1936 | 446k | int eob; |
1937 | 446k | enum TxfmType txtp; |
1938 | 446k | if (t->frame_thread.pass) { |
1939 | 446k | const int p = t->frame_thread.pass & 1; |
1940 | 446k | const int cbi = *ts->frame_thread[p].cbi++; |
1941 | 446k | cf = ts->frame_thread[p].cf; |
1942 | 446k | ts->frame_thread[p].cf += uvtx->w * uvtx->h * 16; |
1943 | 446k | eob = cbi >> 5; |
1944 | 446k | txtp = cbi & 0x1f; |
1945 | 446k | } else { |
1946 | 0 | uint8_t cf_ctx; |
1947 | 0 | cf = bitfn(t->cf); |
1948 | 0 | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + |
1949 | 0 | bx4 + (x << ss_hor)]; |
1950 | 0 | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], |
1951 | 0 | &t->l.ccoef[pl][cby4 + y], |
1952 | 0 | b->uvtx, bs, b, 0, 1 + pl, |
1953 | 0 | cf, &txtp, &cf_ctx); |
1954 | 0 | if (DEBUG_BLOCK_INFO) |
1955 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," |
1956 | 0 | "txtp=%d,eob=%d]: r=%d\n", |
1957 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); |
1958 | 0 | int ctw = imin(uvtx->w, (f->bw - t->bx + ss_hor) >> ss_hor); |
1959 | 0 | int cth = imin(uvtx->h, (f->bh - t->by + ss_ver) >> ss_ver); |
1960 | 0 | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); |
1961 | 0 | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); |
1962 | 0 | } |
1963 | 446k | if (eob >= 0) { |
1964 | 162k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1965 | 0 | coef_dump(cf, uvtx->h * 4, uvtx->w * 4, 3, "dq"); |
1966 | 162k | dsp->itx.itxfm_add[b->uvtx] |
1967 | 162k | [txtp](&uvdst[4 * x], |
1968 | 162k | f->cur.stride[1], |
1969 | 162k | cf, eob HIGHBD_CALL_SUFFIX); |
1970 | 162k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) |
1971 | 0 | hex_dump(&uvdst[4 * x], f->cur.stride[1], |
1972 | 0 | uvtx->w * 4, uvtx->h * 4, "recon"); |
1973 | 162k | } |
1974 | 446k | t->bx += uvtx->w << ss_hor; |
1975 | 446k | } |
1976 | 291k | uvdst += PXSTRIDE(f->cur.stride[1]) * 4 * uvtx->h; |
1977 | 291k | t->bx -= x << ss_hor; |
1978 | 291k | t->by += uvtx->h << ss_ver; |
1979 | 291k | } |
1980 | 239k | t->by -= y << ss_ver; |
1981 | 239k | } |
1982 | 151k | } |
1983 | 149k | } |
1984 | 139k | return 0; |
1985 | 292k | } Line | Count | Source | 1559 | 186k | { | 1560 | 186k | Dav1dTileState *const ts = t->ts; | 1561 | 186k | const Dav1dFrameContext *const f = t->f; | 1562 | 186k | const Dav1dDSPContext *const dsp = f->dsp; | 1563 | 186k | const int bx4 = t->bx & 31, by4 = t->by & 31; | 1564 | 186k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1565 | 186k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 1566 | 186k | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 1567 | 186k | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 1568 | 186k | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 1569 | 186k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 1570 | 186k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 1571 | 164k | (bw4 > ss_hor || t->bx & 1) && | 1572 | 159k | (bh4 > ss_ver || t->by & 1); | 1573 | 186k | const int chr_layout_idx = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I400 ? 0 : | 1574 | 186k | DAV1D_PIXEL_LAYOUT_I444 - f->cur.p.layout; | 1575 | 186k | int res; | 1576 | | | 1577 | | // prediction | 1578 | 186k | const int cbh4 = (bh4 + ss_ver) >> ss_ver, cbw4 = (bw4 + ss_hor) >> ss_hor; | 1579 | 186k | pixel *dst = ((pixel *) f->cur.data[0]) + | 1580 | 186k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); | 1581 | 186k | const ptrdiff_t uvdstoff = | 1582 | 186k | 4 * ((t->bx >> ss_hor) + (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); | 1583 | 186k | if (IS_KEY_OR_INTRA(f->frame_hdr)) { | 1584 | | // intrabc | 1585 | 59.9k | assert(!f->frame_hdr->super_res.enabled); | 1586 | 59.9k | res = mc(t, dst, NULL, f->cur.stride[0], bw4, bh4, t->bx, t->by, 0, | 1587 | 59.9k | b->mv[0], &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); | 1588 | 59.9k | if (res) return res; | 1589 | 151k | if (has_chroma) for (int pl = 1; pl < 3; pl++) { | 1590 | 101k | res = mc(t, ((pixel *)f->cur.data[pl]) + uvdstoff, NULL, f->cur.stride[1], | 1591 | 101k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), | 1592 | 101k | t->bx & ~ss_hor, t->by & ~ss_ver, pl, b->mv[0], | 1593 | 101k | &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); | 1594 | 101k | if (res) return res; | 1595 | 101k | } | 1596 | 126k | } else if (b->comp_type == COMP_INTER_NONE) { | 1597 | 111k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[0]]; | 1598 | 111k | const enum Filter2d filter_2d = b->filter2d; | 1599 | | | 1600 | 111k | if (imin(bw4, bh4) > 1 && | 1601 | 74.1k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || | 1602 | 71.5k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) | 1603 | 4.96k | { | 1604 | 4.96k | res = warp_affine(t, dst, NULL, f->cur.stride[0], b_dim, 0, refp, | 1605 | 4.96k | b->motion_mode == MM_WARP ? &t->warpmv : | 1606 | 4.96k | &f->frame_hdr->gmv[b->ref[0]]); | 1607 | 4.96k | if (res) return res; | 1608 | 106k | } else { | 1609 | 106k | res = mc(t, dst, NULL, f->cur.stride[0], | 1610 | 106k | bw4, bh4, t->bx, t->by, 0, b->mv[0], refp, b->ref[0], filter_2d); | 1611 | 106k | if (res) return res; | 1612 | 106k | if (b->motion_mode == MM_OBMC) { | 1613 | 22.6k | res = obmc(t, dst, f->cur.stride[0], b_dim, 0, bx4, by4, w4, h4); | 1614 | 22.6k | if (res) return res; | 1615 | 22.6k | } | 1616 | 106k | } | 1617 | 111k | if (b->interintra_type) { | 1618 | 3.05k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; | 1619 | 3.05k | enum IntraPredMode m = b->interintra_mode == II_SMOOTH_PRED ? | 1620 | 2.57k | SMOOTH_PRED : b->interintra_mode; | 1621 | 3.05k | pixel *const tmp = bitfn(t->scratch.interintra); | 1622 | 3.05k | int angle = 0; | 1623 | 3.05k | const pixel *top_sb_edge = NULL; | 1624 | 3.05k | if (!(t->by & (f->sb_step - 1))) { | 1625 | 1.58k | top_sb_edge = f->ipred_edge[0]; | 1626 | 1.58k | const int sby = t->by >> f->sb_shift; | 1627 | 1.58k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1628 | 1.58k | } | 1629 | 3.05k | m = bytefn(dav1d_prepare_intra_edges)(t->bx, t->bx > ts->tiling.col_start, | 1630 | 3.05k | t->by, t->by > ts->tiling.row_start, | 1631 | 3.05k | ts->tiling.col_end, ts->tiling.row_end, | 1632 | 3.05k | 0, dst, f->cur.stride[0], top_sb_edge, | 1633 | 3.05k | m, &angle, bw4, bh4, 0, tl_edge | 1634 | 3.05k | HIGHBD_CALL_SUFFIX); | 1635 | 3.05k | dsp->ipred.intra_pred[m](tmp, 4 * bw4 * sizeof(pixel), | 1636 | 3.05k | tl_edge, bw4 * 4, bh4 * 4, 0, 0, 0 | 1637 | 3.05k | HIGHBD_CALL_SUFFIX); | 1638 | 3.05k | dsp->mc.blend(dst, f->cur.stride[0], tmp, | 1639 | 3.05k | bw4 * 4, bh4 * 4, II_MASK(0, bs, b)); | 1640 | 3.05k | } | 1641 | | | 1642 | 111k | if (!has_chroma) goto skip_inter_chroma_pred; | 1643 | | | 1644 | | // sub8x8 derivation | 1645 | 95.0k | int is_sub8x8 = bw4 == ss_hor || bh4 == ss_ver; | 1646 | 95.0k | refmvs_block *const *r; | 1647 | 95.0k | if (is_sub8x8) { | 1648 | 3.17k | assert(ss_hor == 1); | 1649 | 3.17k | r = &t->rt.r[(t->by & 31) + 5]; | 1650 | 3.17k | if (bw4 == 1) is_sub8x8 &= r[0][t->bx - 1].ref.ref[0] > 0; | 1651 | 3.17k | if (bh4 == ss_ver) is_sub8x8 &= r[-1][t->bx].ref.ref[0] > 0; | 1652 | 3.17k | if (bw4 == 1 && bh4 == ss_ver) | 1653 | 1.04k | is_sub8x8 &= r[-1][t->bx - 1].ref.ref[0] > 0; | 1654 | 3.17k | } | 1655 | | | 1656 | | // chroma prediction | 1657 | 95.0k | if (is_sub8x8) { | 1658 | 3.11k | assert(ss_hor == 1); | 1659 | 3.11k | ptrdiff_t h_off = 0, v_off = 0; | 1660 | 3.11k | if (bw4 == 1 && bh4 == ss_ver) { | 1661 | 3.04k | for (int pl = 0; pl < 2; pl++) { | 1662 | 2.02k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1663 | 2.02k | NULL, f->cur.stride[1], | 1664 | 2.02k | bw4, bh4, t->bx - 1, t->by - 1, 1 + pl, | 1665 | 2.02k | r[-1][t->bx - 1].mv.mv[0], | 1666 | 2.02k | &f->refp[r[-1][t->bx - 1].ref.ref[0] - 1], | 1667 | 2.02k | r[-1][t->bx - 1].ref.ref[0] - 1, | 1668 | 2.02k | t->frame_thread.pass != 2 ? t->tl_4x4_filter : | 1669 | 2.02k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx - 1].filter2d); | 1670 | 2.02k | if (res) return res; | 1671 | 2.02k | } | 1672 | 1.01k | v_off = 2 * PXSTRIDE(f->cur.stride[1]); | 1673 | 1.01k | h_off = 2; | 1674 | 1.01k | } | 1675 | 3.11k | if (bw4 == 1) { | 1676 | 2.11k | const enum Filter2d left_filter_2d = | 1677 | 2.11k | dav1d_filter_2d[t->l.filter[1][by4]][t->l.filter[0][by4]]; | 1678 | 6.34k | for (int pl = 0; pl < 2; pl++) { | 1679 | 4.22k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + v_off, NULL, | 1680 | 4.22k | f->cur.stride[1], bw4, bh4, t->bx - 1, | 1681 | 4.22k | t->by, 1 + pl, r[0][t->bx - 1].mv.mv[0], | 1682 | 4.22k | &f->refp[r[0][t->bx - 1].ref.ref[0] - 1], | 1683 | 4.22k | r[0][t->bx - 1].ref.ref[0] - 1, | 1684 | 4.22k | t->frame_thread.pass != 2 ? left_filter_2d : | 1685 | 4.22k | f->frame_thread.b[(t->by * f->b4_stride) + t->bx - 1].filter2d); | 1686 | 4.22k | if (res) return res; | 1687 | 4.22k | } | 1688 | 2.11k | h_off = 2; | 1689 | 2.11k | } | 1690 | 3.11k | if (bh4 == ss_ver) { | 1691 | 2.01k | const enum Filter2d top_filter_2d = | 1692 | 2.01k | dav1d_filter_2d[t->a->filter[1][bx4]][t->a->filter[0][bx4]]; | 1693 | 6.05k | for (int pl = 0; pl < 2; pl++) { | 1694 | 4.03k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off, NULL, | 1695 | 4.03k | f->cur.stride[1], bw4, bh4, t->bx, t->by - 1, | 1696 | 4.03k | 1 + pl, r[-1][t->bx].mv.mv[0], | 1697 | 4.03k | &f->refp[r[-1][t->bx].ref.ref[0] - 1], | 1698 | 4.03k | r[-1][t->bx].ref.ref[0] - 1, | 1699 | 4.03k | t->frame_thread.pass != 2 ? top_filter_2d : | 1700 | 4.03k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx].filter2d); | 1701 | 4.03k | if (res) return res; | 1702 | 4.03k | } | 1703 | 2.01k | v_off = 2 * PXSTRIDE(f->cur.stride[1]); | 1704 | 2.01k | } | 1705 | 9.35k | for (int pl = 0; pl < 2; pl++) { | 1706 | 6.23k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off + v_off, NULL, f->cur.stride[1], | 1707 | 6.23k | bw4, bh4, t->bx, t->by, 1 + pl, b->mv[0], | 1708 | 6.23k | refp, b->ref[0], filter_2d); | 1709 | 6.23k | if (res) return res; | 1710 | 6.23k | } | 1711 | 91.9k | } else { | 1712 | 91.9k | if (imin(cbw4, cbh4) > 1 && | 1713 | 60.8k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || | 1714 | 58.4k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) | 1715 | 4.75k | { | 1716 | 14.2k | for (int pl = 0; pl < 2; pl++) { | 1717 | 9.51k | res = warp_affine(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, NULL, | 1718 | 9.51k | f->cur.stride[1], b_dim, 1 + pl, refp, | 1719 | 9.51k | b->motion_mode == MM_WARP ? &t->warpmv : | 1720 | 9.51k | &f->frame_hdr->gmv[b->ref[0]]); | 1721 | 9.51k | if (res) return res; | 1722 | 9.51k | } | 1723 | 87.1k | } else { | 1724 | 261k | for (int pl = 0; pl < 2; pl++) { | 1725 | 174k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1726 | 174k | NULL, f->cur.stride[1], | 1727 | 174k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), | 1728 | 174k | t->bx & ~ss_hor, t->by & ~ss_ver, | 1729 | 174k | 1 + pl, b->mv[0], refp, b->ref[0], filter_2d); | 1730 | 174k | if (res) return res; | 1731 | 174k | if (b->motion_mode == MM_OBMC) { | 1732 | 42.7k | res = obmc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1733 | 42.7k | f->cur.stride[1], b_dim, 1 + pl, bx4, by4, w4, h4); | 1734 | 42.7k | if (res) return res; | 1735 | 42.7k | } | 1736 | 174k | } | 1737 | 87.1k | } | 1738 | 91.9k | if (b->interintra_type) { | 1739 | | // FIXME for 8x32 with 4:2:2 subsampling, this probably does | 1740 | | // the wrong thing since it will select 4x16, not 4x32, as a | 1741 | | // transform size... | 1742 | 2.38k | const uint8_t *const ii_mask = II_MASK(chr_layout_idx, bs, b); | 1743 | | | 1744 | 7.14k | for (int pl = 0; pl < 2; pl++) { | 1745 | 4.76k | pixel *const tmp = bitfn(t->scratch.interintra); | 1746 | 4.76k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; | 1747 | 4.76k | enum IntraPredMode m = | 1748 | 4.76k | b->interintra_mode == II_SMOOTH_PRED ? | 1749 | 4.05k | SMOOTH_PRED : b->interintra_mode; | 1750 | 4.76k | int angle = 0; | 1751 | 4.76k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; | 1752 | 4.76k | const pixel *top_sb_edge = NULL; | 1753 | 4.76k | if (!(t->by & (f->sb_step - 1))) { | 1754 | 2.44k | top_sb_edge = f->ipred_edge[pl + 1]; | 1755 | 2.44k | const int sby = t->by >> f->sb_shift; | 1756 | 2.44k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1757 | 2.44k | } | 1758 | 4.76k | m = bytefn(dav1d_prepare_intra_edges)(t->bx >> ss_hor, | 1759 | 4.76k | (t->bx >> ss_hor) > | 1760 | 4.76k | (ts->tiling.col_start >> ss_hor), | 1761 | 4.76k | t->by >> ss_ver, | 1762 | 4.76k | (t->by >> ss_ver) > | 1763 | 4.76k | (ts->tiling.row_start >> ss_ver), | 1764 | 4.76k | ts->tiling.col_end >> ss_hor, | 1765 | 4.76k | ts->tiling.row_end >> ss_ver, | 1766 | 4.76k | 0, uvdst, f->cur.stride[1], | 1767 | 4.76k | top_sb_edge, m, | 1768 | 4.76k | &angle, cbw4, cbh4, 0, tl_edge | 1769 | 4.76k | HIGHBD_CALL_SUFFIX); | 1770 | 4.76k | dsp->ipred.intra_pred[m](tmp, cbw4 * 4 * sizeof(pixel), | 1771 | 4.76k | tl_edge, cbw4 * 4, cbh4 * 4, 0, 0, 0 | 1772 | 4.76k | HIGHBD_CALL_SUFFIX); | 1773 | 4.76k | dsp->mc.blend(uvdst, f->cur.stride[1], tmp, | 1774 | 4.76k | cbw4 * 4, cbh4 * 4, ii_mask); | 1775 | 4.76k | } | 1776 | 2.38k | } | 1777 | 91.9k | } | 1778 | | | 1779 | 111k | skip_inter_chroma_pred: {} | 1780 | 111k | t->tl_4x4_filter = filter_2d; | 1781 | 111k | } else { | 1782 | 15.1k | const enum Filter2d filter_2d = b->filter2d; | 1783 | | // Maximum super block size is 128x128 | 1784 | 15.1k | int16_t (*tmp)[128 * 128] = t->scratch.compinter; | 1785 | 15.1k | int jnt_weight; | 1786 | 15.1k | uint8_t *const seg_mask = t->scratch.seg_mask; | 1787 | 15.1k | const uint8_t *mask; | 1788 | | | 1789 | 45.5k | for (int i = 0; i < 2; i++) { | 1790 | 30.3k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; | 1791 | | | 1792 | 30.3k | if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) { | 1793 | 1.16k | res = warp_affine(t, NULL, tmp[i], bw4 * 4, b_dim, 0, refp, | 1794 | 1.16k | &f->frame_hdr->gmv[b->ref[i]]); | 1795 | 1.16k | if (res) return res; | 1796 | 29.1k | } else { | 1797 | 29.1k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, 0, | 1798 | 29.1k | b->mv[i], refp, b->ref[i], filter_2d); | 1799 | 29.1k | if (res) return res; | 1800 | 29.1k | } | 1801 | 30.3k | } | 1802 | 15.1k | switch (b->comp_type) { | 1803 | 11.2k | case COMP_INTER_AVG: | 1804 | 11.2k | dsp->mc.avg(dst, f->cur.stride[0], tmp[0], tmp[1], | 1805 | 11.2k | bw4 * 4, bh4 * 4 HIGHBD_CALL_SUFFIX); | 1806 | 11.2k | break; | 1807 | 1.15k | case COMP_INTER_WEIGHTED_AVG: | 1808 | 1.15k | jnt_weight = f->jnt_weights[b->ref[0]][b->ref[1]]; | 1809 | 1.15k | dsp->mc.w_avg(dst, f->cur.stride[0], tmp[0], tmp[1], | 1810 | 1.15k | bw4 * 4, bh4 * 4, jnt_weight HIGHBD_CALL_SUFFIX); | 1811 | 1.15k | break; | 1812 | 2.10k | case COMP_INTER_SEG: | 1813 | 2.10k | dsp->mc.w_mask[chr_layout_idx](dst, f->cur.stride[0], | 1814 | 2.10k | tmp[b->mask_sign], tmp[!b->mask_sign], | 1815 | 2.10k | bw4 * 4, bh4 * 4, seg_mask, | 1816 | 2.10k | b->mask_sign HIGHBD_CALL_SUFFIX); | 1817 | 2.10k | mask = seg_mask; | 1818 | 2.10k | break; | 1819 | 706 | case COMP_INTER_WEDGE: | 1820 | 706 | mask = WEDGE_MASK(0, bs, 0, b->wedge_idx); | 1821 | 706 | dsp->mc.mask(dst, f->cur.stride[0], | 1822 | 706 | tmp[b->mask_sign], tmp[!b->mask_sign], | 1823 | 706 | bw4 * 4, bh4 * 4, mask HIGHBD_CALL_SUFFIX); | 1824 | 706 | if (has_chroma) | 1825 | 451 | mask = WEDGE_MASK(chr_layout_idx, bs, b->mask_sign, b->wedge_idx); | 1826 | 706 | break; | 1827 | 15.1k | } | 1828 | | | 1829 | | // chroma | 1830 | 29.5k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { | 1831 | 59.1k | for (int i = 0; i < 2; i++) { | 1832 | 39.4k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; | 1833 | 39.4k | if (b->inter_mode == GLOBALMV_GLOBALMV && | 1834 | 6.50k | imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]]) | 1835 | 1.92k | { | 1836 | 1.92k | res = warp_affine(t, NULL, tmp[i], bw4 * 4 >> ss_hor, | 1837 | 1.92k | b_dim, 1 + pl, | 1838 | 1.92k | refp, &f->frame_hdr->gmv[b->ref[i]]); | 1839 | 1.92k | if (res) return res; | 1840 | 37.4k | } else { | 1841 | 37.4k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, | 1842 | 37.4k | 1 + pl, b->mv[i], refp, b->ref[i], filter_2d); | 1843 | 37.4k | if (res) return res; | 1844 | 37.4k | } | 1845 | 39.4k | } | 1846 | 19.7k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; | 1847 | 19.7k | switch (b->comp_type) { | 1848 | 14.9k | case COMP_INTER_AVG: | 1849 | 14.9k | dsp->mc.avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], | 1850 | 14.9k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver | 1851 | 14.9k | HIGHBD_CALL_SUFFIX); | 1852 | 14.9k | break; | 1853 | 1.39k | case COMP_INTER_WEIGHTED_AVG: | 1854 | 1.39k | dsp->mc.w_avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], | 1855 | 1.39k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, jnt_weight | 1856 | 1.39k | HIGHBD_CALL_SUFFIX); | 1857 | 1.39k | break; | 1858 | 902 | case COMP_INTER_WEDGE: | 1859 | 3.37k | case COMP_INTER_SEG: | 1860 | 3.37k | dsp->mc.mask(uvdst, f->cur.stride[1], | 1861 | 3.37k | tmp[b->mask_sign], tmp[!b->mask_sign], | 1862 | 3.37k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, mask | 1863 | 3.37k | HIGHBD_CALL_SUFFIX); | 1864 | 3.37k | break; | 1865 | 19.7k | } | 1866 | 19.7k | } | 1867 | 15.1k | } | 1868 | | | 1869 | 186k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1870 | 0 | hex_dump(dst, f->cur.stride[0], b_dim[0] * 4, b_dim[1] * 4, "y-pred"); | 1871 | 0 | if (has_chroma) { | 1872 | 0 | hex_dump(&((pixel *) f->cur.data[1])[uvdstoff], f->cur.stride[1], | 1873 | 0 | cbw4 * 4, cbh4 * 4, "u-pred"); | 1874 | 0 | hex_dump(&((pixel *) f->cur.data[2])[uvdstoff], f->cur.stride[1], | 1875 | 0 | cbw4 * 4, cbh4 * 4, "v-pred"); | 1876 | 0 | } | 1877 | 0 | } | 1878 | | | 1879 | 186k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 1880 | | | 1881 | 186k | if (b->skip) { | 1882 | | // reset coef contexts | 1883 | 107k | BlockContext *const a = t->a; | 1884 | 107k | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); | 1885 | 107k | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); | 1886 | 107k | if (has_chroma) { | 1887 | 93.7k | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; | 1888 | 93.7k | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; | 1889 | 93.7k | memset_cw(&a->ccoef[0][cbx4], 0x40); | 1890 | 93.7k | memset_cw(&a->ccoef[1][cbx4], 0x40); | 1891 | 93.7k | memset_ch(&t->l.ccoef[0][cby4], 0x40); | 1892 | 93.7k | memset_ch(&t->l.ccoef[1][cby4], 0x40); | 1893 | 93.7k | } | 1894 | 107k | return 0; | 1895 | 107k | } | 1896 | | | 1897 | 78.8k | const TxfmInfo *const uvtx = &dav1d_txfm_dimensions[b->uvtx]; | 1898 | 78.8k | const TxfmInfo *const ytx = &dav1d_txfm_dimensions[b->max_ytx]; | 1899 | 78.8k | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; | 1900 | | | 1901 | 163k | for (int init_y = 0; init_y < bh4; init_y += 16) { | 1902 | 169k | for (int init_x = 0; init_x < bw4; init_x += 16) { | 1903 | | // coefficient coding & inverse transforms | 1904 | 85.5k | int y_off = !!init_y, y; | 1905 | 85.5k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * init_y; | 1906 | 188k | for (y = init_y, t->by += init_y; y < imin(h4, init_y + 16); | 1907 | 103k | y += ytx->h, y_off++) | 1908 | 103k | { | 1909 | 103k | int x, x_off = !!init_x; | 1910 | 279k | for (x = init_x, t->bx += init_x; x < imin(w4, init_x + 16); | 1911 | 175k | x += ytx->w, x_off++) | 1912 | 175k | { | 1913 | 175k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, | 1914 | 175k | x_off, y_off, &dst[x * 4]); | 1915 | 175k | t->bx += ytx->w; | 1916 | 175k | } | 1917 | 103k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * ytx->h; | 1918 | 103k | t->bx -= x; | 1919 | 103k | t->by += ytx->h; | 1920 | 103k | } | 1921 | 85.5k | dst -= PXSTRIDE(f->cur.stride[0]) * 4 * y; | 1922 | 85.5k | t->by -= y; | 1923 | | | 1924 | | // chroma coefs and inverse transform | 1925 | 202k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { | 1926 | 134k | pixel *uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff + | 1927 | 134k | (PXSTRIDE(f->cur.stride[1]) * init_y * 4 >> ss_ver); | 1928 | 134k | for (y = init_y >> ss_ver, t->by += init_y; | 1929 | 311k | y < imin(ch4, (init_y + 16) >> ss_ver); y += uvtx->h) | 1930 | 176k | { | 1931 | 176k | int x; | 1932 | 176k | for (x = init_x >> ss_hor, t->bx += init_x; | 1933 | 498k | x < imin(cw4, (init_x + 16) >> ss_hor); x += uvtx->w) | 1934 | 321k | { | 1935 | 321k | coef *cf; | 1936 | 321k | int eob; | 1937 | 321k | enum TxfmType txtp; | 1938 | 321k | if (t->frame_thread.pass) { | 1939 | 321k | const int p = t->frame_thread.pass & 1; | 1940 | 321k | const int cbi = *ts->frame_thread[p].cbi++; | 1941 | 321k | cf = ts->frame_thread[p].cf; | 1942 | 321k | ts->frame_thread[p].cf += uvtx->w * uvtx->h * 16; | 1943 | 321k | eob = cbi >> 5; | 1944 | 321k | txtp = cbi & 0x1f; | 1945 | 321k | } else { | 1946 | 0 | uint8_t cf_ctx; | 1947 | 0 | cf = bitfn(t->cf); | 1948 | 0 | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + | 1949 | 0 | bx4 + (x << ss_hor)]; | 1950 | 0 | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 1951 | 0 | &t->l.ccoef[pl][cby4 + y], | 1952 | 0 | b->uvtx, bs, b, 0, 1 + pl, | 1953 | 0 | cf, &txtp, &cf_ctx); | 1954 | 0 | if (DEBUG_BLOCK_INFO) | 1955 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 1956 | 0 | "txtp=%d,eob=%d]: r=%d\n", | 1957 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); | 1958 | 0 | int ctw = imin(uvtx->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 1959 | 0 | int cth = imin(uvtx->h, (f->bh - t->by + ss_ver) >> ss_ver); | 1960 | 0 | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 1961 | 0 | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 1962 | 0 | } | 1963 | 321k | if (eob >= 0) { | 1964 | 132k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1965 | 0 | coef_dump(cf, uvtx->h * 4, uvtx->w * 4, 3, "dq"); | 1966 | 132k | dsp->itx.itxfm_add[b->uvtx] | 1967 | 132k | [txtp](&uvdst[4 * x], | 1968 | 132k | f->cur.stride[1], | 1969 | 132k | cf, eob HIGHBD_CALL_SUFFIX); | 1970 | 132k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1971 | 0 | hex_dump(&uvdst[4 * x], f->cur.stride[1], | 1972 | 0 | uvtx->w * 4, uvtx->h * 4, "recon"); | 1973 | 132k | } | 1974 | 321k | t->bx += uvtx->w << ss_hor; | 1975 | 321k | } | 1976 | 176k | uvdst += PXSTRIDE(f->cur.stride[1]) * 4 * uvtx->h; | 1977 | 176k | t->bx -= x << ss_hor; | 1978 | 176k | t->by += uvtx->h << ss_ver; | 1979 | 176k | } | 1980 | 134k | t->by -= y << ss_ver; | 1981 | 134k | } | 1982 | 85.5k | } | 1983 | 84.2k | } | 1984 | 78.8k | return 0; | 1985 | 186k | } |
dav1d_recon_b_inter_16bpc Line | Count | Source | 1559 | 105k | { | 1560 | 105k | Dav1dTileState *const ts = t->ts; | 1561 | 105k | const Dav1dFrameContext *const f = t->f; | 1562 | 105k | const Dav1dDSPContext *const dsp = f->dsp; | 1563 | 105k | const int bx4 = t->bx & 31, by4 = t->by & 31; | 1564 | 105k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1565 | 105k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 1566 | 105k | const int cbx4 = bx4 >> ss_hor, cby4 = by4 >> ss_ver; | 1567 | 105k | const uint8_t *const b_dim = dav1d_block_dimensions[bs]; | 1568 | 105k | const int bw4 = b_dim[0], bh4 = b_dim[1]; | 1569 | 105k | const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by); | 1570 | 105k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 && | 1571 | 92.1k | (bw4 > ss_hor || t->bx & 1) && | 1572 | 88.0k | (bh4 > ss_ver || t->by & 1); | 1573 | 105k | const int chr_layout_idx = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I400 ? 0 : | 1574 | 105k | DAV1D_PIXEL_LAYOUT_I444 - f->cur.p.layout; | 1575 | 105k | int res; | 1576 | | | 1577 | | // prediction | 1578 | 105k | const int cbh4 = (bh4 + ss_ver) >> ss_ver, cbw4 = (bw4 + ss_hor) >> ss_hor; | 1579 | 105k | pixel *dst = ((pixel *) f->cur.data[0]) + | 1580 | 105k | 4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx); | 1581 | 105k | const ptrdiff_t uvdstoff = | 1582 | 105k | 4 * ((t->bx >> ss_hor) + (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1])); | 1583 | 105k | if (IS_KEY_OR_INTRA(f->frame_hdr)) { | 1584 | | // intrabc | 1585 | 37.4k | assert(!f->frame_hdr->super_res.enabled); | 1586 | 37.4k | res = mc(t, dst, NULL, f->cur.stride[0], bw4, bh4, t->bx, t->by, 0, | 1587 | 37.4k | b->mv[0], &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); | 1588 | 37.4k | if (res) return res; | 1589 | 100k | if (has_chroma) for (int pl = 1; pl < 3; pl++) { | 1590 | 67.0k | res = mc(t, ((pixel *)f->cur.data[pl]) + uvdstoff, NULL, f->cur.stride[1], | 1591 | 67.0k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), | 1592 | 67.0k | t->bx & ~ss_hor, t->by & ~ss_ver, pl, b->mv[0], | 1593 | 67.0k | &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR); | 1594 | 67.0k | if (res) return res; | 1595 | 67.0k | } | 1596 | 68.0k | } else if (b->comp_type == COMP_INTER_NONE) { | 1597 | 56.0k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[0]]; | 1598 | 56.0k | const enum Filter2d filter_2d = b->filter2d; | 1599 | | | 1600 | 56.0k | if (imin(bw4, bh4) > 1 && | 1601 | 32.6k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || | 1602 | 31.0k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) | 1603 | 2.05k | { | 1604 | 2.05k | res = warp_affine(t, dst, NULL, f->cur.stride[0], b_dim, 0, refp, | 1605 | 2.05k | b->motion_mode == MM_WARP ? &t->warpmv : | 1606 | 2.05k | &f->frame_hdr->gmv[b->ref[0]]); | 1607 | 2.05k | if (res) return res; | 1608 | 53.9k | } else { | 1609 | 53.9k | res = mc(t, dst, NULL, f->cur.stride[0], | 1610 | 53.9k | bw4, bh4, t->bx, t->by, 0, b->mv[0], refp, b->ref[0], filter_2d); | 1611 | 53.9k | if (res) return res; | 1612 | 53.9k | if (b->motion_mode == MM_OBMC) { | 1613 | 7.79k | res = obmc(t, dst, f->cur.stride[0], b_dim, 0, bx4, by4, w4, h4); | 1614 | 7.79k | if (res) return res; | 1615 | 7.79k | } | 1616 | 53.9k | } | 1617 | 56.0k | if (b->interintra_type) { | 1618 | 2.14k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; | 1619 | 2.14k | enum IntraPredMode m = b->interintra_mode == II_SMOOTH_PRED ? | 1620 | 1.71k | SMOOTH_PRED : b->interintra_mode; | 1621 | 2.14k | pixel *const tmp = bitfn(t->scratch.interintra); | 1622 | 2.14k | int angle = 0; | 1623 | 2.14k | const pixel *top_sb_edge = NULL; | 1624 | 2.14k | if (!(t->by & (f->sb_step - 1))) { | 1625 | 1.19k | top_sb_edge = f->ipred_edge[0]; | 1626 | 1.19k | const int sby = t->by >> f->sb_shift; | 1627 | 1.19k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1628 | 1.19k | } | 1629 | 2.14k | m = bytefn(dav1d_prepare_intra_edges)(t->bx, t->bx > ts->tiling.col_start, | 1630 | 2.14k | t->by, t->by > ts->tiling.row_start, | 1631 | 2.14k | ts->tiling.col_end, ts->tiling.row_end, | 1632 | 2.14k | 0, dst, f->cur.stride[0], top_sb_edge, | 1633 | 2.14k | m, &angle, bw4, bh4, 0, tl_edge | 1634 | 2.14k | HIGHBD_CALL_SUFFIX); | 1635 | 2.14k | dsp->ipred.intra_pred[m](tmp, 4 * bw4 * sizeof(pixel), | 1636 | 2.14k | tl_edge, bw4 * 4, bh4 * 4, 0, 0, 0 | 1637 | 2.14k | HIGHBD_CALL_SUFFIX); | 1638 | 2.14k | dsp->mc.blend(dst, f->cur.stride[0], tmp, | 1639 | 2.14k | bw4 * 4, bh4 * 4, II_MASK(0, bs, b)); | 1640 | 2.14k | } | 1641 | | | 1642 | 56.0k | if (!has_chroma) goto skip_inter_chroma_pred; | 1643 | | | 1644 | | // sub8x8 derivation | 1645 | 41.3k | int is_sub8x8 = bw4 == ss_hor || bh4 == ss_ver; | 1646 | 41.3k | refmvs_block *const *r; | 1647 | 41.3k | if (is_sub8x8) { | 1648 | 2.92k | assert(ss_hor == 1); | 1649 | 2.92k | r = &t->rt.r[(t->by & 31) + 5]; | 1650 | 2.92k | if (bw4 == 1) is_sub8x8 &= r[0][t->bx - 1].ref.ref[0] > 0; | 1651 | 2.92k | if (bh4 == ss_ver) is_sub8x8 &= r[-1][t->bx].ref.ref[0] > 0; | 1652 | 2.92k | if (bw4 == 1 && bh4 == ss_ver) | 1653 | 749 | is_sub8x8 &= r[-1][t->bx - 1].ref.ref[0] > 0; | 1654 | 2.92k | } | 1655 | | | 1656 | | // chroma prediction | 1657 | 41.3k | if (is_sub8x8) { | 1658 | 2.90k | assert(ss_hor == 1); | 1659 | 2.90k | ptrdiff_t h_off = 0, v_off = 0; | 1660 | 2.90k | if (bw4 == 1 && bh4 == ss_ver) { | 1661 | 2.23k | for (int pl = 0; pl < 2; pl++) { | 1662 | 1.49k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1663 | 1.49k | NULL, f->cur.stride[1], | 1664 | 1.49k | bw4, bh4, t->bx - 1, t->by - 1, 1 + pl, | 1665 | 1.49k | r[-1][t->bx - 1].mv.mv[0], | 1666 | 1.49k | &f->refp[r[-1][t->bx - 1].ref.ref[0] - 1], | 1667 | 1.49k | r[-1][t->bx - 1].ref.ref[0] - 1, | 1668 | 1.49k | t->frame_thread.pass != 2 ? t->tl_4x4_filter : | 1669 | 1.49k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx - 1].filter2d); | 1670 | 1.49k | if (res) return res; | 1671 | 1.49k | } | 1672 | 745 | v_off = 2 * PXSTRIDE(f->cur.stride[1]); | 1673 | 745 | h_off = 2; | 1674 | 745 | } | 1675 | 2.90k | if (bw4 == 1) { | 1676 | 1.59k | const enum Filter2d left_filter_2d = | 1677 | 1.59k | dav1d_filter_2d[t->l.filter[1][by4]][t->l.filter[0][by4]]; | 1678 | 4.78k | for (int pl = 0; pl < 2; pl++) { | 1679 | 3.19k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + v_off, NULL, | 1680 | 3.19k | f->cur.stride[1], bw4, bh4, t->bx - 1, | 1681 | 3.19k | t->by, 1 + pl, r[0][t->bx - 1].mv.mv[0], | 1682 | 3.19k | &f->refp[r[0][t->bx - 1].ref.ref[0] - 1], | 1683 | 3.19k | r[0][t->bx - 1].ref.ref[0] - 1, | 1684 | 3.19k | t->frame_thread.pass != 2 ? left_filter_2d : | 1685 | 3.19k | f->frame_thread.b[(t->by * f->b4_stride) + t->bx - 1].filter2d); | 1686 | 3.19k | if (res) return res; | 1687 | 3.19k | } | 1688 | 1.59k | h_off = 2; | 1689 | 1.59k | } | 1690 | 2.90k | if (bh4 == ss_ver) { | 1691 | 2.05k | const enum Filter2d top_filter_2d = | 1692 | 2.05k | dav1d_filter_2d[t->a->filter[1][bx4]][t->a->filter[0][bx4]]; | 1693 | 6.15k | for (int pl = 0; pl < 2; pl++) { | 1694 | 4.10k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off, NULL, | 1695 | 4.10k | f->cur.stride[1], bw4, bh4, t->bx, t->by - 1, | 1696 | 4.10k | 1 + pl, r[-1][t->bx].mv.mv[0], | 1697 | 4.10k | &f->refp[r[-1][t->bx].ref.ref[0] - 1], | 1698 | 4.10k | r[-1][t->bx].ref.ref[0] - 1, | 1699 | 4.10k | t->frame_thread.pass != 2 ? top_filter_2d : | 1700 | 4.10k | f->frame_thread.b[((t->by - 1) * f->b4_stride) + t->bx].filter2d); | 1701 | 4.10k | if (res) return res; | 1702 | 4.10k | } | 1703 | 2.05k | v_off = 2 * PXSTRIDE(f->cur.stride[1]); | 1704 | 2.05k | } | 1705 | 8.70k | for (int pl = 0; pl < 2; pl++) { | 1706 | 5.80k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff + h_off + v_off, NULL, f->cur.stride[1], | 1707 | 5.80k | bw4, bh4, t->bx, t->by, 1 + pl, b->mv[0], | 1708 | 5.80k | refp, b->ref[0], filter_2d); | 1709 | 5.80k | if (res) return res; | 1710 | 5.80k | } | 1711 | 38.4k | } else { | 1712 | 38.4k | if (imin(cbw4, cbh4) > 1 && | 1713 | 19.6k | ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) || | 1714 | 18.1k | (b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION))) | 1715 | 1.82k | { | 1716 | 5.47k | for (int pl = 0; pl < 2; pl++) { | 1717 | 3.64k | res = warp_affine(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, NULL, | 1718 | 3.64k | f->cur.stride[1], b_dim, 1 + pl, refp, | 1719 | 3.64k | b->motion_mode == MM_WARP ? &t->warpmv : | 1720 | 3.64k | &f->frame_hdr->gmv[b->ref[0]]); | 1721 | 3.64k | if (res) return res; | 1722 | 3.64k | } | 1723 | 36.6k | } else { | 1724 | 109k | for (int pl = 0; pl < 2; pl++) { | 1725 | 73.3k | res = mc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1726 | 73.3k | NULL, f->cur.stride[1], | 1727 | 73.3k | bw4 << (bw4 == ss_hor), bh4 << (bh4 == ss_ver), | 1728 | 73.3k | t->bx & ~ss_hor, t->by & ~ss_ver, | 1729 | 73.3k | 1 + pl, b->mv[0], refp, b->ref[0], filter_2d); | 1730 | 73.3k | if (res) return res; | 1731 | 73.3k | if (b->motion_mode == MM_OBMC) { | 1732 | 12.7k | res = obmc(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, | 1733 | 12.7k | f->cur.stride[1], b_dim, 1 + pl, bx4, by4, w4, h4); | 1734 | 12.7k | if (res) return res; | 1735 | 12.7k | } | 1736 | 73.3k | } | 1737 | 36.6k | } | 1738 | 38.4k | if (b->interintra_type) { | 1739 | | // FIXME for 8x32 with 4:2:2 subsampling, this probably does | 1740 | | // the wrong thing since it will select 4x16, not 4x32, as a | 1741 | | // transform size... | 1742 | 1.59k | const uint8_t *const ii_mask = II_MASK(chr_layout_idx, bs, b); | 1743 | | | 1744 | 4.77k | for (int pl = 0; pl < 2; pl++) { | 1745 | 3.18k | pixel *const tmp = bitfn(t->scratch.interintra); | 1746 | 3.18k | pixel *const tl_edge = bitfn(t->scratch.edge) + 32; | 1747 | 3.18k | enum IntraPredMode m = | 1748 | 3.18k | b->interintra_mode == II_SMOOTH_PRED ? | 1749 | 2.63k | SMOOTH_PRED : b->interintra_mode; | 1750 | 3.18k | int angle = 0; | 1751 | 3.18k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; | 1752 | 3.18k | const pixel *top_sb_edge = NULL; | 1753 | 3.18k | if (!(t->by & (f->sb_step - 1))) { | 1754 | 1.77k | top_sb_edge = f->ipred_edge[pl + 1]; | 1755 | 1.77k | const int sby = t->by >> f->sb_shift; | 1756 | 1.77k | top_sb_edge += f->sb128w * 128 * (sby - 1); | 1757 | 1.77k | } | 1758 | 3.18k | m = bytefn(dav1d_prepare_intra_edges)(t->bx >> ss_hor, | 1759 | 3.18k | (t->bx >> ss_hor) > | 1760 | 3.18k | (ts->tiling.col_start >> ss_hor), | 1761 | 3.18k | t->by >> ss_ver, | 1762 | 3.18k | (t->by >> ss_ver) > | 1763 | 3.18k | (ts->tiling.row_start >> ss_ver), | 1764 | 3.18k | ts->tiling.col_end >> ss_hor, | 1765 | 3.18k | ts->tiling.row_end >> ss_ver, | 1766 | 3.18k | 0, uvdst, f->cur.stride[1], | 1767 | 3.18k | top_sb_edge, m, | 1768 | 3.18k | &angle, cbw4, cbh4, 0, tl_edge | 1769 | 3.18k | HIGHBD_CALL_SUFFIX); | 1770 | 3.18k | dsp->ipred.intra_pred[m](tmp, cbw4 * 4 * sizeof(pixel), | 1771 | 3.18k | tl_edge, cbw4 * 4, cbh4 * 4, 0, 0, 0 | 1772 | 3.18k | HIGHBD_CALL_SUFFIX); | 1773 | 3.18k | dsp->mc.blend(uvdst, f->cur.stride[1], tmp, | 1774 | 3.18k | cbw4 * 4, cbh4 * 4, ii_mask); | 1775 | 3.18k | } | 1776 | 1.59k | } | 1777 | 38.4k | } | 1778 | | | 1779 | 56.0k | skip_inter_chroma_pred: {} | 1780 | 56.0k | t->tl_4x4_filter = filter_2d; | 1781 | 56.0k | } else { | 1782 | 12.0k | const enum Filter2d filter_2d = b->filter2d; | 1783 | | // Maximum super block size is 128x128 | 1784 | 12.0k | int16_t (*tmp)[128 * 128] = t->scratch.compinter; | 1785 | 12.0k | int jnt_weight; | 1786 | 12.0k | uint8_t *const seg_mask = t->scratch.seg_mask; | 1787 | 12.0k | const uint8_t *mask; | 1788 | | | 1789 | 36.1k | for (int i = 0; i < 2; i++) { | 1790 | 24.0k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; | 1791 | | | 1792 | 24.0k | if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) { | 1793 | 1.30k | res = warp_affine(t, NULL, tmp[i], bw4 * 4, b_dim, 0, refp, | 1794 | 1.30k | &f->frame_hdr->gmv[b->ref[i]]); | 1795 | 1.30k | if (res) return res; | 1796 | 22.7k | } else { | 1797 | 22.7k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, 0, | 1798 | 22.7k | b->mv[i], refp, b->ref[i], filter_2d); | 1799 | 22.7k | if (res) return res; | 1800 | 22.7k | } | 1801 | 24.0k | } | 1802 | 12.0k | switch (b->comp_type) { | 1803 | 8.82k | case COMP_INTER_AVG: | 1804 | 8.82k | dsp->mc.avg(dst, f->cur.stride[0], tmp[0], tmp[1], | 1805 | 8.82k | bw4 * 4, bh4 * 4 HIGHBD_CALL_SUFFIX); | 1806 | 8.82k | break; | 1807 | 1.30k | case COMP_INTER_WEIGHTED_AVG: | 1808 | 1.30k | jnt_weight = f->jnt_weights[b->ref[0]][b->ref[1]]; | 1809 | 1.30k | dsp->mc.w_avg(dst, f->cur.stride[0], tmp[0], tmp[1], | 1810 | 1.30k | bw4 * 4, bh4 * 4, jnt_weight HIGHBD_CALL_SUFFIX); | 1811 | 1.30k | break; | 1812 | 1.21k | case COMP_INTER_SEG: | 1813 | 1.21k | dsp->mc.w_mask[chr_layout_idx](dst, f->cur.stride[0], | 1814 | 1.21k | tmp[b->mask_sign], tmp[!b->mask_sign], | 1815 | 1.21k | bw4 * 4, bh4 * 4, seg_mask, | 1816 | 1.21k | b->mask_sign HIGHBD_CALL_SUFFIX); | 1817 | 1.21k | mask = seg_mask; | 1818 | 1.21k | break; | 1819 | 687 | case COMP_INTER_WEDGE: | 1820 | 687 | mask = WEDGE_MASK(0, bs, 0, b->wedge_idx); | 1821 | 687 | dsp->mc.mask(dst, f->cur.stride[0], | 1822 | 687 | tmp[b->mask_sign], tmp[!b->mask_sign], | 1823 | 687 | bw4 * 4, bh4 * 4, mask HIGHBD_CALL_SUFFIX); | 1824 | 687 | if (has_chroma) | 1825 | 504 | mask = WEDGE_MASK(chr_layout_idx, bs, b->mask_sign, b->wedge_idx); | 1826 | 687 | break; | 1827 | 12.0k | } | 1828 | | | 1829 | | // chroma | 1830 | 28.0k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { | 1831 | 56.1k | for (int i = 0; i < 2; i++) { | 1832 | 37.4k | const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]]; | 1833 | 37.4k | if (b->inter_mode == GLOBALMV_GLOBALMV && | 1834 | 6.61k | imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]]) | 1835 | 2.34k | { | 1836 | 2.34k | res = warp_affine(t, NULL, tmp[i], bw4 * 4 >> ss_hor, | 1837 | 2.34k | b_dim, 1 + pl, | 1838 | 2.34k | refp, &f->frame_hdr->gmv[b->ref[i]]); | 1839 | 2.34k | if (res) return res; | 1840 | 35.0k | } else { | 1841 | 35.0k | res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, | 1842 | 35.0k | 1 + pl, b->mv[i], refp, b->ref[i], filter_2d); | 1843 | 35.0k | if (res) return res; | 1844 | 35.0k | } | 1845 | 37.4k | } | 1846 | 18.7k | pixel *const uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff; | 1847 | 18.7k | switch (b->comp_type) { | 1848 | 14.2k | case COMP_INTER_AVG: | 1849 | 14.2k | dsp->mc.avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], | 1850 | 14.2k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver | 1851 | 14.2k | HIGHBD_CALL_SUFFIX); | 1852 | 14.2k | break; | 1853 | 1.75k | case COMP_INTER_WEIGHTED_AVG: | 1854 | 1.75k | dsp->mc.w_avg(uvdst, f->cur.stride[1], tmp[0], tmp[1], | 1855 | 1.75k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, jnt_weight | 1856 | 1.75k | HIGHBD_CALL_SUFFIX); | 1857 | 1.75k | break; | 1858 | 1.00k | case COMP_INTER_WEDGE: | 1859 | 2.71k | case COMP_INTER_SEG: | 1860 | 2.71k | dsp->mc.mask(uvdst, f->cur.stride[1], | 1861 | 2.71k | tmp[b->mask_sign], tmp[!b->mask_sign], | 1862 | 2.71k | bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, mask | 1863 | 2.71k | HIGHBD_CALL_SUFFIX); | 1864 | 2.71k | break; | 1865 | 18.7k | } | 1866 | 18.7k | } | 1867 | 12.0k | } | 1868 | | | 1869 | 105k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) { | 1870 | 0 | hex_dump(dst, f->cur.stride[0], b_dim[0] * 4, b_dim[1] * 4, "y-pred"); | 1871 | 0 | if (has_chroma) { | 1872 | 0 | hex_dump(&((pixel *) f->cur.data[1])[uvdstoff], f->cur.stride[1], | 1873 | 0 | cbw4 * 4, cbh4 * 4, "u-pred"); | 1874 | 0 | hex_dump(&((pixel *) f->cur.data[2])[uvdstoff], f->cur.stride[1], | 1875 | 0 | cbw4 * 4, cbh4 * 4, "v-pred"); | 1876 | 0 | } | 1877 | 0 | } | 1878 | | | 1879 | 105k | const int cw4 = (w4 + ss_hor) >> ss_hor, ch4 = (h4 + ss_ver) >> ss_ver; | 1880 | | | 1881 | 105k | if (b->skip) { | 1882 | | // reset coef contexts | 1883 | 45.3k | BlockContext *const a = t->a; | 1884 | 45.3k | dav1d_memset_pow2[b_dim[2]](&a->lcoef[bx4], 0x40); | 1885 | 45.3k | dav1d_memset_pow2[b_dim[3]](&t->l.lcoef[by4], 0x40); | 1886 | 45.3k | if (has_chroma) { | 1887 | 36.1k | dav1d_memset_pow2_fn memset_cw = dav1d_memset_pow2[ulog2(cbw4)]; | 1888 | 36.1k | dav1d_memset_pow2_fn memset_ch = dav1d_memset_pow2[ulog2(cbh4)]; | 1889 | 36.1k | memset_cw(&a->ccoef[0][cbx4], 0x40); | 1890 | 36.1k | memset_cw(&a->ccoef[1][cbx4], 0x40); | 1891 | 36.1k | memset_ch(&t->l.ccoef[0][cby4], 0x40); | 1892 | 36.1k | memset_ch(&t->l.ccoef[1][cby4], 0x40); | 1893 | 36.1k | } | 1894 | 45.3k | return 0; | 1895 | 45.3k | } | 1896 | | | 1897 | 60.2k | const TxfmInfo *const uvtx = &dav1d_txfm_dimensions[b->uvtx]; | 1898 | 60.2k | const TxfmInfo *const ytx = &dav1d_txfm_dimensions[b->max_ytx]; | 1899 | 60.2k | const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 }; | 1900 | | | 1901 | 125k | for (int init_y = 0; init_y < bh4; init_y += 16) { | 1902 | 130k | for (int init_x = 0; init_x < bw4; init_x += 16) { | 1903 | | // coefficient coding & inverse transforms | 1904 | 65.6k | int y_off = !!init_y, y; | 1905 | 65.6k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * init_y; | 1906 | 134k | for (y = init_y, t->by += init_y; y < imin(h4, init_y + 16); | 1907 | 68.3k | y += ytx->h, y_off++) | 1908 | 68.3k | { | 1909 | 68.3k | int x, x_off = !!init_x; | 1910 | 142k | for (x = init_x, t->bx += init_x; x < imin(w4, init_x + 16); | 1911 | 74.4k | x += ytx->w, x_off++) | 1912 | 74.4k | { | 1913 | 74.4k | read_coef_tree(t, bs, b, b->max_ytx, 0, tx_split, | 1914 | 74.4k | x_off, y_off, &dst[x * 4]); | 1915 | 74.4k | t->bx += ytx->w; | 1916 | 74.4k | } | 1917 | 68.3k | dst += PXSTRIDE(f->cur.stride[0]) * 4 * ytx->h; | 1918 | 68.3k | t->bx -= x; | 1919 | 68.3k | t->by += ytx->h; | 1920 | 68.3k | } | 1921 | 65.6k | dst -= PXSTRIDE(f->cur.stride[0]) * 4 * y; | 1922 | 65.6k | t->by -= y; | 1923 | | | 1924 | | // chroma coefs and inverse transform | 1925 | 156k | if (has_chroma) for (int pl = 0; pl < 2; pl++) { | 1926 | 104k | pixel *uvdst = ((pixel *) f->cur.data[1 + pl]) + uvdstoff + | 1927 | 104k | (PXSTRIDE(f->cur.stride[1]) * init_y * 4 >> ss_ver); | 1928 | 104k | for (y = init_y >> ss_ver, t->by += init_y; | 1929 | 219k | y < imin(ch4, (init_y + 16) >> ss_ver); y += uvtx->h) | 1930 | 115k | { | 1931 | 115k | int x; | 1932 | 115k | for (x = init_x >> ss_hor, t->bx += init_x; | 1933 | 240k | x < imin(cw4, (init_x + 16) >> ss_hor); x += uvtx->w) | 1934 | 125k | { | 1935 | 125k | coef *cf; | 1936 | 125k | int eob; | 1937 | 125k | enum TxfmType txtp; | 1938 | 125k | if (t->frame_thread.pass) { | 1939 | 125k | const int p = t->frame_thread.pass & 1; | 1940 | 125k | const int cbi = *ts->frame_thread[p].cbi++; | 1941 | 125k | cf = ts->frame_thread[p].cf; | 1942 | 125k | ts->frame_thread[p].cf += uvtx->w * uvtx->h * 16; | 1943 | 125k | eob = cbi >> 5; | 1944 | 125k | txtp = cbi & 0x1f; | 1945 | 125k | } else { | 1946 | 0 | uint8_t cf_ctx; | 1947 | 0 | cf = bitfn(t->cf); | 1948 | 0 | txtp = t->scratch.txtp_map[(by4 + (y << ss_ver)) * 32 + | 1949 | 0 | bx4 + (x << ss_hor)]; | 1950 | 0 | eob = decode_coefs(t, &t->a->ccoef[pl][cbx4 + x], | 1951 | 0 | &t->l.ccoef[pl][cby4 + y], | 1952 | 0 | b->uvtx, bs, b, 0, 1 + pl, | 1953 | 0 | cf, &txtp, &cf_ctx); | 1954 | 0 | if (DEBUG_BLOCK_INFO) | 1955 | 0 | printf("Post-uv-cf-blk[pl=%d,tx=%d," | 1956 | 0 | "txtp=%d,eob=%d]: r=%d\n", | 1957 | 0 | pl, b->uvtx, txtp, eob, ts->msac.rng); | 1958 | 0 | int ctw = imin(uvtx->w, (f->bw - t->bx + ss_hor) >> ss_hor); | 1959 | 0 | int cth = imin(uvtx->h, (f->bh - t->by + ss_ver) >> ss_ver); | 1960 | 0 | dav1d_memset_likely_pow2(&t->a->ccoef[pl][cbx4 + x], cf_ctx, ctw); | 1961 | 0 | dav1d_memset_likely_pow2(&t->l.ccoef[pl][cby4 + y], cf_ctx, cth); | 1962 | 0 | } | 1963 | 125k | if (eob >= 0) { | 1964 | 30.6k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1965 | 0 | coef_dump(cf, uvtx->h * 4, uvtx->w * 4, 3, "dq"); | 1966 | 30.6k | dsp->itx.itxfm_add[b->uvtx] | 1967 | 30.6k | [txtp](&uvdst[4 * x], | 1968 | 30.6k | f->cur.stride[1], | 1969 | 30.6k | cf, eob HIGHBD_CALL_SUFFIX); | 1970 | 30.6k | if (DEBUG_BLOCK_INFO && DEBUG_B_PIXELS) | 1971 | 0 | hex_dump(&uvdst[4 * x], f->cur.stride[1], | 1972 | 0 | uvtx->w * 4, uvtx->h * 4, "recon"); | 1973 | 30.6k | } | 1974 | 125k | t->bx += uvtx->w << ss_hor; | 1975 | 125k | } | 1976 | 115k | uvdst += PXSTRIDE(f->cur.stride[1]) * 4 * uvtx->h; | 1977 | 115k | t->bx -= x << ss_hor; | 1978 | 115k | t->by += uvtx->h << ss_ver; | 1979 | 115k | } | 1980 | 104k | t->by -= y << ss_ver; | 1981 | 104k | } | 1982 | 65.6k | } | 1983 | 64.9k | } | 1984 | 60.2k | return 0; | 1985 | 105k | } |
|
1986 | | |
1987 | 162k | void bytefn(dav1d_filter_sbrow_deblock_cols)(Dav1dFrameContext *const f, const int sby) { |
1988 | 162k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK) || |
1989 | 162k | (!f->frame_hdr->loopfilter.level_y[0] && !f->frame_hdr->loopfilter.level_y[1])) |
1990 | 0 | { |
1991 | 0 | return; |
1992 | 0 | } |
1993 | 162k | const int y = sby * f->sb_step * 4; |
1994 | 162k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
1995 | 162k | pixel *const p[3] = { |
1996 | 162k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), |
1997 | 162k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
1998 | 162k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) |
1999 | 162k | }; |
2000 | 162k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; |
2001 | 162k | bytefn(dav1d_loopfilter_sbrow_cols)(f, p, mask, sby, |
2002 | 162k | f->lf.start_of_tile_row[sby]); |
2003 | 162k | } dav1d_filter_sbrow_deblock_cols_8bpc Line | Count | Source | 1987 | 83.2k | void bytefn(dav1d_filter_sbrow_deblock_cols)(Dav1dFrameContext *const f, const int sby) { | 1988 | 83.2k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK) || | 1989 | 83.2k | (!f->frame_hdr->loopfilter.level_y[0] && !f->frame_hdr->loopfilter.level_y[1])) | 1990 | 0 | { | 1991 | 0 | return; | 1992 | 0 | } | 1993 | 83.2k | const int y = sby * f->sb_step * 4; | 1994 | 83.2k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1995 | 83.2k | pixel *const p[3] = { | 1996 | 83.2k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 1997 | 83.2k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 1998 | 83.2k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 1999 | 83.2k | }; | 2000 | 83.2k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2001 | 83.2k | bytefn(dav1d_loopfilter_sbrow_cols)(f, p, mask, sby, | 2002 | 83.2k | f->lf.start_of_tile_row[sby]); | 2003 | 83.2k | } |
dav1d_filter_sbrow_deblock_cols_16bpc Line | Count | Source | 1987 | 79.5k | void bytefn(dav1d_filter_sbrow_deblock_cols)(Dav1dFrameContext *const f, const int sby) { | 1988 | 79.5k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK) || | 1989 | 79.5k | (!f->frame_hdr->loopfilter.level_y[0] && !f->frame_hdr->loopfilter.level_y[1])) | 1990 | 0 | { | 1991 | 0 | return; | 1992 | 0 | } | 1993 | 79.5k | const int y = sby * f->sb_step * 4; | 1994 | 79.5k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 1995 | 79.5k | pixel *const p[3] = { | 1996 | 79.5k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 1997 | 79.5k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 1998 | 79.5k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 1999 | 79.5k | }; | 2000 | 79.5k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2001 | 79.5k | bytefn(dav1d_loopfilter_sbrow_cols)(f, p, mask, sby, | 2002 | 79.5k | f->lf.start_of_tile_row[sby]); | 2003 | 79.5k | } |
|
2004 | | |
2005 | 201k | void bytefn(dav1d_filter_sbrow_deblock_rows)(Dav1dFrameContext *const f, const int sby) { |
2006 | 201k | const int y = sby * f->sb_step * 4; |
2007 | 201k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2008 | 201k | pixel *const p[3] = { |
2009 | 201k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), |
2010 | 201k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
2011 | 201k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) |
2012 | 201k | }; |
2013 | 201k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; |
2014 | 201k | if (f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK && |
2015 | 201k | (f->frame_hdr->loopfilter.level_y[0] || f->frame_hdr->loopfilter.level_y[1])) |
2016 | 162k | { |
2017 | 162k | bytefn(dav1d_loopfilter_sbrow_rows)(f, p, mask, sby); |
2018 | 162k | } |
2019 | 201k | if (f->seq_hdr->cdef || f->lf.restore_planes) { |
2020 | | // Store loop filtered pixels required by CDEF / LR |
2021 | 173k | bytefn(dav1d_copy_lpf)(f, p, sby); |
2022 | 173k | } |
2023 | 201k | } dav1d_filter_sbrow_deblock_rows_8bpc Line | Count | Source | 2005 | 97.7k | void bytefn(dav1d_filter_sbrow_deblock_rows)(Dav1dFrameContext *const f, const int sby) { | 2006 | 97.7k | const int y = sby * f->sb_step * 4; | 2007 | 97.7k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2008 | 97.7k | pixel *const p[3] = { | 2009 | 97.7k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2010 | 97.7k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2011 | 97.7k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2012 | 97.7k | }; | 2013 | 97.7k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2014 | 97.7k | if (f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK && | 2015 | 97.7k | (f->frame_hdr->loopfilter.level_y[0] || f->frame_hdr->loopfilter.level_y[1])) | 2016 | 83.0k | { | 2017 | 83.0k | bytefn(dav1d_loopfilter_sbrow_rows)(f, p, mask, sby); | 2018 | 83.0k | } | 2019 | 97.7k | if (f->seq_hdr->cdef || f->lf.restore_planes) { | 2020 | | // Store loop filtered pixels required by CDEF / LR | 2021 | 85.9k | bytefn(dav1d_copy_lpf)(f, p, sby); | 2022 | 85.9k | } | 2023 | 97.7k | } |
dav1d_filter_sbrow_deblock_rows_16bpc Line | Count | Source | 2005 | 103k | void bytefn(dav1d_filter_sbrow_deblock_rows)(Dav1dFrameContext *const f, const int sby) { | 2006 | 103k | const int y = sby * f->sb_step * 4; | 2007 | 103k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2008 | 103k | pixel *const p[3] = { | 2009 | 103k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2010 | 103k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2011 | 103k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2012 | 103k | }; | 2013 | 103k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2014 | 103k | if (f->c->inloop_filters & DAV1D_INLOOPFILTER_DEBLOCK && | 2015 | 103k | (f->frame_hdr->loopfilter.level_y[0] || f->frame_hdr->loopfilter.level_y[1])) | 2016 | 79.4k | { | 2017 | 79.4k | bytefn(dav1d_loopfilter_sbrow_rows)(f, p, mask, sby); | 2018 | 79.4k | } | 2019 | 103k | if (f->seq_hdr->cdef || f->lf.restore_planes) { | 2020 | | // Store loop filtered pixels required by CDEF / LR | 2021 | 88.0k | bytefn(dav1d_copy_lpf)(f, p, sby); | 2022 | 88.0k | } | 2023 | 103k | } |
|
2024 | | |
2025 | 124k | void bytefn(dav1d_filter_sbrow_cdef)(Dav1dTaskContext *const tc, const int sby) { |
2026 | 124k | const Dav1dFrameContext *const f = tc->f; |
2027 | 124k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_CDEF)) return; |
2028 | 124k | const int sbsz = f->sb_step; |
2029 | 124k | const int y = sby * sbsz * 4; |
2030 | 124k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2031 | 124k | pixel *const p[3] = { |
2032 | 124k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), |
2033 | 124k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
2034 | 124k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) |
2035 | 124k | }; |
2036 | 124k | Av1Filter *prev_mask = f->lf.mask + ((sby - 1) >> !f->seq_hdr->sb128) * f->sb128w; |
2037 | 124k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; |
2038 | 124k | const int start = sby * sbsz; |
2039 | 124k | if (sby) { |
2040 | 69.5k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2041 | 69.5k | pixel *p_up[3] = { |
2042 | 69.5k | p[0] - 8 * PXSTRIDE(f->cur.stride[0]), |
2043 | 69.5k | p[1] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
2044 | 69.5k | p[2] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
2045 | 69.5k | }; |
2046 | 69.5k | bytefn(dav1d_cdef_brow)(tc, p_up, prev_mask, start - 2, start, 1, sby); |
2047 | 69.5k | } |
2048 | 124k | const int n_blks = sbsz - 2 * (sby + 1 < f->sbh); |
2049 | 124k | const int end = imin(start + n_blks, f->bh); |
2050 | 124k | bytefn(dav1d_cdef_brow)(tc, p, mask, start, end, 0, sby); |
2051 | 124k | } dav1d_filter_sbrow_cdef_8bpc Line | Count | Source | 2025 | 60.7k | void bytefn(dav1d_filter_sbrow_cdef)(Dav1dTaskContext *const tc, const int sby) { | 2026 | 60.7k | const Dav1dFrameContext *const f = tc->f; | 2027 | 60.7k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_CDEF)) return; | 2028 | 60.7k | const int sbsz = f->sb_step; | 2029 | 60.7k | const int y = sby * sbsz * 4; | 2030 | 60.7k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2031 | 60.7k | pixel *const p[3] = { | 2032 | 60.7k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2033 | 60.7k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2034 | 60.7k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2035 | 60.7k | }; | 2036 | 60.7k | Av1Filter *prev_mask = f->lf.mask + ((sby - 1) >> !f->seq_hdr->sb128) * f->sb128w; | 2037 | 60.7k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2038 | 60.7k | const int start = sby * sbsz; | 2039 | 60.7k | if (sby) { | 2040 | 27.2k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2041 | 27.2k | pixel *p_up[3] = { | 2042 | 27.2k | p[0] - 8 * PXSTRIDE(f->cur.stride[0]), | 2043 | 27.2k | p[1] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2044 | 27.2k | p[2] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2045 | 27.2k | }; | 2046 | 27.2k | bytefn(dav1d_cdef_brow)(tc, p_up, prev_mask, start - 2, start, 1, sby); | 2047 | 27.2k | } | 2048 | 60.7k | const int n_blks = sbsz - 2 * (sby + 1 < f->sbh); | 2049 | 60.7k | const int end = imin(start + n_blks, f->bh); | 2050 | 60.7k | bytefn(dav1d_cdef_brow)(tc, p, mask, start, end, 0, sby); | 2051 | 60.7k | } |
dav1d_filter_sbrow_cdef_16bpc Line | Count | Source | 2025 | 63.7k | void bytefn(dav1d_filter_sbrow_cdef)(Dav1dTaskContext *const tc, const int sby) { | 2026 | 63.7k | const Dav1dFrameContext *const f = tc->f; | 2027 | 63.7k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_CDEF)) return; | 2028 | 63.7k | const int sbsz = f->sb_step; | 2029 | 63.7k | const int y = sby * sbsz * 4; | 2030 | 63.7k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2031 | 63.7k | pixel *const p[3] = { | 2032 | 63.7k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2033 | 63.7k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2034 | 63.7k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2035 | 63.7k | }; | 2036 | 63.7k | Av1Filter *prev_mask = f->lf.mask + ((sby - 1) >> !f->seq_hdr->sb128) * f->sb128w; | 2037 | 63.7k | Av1Filter *mask = f->lf.mask + (sby >> !f->seq_hdr->sb128) * f->sb128w; | 2038 | 63.7k | const int start = sby * sbsz; | 2039 | 63.7k | if (sby) { | 2040 | 42.3k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2041 | 42.3k | pixel *p_up[3] = { | 2042 | 42.3k | p[0] - 8 * PXSTRIDE(f->cur.stride[0]), | 2043 | 42.3k | p[1] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2044 | 42.3k | p[2] - (8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2045 | 42.3k | }; | 2046 | 42.3k | bytefn(dav1d_cdef_brow)(tc, p_up, prev_mask, start - 2, start, 1, sby); | 2047 | 42.3k | } | 2048 | 63.7k | const int n_blks = sbsz - 2 * (sby + 1 < f->sbh); | 2049 | 63.7k | const int end = imin(start + n_blks, f->bh); | 2050 | 63.7k | bytefn(dav1d_cdef_brow)(tc, p, mask, start, end, 0, sby); | 2051 | 63.7k | } |
|
2052 | | |
2053 | 30.5k | void bytefn(dav1d_filter_sbrow_resize)(Dav1dFrameContext *const f, const int sby) { |
2054 | 30.5k | const int sbsz = f->sb_step; |
2055 | 30.5k | const int y = sby * sbsz * 4; |
2056 | 30.5k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2057 | 30.5k | const pixel *const p[3] = { |
2058 | 30.5k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), |
2059 | 30.5k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), |
2060 | 30.5k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) |
2061 | 30.5k | }; |
2062 | 30.5k | pixel *const sr_p[3] = { |
2063 | 30.5k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), |
2064 | 30.5k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), |
2065 | 30.5k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) |
2066 | 30.5k | }; |
2067 | 30.5k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400; |
2068 | 100k | for (int pl = 0; pl < 1 + 2 * has_chroma; pl++) { |
2069 | 69.8k | const int ss_ver = pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2070 | 69.8k | const int h_start = 8 * !!sby >> ss_ver; |
2071 | 69.8k | const ptrdiff_t dst_stride = f->sr_cur.p.stride[!!pl]; |
2072 | 69.8k | pixel *dst = sr_p[pl] - h_start * PXSTRIDE(dst_stride); |
2073 | 69.8k | const ptrdiff_t src_stride = f->cur.stride[!!pl]; |
2074 | 69.8k | const pixel *src = p[pl] - h_start * PXSTRIDE(src_stride); |
2075 | 69.8k | const int h_end = 4 * (sbsz - 2 * (sby + 1 < f->sbh)) >> ss_ver; |
2076 | 69.8k | const int ss_hor = pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
2077 | 69.8k | const int dst_w = (f->sr_cur.p.p.w + ss_hor) >> ss_hor; |
2078 | 69.8k | const int src_w = (4 * f->bw + ss_hor) >> ss_hor; |
2079 | 69.8k | const int img_h = (f->cur.p.h - sbsz * 4 * sby + ss_ver) >> ss_ver; |
2080 | | |
2081 | 69.8k | f->dsp->mc.resize(dst, dst_stride, src, src_stride, dst_w, |
2082 | 69.8k | imin(img_h, h_end) + h_start, src_w, |
2083 | 69.8k | f->resize_step[!!pl], f->resize_start[!!pl] |
2084 | 69.8k | HIGHBD_CALL_SUFFIX); |
2085 | 69.8k | } |
2086 | 30.5k | } dav1d_filter_sbrow_resize_8bpc Line | Count | Source | 2053 | 15.4k | void bytefn(dav1d_filter_sbrow_resize)(Dav1dFrameContext *const f, const int sby) { | 2054 | 15.4k | const int sbsz = f->sb_step; | 2055 | 15.4k | const int y = sby * sbsz * 4; | 2056 | 15.4k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2057 | 15.4k | const pixel *const p[3] = { | 2058 | 15.4k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2059 | 15.4k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2060 | 15.4k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2061 | 15.4k | }; | 2062 | 15.4k | pixel *const sr_p[3] = { | 2063 | 15.4k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), | 2064 | 15.4k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), | 2065 | 15.4k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) | 2066 | 15.4k | }; | 2067 | 15.4k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400; | 2068 | 51.7k | for (int pl = 0; pl < 1 + 2 * has_chroma; pl++) { | 2069 | 36.2k | const int ss_ver = pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2070 | 36.2k | const int h_start = 8 * !!sby >> ss_ver; | 2071 | 36.2k | const ptrdiff_t dst_stride = f->sr_cur.p.stride[!!pl]; | 2072 | 36.2k | pixel *dst = sr_p[pl] - h_start * PXSTRIDE(dst_stride); | 2073 | 36.2k | const ptrdiff_t src_stride = f->cur.stride[!!pl]; | 2074 | 36.2k | const pixel *src = p[pl] - h_start * PXSTRIDE(src_stride); | 2075 | 36.2k | const int h_end = 4 * (sbsz - 2 * (sby + 1 < f->sbh)) >> ss_ver; | 2076 | 36.2k | const int ss_hor = pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 2077 | 36.2k | const int dst_w = (f->sr_cur.p.p.w + ss_hor) >> ss_hor; | 2078 | 36.2k | const int src_w = (4 * f->bw + ss_hor) >> ss_hor; | 2079 | 36.2k | const int img_h = (f->cur.p.h - sbsz * 4 * sby + ss_ver) >> ss_ver; | 2080 | | | 2081 | 36.2k | f->dsp->mc.resize(dst, dst_stride, src, src_stride, dst_w, | 2082 | 36.2k | imin(img_h, h_end) + h_start, src_w, | 2083 | 36.2k | f->resize_step[!!pl], f->resize_start[!!pl] | 2084 | 36.2k | HIGHBD_CALL_SUFFIX); | 2085 | 36.2k | } | 2086 | 15.4k | } |
dav1d_filter_sbrow_resize_16bpc Line | Count | Source | 2053 | 15.1k | void bytefn(dav1d_filter_sbrow_resize)(Dav1dFrameContext *const f, const int sby) { | 2054 | 15.1k | const int sbsz = f->sb_step; | 2055 | 15.1k | const int y = sby * sbsz * 4; | 2056 | 15.1k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2057 | 15.1k | const pixel *const p[3] = { | 2058 | 15.1k | f->lf.p[0] + y * PXSTRIDE(f->cur.stride[0]), | 2059 | 15.1k | f->lf.p[1] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver), | 2060 | 15.1k | f->lf.p[2] + (y * PXSTRIDE(f->cur.stride[1]) >> ss_ver) | 2061 | 15.1k | }; | 2062 | 15.1k | pixel *const sr_p[3] = { | 2063 | 15.1k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), | 2064 | 15.1k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), | 2065 | 15.1k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) | 2066 | 15.1k | }; | 2067 | 15.1k | const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400; | 2068 | 48.7k | for (int pl = 0; pl < 1 + 2 * has_chroma; pl++) { | 2069 | 33.6k | const int ss_ver = pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2070 | 33.6k | const int h_start = 8 * !!sby >> ss_ver; | 2071 | 33.6k | const ptrdiff_t dst_stride = f->sr_cur.p.stride[!!pl]; | 2072 | 33.6k | pixel *dst = sr_p[pl] - h_start * PXSTRIDE(dst_stride); | 2073 | 33.6k | const ptrdiff_t src_stride = f->cur.stride[!!pl]; | 2074 | 33.6k | const pixel *src = p[pl] - h_start * PXSTRIDE(src_stride); | 2075 | 33.6k | const int h_end = 4 * (sbsz - 2 * (sby + 1 < f->sbh)) >> ss_ver; | 2076 | 33.6k | const int ss_hor = pl && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 2077 | 33.6k | const int dst_w = (f->sr_cur.p.p.w + ss_hor) >> ss_hor; | 2078 | 33.6k | const int src_w = (4 * f->bw + ss_hor) >> ss_hor; | 2079 | 33.6k | const int img_h = (f->cur.p.h - sbsz * 4 * sby + ss_ver) >> ss_ver; | 2080 | | | 2081 | 33.6k | f->dsp->mc.resize(dst, dst_stride, src, src_stride, dst_w, | 2082 | 33.6k | imin(img_h, h_end) + h_start, src_w, | 2083 | 33.6k | f->resize_step[!!pl], f->resize_start[!!pl] | 2084 | 33.6k | HIGHBD_CALL_SUFFIX); | 2085 | 33.6k | } | 2086 | 15.1k | } |
|
2087 | | |
2088 | 96.5k | void bytefn(dav1d_filter_sbrow_lr)(Dav1dFrameContext *const f, const int sby) { |
2089 | 96.5k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_RESTORATION)) return; |
2090 | 96.5k | const int y = sby * f->sb_step * 4; |
2091 | 96.5k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2092 | 96.5k | pixel *const sr_p[3] = { |
2093 | 96.5k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), |
2094 | 96.5k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), |
2095 | 96.5k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) |
2096 | 96.5k | }; |
2097 | 96.5k | bytefn(dav1d_lr_sbrow)(f, sr_p, sby); |
2098 | 96.5k | } dav1d_filter_sbrow_lr_8bpc Line | Count | Source | 2088 | 55.6k | void bytefn(dav1d_filter_sbrow_lr)(Dav1dFrameContext *const f, const int sby) { | 2089 | 55.6k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_RESTORATION)) return; | 2090 | 55.6k | const int y = sby * f->sb_step * 4; | 2091 | 55.6k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2092 | 55.6k | pixel *const sr_p[3] = { | 2093 | 55.6k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), | 2094 | 55.6k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), | 2095 | 55.6k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) | 2096 | 55.6k | }; | 2097 | 55.6k | bytefn(dav1d_lr_sbrow)(f, sr_p, sby); | 2098 | 55.6k | } |
dav1d_filter_sbrow_lr_16bpc Line | Count | Source | 2088 | 40.9k | void bytefn(dav1d_filter_sbrow_lr)(Dav1dFrameContext *const f, const int sby) { | 2089 | 40.9k | if (!(f->c->inloop_filters & DAV1D_INLOOPFILTER_RESTORATION)) return; | 2090 | 40.9k | const int y = sby * f->sb_step * 4; | 2091 | 40.9k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2092 | 40.9k | pixel *const sr_p[3] = { | 2093 | 40.9k | f->lf.sr_p[0] + y * PXSTRIDE(f->sr_cur.p.stride[0]), | 2094 | 40.9k | f->lf.sr_p[1] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver), | 2095 | 40.9k | f->lf.sr_p[2] + (y * PXSTRIDE(f->sr_cur.p.stride[1]) >> ss_ver) | 2096 | 40.9k | }; | 2097 | 40.9k | bytefn(dav1d_lr_sbrow)(f, sr_p, sby); | 2098 | 40.9k | } |
|
2099 | | |
2100 | 0 | void bytefn(dav1d_filter_sbrow)(Dav1dFrameContext *const f, const int sby) { |
2101 | 0 | bytefn(dav1d_filter_sbrow_deblock_cols)(f, sby); |
2102 | 0 | bytefn(dav1d_filter_sbrow_deblock_rows)(f, sby); |
2103 | 0 | if (f->seq_hdr->cdef) |
2104 | 0 | bytefn(dav1d_filter_sbrow_cdef)(f->c->tc, sby); |
2105 | 0 | if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) |
2106 | 0 | bytefn(dav1d_filter_sbrow_resize)(f, sby); |
2107 | 0 | if (f->lf.restore_planes) |
2108 | 0 | bytefn(dav1d_filter_sbrow_lr)(f, sby); |
2109 | 0 | } Unexecuted instantiation: dav1d_filter_sbrow_8bpc Unexecuted instantiation: dav1d_filter_sbrow_16bpc |
2110 | | |
2111 | 244k | void bytefn(dav1d_backup_ipred_edge)(Dav1dTaskContext *const t) { |
2112 | 244k | const Dav1dFrameContext *const f = t->f; |
2113 | 244k | Dav1dTileState *const ts = t->ts; |
2114 | 244k | const int sby = t->by >> f->sb_shift; |
2115 | 244k | const int sby_off = f->sb128w * 128 * sby; |
2116 | 244k | const int x_off = ts->tiling.col_start; |
2117 | | |
2118 | 244k | const pixel *const y = |
2119 | 244k | ((const pixel *) f->cur.data[0]) + x_off * 4 + |
2120 | 244k | ((t->by + f->sb_step) * 4 - 1) * PXSTRIDE(f->cur.stride[0]); |
2121 | 244k | pixel_copy(&f->ipred_edge[0][sby_off + x_off * 4], y, |
2122 | 244k | 4 * (ts->tiling.col_end - x_off)); |
2123 | | |
2124 | 244k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { |
2125 | 200k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
2126 | 200k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
2127 | | |
2128 | 200k | const ptrdiff_t uv_off = (x_off * 4 >> ss_hor) + |
2129 | 200k | (((t->by + f->sb_step) * 4 >> ss_ver) - 1) * PXSTRIDE(f->cur.stride[1]); |
2130 | 602k | for (int pl = 1; pl <= 2; pl++) |
2131 | 401k | pixel_copy(&f->ipred_edge[pl][sby_off + (x_off * 4 >> ss_hor)], |
2132 | 203k | &((const pixel *) f->cur.data[pl])[uv_off], |
2133 | 203k | 4 * (ts->tiling.col_end - x_off) >> ss_hor); |
2134 | 200k | } |
2135 | 244k | } dav1d_backup_ipred_edge_8bpc Line | Count | Source | 2111 | 120k | void bytefn(dav1d_backup_ipred_edge)(Dav1dTaskContext *const t) { | 2112 | 120k | const Dav1dFrameContext *const f = t->f; | 2113 | 120k | Dav1dTileState *const ts = t->ts; | 2114 | 120k | const int sby = t->by >> f->sb_shift; | 2115 | 120k | const int sby_off = f->sb128w * 128 * sby; | 2116 | 120k | const int x_off = ts->tiling.col_start; | 2117 | | | 2118 | 120k | const pixel *const y = | 2119 | 120k | ((const pixel *) f->cur.data[0]) + x_off * 4 + | 2120 | 120k | ((t->by + f->sb_step) * 4 - 1) * PXSTRIDE(f->cur.stride[0]); | 2121 | 120k | pixel_copy(&f->ipred_edge[0][sby_off + x_off * 4], y, | 2122 | 120k | 4 * (ts->tiling.col_end - x_off)); | 2123 | | | 2124 | 120k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 2125 | 101k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2126 | 101k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 2127 | | | 2128 | 101k | const ptrdiff_t uv_off = (x_off * 4 >> ss_hor) + | 2129 | 101k | (((t->by + f->sb_step) * 4 >> ss_ver) - 1) * PXSTRIDE(f->cur.stride[1]); | 2130 | 305k | for (int pl = 1; pl <= 2; pl++) | 2131 | 203k | pixel_copy(&f->ipred_edge[pl][sby_off + (x_off * 4 >> ss_hor)], | 2132 | 203k | &((const pixel *) f->cur.data[pl])[uv_off], | 2133 | 203k | 4 * (ts->tiling.col_end - x_off) >> ss_hor); | 2134 | 101k | } | 2135 | 120k | } |
dav1d_backup_ipred_edge_16bpc Line | Count | Source | 2111 | 123k | void bytefn(dav1d_backup_ipred_edge)(Dav1dTaskContext *const t) { | 2112 | 123k | const Dav1dFrameContext *const f = t->f; | 2113 | 123k | Dav1dTileState *const ts = t->ts; | 2114 | 123k | const int sby = t->by >> f->sb_shift; | 2115 | 123k | const int sby_off = f->sb128w * 128 * sby; | 2116 | 123k | const int x_off = ts->tiling.col_start; | 2117 | | | 2118 | 123k | const pixel *const y = | 2119 | 123k | ((const pixel *) f->cur.data[0]) + x_off * 4 + | 2120 | 123k | ((t->by + f->sb_step) * 4 - 1) * PXSTRIDE(f->cur.stride[0]); | 2121 | 123k | pixel_copy(&f->ipred_edge[0][sby_off + x_off * 4], y, | 2122 | 123k | 4 * (ts->tiling.col_end - x_off)); | 2123 | | | 2124 | 123k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 2125 | 99.1k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 2126 | 99.1k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 2127 | | | 2128 | 99.1k | const ptrdiff_t uv_off = (x_off * 4 >> ss_hor) + | 2129 | 99.1k | (((t->by + f->sb_step) * 4 >> ss_ver) - 1) * PXSTRIDE(f->cur.stride[1]); | 2130 | 297k | for (int pl = 1; pl <= 2; pl++) | 2131 | 198k | pixel_copy(&f->ipred_edge[pl][sby_off + (x_off * 4 >> ss_hor)], | 2132 | 99.1k | &((const pixel *) f->cur.data[pl])[uv_off], | 2133 | 99.1k | 4 * (ts->tiling.col_end - x_off) >> ss_hor); | 2134 | 99.1k | } | 2135 | 123k | } |
|
2136 | | |
2137 | | void bytefn(dav1d_copy_pal_block_y)(Dav1dTaskContext *const t, |
2138 | | const int bx4, const int by4, |
2139 | | const int bw4, const int bh4) |
2140 | | |
2141 | 26.0k | { |
2142 | 26.0k | const Dav1dFrameContext *const f = t->f; |
2143 | 26.0k | pixel *const pal = t->frame_thread.pass ? |
2144 | 26.0k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
2145 | 26.0k | ((t->bx >> 1) + (t->by & 1))][0] : |
2146 | 26.0k | bytefn(t->scratch.pal)[0]; |
2147 | 125k | for (int x = 0; x < bw4; x++) |
2148 | 99.0k | memcpy(bytefn(t->al_pal)[0][bx4 + x][0], pal, 8 * sizeof(pixel)); |
2149 | 108k | for (int y = 0; y < bh4; y++) |
2150 | 82.8k | memcpy(bytefn(t->al_pal)[1][by4 + y][0], pal, 8 * sizeof(pixel)); |
2151 | 26.0k | } dav1d_copy_pal_block_y_8bpc Line | Count | Source | 2141 | 12.4k | { | 2142 | 12.4k | const Dav1dFrameContext *const f = t->f; | 2143 | 12.4k | pixel *const pal = t->frame_thread.pass ? | 2144 | 12.4k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2145 | 12.4k | ((t->bx >> 1) + (t->by & 1))][0] : | 2146 | 12.4k | bytefn(t->scratch.pal)[0]; | 2147 | 58.8k | for (int x = 0; x < bw4; x++) | 2148 | 46.4k | memcpy(bytefn(t->al_pal)[0][bx4 + x][0], pal, 8 * sizeof(pixel)); | 2149 | 50.9k | for (int y = 0; y < bh4; y++) | 2150 | 38.5k | memcpy(bytefn(t->al_pal)[1][by4 + y][0], pal, 8 * sizeof(pixel)); | 2151 | 12.4k | } |
dav1d_copy_pal_block_y_16bpc Line | Count | Source | 2141 | 13.6k | { | 2142 | 13.6k | const Dav1dFrameContext *const f = t->f; | 2143 | 13.6k | pixel *const pal = t->frame_thread.pass ? | 2144 | 13.6k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2145 | 13.6k | ((t->bx >> 1) + (t->by & 1))][0] : | 2146 | 13.6k | bytefn(t->scratch.pal)[0]; | 2147 | 66.2k | for (int x = 0; x < bw4; x++) | 2148 | 52.6k | memcpy(bytefn(t->al_pal)[0][bx4 + x][0], pal, 8 * sizeof(pixel)); | 2149 | 57.9k | for (int y = 0; y < bh4; y++) | 2150 | 44.3k | memcpy(bytefn(t->al_pal)[1][by4 + y][0], pal, 8 * sizeof(pixel)); | 2151 | 13.6k | } |
|
2152 | | |
2153 | | void bytefn(dav1d_copy_pal_block_uv)(Dav1dTaskContext *const t, |
2154 | | const int bx4, const int by4, |
2155 | | const int bw4, const int bh4) |
2156 | | |
2157 | 10.1k | { |
2158 | 10.1k | const Dav1dFrameContext *const f = t->f; |
2159 | 10.1k | const pixel (*const pal)[8] = t->frame_thread.pass ? |
2160 | 10.1k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
2161 | 10.1k | ((t->bx >> 1) + (t->by & 1))] : |
2162 | 10.1k | bytefn(t->scratch.pal); |
2163 | | // see aomedia bug 2183 for why we use luma coordinates here |
2164 | 30.5k | for (int pl = 1; pl <= 2; pl++) { |
2165 | 113k | for (int x = 0; x < bw4; x++) |
2166 | 93.1k | memcpy(bytefn(t->al_pal)[0][bx4 + x][pl], pal[pl], 8 * sizeof(pixel)); |
2167 | 108k | for (int y = 0; y < bh4; y++) |
2168 | 88.1k | memcpy(bytefn(t->al_pal)[1][by4 + y][pl], pal[pl], 8 * sizeof(pixel)); |
2169 | 20.3k | } |
2170 | 10.1k | } dav1d_copy_pal_block_uv_8bpc Line | Count | Source | 2157 | 5.49k | { | 2158 | 5.49k | const Dav1dFrameContext *const f = t->f; | 2159 | 5.49k | const pixel (*const pal)[8] = t->frame_thread.pass ? | 2160 | 5.49k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2161 | 5.49k | ((t->bx >> 1) + (t->by & 1))] : | 2162 | 5.49k | bytefn(t->scratch.pal); | 2163 | | // see aomedia bug 2183 for why we use luma coordinates here | 2164 | 16.4k | for (int pl = 1; pl <= 2; pl++) { | 2165 | 60.6k | for (int x = 0; x < bw4; x++) | 2166 | 49.6k | memcpy(bytefn(t->al_pal)[0][bx4 + x][pl], pal[pl], 8 * sizeof(pixel)); | 2167 | 59.4k | for (int y = 0; y < bh4; y++) | 2168 | 48.4k | memcpy(bytefn(t->al_pal)[1][by4 + y][pl], pal[pl], 8 * sizeof(pixel)); | 2169 | 10.9k | } | 2170 | 5.49k | } |
dav1d_copy_pal_block_uv_16bpc Line | Count | Source | 2157 | 4.70k | { | 2158 | 4.70k | const Dav1dFrameContext *const f = t->f; | 2159 | 4.70k | const pixel (*const pal)[8] = t->frame_thread.pass ? | 2160 | 4.70k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2161 | 4.70k | ((t->bx >> 1) + (t->by & 1))] : | 2162 | 4.70k | bytefn(t->scratch.pal); | 2163 | | // see aomedia bug 2183 for why we use luma coordinates here | 2164 | 14.1k | for (int pl = 1; pl <= 2; pl++) { | 2165 | 52.8k | for (int x = 0; x < bw4; x++) | 2166 | 43.4k | memcpy(bytefn(t->al_pal)[0][bx4 + x][pl], pal[pl], 8 * sizeof(pixel)); | 2167 | 49.1k | for (int y = 0; y < bh4; y++) | 2168 | 39.6k | memcpy(bytefn(t->al_pal)[1][by4 + y][pl], pal[pl], 8 * sizeof(pixel)); | 2169 | 9.41k | } | 2170 | 4.70k | } |
|
2171 | | |
2172 | | void bytefn(dav1d_read_pal_plane)(Dav1dTaskContext *const t, Av1Block *const b, |
2173 | | const int pl, const int sz_ctx, |
2174 | | const int bx4, const int by4) |
2175 | 36.2k | { |
2176 | 36.2k | Dav1dTileState *const ts = t->ts; |
2177 | 36.2k | const Dav1dFrameContext *const f = t->f; |
2178 | 36.2k | const int pal_sz = b->pal_sz[pl] = dav1d_msac_decode_symbol_adapt8(&ts->msac, |
2179 | 36.2k | ts->cdf.m.pal_sz[pl][sz_ctx], 6) + 2; |
2180 | 36.2k | pixel cache[16], used_cache[8]; |
2181 | 36.2k | int l_cache = pl ? t->pal_sz_uv[1][by4] : t->l.pal_sz[by4]; |
2182 | 36.2k | int n_cache = 0; |
2183 | | // don't reuse above palette outside SB64 boundaries |
2184 | 36.2k | int a_cache = by4 & 15 ? pl ? t->pal_sz_uv[0][bx4] : t->a->pal_sz[bx4] : 0; |
2185 | 36.2k | const pixel *l = bytefn(t->al_pal)[1][by4][pl]; |
2186 | 36.2k | const pixel *a = bytefn(t->al_pal)[0][bx4][pl]; |
2187 | | |
2188 | | // fill/sort cache |
2189 | 56.4k | while (l_cache && a_cache) { |
2190 | 20.1k | if (*l < *a) { |
2191 | 7.71k | if (!n_cache || cache[n_cache - 1] != *l) |
2192 | 7.67k | cache[n_cache++] = *l; |
2193 | 7.71k | l++; |
2194 | 7.71k | l_cache--; |
2195 | 12.4k | } else { |
2196 | 12.4k | if (*a == *l) { |
2197 | 5.03k | l++; |
2198 | 5.03k | l_cache--; |
2199 | 5.03k | } |
2200 | 12.4k | if (!n_cache || cache[n_cache - 1] != *a) |
2201 | 12.0k | cache[n_cache++] = *a; |
2202 | 12.4k | a++; |
2203 | 12.4k | a_cache--; |
2204 | 12.4k | } |
2205 | 20.1k | } |
2206 | 36.2k | if (l_cache) { |
2207 | 41.7k | do { |
2208 | 41.7k | if (!n_cache || cache[n_cache - 1] != *l) |
2209 | 33.9k | cache[n_cache++] = *l; |
2210 | 41.7k | l++; |
2211 | 41.7k | } while (--l_cache > 0); |
2212 | 26.3k | } else if (a_cache) { |
2213 | 29.0k | do { |
2214 | 29.0k | if (!n_cache || cache[n_cache - 1] != *a) |
2215 | 23.3k | cache[n_cache++] = *a; |
2216 | 29.0k | a++; |
2217 | 29.0k | } while (--a_cache > 0); |
2218 | 7.16k | } |
2219 | | |
2220 | | // find reused cache entries |
2221 | 36.2k | int i = 0; |
2222 | 105k | for (int n = 0; n < n_cache && i < pal_sz; n++) |
2223 | 68.8k | if (dav1d_msac_decode_bool_equi(&ts->msac)) |
2224 | 33.9k | used_cache[i++] = cache[n]; |
2225 | 36.2k | const int n_used_cache = i; |
2226 | | |
2227 | | // parse new entries |
2228 | 36.2k | pixel *const pal = t->frame_thread.pass ? |
2229 | 36.2k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
2230 | 36.2k | ((t->bx >> 1) + (t->by & 1))][pl] : |
2231 | 36.2k | bytefn(t->scratch.pal)[pl]; |
2232 | 36.2k | if (i < pal_sz) { |
2233 | 32.1k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; |
2234 | 32.1k | int prev = pal[i++] = dav1d_msac_decode_bools(&ts->msac, bpc); |
2235 | | |
2236 | 32.1k | if (i < pal_sz) { |
2237 | 29.3k | int bits = bpc - 3 + dav1d_msac_decode_bools(&ts->msac, 2); |
2238 | 29.3k | const int max = (1 << bpc) - 1; |
2239 | | |
2240 | 69.0k | do { |
2241 | 69.0k | const int delta = dav1d_msac_decode_bools(&ts->msac, bits); |
2242 | 69.0k | prev = pal[i++] = imin(prev + delta + !pl, max); |
2243 | 69.0k | if (prev + !pl >= max) { |
2244 | 38.4k | for (; i < pal_sz; i++) |
2245 | 25.1k | pal[i] = max; |
2246 | 13.3k | break; |
2247 | 13.3k | } |
2248 | 55.7k | bits = imin(bits, 1 + ulog2(max - prev - !pl)); |
2249 | 55.7k | } while (i < pal_sz); |
2250 | 29.3k | } |
2251 | | |
2252 | | // merge cache+new entries |
2253 | 32.1k | int n = 0, m = n_used_cache; |
2254 | 181k | for (i = 0; i < pal_sz; i++) { |
2255 | 149k | if (n < n_used_cache && (m >= pal_sz || used_cache[n] <= pal[m])) { |
2256 | 22.8k | pal[i] = used_cache[n++]; |
2257 | 126k | } else { |
2258 | 126k | assert(m < pal_sz); |
2259 | 126k | pal[i] = pal[m++]; |
2260 | 126k | } |
2261 | 149k | } |
2262 | 32.1k | } else { |
2263 | 4.16k | memcpy(pal, used_cache, n_used_cache * sizeof(*used_cache)); |
2264 | 4.16k | } |
2265 | | |
2266 | 36.2k | if (DEBUG_BLOCK_INFO) { |
2267 | 0 | printf("Post-pal[pl=%d,sz=%d,cache_size=%d,used_cache=%d]: r=%d, cache=", |
2268 | 0 | pl, pal_sz, n_cache, n_used_cache, ts->msac.rng); |
2269 | 0 | for (int n = 0; n < n_cache; n++) |
2270 | 0 | printf("%c%02x", n ? ' ' : '[', cache[n]); |
2271 | 0 | printf("%s, pal=", n_cache ? "]" : "[]"); |
2272 | 0 | for (int n = 0; n < pal_sz; n++) |
2273 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); |
2274 | 0 | printf("]\n"); |
2275 | 0 | } |
2276 | 36.2k | } dav1d_read_pal_plane_8bpc Line | Count | Source | 2175 | 17.9k | { | 2176 | 17.9k | Dav1dTileState *const ts = t->ts; | 2177 | 17.9k | const Dav1dFrameContext *const f = t->f; | 2178 | 17.9k | const int pal_sz = b->pal_sz[pl] = dav1d_msac_decode_symbol_adapt8(&ts->msac, | 2179 | 17.9k | ts->cdf.m.pal_sz[pl][sz_ctx], 6) + 2; | 2180 | 17.9k | pixel cache[16], used_cache[8]; | 2181 | 17.9k | int l_cache = pl ? t->pal_sz_uv[1][by4] : t->l.pal_sz[by4]; | 2182 | 17.9k | int n_cache = 0; | 2183 | | // don't reuse above palette outside SB64 boundaries | 2184 | 17.9k | int a_cache = by4 & 15 ? pl ? t->pal_sz_uv[0][bx4] : t->a->pal_sz[bx4] : 0; | 2185 | 17.9k | const pixel *l = bytefn(t->al_pal)[1][by4][pl]; | 2186 | 17.9k | const pixel *a = bytefn(t->al_pal)[0][bx4][pl]; | 2187 | | | 2188 | | // fill/sort cache | 2189 | 30.3k | while (l_cache && a_cache) { | 2190 | 12.4k | if (*l < *a) { | 2191 | 4.73k | if (!n_cache || cache[n_cache - 1] != *l) | 2192 | 4.70k | cache[n_cache++] = *l; | 2193 | 4.73k | l++; | 2194 | 4.73k | l_cache--; | 2195 | 7.72k | } else { | 2196 | 7.72k | if (*a == *l) { | 2197 | 3.08k | l++; | 2198 | 3.08k | l_cache--; | 2199 | 3.08k | } | 2200 | 7.72k | if (!n_cache || cache[n_cache - 1] != *a) | 2201 | 7.45k | cache[n_cache++] = *a; | 2202 | 7.72k | a++; | 2203 | 7.72k | a_cache--; | 2204 | 7.72k | } | 2205 | 12.4k | } | 2206 | 17.9k | if (l_cache) { | 2207 | 20.6k | do { | 2208 | 20.6k | if (!n_cache || cache[n_cache - 1] != *l) | 2209 | 16.6k | cache[n_cache++] = *l; | 2210 | 20.6k | l++; | 2211 | 20.6k | } while (--l_cache > 0); | 2212 | 12.9k | } else if (a_cache) { | 2213 | 14.7k | do { | 2214 | 14.7k | if (!n_cache || cache[n_cache - 1] != *a) | 2215 | 11.7k | cache[n_cache++] = *a; | 2216 | 14.7k | a++; | 2217 | 14.7k | } while (--a_cache > 0); | 2218 | 3.71k | } | 2219 | | | 2220 | | // find reused cache entries | 2221 | 17.9k | int i = 0; | 2222 | 53.9k | for (int n = 0; n < n_cache && i < pal_sz; n++) | 2223 | 36.0k | if (dav1d_msac_decode_bool_equi(&ts->msac)) | 2224 | 17.6k | used_cache[i++] = cache[n]; | 2225 | 17.9k | const int n_used_cache = i; | 2226 | | | 2227 | | // parse new entries | 2228 | 17.9k | pixel *const pal = t->frame_thread.pass ? | 2229 | 17.9k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2230 | 17.9k | ((t->bx >> 1) + (t->by & 1))][pl] : | 2231 | 17.9k | bytefn(t->scratch.pal)[pl]; | 2232 | 17.9k | if (i < pal_sz) { | 2233 | 15.7k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; | 2234 | 15.7k | int prev = pal[i++] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2235 | | | 2236 | 15.7k | if (i < pal_sz) { | 2237 | 14.2k | int bits = bpc - 3 + dav1d_msac_decode_bools(&ts->msac, 2); | 2238 | 14.2k | const int max = (1 << bpc) - 1; | 2239 | | | 2240 | 33.2k | do { | 2241 | 33.2k | const int delta = dav1d_msac_decode_bools(&ts->msac, bits); | 2242 | 33.2k | prev = pal[i++] = imin(prev + delta + !pl, max); | 2243 | 33.2k | if (prev + !pl >= max) { | 2244 | 19.0k | for (; i < pal_sz; i++) | 2245 | 12.5k | pal[i] = max; | 2246 | 6.51k | break; | 2247 | 6.51k | } | 2248 | 26.7k | bits = imin(bits, 1 + ulog2(max - prev - !pl)); | 2249 | 26.7k | } while (i < pal_sz); | 2250 | 14.2k | } | 2251 | | | 2252 | | // merge cache+new entries | 2253 | 15.7k | int n = 0, m = n_used_cache; | 2254 | 89.2k | for (i = 0; i < pal_sz; i++) { | 2255 | 73.4k | if (n < n_used_cache && (m >= pal_sz || used_cache[n] <= pal[m])) { | 2256 | 11.8k | pal[i] = used_cache[n++]; | 2257 | 61.6k | } else { | 2258 | 61.6k | assert(m < pal_sz); | 2259 | 61.6k | pal[i] = pal[m++]; | 2260 | 61.6k | } | 2261 | 73.4k | } | 2262 | 15.7k | } else { | 2263 | 2.13k | memcpy(pal, used_cache, n_used_cache * sizeof(*used_cache)); | 2264 | 2.13k | } | 2265 | | | 2266 | 17.9k | if (DEBUG_BLOCK_INFO) { | 2267 | 0 | printf("Post-pal[pl=%d,sz=%d,cache_size=%d,used_cache=%d]: r=%d, cache=", | 2268 | 0 | pl, pal_sz, n_cache, n_used_cache, ts->msac.rng); | 2269 | 0 | for (int n = 0; n < n_cache; n++) | 2270 | 0 | printf("%c%02x", n ? ' ' : '[', cache[n]); | 2271 | 0 | printf("%s, pal=", n_cache ? "]" : "[]"); | 2272 | 0 | for (int n = 0; n < pal_sz; n++) | 2273 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); | 2274 | 0 | printf("]\n"); | 2275 | 0 | } | 2276 | 17.9k | } |
dav1d_read_pal_plane_16bpc Line | Count | Source | 2175 | 18.3k | { | 2176 | 18.3k | Dav1dTileState *const ts = t->ts; | 2177 | 18.3k | const Dav1dFrameContext *const f = t->f; | 2178 | 18.3k | const int pal_sz = b->pal_sz[pl] = dav1d_msac_decode_symbol_adapt8(&ts->msac, | 2179 | 18.3k | ts->cdf.m.pal_sz[pl][sz_ctx], 6) + 2; | 2180 | 18.3k | pixel cache[16], used_cache[8]; | 2181 | 18.3k | int l_cache = pl ? t->pal_sz_uv[1][by4] : t->l.pal_sz[by4]; | 2182 | 18.3k | int n_cache = 0; | 2183 | | // don't reuse above palette outside SB64 boundaries | 2184 | 18.3k | int a_cache = by4 & 15 ? pl ? t->pal_sz_uv[0][bx4] : t->a->pal_sz[bx4] : 0; | 2185 | 18.3k | const pixel *l = bytefn(t->al_pal)[1][by4][pl]; | 2186 | 18.3k | const pixel *a = bytefn(t->al_pal)[0][bx4][pl]; | 2187 | | | 2188 | | // fill/sort cache | 2189 | 26.0k | while (l_cache && a_cache) { | 2190 | 7.73k | if (*l < *a) { | 2191 | 2.98k | if (!n_cache || cache[n_cache - 1] != *l) | 2192 | 2.97k | cache[n_cache++] = *l; | 2193 | 2.98k | l++; | 2194 | 2.98k | l_cache--; | 2195 | 4.74k | } else { | 2196 | 4.74k | if (*a == *l) { | 2197 | 1.94k | l++; | 2198 | 1.94k | l_cache--; | 2199 | 1.94k | } | 2200 | 4.74k | if (!n_cache || cache[n_cache - 1] != *a) | 2201 | 4.59k | cache[n_cache++] = *a; | 2202 | 4.74k | a++; | 2203 | 4.74k | a_cache--; | 2204 | 4.74k | } | 2205 | 7.73k | } | 2206 | 18.3k | if (l_cache) { | 2207 | 21.0k | do { | 2208 | 21.0k | if (!n_cache || cache[n_cache - 1] != *l) | 2209 | 17.3k | cache[n_cache++] = *l; | 2210 | 21.0k | l++; | 2211 | 21.0k | } while (--l_cache > 0); | 2212 | 13.4k | } else if (a_cache) { | 2213 | 14.3k | do { | 2214 | 14.3k | if (!n_cache || cache[n_cache - 1] != *a) | 2215 | 11.6k | cache[n_cache++] = *a; | 2216 | 14.3k | a++; | 2217 | 14.3k | } while (--a_cache > 0); | 2218 | 3.44k | } | 2219 | | | 2220 | | // find reused cache entries | 2221 | 18.3k | int i = 0; | 2222 | 51.1k | for (int n = 0; n < n_cache && i < pal_sz; n++) | 2223 | 32.8k | if (dav1d_msac_decode_bool_equi(&ts->msac)) | 2224 | 16.3k | used_cache[i++] = cache[n]; | 2225 | 18.3k | const int n_used_cache = i; | 2226 | | | 2227 | | // parse new entries | 2228 | 18.3k | pixel *const pal = t->frame_thread.pass ? | 2229 | 18.3k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2230 | 18.3k | ((t->bx >> 1) + (t->by & 1))][pl] : | 2231 | 18.3k | bytefn(t->scratch.pal)[pl]; | 2232 | 18.3k | if (i < pal_sz) { | 2233 | 16.3k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; | 2234 | 16.3k | int prev = pal[i++] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2235 | | | 2236 | 16.3k | if (i < pal_sz) { | 2237 | 15.0k | int bits = bpc - 3 + dav1d_msac_decode_bools(&ts->msac, 2); | 2238 | 15.0k | const int max = (1 << bpc) - 1; | 2239 | | | 2240 | 35.7k | do { | 2241 | 35.7k | const int delta = dav1d_msac_decode_bools(&ts->msac, bits); | 2242 | 35.7k | prev = pal[i++] = imin(prev + delta + !pl, max); | 2243 | 35.7k | if (prev + !pl >= max) { | 2244 | 19.3k | for (; i < pal_sz; i++) | 2245 | 12.5k | pal[i] = max; | 2246 | 6.79k | break; | 2247 | 6.79k | } | 2248 | 28.9k | bits = imin(bits, 1 + ulog2(max - prev - !pl)); | 2249 | 28.9k | } while (i < pal_sz); | 2250 | 15.0k | } | 2251 | | | 2252 | | // merge cache+new entries | 2253 | 16.3k | int n = 0, m = n_used_cache; | 2254 | 91.9k | for (i = 0; i < pal_sz; i++) { | 2255 | 75.6k | if (n < n_used_cache && (m >= pal_sz || used_cache[n] <= pal[m])) { | 2256 | 10.9k | pal[i] = used_cache[n++]; | 2257 | 64.6k | } else { | 2258 | 64.6k | assert(m < pal_sz); | 2259 | 64.6k | pal[i] = pal[m++]; | 2260 | 64.6k | } | 2261 | 75.6k | } | 2262 | 16.3k | } else { | 2263 | 2.02k | memcpy(pal, used_cache, n_used_cache * sizeof(*used_cache)); | 2264 | 2.02k | } | 2265 | | | 2266 | 18.3k | if (DEBUG_BLOCK_INFO) { | 2267 | 0 | printf("Post-pal[pl=%d,sz=%d,cache_size=%d,used_cache=%d]: r=%d, cache=", | 2268 | 0 | pl, pal_sz, n_cache, n_used_cache, ts->msac.rng); | 2269 | 0 | for (int n = 0; n < n_cache; n++) | 2270 | 0 | printf("%c%02x", n ? ' ' : '[', cache[n]); | 2271 | 0 | printf("%s, pal=", n_cache ? "]" : "[]"); | 2272 | 0 | for (int n = 0; n < pal_sz; n++) | 2273 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); | 2274 | 0 | printf("]\n"); | 2275 | 0 | } | 2276 | 18.3k | } |
|
2277 | | |
2278 | | void bytefn(dav1d_read_pal_uv)(Dav1dTaskContext *const t, Av1Block *const b, |
2279 | | const int sz_ctx, const int bx4, const int by4) |
2280 | 10.1k | { |
2281 | 10.1k | bytefn(dav1d_read_pal_plane)(t, b, 1, sz_ctx, bx4, by4); |
2282 | | |
2283 | | // V pal coding |
2284 | 10.1k | Dav1dTileState *const ts = t->ts; |
2285 | 10.1k | const Dav1dFrameContext *const f = t->f; |
2286 | 10.1k | pixel *const pal = t->frame_thread.pass ? |
2287 | 10.1k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + |
2288 | 10.1k | ((t->bx >> 1) + (t->by & 1))][2] : |
2289 | 10.1k | bytefn(t->scratch.pal)[2]; |
2290 | 10.1k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; |
2291 | 10.1k | if (dav1d_msac_decode_bool_equi(&ts->msac)) { |
2292 | 5.18k | const int bits = bpc - 4 + dav1d_msac_decode_bools(&ts->msac, 2); |
2293 | 5.18k | int prev = pal[0] = dav1d_msac_decode_bools(&ts->msac, bpc); |
2294 | 5.18k | const int max = (1 << bpc) - 1; |
2295 | 21.6k | for (int i = 1; i < b->pal_sz[1]; i++) { |
2296 | 16.5k | int delta = dav1d_msac_decode_bools(&ts->msac, bits); |
2297 | 16.5k | if (delta && dav1d_msac_decode_bool_equi(&ts->msac)) delta = -delta; |
2298 | 16.5k | prev = pal[i] = (prev + delta) & max; |
2299 | 16.5k | } |
2300 | 5.18k | } else { |
2301 | 25.9k | for (int i = 0; i < b->pal_sz[1]; i++) |
2302 | 20.8k | pal[i] = dav1d_msac_decode_bools(&ts->msac, bpc); |
2303 | 5.01k | } |
2304 | 10.1k | if (DEBUG_BLOCK_INFO) { |
2305 | 0 | printf("Post-pal[pl=2]: r=%d ", ts->msac.rng); |
2306 | 0 | for (int n = 0; n < b->pal_sz[1]; n++) |
2307 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); |
2308 | 0 | printf("]\n"); |
2309 | 0 | } |
2310 | 10.1k | } Line | Count | Source | 2280 | 5.49k | { | 2281 | 5.49k | bytefn(dav1d_read_pal_plane)(t, b, 1, sz_ctx, bx4, by4); | 2282 | | | 2283 | | // V pal coding | 2284 | 5.49k | Dav1dTileState *const ts = t->ts; | 2285 | 5.49k | const Dav1dFrameContext *const f = t->f; | 2286 | 5.49k | pixel *const pal = t->frame_thread.pass ? | 2287 | 5.49k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2288 | 5.49k | ((t->bx >> 1) + (t->by & 1))][2] : | 2289 | 5.49k | bytefn(t->scratch.pal)[2]; | 2290 | 5.49k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; | 2291 | 5.49k | if (dav1d_msac_decode_bool_equi(&ts->msac)) { | 2292 | 2.84k | const int bits = bpc - 4 + dav1d_msac_decode_bools(&ts->msac, 2); | 2293 | 2.84k | int prev = pal[0] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2294 | 2.84k | const int max = (1 << bpc) - 1; | 2295 | 11.9k | for (int i = 1; i < b->pal_sz[1]; i++) { | 2296 | 9.14k | int delta = dav1d_msac_decode_bools(&ts->msac, bits); | 2297 | 9.14k | if (delta && dav1d_msac_decode_bool_equi(&ts->msac)) delta = -delta; | 2298 | 9.14k | prev = pal[i] = (prev + delta) & max; | 2299 | 9.14k | } | 2300 | 2.84k | } else { | 2301 | 13.8k | for (int i = 0; i < b->pal_sz[1]; i++) | 2302 | 11.1k | pal[i] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2303 | 2.65k | } | 2304 | 5.49k | if (DEBUG_BLOCK_INFO) { | 2305 | 0 | printf("Post-pal[pl=2]: r=%d ", ts->msac.rng); | 2306 | 0 | for (int n = 0; n < b->pal_sz[1]; n++) | 2307 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); | 2308 | 0 | printf("]\n"); | 2309 | 0 | } | 2310 | 5.49k | } |
Line | Count | Source | 2280 | 4.70k | { | 2281 | 4.70k | bytefn(dav1d_read_pal_plane)(t, b, 1, sz_ctx, bx4, by4); | 2282 | | | 2283 | | // V pal coding | 2284 | 4.70k | Dav1dTileState *const ts = t->ts; | 2285 | 4.70k | const Dav1dFrameContext *const f = t->f; | 2286 | 4.70k | pixel *const pal = t->frame_thread.pass ? | 2287 | 4.70k | f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) + | 2288 | 4.70k | ((t->bx >> 1) + (t->by & 1))][2] : | 2289 | 4.70k | bytefn(t->scratch.pal)[2]; | 2290 | 4.70k | const int bpc = BITDEPTH == 8 ? 8 : f->cur.p.bpc; | 2291 | 4.70k | if (dav1d_msac_decode_bool_equi(&ts->msac)) { | 2292 | 2.34k | const int bits = bpc - 4 + dav1d_msac_decode_bools(&ts->msac, 2); | 2293 | 2.34k | int prev = pal[0] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2294 | 2.34k | const int max = (1 << bpc) - 1; | 2295 | 9.71k | for (int i = 1; i < b->pal_sz[1]; i++) { | 2296 | 7.37k | int delta = dav1d_msac_decode_bools(&ts->msac, bits); | 2297 | 7.37k | if (delta && dav1d_msac_decode_bool_equi(&ts->msac)) delta = -delta; | 2298 | 7.37k | prev = pal[i] = (prev + delta) & max; | 2299 | 7.37k | } | 2300 | 2.36k | } else { | 2301 | 12.0k | for (int i = 0; i < b->pal_sz[1]; i++) | 2302 | 9.70k | pal[i] = dav1d_msac_decode_bools(&ts->msac, bpc); | 2303 | 2.36k | } | 2304 | 4.70k | if (DEBUG_BLOCK_INFO) { | 2305 | 0 | printf("Post-pal[pl=2]: r=%d ", ts->msac.rng); | 2306 | 0 | for (int n = 0; n < b->pal_sz[1]; n++) | 2307 | 0 | printf("%c%02x", n ? ' ' : '[', pal[n]); | 2308 | 0 | printf("]\n"); | 2309 | 0 | } | 2310 | 4.70k | } |
|