/src/ffmpeg/libswscale/ops_tmpl_int.c
Line | Count | 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 | 0 | # define SWAP_BYTES av_bswap32 |
34 | | # define pixel_t uint32_t |
35 | 0 | # define block_t u32block_t |
36 | 0 | # define px u32 |
37 | | #elif BIT_DEPTH == 16 |
38 | | # define PIXEL_TYPE SWS_PIXEL_U16 |
39 | | # define PIXEL_MAX 0xFFFFu |
40 | 0 | # define SWAP_BYTES av_bswap16 |
41 | | # define pixel_t uint16_t |
42 | 0 | # define block_t u16block_t |
43 | 0 | # define px u16 |
44 | | #elif BIT_DEPTH == 8 |
45 | | # define PIXEL_TYPE SWS_PIXEL_U8 |
46 | | # define PIXEL_MAX 0xFFu |
47 | | # define pixel_t uint8_t |
48 | 0 | # define block_t u8block_t |
49 | 0 | # define px u8 |
50 | | #else |
51 | | # error Invalid BIT_DEPTH |
52 | | #endif |
53 | | |
54 | | #define IS_FLOAT 0 |
55 | | #define FMT_CHAR u |
56 | | #define PIXEL_MIN 0 |
57 | | #include "ops_tmpl_common.c" |
58 | | |
59 | | DECL_READ(read_planar, const int elems) |
60 | 0 | { |
61 | 0 | block_t x, y, z, w; |
62 | |
|
63 | 0 | SWS_LOOP |
64 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
65 | 0 | x[i] = in0[i]; |
66 | 0 | if (elems > 1) |
67 | 0 | y[i] = in1[i]; |
68 | 0 | if (elems > 2) |
69 | 0 | z[i] = in2[i]; |
70 | 0 | if (elems > 3) |
71 | 0 | w[i] = in3[i]; |
72 | 0 | } |
73 | |
|
74 | 0 | CONTINUE(block_t, x, y, z, w); |
75 | 0 | } Unexecuted instantiation: ops_backend.c:read_planar_u8 Unexecuted instantiation: ops_backend.c:read_planar_u16 Unexecuted instantiation: ops_backend.c:read_planar_u32 |
76 | | |
77 | | DECL_READ(read_packed, const int elems) |
78 | 0 | { |
79 | 0 | block_t x, y, z, w; |
80 | |
|
81 | 0 | SWS_LOOP |
82 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
83 | 0 | x[i] = in0[elems * i + 0]; |
84 | 0 | if (elems > 1) |
85 | 0 | y[i] = in0[elems * i + 1]; |
86 | 0 | if (elems > 2) |
87 | 0 | z[i] = in0[elems * i + 2]; |
88 | 0 | if (elems > 3) |
89 | 0 | w[i] = in0[elems * i + 3]; |
90 | 0 | } |
91 | |
|
92 | 0 | CONTINUE(block_t, x, y, z, w); |
93 | 0 | } Unexecuted instantiation: ops_backend.c:read_packed_u8 Unexecuted instantiation: ops_backend.c:read_packed_u16 Unexecuted instantiation: ops_backend.c:read_packed_u32 |
94 | | |
95 | | DECL_WRITE(write_planar, const int elems) |
96 | 0 | { |
97 | 0 | SWS_LOOP |
98 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
99 | 0 | out0[i] = x[i]; |
100 | 0 | if (elems > 1) |
101 | 0 | out1[i] = y[i]; |
102 | 0 | if (elems > 2) |
103 | 0 | out2[i] = z[i]; |
104 | 0 | if (elems > 3) |
105 | 0 | out3[i] = w[i]; |
106 | 0 | } |
107 | 0 | } Unexecuted instantiation: ops_backend.c:write_planar_u8 Unexecuted instantiation: ops_backend.c:write_planar_u16 Unexecuted instantiation: ops_backend.c:write_planar_u32 |
108 | | |
109 | | DECL_WRITE(write_packed, const int elems) |
110 | 0 | { |
111 | 0 | SWS_LOOP |
112 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
113 | 0 | out0[elems * i + 0] = x[i]; |
114 | 0 | if (elems > 1) |
115 | 0 | out0[elems * i + 1] = y[i]; |
116 | 0 | if (elems > 2) |
117 | 0 | out0[elems * i + 2] = z[i]; |
118 | 0 | if (elems > 3) |
119 | 0 | out0[elems * i + 3] = w[i]; |
120 | 0 | } |
121 | 0 | } Unexecuted instantiation: ops_backend.c:write_packed_u8 Unexecuted instantiation: ops_backend.c:write_packed_u16 Unexecuted instantiation: ops_backend.c:write_packed_u32 |
122 | | |
123 | | #define WRAP_READ(FUNC, ELEMS, FRAC, PACKED) \ |
124 | 0 | DECL_IMPL_READ(FUNC##ELEMS) \ |
125 | 0 | { \ |
126 | 0 | CALL_READ(FUNC, ELEMS); \ |
127 | 0 | for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \ |
128 | 0 | iter->in[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \ |
129 | 0 | } \ Unexecuted instantiation: ops_backend.c:read_planar1_u8 Unexecuted instantiation: ops_backend.c:read_planar2_u8 Unexecuted instantiation: ops_backend.c:read_planar3_u8 Unexecuted instantiation: ops_backend.c:read_planar4_u8 Unexecuted instantiation: ops_backend.c:read_packed2_u8 Unexecuted instantiation: ops_backend.c:read_packed3_u8 Unexecuted instantiation: ops_backend.c:read_packed4_u8 Unexecuted instantiation: ops_backend.c:read_bits1_u8 Unexecuted instantiation: ops_backend.c:read_nibbles1_u8 Unexecuted instantiation: ops_backend.c:read_planar1_u16 Unexecuted instantiation: ops_backend.c:read_planar2_u16 Unexecuted instantiation: ops_backend.c:read_planar3_u16 Unexecuted instantiation: ops_backend.c:read_planar4_u16 Unexecuted instantiation: ops_backend.c:read_packed2_u16 Unexecuted instantiation: ops_backend.c:read_packed3_u16 Unexecuted instantiation: ops_backend.c:read_packed4_u16 Unexecuted instantiation: ops_backend.c:read_planar1_u32 Unexecuted instantiation: ops_backend.c:read_planar2_u32 Unexecuted instantiation: ops_backend.c:read_planar3_u32 Unexecuted instantiation: ops_backend.c:read_planar4_u32 Unexecuted instantiation: ops_backend.c:read_packed2_u32 Unexecuted instantiation: ops_backend.c:read_packed3_u32 Unexecuted instantiation: ops_backend.c:read_packed4_u32 |
130 | | \ |
131 | | DECL_ENTRY(FUNC##ELEMS, \ |
132 | | .op = SWS_OP_READ, \ |
133 | | .rw = { \ |
134 | | .elems = ELEMS, \ |
135 | | .packed = PACKED, \ |
136 | | .frac = FRAC, \ |
137 | | }, \ |
138 | | ); |
139 | | |
140 | | WRAP_READ(read_planar, 1, 0, false) |
141 | | WRAP_READ(read_planar, 2, 0, false) |
142 | | WRAP_READ(read_planar, 3, 0, false) |
143 | | WRAP_READ(read_planar, 4, 0, false) |
144 | | WRAP_READ(read_packed, 2, 0, true) |
145 | | WRAP_READ(read_packed, 3, 0, true) |
146 | | WRAP_READ(read_packed, 4, 0, true) |
147 | | |
148 | | #define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED) \ |
149 | 0 | DECL_IMPL(FUNC##ELEMS) \ |
150 | 0 | { \ |
151 | 0 | CALL_WRITE(FUNC, ELEMS); \ |
152 | 0 | for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \ |
153 | 0 | iter->out[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \ |
154 | 0 | } \ Unexecuted instantiation: ops_backend.c:write_planar1_u8 Unexecuted instantiation: ops_backend.c:write_planar2_u8 Unexecuted instantiation: ops_backend.c:write_planar3_u8 Unexecuted instantiation: ops_backend.c:write_planar4_u8 Unexecuted instantiation: ops_backend.c:write_packed2_u8 Unexecuted instantiation: ops_backend.c:write_packed3_u8 Unexecuted instantiation: ops_backend.c:write_packed4_u8 Unexecuted instantiation: ops_backend.c:write_bits1_u8 Unexecuted instantiation: ops_backend.c:write_nibbles1_u8 Unexecuted instantiation: ops_backend.c:write_planar1_u16 Unexecuted instantiation: ops_backend.c:write_planar2_u16 Unexecuted instantiation: ops_backend.c:write_planar3_u16 Unexecuted instantiation: ops_backend.c:write_planar4_u16 Unexecuted instantiation: ops_backend.c:write_packed2_u16 Unexecuted instantiation: ops_backend.c:write_packed3_u16 Unexecuted instantiation: ops_backend.c:write_packed4_u16 Unexecuted instantiation: ops_backend.c:write_planar1_u32 Unexecuted instantiation: ops_backend.c:write_planar2_u32 Unexecuted instantiation: ops_backend.c:write_planar3_u32 Unexecuted instantiation: ops_backend.c:write_planar4_u32 Unexecuted instantiation: ops_backend.c:write_packed2_u32 Unexecuted instantiation: ops_backend.c:write_packed3_u32 Unexecuted instantiation: ops_backend.c:write_packed4_u32 |
155 | | \ |
156 | | DECL_ENTRY(FUNC##ELEMS, \ |
157 | | .op = SWS_OP_WRITE, \ |
158 | | .rw = { \ |
159 | | .elems = ELEMS, \ |
160 | | .packed = PACKED, \ |
161 | | .frac = FRAC, \ |
162 | | }, \ |
163 | | ); |
164 | | |
165 | | WRAP_WRITE(write_planar, 1, 0, false) |
166 | | WRAP_WRITE(write_planar, 2, 0, false) |
167 | | WRAP_WRITE(write_planar, 3, 0, false) |
168 | | WRAP_WRITE(write_planar, 4, 0, false) |
169 | | WRAP_WRITE(write_packed, 2, 0, true) |
170 | | WRAP_WRITE(write_packed, 3, 0, true) |
171 | | WRAP_WRITE(write_packed, 4, 0, true) |
172 | | |
173 | | #if BIT_DEPTH == 8 |
174 | | DECL_READ(read_nibbles, const int elems) |
175 | 0 | { |
176 | 0 | block_t x, y, z, w; |
177 | |
|
178 | 0 | SWS_LOOP |
179 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 2) { |
180 | 0 | const pixel_t val = ((const pixel_t *) in0)[i >> 1]; |
181 | 0 | x[i + 0] = val >> 4; /* high nibble */ |
182 | 0 | x[i + 1] = val & 0xF; /* low nibble */ |
183 | 0 | } |
184 | |
|
185 | 0 | CONTINUE(block_t, x, y, z, w); |
186 | 0 | } |
187 | | |
188 | | DECL_READ(read_bits, const int elems) |
189 | 0 | { |
190 | 0 | block_t x, y, z, w; |
191 | |
|
192 | 0 | SWS_LOOP |
193 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) { |
194 | 0 | const pixel_t val = ((const pixel_t *) in0)[i >> 3]; |
195 | 0 | x[i + 0] = (val >> 7) & 1; |
196 | 0 | x[i + 1] = (val >> 6) & 1; |
197 | 0 | x[i + 2] = (val >> 5) & 1; |
198 | 0 | x[i + 3] = (val >> 4) & 1; |
199 | 0 | x[i + 4] = (val >> 3) & 1; |
200 | 0 | x[i + 5] = (val >> 2) & 1; |
201 | 0 | x[i + 6] = (val >> 1) & 1; |
202 | 0 | x[i + 7] = (val >> 0) & 1; |
203 | 0 | } |
204 | |
|
205 | 0 | CONTINUE(block_t, x, y, z, w); |
206 | 0 | } |
207 | | |
208 | | WRAP_READ(read_nibbles, 1, 1, false) |
209 | | WRAP_READ(read_bits, 1, 3, false) |
210 | | |
211 | | DECL_WRITE(write_nibbles, const int elems) |
212 | 0 | { |
213 | 0 | SWS_LOOP |
214 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 2) |
215 | 0 | out0[i >> 1] = x[i] << 4 | x[i + 1]; |
216 | 0 | } |
217 | | |
218 | | DECL_WRITE(write_bits, const int elems) |
219 | 0 | { |
220 | 0 | SWS_LOOP |
221 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) { |
222 | 0 | out0[i >> 3] = x[i + 0] << 7 | |
223 | 0 | x[i + 1] << 6 | |
224 | 0 | x[i + 2] << 5 | |
225 | 0 | x[i + 3] << 4 | |
226 | 0 | x[i + 4] << 3 | |
227 | 0 | x[i + 5] << 2 | |
228 | 0 | x[i + 6] << 1 | |
229 | 0 | x[i + 7]; |
230 | 0 | } |
231 | 0 | } |
232 | | |
233 | | WRAP_WRITE(write_nibbles, 1, 1, false) |
234 | | WRAP_WRITE(write_bits, 1, 3, false) |
235 | | #endif /* BIT_DEPTH == 8 */ |
236 | | |
237 | | #ifdef SWAP_BYTES |
238 | | DECL_PATTERN(swap_bytes) |
239 | 0 | { |
240 | 0 | SWS_LOOP |
241 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
242 | 0 | if (X) |
243 | 0 | x[i] = SWAP_BYTES(x[i]); |
244 | 0 | if (Y) |
245 | 0 | y[i] = SWAP_BYTES(y[i]); |
246 | 0 | if (Z) |
247 | 0 | z[i] = SWAP_BYTES(z[i]); |
248 | 0 | if (W) |
249 | 0 | w[i] = SWAP_BYTES(w[i]); |
250 | 0 | } |
251 | |
|
252 | 0 | CONTINUE(block_t, x, y, z, w); |
253 | 0 | } Unexecuted instantiation: ops_backend.c:swap_bytes_u16 Unexecuted instantiation: ops_backend.c:swap_bytes_u32 |
254 | | |
255 | | WRAP_COMMON_PATTERNS(swap_bytes, .op = SWS_OP_SWAP_BYTES); |
256 | | #endif /* SWAP_BYTES */ |
257 | | |
258 | | #if BIT_DEPTH == 8 |
259 | | DECL_PATTERN(expand16) |
260 | 0 | { |
261 | 0 | u16block_t x16, y16, z16, w16; |
262 | |
|
263 | 0 | SWS_LOOP |
264 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
265 | 0 | if (X) |
266 | 0 | x16[i] = x[i] << 8 | x[i]; |
267 | 0 | if (Y) |
268 | 0 | y16[i] = y[i] << 8 | y[i]; |
269 | 0 | if (Z) |
270 | 0 | z16[i] = z[i] << 8 | z[i]; |
271 | 0 | if (W) |
272 | 0 | w16[i] = w[i] << 8 | w[i]; |
273 | 0 | } |
274 | |
|
275 | 0 | CONTINUE(u16block_t, x16, y16, z16, w16); |
276 | 0 | } |
277 | | |
278 | | WRAP_COMMON_PATTERNS(expand16, |
279 | | .op = SWS_OP_CONVERT, |
280 | | .convert.to = SWS_PIXEL_U16, |
281 | | .convert.expand = true, |
282 | | ); |
283 | | |
284 | | DECL_PATTERN(expand32) |
285 | 0 | { |
286 | 0 | u32block_t x32, y32, z32, w32; |
287 | |
|
288 | 0 | SWS_LOOP |
289 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
290 | 0 | x32[i] = (uint32_t)x[i] << 24 | x[i] << 16 | x[i] << 8 | x[i]; |
291 | 0 | y32[i] = (uint32_t)y[i] << 24 | y[i] << 16 | y[i] << 8 | y[i]; |
292 | 0 | z32[i] = (uint32_t)z[i] << 24 | z[i] << 16 | z[i] << 8 | z[i]; |
293 | 0 | w32[i] = (uint32_t)w[i] << 24 | w[i] << 16 | w[i] << 8 | w[i]; |
294 | 0 | } |
295 | |
|
296 | 0 | CONTINUE(u32block_t, x32, y32, z32, w32); |
297 | 0 | } |
298 | | |
299 | | WRAP_COMMON_PATTERNS(expand32, |
300 | | .op = SWS_OP_CONVERT, |
301 | | .convert.to = SWS_PIXEL_U32, |
302 | | .convert.expand = true, |
303 | | ); |
304 | | #endif |
305 | | |
306 | | #define WRAP_PACK_UNPACK(X, Y, Z, W) \ |
307 | 0 | inline DECL_IMPL(pack_##X##Y##Z##W) \ |
308 | 0 | { \ |
309 | 0 | SWS_LOOP \ |
310 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \ |
311 | 0 | x[i] = x[i] << (Y+Z+W); \ |
312 | 0 | if (Y) \ |
313 | 0 | x[i] |= y[i] << (Z+W); \ |
314 | 0 | if (Z) \ |
315 | 0 | x[i] |= z[i] << W; \ |
316 | 0 | if (W) \ |
317 | 0 | x[i] |= w[i]; \ |
318 | 0 | } \ |
319 | 0 | \ |
320 | 0 | CONTINUE(block_t, x, y, z, w); \ |
321 | 0 | } \ Unexecuted instantiation: ops_backend.c:pack_1210_u8 Unexecuted instantiation: ops_backend.c:pack_2330_u8 Unexecuted instantiation: ops_backend.c:pack_3320_u8 Unexecuted instantiation: ops_backend.c:pack_4440_u16 Unexecuted instantiation: ops_backend.c:pack_5550_u16 Unexecuted instantiation: ops_backend.c:pack_5650_u16 Unexecuted instantiation: ops_backend.c:pack_2101010_u32 Unexecuted instantiation: ops_backend.c:pack_1010102_u32 Unexecuted instantiation: ops_backend.c:pack_5650_u8 Unexecuted instantiation: ops_backend.c:pack_5550_u8 Unexecuted instantiation: ops_backend.c:pack_4440_u8 Unexecuted instantiation: ops_backend.c:pack_2101010_u8 Unexecuted instantiation: ops_backend.c:pack_1010102_u8 Unexecuted instantiation: ops_backend.c:pack_3320_u16 Unexecuted instantiation: ops_backend.c:pack_2330_u16 Unexecuted instantiation: ops_backend.c:pack_1210_u16 Unexecuted instantiation: ops_backend.c:pack_2101010_u16 Unexecuted instantiation: ops_backend.c:pack_1010102_u16 Unexecuted instantiation: ops_backend.c:pack_3320_u32 Unexecuted instantiation: ops_backend.c:pack_2330_u32 Unexecuted instantiation: ops_backend.c:pack_1210_u32 Unexecuted instantiation: ops_backend.c:pack_5650_u32 Unexecuted instantiation: ops_backend.c:pack_5550_u32 Unexecuted instantiation: ops_backend.c:pack_4440_u32 |
322 | | \ |
323 | | DECL_ENTRY(pack_##X##Y##Z##W, \ |
324 | | .op = SWS_OP_PACK, \ |
325 | | .pack.pattern = { X, Y, Z, W }, \ |
326 | | ); \ |
327 | | \ |
328 | 0 | inline DECL_IMPL(unpack_##X##Y##Z##W) \ |
329 | 0 | { \ |
330 | 0 | SWS_LOOP \ |
331 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \ |
332 | 0 | const pixel_t val = x[i]; \ |
333 | 0 | x[i] = val >> (Y+Z+W); \ |
334 | 0 | if (Y) \ |
335 | 0 | y[i] = (val >> (Z+W)) & ((1 << Y) - 1); \ |
336 | 0 | if (Z) \ |
337 | 0 | z[i] = (val >> W) & ((1 << Z) - 1); \ |
338 | 0 | if (W) \ |
339 | 0 | w[i] = val & ((1 << W) - 1); \ |
340 | 0 | } \ |
341 | 0 | \ |
342 | 0 | CONTINUE(block_t, x, y, z, w); \ |
343 | 0 | } \ Unexecuted instantiation: ops_backend.c:unpack_1210_u8 Unexecuted instantiation: ops_backend.c:unpack_2330_u8 Unexecuted instantiation: ops_backend.c:unpack_3320_u8 Unexecuted instantiation: ops_backend.c:unpack_4440_u16 Unexecuted instantiation: ops_backend.c:unpack_5550_u16 Unexecuted instantiation: ops_backend.c:unpack_5650_u16 Unexecuted instantiation: ops_backend.c:unpack_2101010_u32 Unexecuted instantiation: ops_backend.c:unpack_1010102_u32 Unexecuted instantiation: ops_backend.c:unpack_5650_u8 Unexecuted instantiation: ops_backend.c:unpack_5550_u8 Unexecuted instantiation: ops_backend.c:unpack_4440_u8 Unexecuted instantiation: ops_backend.c:unpack_2101010_u8 Unexecuted instantiation: ops_backend.c:unpack_1010102_u8 Unexecuted instantiation: ops_backend.c:unpack_3320_u16 Unexecuted instantiation: ops_backend.c:unpack_2330_u16 Unexecuted instantiation: ops_backend.c:unpack_1210_u16 Unexecuted instantiation: ops_backend.c:unpack_2101010_u16 Unexecuted instantiation: ops_backend.c:unpack_1010102_u16 Unexecuted instantiation: ops_backend.c:unpack_3320_u32 Unexecuted instantiation: ops_backend.c:unpack_2330_u32 Unexecuted instantiation: ops_backend.c:unpack_1210_u32 Unexecuted instantiation: ops_backend.c:unpack_5650_u32 Unexecuted instantiation: ops_backend.c:unpack_5550_u32 Unexecuted instantiation: ops_backend.c:unpack_4440_u32 |
344 | | \ |
345 | | DECL_ENTRY(unpack_##X##Y##Z##W, \ |
346 | | .op = SWS_OP_UNPACK, \ |
347 | | .pack.pattern = { X, Y, Z, W }, \ |
348 | | ); |
349 | | |
350 | | WRAP_PACK_UNPACK( 3, 3, 2, 0) |
351 | | WRAP_PACK_UNPACK( 2, 3, 3, 0) |
352 | | WRAP_PACK_UNPACK( 1, 2, 1, 0) |
353 | | WRAP_PACK_UNPACK( 5, 6, 5, 0) |
354 | | WRAP_PACK_UNPACK( 5, 5, 5, 0) |
355 | | WRAP_PACK_UNPACK( 4, 4, 4, 0) |
356 | | WRAP_PACK_UNPACK( 2, 10, 10, 10) |
357 | | WRAP_PACK_UNPACK(10, 10, 10, 2) |
358 | | |
359 | | #if BIT_DEPTH != 8 |
360 | | DECL_PATTERN(lshift) |
361 | 0 | { |
362 | 0 | const uint8_t amount = impl->priv.u8[0]; |
363 | |
|
364 | 0 | SWS_LOOP |
365 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
366 | 0 | x[i] <<= amount; |
367 | 0 | y[i] <<= amount; |
368 | 0 | z[i] <<= amount; |
369 | 0 | w[i] <<= amount; |
370 | 0 | } |
371 | |
|
372 | 0 | CONTINUE(block_t, x, y, z, w); |
373 | 0 | } Unexecuted instantiation: ops_backend.c:lshift_u16 Unexecuted instantiation: ops_backend.c:lshift_u32 |
374 | | |
375 | | DECL_PATTERN(rshift) |
376 | 0 | { |
377 | 0 | const uint8_t amount = impl->priv.u8[0]; |
378 | |
|
379 | 0 | SWS_LOOP |
380 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
381 | 0 | x[i] >>= amount; |
382 | 0 | y[i] >>= amount; |
383 | 0 | z[i] >>= amount; |
384 | 0 | w[i] >>= amount; |
385 | 0 | } |
386 | |
|
387 | 0 | CONTINUE(block_t, x, y, z, w); |
388 | 0 | } Unexecuted instantiation: ops_backend.c:rshift_u16 Unexecuted instantiation: ops_backend.c:rshift_u32 |
389 | | |
390 | | WRAP_COMMON_PATTERNS(lshift, |
391 | | .op = SWS_OP_LSHIFT, |
392 | | .setup = ff_sws_setup_u8, |
393 | | .flexible = true, |
394 | | ); |
395 | | |
396 | | WRAP_COMMON_PATTERNS(rshift, |
397 | | .op = SWS_OP_RSHIFT, |
398 | | .setup = ff_sws_setup_u8, |
399 | | .flexible = true, |
400 | | ); |
401 | | #endif /* BIT_DEPTH != 8 */ |
402 | | |
403 | | DECL_PATTERN(convert_float) |
404 | 0 | { |
405 | 0 | f32block_t xf, yf, zf, wf; |
406 | |
|
407 | 0 | SWS_LOOP |
408 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
409 | 0 | xf[i] = x[i]; |
410 | 0 | yf[i] = y[i]; |
411 | 0 | zf[i] = z[i]; |
412 | 0 | wf[i] = w[i]; |
413 | 0 | } |
414 | |
|
415 | 0 | CONTINUE(f32block_t, xf, yf, zf, wf); |
416 | 0 | } Unexecuted instantiation: ops_backend.c:convert_float_u8 Unexecuted instantiation: ops_backend.c:convert_float_u16 Unexecuted instantiation: ops_backend.c:convert_float_u32 |
417 | | |
418 | | WRAP_COMMON_PATTERNS(convert_float, |
419 | | .op = SWS_OP_CONVERT, |
420 | | .convert.to = SWS_PIXEL_F32, |
421 | | ); |
422 | | |
423 | | /** |
424 | | * Swizzle by directly swapping the order of arguments to the continuation. |
425 | | * Note that this is only safe to do if no arguments are duplicated. |
426 | | */ |
427 | | #define DECL_SWIZZLE(X, Y, Z, W) \ |
428 | | static SWS_FUNC void \ |
429 | | fn(swizzle_##X##Y##Z##W)(SwsOpIter *restrict iter, \ |
430 | | const SwsOpImpl *restrict impl, \ |
431 | 0 | block_t c0, block_t c1, block_t c2, block_t c3) \ |
432 | 0 | { \ |
433 | 0 | CONTINUE(block_t, c##X, c##Y, c##Z, c##W); \ |
434 | 0 | } \ Unexecuted instantiation: ops_backend.c:swizzle_3012_u8 Unexecuted instantiation: ops_backend.c:swizzle_3021_u8 Unexecuted instantiation: ops_backend.c:swizzle_2103_u8 Unexecuted instantiation: ops_backend.c:swizzle_3210_u8 Unexecuted instantiation: ops_backend.c:swizzle_3102_u8 Unexecuted instantiation: ops_backend.c:swizzle_3201_u8 Unexecuted instantiation: ops_backend.c:swizzle_1203_u8 Unexecuted instantiation: ops_backend.c:swizzle_1023_u8 Unexecuted instantiation: ops_backend.c:swizzle_2013_u8 Unexecuted instantiation: ops_backend.c:swizzle_2310_u8 Unexecuted instantiation: ops_backend.c:swizzle_2130_u8 Unexecuted instantiation: ops_backend.c:swizzle_1230_u8 Unexecuted instantiation: ops_backend.c:swizzle_1320_u8 Unexecuted instantiation: ops_backend.c:swizzle_0213_u8 Unexecuted instantiation: ops_backend.c:swizzle_0231_u8 Unexecuted instantiation: ops_backend.c:swizzle_0312_u8 Unexecuted instantiation: ops_backend.c:swizzle_3120_u8 Unexecuted instantiation: ops_backend.c:swizzle_0321_u8 Unexecuted instantiation: ops_backend.c:swizzle_3012_u16 Unexecuted instantiation: ops_backend.c:swizzle_3021_u16 Unexecuted instantiation: ops_backend.c:swizzle_2103_u16 Unexecuted instantiation: ops_backend.c:swizzle_3210_u16 Unexecuted instantiation: ops_backend.c:swizzle_3102_u16 Unexecuted instantiation: ops_backend.c:swizzle_3201_u16 Unexecuted instantiation: ops_backend.c:swizzle_1203_u16 Unexecuted instantiation: ops_backend.c:swizzle_1023_u16 Unexecuted instantiation: ops_backend.c:swizzle_2013_u16 Unexecuted instantiation: ops_backend.c:swizzle_2310_u16 Unexecuted instantiation: ops_backend.c:swizzle_2130_u16 Unexecuted instantiation: ops_backend.c:swizzle_1230_u16 Unexecuted instantiation: ops_backend.c:swizzle_1320_u16 Unexecuted instantiation: ops_backend.c:swizzle_0213_u16 Unexecuted instantiation: ops_backend.c:swizzle_0231_u16 Unexecuted instantiation: ops_backend.c:swizzle_0312_u16 Unexecuted instantiation: ops_backend.c:swizzle_3120_u16 Unexecuted instantiation: ops_backend.c:swizzle_0321_u16 Unexecuted instantiation: ops_backend.c:swizzle_3012_u32 Unexecuted instantiation: ops_backend.c:swizzle_3021_u32 Unexecuted instantiation: ops_backend.c:swizzle_2103_u32 Unexecuted instantiation: ops_backend.c:swizzle_3210_u32 Unexecuted instantiation: ops_backend.c:swizzle_3102_u32 Unexecuted instantiation: ops_backend.c:swizzle_3201_u32 Unexecuted instantiation: ops_backend.c:swizzle_1203_u32 Unexecuted instantiation: ops_backend.c:swizzle_1023_u32 Unexecuted instantiation: ops_backend.c:swizzle_2013_u32 Unexecuted instantiation: ops_backend.c:swizzle_2310_u32 Unexecuted instantiation: ops_backend.c:swizzle_2130_u32 Unexecuted instantiation: ops_backend.c:swizzle_1230_u32 Unexecuted instantiation: ops_backend.c:swizzle_1320_u32 Unexecuted instantiation: ops_backend.c:swizzle_0213_u32 Unexecuted instantiation: ops_backend.c:swizzle_0231_u32 Unexecuted instantiation: ops_backend.c:swizzle_0312_u32 Unexecuted instantiation: ops_backend.c:swizzle_3120_u32 Unexecuted instantiation: ops_backend.c:swizzle_0321_u32 |
435 | | \ |
436 | | DECL_ENTRY(swizzle_##X##Y##Z##W, \ |
437 | | .op = SWS_OP_SWIZZLE, \ |
438 | | .swizzle.in = { X, Y, Z, W }, \ |
439 | | ); |
440 | | |
441 | | DECL_SWIZZLE(3, 0, 1, 2) |
442 | | DECL_SWIZZLE(3, 0, 2, 1) |
443 | | DECL_SWIZZLE(2, 1, 0, 3) |
444 | | DECL_SWIZZLE(3, 2, 1, 0) |
445 | | DECL_SWIZZLE(3, 1, 0, 2) |
446 | | DECL_SWIZZLE(3, 2, 0, 1) |
447 | | DECL_SWIZZLE(1, 2, 0, 3) |
448 | | DECL_SWIZZLE(1, 0, 2, 3) |
449 | | DECL_SWIZZLE(2, 0, 1, 3) |
450 | | DECL_SWIZZLE(2, 3, 1, 0) |
451 | | DECL_SWIZZLE(2, 1, 3, 0) |
452 | | DECL_SWIZZLE(1, 2, 3, 0) |
453 | | DECL_SWIZZLE(1, 3, 2, 0) |
454 | | DECL_SWIZZLE(0, 2, 1, 3) |
455 | | DECL_SWIZZLE(0, 2, 3, 1) |
456 | | DECL_SWIZZLE(0, 3, 1, 2) |
457 | | DECL_SWIZZLE(3, 1, 2, 0) |
458 | | DECL_SWIZZLE(0, 3, 2, 1) |
459 | | |
460 | | /* Broadcast luma -> rgb (only used for y(a) -> rgb(a)) */ |
461 | | #define DECL_EXPAND_LUMA(X, W, T0, T1) \ |
462 | | static SWS_FUNC void \ |
463 | | fn(expand_luma_##X##W)(SwsOpIter *restrict iter, \ |
464 | | const SwsOpImpl *restrict impl, \ |
465 | 0 | block_t c0, block_t c1, block_t c2, block_t c3) \ |
466 | 0 | { \ |
467 | 0 | SWS_LOOP \ |
468 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) \ |
469 | 0 | T0[i] = T1[i] = c0[i]; \ |
470 | 0 | \ |
471 | 0 | CONTINUE(block_t, c##X, T0, T1, c##W); \ |
472 | 0 | } \ Unexecuted instantiation: ops_backend.c:expand_luma_03_u8 Unexecuted instantiation: ops_backend.c:expand_luma_30_u8 Unexecuted instantiation: ops_backend.c:expand_luma_10_u8 Unexecuted instantiation: ops_backend.c:expand_luma_01_u8 Unexecuted instantiation: ops_backend.c:expand_luma_03_u16 Unexecuted instantiation: ops_backend.c:expand_luma_30_u16 Unexecuted instantiation: ops_backend.c:expand_luma_10_u16 Unexecuted instantiation: ops_backend.c:expand_luma_01_u16 Unexecuted instantiation: ops_backend.c:expand_luma_03_u32 Unexecuted instantiation: ops_backend.c:expand_luma_30_u32 Unexecuted instantiation: ops_backend.c:expand_luma_10_u32 Unexecuted instantiation: ops_backend.c:expand_luma_01_u32 |
473 | | \ |
474 | | DECL_ENTRY(expand_luma_##X##W, \ |
475 | | .op = SWS_OP_SWIZZLE, \ |
476 | | .swizzle.in = { X, 0, 0, W }, \ |
477 | | ); |
478 | | |
479 | | DECL_EXPAND_LUMA(0, 3, c1, c2) |
480 | | DECL_EXPAND_LUMA(3, 0, c1, c2) |
481 | | DECL_EXPAND_LUMA(1, 0, c2, c3) |
482 | | DECL_EXPAND_LUMA(0, 1, c2, c3) |
483 | | |
484 | | static const SwsOpTable fn(op_table_int) = { |
485 | | .block_size = SWS_BLOCK_SIZE, |
486 | | .entries = { |
487 | | &fn(op_read_planar1), |
488 | | &fn(op_read_planar2), |
489 | | &fn(op_read_planar3), |
490 | | &fn(op_read_planar4), |
491 | | &fn(op_read_packed2), |
492 | | &fn(op_read_packed3), |
493 | | &fn(op_read_packed4), |
494 | | |
495 | | &fn(op_write_planar1), |
496 | | &fn(op_write_planar2), |
497 | | &fn(op_write_planar3), |
498 | | &fn(op_write_planar4), |
499 | | &fn(op_write_packed2), |
500 | | &fn(op_write_packed3), |
501 | | &fn(op_write_packed4), |
502 | | |
503 | | #if BIT_DEPTH == 8 |
504 | | &fn(op_read_bits1), |
505 | | &fn(op_read_nibbles1), |
506 | | &fn(op_write_bits1), |
507 | | &fn(op_write_nibbles1), |
508 | | |
509 | | &fn(op_pack_1210), |
510 | | &fn(op_pack_2330), |
511 | | &fn(op_pack_3320), |
512 | | |
513 | | &fn(op_unpack_1210), |
514 | | &fn(op_unpack_2330), |
515 | | &fn(op_unpack_3320), |
516 | | |
517 | | REF_COMMON_PATTERNS(expand16), |
518 | | REF_COMMON_PATTERNS(expand32), |
519 | | #elif BIT_DEPTH == 16 |
520 | | &fn(op_pack_4440), |
521 | | &fn(op_pack_5550), |
522 | | &fn(op_pack_5650), |
523 | | &fn(op_unpack_4440), |
524 | | &fn(op_unpack_5550), |
525 | | &fn(op_unpack_5650), |
526 | | #elif BIT_DEPTH == 32 |
527 | | &fn(op_pack_2101010), |
528 | | &fn(op_pack_1010102), |
529 | | &fn(op_unpack_2101010), |
530 | | &fn(op_unpack_1010102), |
531 | | #endif |
532 | | |
533 | | #ifdef SWAP_BYTES |
534 | | REF_COMMON_PATTERNS(swap_bytes), |
535 | | #endif |
536 | | |
537 | | REF_COMMON_PATTERNS(min), |
538 | | REF_COMMON_PATTERNS(max), |
539 | | REF_COMMON_PATTERNS(scale), |
540 | | REF_COMMON_PATTERNS(convert_float), |
541 | | |
542 | | &fn(op_clear_1110), |
543 | | &fn(op_clear_0111), |
544 | | &fn(op_clear_0011), |
545 | | &fn(op_clear_1001), |
546 | | &fn(op_clear_1100), |
547 | | &fn(op_clear_0101), |
548 | | &fn(op_clear_1010), |
549 | | &fn(op_clear_1000), |
550 | | &fn(op_clear_0100), |
551 | | &fn(op_clear_0010), |
552 | | |
553 | | &fn(op_swizzle_3012), |
554 | | &fn(op_swizzle_3021), |
555 | | &fn(op_swizzle_2103), |
556 | | &fn(op_swizzle_3210), |
557 | | &fn(op_swizzle_3102), |
558 | | &fn(op_swizzle_3201), |
559 | | &fn(op_swizzle_1203), |
560 | | &fn(op_swizzle_1023), |
561 | | &fn(op_swizzle_2013), |
562 | | &fn(op_swizzle_2310), |
563 | | &fn(op_swizzle_2130), |
564 | | &fn(op_swizzle_1230), |
565 | | &fn(op_swizzle_1320), |
566 | | &fn(op_swizzle_0213), |
567 | | &fn(op_swizzle_0231), |
568 | | &fn(op_swizzle_0312), |
569 | | &fn(op_swizzle_3120), |
570 | | &fn(op_swizzle_0321), |
571 | | |
572 | | &fn(op_expand_luma_03), |
573 | | &fn(op_expand_luma_30), |
574 | | &fn(op_expand_luma_10), |
575 | | &fn(op_expand_luma_01), |
576 | | |
577 | | #if BIT_DEPTH != 8 |
578 | | REF_COMMON_PATTERNS(lshift), |
579 | | REF_COMMON_PATTERNS(rshift), |
580 | | REF_COMMON_PATTERNS(convert_uint8), |
581 | | #endif /* BIT_DEPTH != 8 */ |
582 | | |
583 | | #if BIT_DEPTH != 16 |
584 | | REF_COMMON_PATTERNS(convert_uint16), |
585 | | #endif |
586 | | #if BIT_DEPTH != 32 |
587 | | REF_COMMON_PATTERNS(convert_uint32), |
588 | | #endif |
589 | | |
590 | | NULL |
591 | | }, |
592 | | }; |
593 | | |
594 | | #undef PIXEL_TYPE |
595 | | #undef PIXEL_MAX |
596 | | #undef PIXEL_MIN |
597 | | #undef SWAP_BYTES |
598 | | #undef pixel_t |
599 | | #undef block_t |
600 | | #undef px |
601 | | |
602 | | #undef FMT_CHAR |
603 | | #undef IS_FLOAT |