FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/ops_tmpl_int.c
Date: 2026-04-24 19:58:39
Exec Total Coverage
Lines: 212 212 100.0%
Functions: 197 249 79.1%
Branches: 117 128 91.4%

Line Branch Exec Source
1 /**
2 * Copyright (C) 2025 Niklas Haas
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "libavutil/avassert.h"
22 #include "libavutil/bswap.h"
23
24 #include "ops_backend.h"
25
26 #ifndef BIT_DEPTH
27 # define BIT_DEPTH 8
28 #endif
29
30 #if BIT_DEPTH == 32
31 # define PIXEL_TYPE SWS_PIXEL_U32
32 # define PIXEL_MAX 0xFFFFFFFFu
33 # define SWAP_BYTES av_bswap32
34 # define pixel_t uint32_t
35 # define inter_t int64_t
36 # define block_t u32block_t
37 # define px u32
38 #elif BIT_DEPTH == 16
39 # define PIXEL_TYPE SWS_PIXEL_U16
40 # define PIXEL_MAX 0xFFFFu
41 # define SWAP_BYTES av_bswap16
42 # define pixel_t uint16_t
43 # define inter_t int64_t
44 # define block_t u16block_t
45 # define px u16
46 #elif BIT_DEPTH == 8
47 # define PIXEL_TYPE SWS_PIXEL_U8
48 # define PIXEL_MAX 0xFFu
49 # define pixel_t uint8_t
50 # define inter_t int32_t
51 # define block_t u8block_t
52 # define px u8
53 #else
54 # error Invalid BIT_DEPTH
55 #endif
56
57 #define IS_FLOAT 0
58 #define FMT_CHAR u
59 #include "ops_tmpl_common.c"
60
61 661056 DECL_READ(read_planar, const int elems)
62 {
63 SWS_LOOP
64
2/2
✓ Branch 0 taken 10576896 times.
✓ Branch 1 taken 330528 times.
21814848 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
65 21153792 x[i] = in0[i];
66
2/2
✓ Branch 0 taken 4337664 times.
✓ Branch 1 taken 6239232 times.
21153792 if (elems > 1)
67 8675328 y[i] = in1[i];
68
2/2
✓ Branch 0 taken 4258816 times.
✓ Branch 1 taken 6318080 times.
21153792 if (elems > 2)
69 8517632 z[i] = in2[i];
70
2/2
✓ Branch 0 taken 3103744 times.
✓ Branch 1 taken 7473152 times.
21153792 if (elems > 3)
71 6207488 w[i] = in3[i];
72 }
73
74 661056 CONTINUE(x, y, z, w);
75 661056 }
76
77 76032 DECL_READ(read_packed, const int elems)
78 {
79 SWS_LOOP
80
2/2
✓ Branch 0 taken 1216512 times.
✓ Branch 1 taken 38016 times.
2509056 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
81 2433024 x[i] = in0[elems * i + 0];
82
1/2
✓ Branch 0 taken 1216512 times.
✗ Branch 1 not taken.
2433024 if (elems > 1)
83 2433024 y[i] = in0[elems * i + 1];
84
2/2
✓ Branch 0 taken 1084416 times.
✓ Branch 1 taken 132096 times.
2433024 if (elems > 2)
85 2168832 z[i] = in0[elems * i + 2];
86
2/2
✓ Branch 0 taken 814080 times.
✓ Branch 1 taken 402432 times.
2433024 if (elems > 3)
87 1628160 w[i] = in0[elems * i + 3];
88 }
89
90 76032 CONTINUE(x, y, z, w);
91 76032 }
92
93 761216 DECL_WRITE(write_planar, const int elems)
94 {
95 SWS_LOOP
96
2/2
✓ Branch 0 taken 12179456 times.
✓ Branch 1 taken 380608 times.
25120128 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
97 24358912 out0[i] = x[i];
98
2/2
✓ Branch 0 taken 6242304 times.
✓ Branch 1 taken 5937152 times.
24358912 if (elems > 1)
99 12484608 out1[i] = y[i];
100
2/2
✓ Branch 0 taken 5667840 times.
✓ Branch 1 taken 6511616 times.
24358912 if (elems > 2)
101 11335680 out2[i] = z[i];
102
2/2
✓ Branch 0 taken 3650560 times.
✓ Branch 1 taken 8528896 times.
24358912 if (elems > 3)
103 7301120 out3[i] = w[i];
104 }
105 761216 }
106
107 112320 DECL_WRITE(write_packed, const int elems)
108 {
109 SWS_LOOP
110
2/2
✓ Branch 0 taken 1797120 times.
✓ Branch 1 taken 56160 times.
3706560 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
111 3594240 out0[elems * i + 0] = x[i];
112
1/2
✓ Branch 0 taken 1797120 times.
✗ Branch 1 not taken.
3594240 if (elems > 1)
113 3594240 out0[elems * i + 1] = y[i];
114
2/2
✓ Branch 0 taken 1665024 times.
✓ Branch 1 taken 132096 times.
3594240 if (elems > 2)
115 3330048 out0[elems * i + 2] = z[i];
116
2/2
✓ Branch 0 taken 1164288 times.
✓ Branch 1 taken 632832 times.
3594240 if (elems > 3)
117 2328576 out0[elems * i + 3] = w[i];
118 }
119 112320 }
120
121 #define WRAP_READ(FUNC, ELEMS, FRAC, PACKED) \
122 static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
123 const SwsOpImpl *restrict impl, \
124 void *restrict x, void *restrict y, \
125 void *restrict z, void *restrict w) \
126 { \
127 CALL_READ(FUNC, ELEMS); \
128 for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
129 iter->in[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
130 } \
131 \
132 DECL_ENTRY(FUNC##ELEMS, SWS_COMP_ELEMS(ELEMS), \
133 .op = SWS_OP_READ, \
134 .rw = { \
135 .elems = ELEMS, \
136 .packed = PACKED, \
137 .frac = FRAC, \
138 }, \
139 );
140
141
2/2
✓ Branch 1 taken 194976 times.
✓ Branch 2 taken 194976 times.
779904 WRAP_READ(read_planar, 1, 0, false)
142
2/2
✓ Branch 1 taken 4928 times.
✓ Branch 2 taken 2464 times.
14784 WRAP_READ(read_planar, 2, 0, false)
143
2/2
✓ Branch 1 taken 108288 times.
✓ Branch 2 taken 36096 times.
288768 WRAP_READ(read_planar, 3, 0, false)
144
2/2
✓ Branch 1 taken 387968 times.
✓ Branch 2 taken 96992 times.
969920 WRAP_READ(read_planar, 4, 0, false)
145
2/2
✓ Branch 1 taken 4128 times.
✓ Branch 2 taken 4128 times.
16512 WRAP_READ(read_packed, 2, 0, true)
146
2/2
✓ Branch 1 taken 8448 times.
✓ Branch 2 taken 8448 times.
33792 WRAP_READ(read_packed, 3, 0, true)
147
2/2
✓ Branch 1 taken 25440 times.
✓ Branch 2 taken 25440 times.
101760 WRAP_READ(read_packed, 4, 0, true)
148
149 #define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED) \
150 static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
151 const SwsOpImpl *restrict impl, \
152 void *restrict x, void *restrict y, \
153 void *restrict z, void *restrict w) \
154 { \
155 CALL_WRITE(FUNC, ELEMS); \
156 for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
157 iter->out[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
158 } \
159 \
160 DECL_ENTRY(FUNC##ELEMS, SWS_COMP_ALL, \
161 .op = SWS_OP_WRITE, \
162 .rw = { \
163 .elems = ELEMS, \
164 .packed = PACKED, \
165 .frac = FRAC, \
166 }, \
167 );
168
169
2/2
✓ Branch 1 taken 185536 times.
✓ Branch 2 taken 185536 times.
742144 WRAP_WRITE(write_planar, 1, 0, false)
170
2/2
✓ Branch 1 taken 35904 times.
✓ Branch 2 taken 17952 times.
107712 WRAP_WRITE(write_planar, 2, 0, false)
171
2/2
✓ Branch 1 taken 189120 times.
✓ Branch 2 taken 63040 times.
504320 WRAP_WRITE(write_planar, 3, 0, false)
172
2/2
✓ Branch 1 taken 456320 times.
✓ Branch 2 taken 114080 times.
1140800 WRAP_WRITE(write_planar, 4, 0, false)
173
2/2
✓ Branch 1 taken 4128 times.
✓ Branch 2 taken 4128 times.
16512 WRAP_WRITE(write_packed, 2, 0, true)
174
2/2
✓ Branch 1 taken 15648 times.
✓ Branch 2 taken 15648 times.
62592 WRAP_WRITE(write_packed, 3, 0, true)
175
2/2
✓ Branch 1 taken 36384 times.
✓ Branch 2 taken 36384 times.
145536 WRAP_WRITE(write_packed, 4, 0, true)
176
177 #if BIT_DEPTH == 8
178 192 DECL_READ(read_nibbles, const int elems)
179 {
180 SWS_LOOP
181
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 192 times.
3264 for (int i = 0; i < SWS_BLOCK_SIZE; i += 2) {
182 3072 const pixel_t val = ((const pixel_t *) in0)[i >> 1];
183 3072 x[i + 0] = val >> 4; /* high nibble */
184 3072 x[i + 1] = val & 0xF; /* low nibble */
185 }
186
187 192 CONTINUE(x, y, z, w);
188 192 }
189
190 12288 DECL_READ(read_bits, const int elems)
191 {
192 SWS_LOOP
193
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 12288 times.
61440 for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) {
194 49152 const pixel_t val = ((const pixel_t *) in0)[i >> 3];
195 49152 x[i + 0] = (val >> 7) & 1;
196 49152 x[i + 1] = (val >> 6) & 1;
197 49152 x[i + 2] = (val >> 5) & 1;
198 49152 x[i + 3] = (val >> 4) & 1;
199 49152 x[i + 4] = (val >> 3) & 1;
200 49152 x[i + 5] = (val >> 2) & 1;
201 49152 x[i + 6] = (val >> 1) & 1;
202 49152 x[i + 7] = (val >> 0) & 1;
203 }
204
205 12288 CONTINUE(x, y, z, w);
206 12288 }
207
208
2/2
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 192 times.
384 WRAP_READ(read_nibbles, 1, 1, false)
209
2/2
✓ Branch 1 taken 12288 times.
✓ Branch 2 taken 12288 times.
24576 WRAP_READ(read_bits, 1, 3, false)
210
211 128 DECL_WRITE(write_nibbles, const int elems)
212 {
213 SWS_LOOP
214
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 128 times.
2176 for (int i = 0; i < SWS_BLOCK_SIZE; i += 2)
215 2048 out0[i >> 1] = x[i] << 4 | x[i + 1];
216 128 }
217
218 2496 DECL_WRITE(write_bits, const int elems)
219 {
220 SWS_LOOP
221
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 2496 times.
12480 for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) {
222 9984 out0[i >> 3] = x[i + 0] << 7 |
223 9984 x[i + 1] << 6 |
224 9984 x[i + 2] << 5 |
225 9984 x[i + 3] << 4 |
226 9984 x[i + 4] << 3 |
227 9984 x[i + 5] << 2 |
228 9984 x[i + 6] << 1 |
229 9984 x[i + 7];
230 }
231 2496 }
232
233
2/2
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 128 times.
256 WRAP_WRITE(write_nibbles, 1, 1, false)
234
2/2
✓ Branch 1 taken 2496 times.
✓ Branch 2 taken 2496 times.
4992 WRAP_WRITE(write_bits, 1, 3, false)
235 #endif /* BIT_DEPTH == 8 */
236
237 #ifdef SWAP_BYTES
238 260032 DECL_PATTERN(swap_bytes)
239 {
240 SWS_LOOP
241
2/2
✓ Branch 0 taken 4160512 times.
✓ Branch 1 taken 130016 times.
8581056 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
242
1/2
✓ Branch 0 taken 4160512 times.
✗ Branch 1 not taken.
8321024 if (X)
243 8321024 x[i] = SWAP_BYTES(x[i]);
244
2/2
✓ Branch 0 taken 2437120 times.
✓ Branch 1 taken 1723392 times.
8321024 if (Y)
245 4874240 y[i] = SWAP_BYTES(y[i]);
246
2/2
✓ Branch 0 taken 2437120 times.
✓ Branch 1 taken 1723392 times.
8321024 if (Z)
247 4874240 z[i] = SWAP_BYTES(z[i]);
248
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 3382272 times.
8321024 if (W)
249 1556480 w[i] = SWAP_BYTES(w[i]);
250 }
251
252 260032 CONTINUE(x, y, z, w);
253 260032 }
254
255 260032 WRAP_COMMON_PATTERNS(swap_bytes, .op = SWS_OP_SWAP_BYTES);
256 #endif /* SWAP_BYTES */
257
258 #if BIT_DEPTH == 8
259 640 DECL_PATTERN(expand16)
260 {
261 u16block_t x16, y16, z16, w16;
262
263 SWS_LOOP
264
2/2
✓ Branch 0 taken 20480 times.
✓ Branch 1 taken 640 times.
21120 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
265
1/2
✓ Branch 0 taken 20480 times.
✗ Branch 1 not taken.
20480 if (X)
266 20480 x16[i] = x[i] << 8 | x[i];
267
1/2
✓ Branch 0 taken 20480 times.
✗ Branch 1 not taken.
20480 if (Y)
268 20480 y16[i] = y[i] << 8 | y[i];
269
1/2
✓ Branch 0 taken 20480 times.
✗ Branch 1 not taken.
20480 if (Z)
270 20480 z16[i] = z[i] << 8 | z[i];
271
1/2
✓ Branch 0 taken 20480 times.
✗ Branch 1 not taken.
20480 if (W)
272 20480 w16[i] = w[i] << 8 | w[i];
273 }
274
275 640 CONTINUE(x16, y16, z16, w16);
276 640 }
277
278 1280 WRAP_COMMON_PATTERNS(expand16,
279 .op = SWS_OP_CONVERT,
280 .convert.to = SWS_PIXEL_U16,
281 .convert.expand = true,
282 );
283
284 640 DECL_PATTERN(expand32)
285 {
286 u32block_t x32, y32, z32, w32;
287
288 SWS_LOOP
289
2/2
✓ Branch 0 taken 20480 times.
✓ Branch 1 taken 640 times.
21120 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
290 20480 x32[i] = (uint32_t)x[i] << 24 | x[i] << 16 | x[i] << 8 | x[i];
291 20480 y32[i] = (uint32_t)y[i] << 24 | y[i] << 16 | y[i] << 8 | y[i];
292 20480 z32[i] = (uint32_t)z[i] << 24 | z[i] << 16 | z[i] << 8 | z[i];
293 20480 w32[i] = (uint32_t)w[i] << 24 | w[i] << 16 | w[i] << 8 | w[i];
294 }
295
296 640 CONTINUE(x32, y32, z32, w32);
297 640 }
298
299 1280 WRAP_COMMON_PATTERNS(expand32,
300 .op = SWS_OP_CONVERT,
301 .convert.to = SWS_PIXEL_U32,
302 .convert.expand = true,
303 );
304 #endif
305
306 299392 DECL_FUNC(pack, const int bits0, const int bits1, const int bits2, const int bits3)
307 {
308 SWS_LOOP
309
2/2
✓ Branch 0 taken 4790272 times.
✓ Branch 1 taken 149696 times.
9879936 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
310 9580544 x[i] = x[i] << (bits1 + bits2 + bits3);
311
1/2
✓ Branch 0 taken 4790272 times.
✗ Branch 1 not taken.
9580544 if (bits1)
312 9580544 x[i] |= y[i] << (bits2 + bits3);
313
1/2
✓ Branch 0 taken 4790272 times.
✗ Branch 1 not taken.
9580544 if (bits2)
314 9580544 x[i] |= z[i] << bits3;
315
2/2
✓ Branch 0 taken 4092928 times.
✓ Branch 1 taken 697344 times.
9580544 if (bits3)
316 8185856 x[i] |= w[i];
317 }
318
319 299392 CONTINUE(x, y, z, w);
320 299392 }
321
322 359872 DECL_FUNC(unpack, const int bits0, const int bits1, const int bits2, const int bits3)
323 {
324 SWS_LOOP
325
2/2
✓ Branch 0 taken 5757952 times.
✓ Branch 1 taken 179936 times.
11875776 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
326 11515904 const pixel_t val = x[i];
327 11515904 x[i] = val >> (bits1 + bits2 + bits3);
328
1/2
✓ Branch 0 taken 5757952 times.
✗ Branch 1 not taken.
11515904 if (bits1)
329 11515904 y[i] = (val >> (bits2 + bits3)) & ((1 << bits1) - 1);
330
1/2
✓ Branch 0 taken 5757952 times.
✗ Branch 1 not taken.
11515904 if (bits2)
331 11515904 z[i] = (val >> bits3) & ((1 << bits2) - 1);
332
2/2
✓ Branch 0 taken 3807232 times.
✓ Branch 1 taken 1950720 times.
11515904 if (bits3)
333 7614464 w[i] = val & ((1 << bits3) - 1);
334 }
335
336 359872 CONTINUE(x, y, z, w);
337 359872 }
338
339 #define WRAP_PACK_UNPACK(X, Y, Z, W) \
340 DECL_IMPL(pack, pack_##X##Y##Z##W, X, Y, Z, W) \
341 \
342 DECL_ENTRY(pack_##X##Y##Z##W, SWS_COMP(0), \
343 .op = SWS_OP_PACK, \
344 .pack.pattern = { X, Y, Z, W }, \
345 ); \
346 \
347 DECL_IMPL(unpack, unpack_##X##Y##Z##W, X, Y, Z, W) \
348 \
349 DECL_ENTRY(unpack_##X##Y##Z##W, SWS_COMP_MASK(X, Y, Z, W), \
350 .op = SWS_OP_UNPACK, \
351 .pack.pattern = { X, Y, Z, W }, \
352 );
353
354 5376 WRAP_PACK_UNPACK( 3, 3, 2, 0)
355 5376 WRAP_PACK_UNPACK( 2, 3, 3, 0)
356 9984 WRAP_PACK_UNPACK( 1, 2, 1, 0)
357 19072 WRAP_PACK_UNPACK( 5, 6, 5, 0)
358 35200 WRAP_PACK_UNPACK( 5, 5, 5, 0)
359 90496 WRAP_PACK_UNPACK( 4, 4, 4, 0)
360 375616 WRAP_PACK_UNPACK( 2, 10, 10, 10)
361 118144 WRAP_PACK_UNPACK(10, 10, 10, 2)
362
363 #if BIT_DEPTH != 8
364 44352 DECL_PATTERN(lshift)
365 {
366 44352 const uint8_t amount = impl->priv.u8[0];
367
368 SWS_LOOP
369
2/2
✓ Branch 0 taken 709632 times.
✓ Branch 1 taken 22176 times.
1463616 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
370 1419264 x[i] <<= amount;
371 1419264 y[i] <<= amount;
372 1419264 z[i] <<= amount;
373 1419264 w[i] <<= amount;
374 }
375
376 44352 CONTINUE(x, y, z, w);
377 44352 }
378
379 36864 DECL_PATTERN(rshift)
380 {
381 36864 const uint8_t amount = impl->priv.u8[0];
382
383 SWS_LOOP
384
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
1216512 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
385 1179648 x[i] >>= amount;
386 1179648 y[i] >>= amount;
387 1179648 z[i] >>= amount;
388 1179648 w[i] >>= amount;
389 }
390
391 36864 CONTINUE(x, y, z, w);
392 36864 }
393
394 44352 WRAP_COMMON_PATTERNS(lshift,
395 .op = SWS_OP_LSHIFT,
396 .setup = ff_sws_setup_shift,
397 .flexible = true,
398 );
399
400 36864 WRAP_COMMON_PATTERNS(rshift,
401 .op = SWS_OP_RSHIFT,
402 .setup = ff_sws_setup_shift,
403 .flexible = true,
404 );
405 #endif /* BIT_DEPTH != 8 */
406
407 471296 DECL_PATTERN(convert_float)
408 {
409 f32block_t xf, yf, zf, wf;
410
411 SWS_LOOP
412
2/2
✓ Branch 0 taken 7540736 times.
✓ Branch 1 taken 235648 times.
15552768 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
413 15081472 xf[i] = x[i];
414 15081472 yf[i] = y[i];
415 15081472 zf[i] = z[i];
416 15081472 wf[i] = w[i];
417 }
418
419 471296 CONTINUE(xf, yf, zf, wf);
420 471296 }
421
422 471296 WRAP_COMMON_PATTERNS(convert_float,
423 .op = SWS_OP_CONVERT,
424 .convert.to = SWS_PIXEL_F32,
425 );
426
427 /**
428 * Swizzle by directly swapping the order of arguments to the continuation.
429 * Note that this is only safe to do if no arguments are duplicated.
430 */
431 #define DECL_SWIZZLE(X, Y, Z, W) \
432 static void \
433 fn(swizzle_##X##Y##Z##W)(SwsOpIter *restrict iter, \
434 const SwsOpImpl *restrict impl, \
435 void *restrict c0, void *restrict c1, \
436 void *restrict c2, void *restrict c3) \
437 { \
438 CONTINUE(c##X, c##Y, c##Z, c##W); \
439 } \
440 \
441 DECL_ENTRY(swizzle_##X##Y##Z##W, SWS_COMP_ALL, \
442 .op = SWS_OP_SWIZZLE, \
443 .swizzle.in = { X, Y, Z, W }, \
444 );
445
446 73792 DECL_SWIZZLE(3, 0, 1, 2)
447 1792 DECL_SWIZZLE(3, 0, 2, 1)
448 97408 DECL_SWIZZLE(2, 1, 0, 3)
449 120448 DECL_SWIZZLE(3, 2, 1, 0)
450 6976 DECL_SWIZZLE(3, 1, 0, 2)
451 55360 DECL_SWIZZLE(3, 2, 0, 1)
452 61696 DECL_SWIZZLE(1, 2, 0, 3)
453 19648 DECL_SWIZZLE(1, 0, 2, 3)
454 73792 DECL_SWIZZLE(2, 0, 1, 3)
455 43264 DECL_SWIZZLE(2, 3, 1, 0)
456 4096 DECL_SWIZZLE(2, 1, 3, 0)
457 65152 DECL_SWIZZLE(1, 2, 3, 0)
458 2944 DECL_SWIZZLE(1, 3, 2, 0)
459 2944 DECL_SWIZZLE(0, 2, 1, 3)
460 5824 DECL_SWIZZLE(0, 2, 3, 1)
461 22912 DECL_SWIZZLE(0, 3, 1, 2)
462 19072 DECL_SWIZZLE(3, 1, 2, 0)
463 5248 DECL_SWIZZLE(0, 3, 2, 1)
464
465 /* Broadcast luma -> rgb (only used for y(a) -> rgb(a)) */
466 #define DECL_EXPAND_LUMA(X, W, T0, T1) \
467 DECL_FUNC(expand_luma_##X##W##_impl, \
468 block_t c0, block_t c1, block_t c2, block_t c3) \
469 { \
470 SWS_LOOP \
471 for (int i = 0; i < SWS_BLOCK_SIZE; i++) \
472 T0[i] = T1[i] = c0[i]; \
473 \
474 CONTINUE(c##X, T0, T1, c##W); \
475 } \
476 \
477 DECL_IMPL(expand_luma_##X##W##_impl, expand_luma_##X##W, x, y, z, w) \
478 \
479 DECL_ENTRY(expand_luma_##X##W, SWS_COMP_ALL, \
480 .op = SWS_OP_SWIZZLE, \
481 .swizzle.in = { X, 0, 0, W }, \
482 );
483
484
2/2
✓ Branch 0 taken 282624 times.
✓ Branch 1 taken 8832 times.
600576 DECL_EXPAND_LUMA(0, 3, c1, c2)
485
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 7680 times.
522240 DECL_EXPAND_LUMA(3, 0, c1, c2)
486
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
52224 DECL_EXPAND_LUMA(1, 0, c2, c3)
487
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 2496 times.
169728 DECL_EXPAND_LUMA(0, 1, c2, c3)
488
489 static const SwsOpTable fn(op_table_int) = {
490 .block_size = SWS_BLOCK_SIZE,
491 .entries = {
492 &fn(op_read_planar1),
493 &fn(op_read_planar2),
494 &fn(op_read_planar3),
495 &fn(op_read_planar4),
496 &fn(op_read_packed2),
497 &fn(op_read_packed3),
498 &fn(op_read_packed4),
499
500 &fn(op_write_planar1),
501 &fn(op_write_planar2),
502 &fn(op_write_planar3),
503 &fn(op_write_planar4),
504 &fn(op_write_packed2),
505 &fn(op_write_packed3),
506 &fn(op_write_packed4),
507
508 &fn(op_filter1_v),
509 &fn(op_filter2_v),
510 &fn(op_filter3_v),
511 &fn(op_filter4_v),
512
513 &fn(op_filter1_h),
514 &fn(op_filter2_h),
515 &fn(op_filter3_h),
516 &fn(op_filter4_h),
517
518 #if BIT_DEPTH == 8
519 &fn(op_read_bits1),
520 &fn(op_read_nibbles1),
521 &fn(op_write_bits1),
522 &fn(op_write_nibbles1),
523
524 &fn(op_pack_1210),
525 &fn(op_pack_2330),
526 &fn(op_pack_3320),
527
528 &fn(op_unpack_1210),
529 &fn(op_unpack_2330),
530 &fn(op_unpack_3320),
531
532 REF_COMMON_PATTERNS(expand16),
533 REF_COMMON_PATTERNS(expand32),
534 #elif BIT_DEPTH == 16
535 &fn(op_pack_4440),
536 &fn(op_pack_5550),
537 &fn(op_pack_5650),
538 &fn(op_unpack_4440),
539 &fn(op_unpack_5550),
540 &fn(op_unpack_5650),
541 #elif BIT_DEPTH == 32
542 &fn(op_pack_2101010),
543 &fn(op_pack_1010102),
544 &fn(op_unpack_2101010),
545 &fn(op_unpack_1010102),
546 #endif
547
548 #ifdef SWAP_BYTES
549 REF_COMMON_PATTERNS(swap_bytes),
550 #endif
551
552 REF_COMMON_PATTERNS(min),
553 REF_COMMON_PATTERNS(max),
554 REF_COMMON_PATTERNS(scale),
555 REF_COMMON_PATTERNS(convert_float),
556
557 &fn(op_clear_0001),
558 &fn(op_clear_1000),
559 &fn(op_clear_1100),
560 &fn(op_clear_0100),
561 &fn(op_clear_0110),
562 &fn(op_clear_0011),
563 &fn(op_clear_1010),
564 &fn(op_clear_0101),
565 &fn(op_clear_0111),
566 &fn(op_clear_1011),
567 &fn(op_clear_1101),
568
569 &fn(op_swizzle_3012),
570 &fn(op_swizzle_3021),
571 &fn(op_swizzle_2103),
572 &fn(op_swizzle_3210),
573 &fn(op_swizzle_3102),
574 &fn(op_swizzle_3201),
575 &fn(op_swizzle_1203),
576 &fn(op_swizzle_1023),
577 &fn(op_swizzle_2013),
578 &fn(op_swizzle_2310),
579 &fn(op_swizzle_2130),
580 &fn(op_swizzle_1230),
581 &fn(op_swizzle_1320),
582 &fn(op_swizzle_0213),
583 &fn(op_swizzle_0231),
584 &fn(op_swizzle_0312),
585 &fn(op_swizzle_3120),
586 &fn(op_swizzle_0321),
587
588 &fn(op_expand_luma_03),
589 &fn(op_expand_luma_30),
590 &fn(op_expand_luma_10),
591 &fn(op_expand_luma_01),
592
593 #if BIT_DEPTH != 8
594 REF_COMMON_PATTERNS(lshift),
595 REF_COMMON_PATTERNS(rshift),
596 REF_COMMON_PATTERNS(convert_uint8),
597 #endif /* BIT_DEPTH != 8 */
598
599 #if BIT_DEPTH != 16
600 REF_COMMON_PATTERNS(convert_uint16),
601 #endif
602 #if BIT_DEPTH != 32
603 REF_COMMON_PATTERNS(convert_uint32),
604 #endif
605
606 NULL
607 },
608 };
609
610 #undef PIXEL_TYPE
611 #undef PIXEL_MAX
612 #undef SWAP_BYTES
613 #undef pixel_t
614 #undef inter_t
615 #undef block_t
616 #undef px
617
618 #undef FMT_CHAR
619 #undef IS_FLOAT
620