/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 | | # 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 | | # 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 | | # 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 | SWS_LOOP |
62 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
63 | 0 | x[i] = in0[i]; |
64 | 0 | if (elems > 1) |
65 | 0 | y[i] = in1[i]; |
66 | 0 | if (elems > 2) |
67 | 0 | z[i] = in2[i]; |
68 | 0 | if (elems > 3) |
69 | 0 | w[i] = in3[i]; |
70 | 0 | } |
71 | |
|
72 | 0 | CONTINUE(block_t, x, y, z, w); |
73 | 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 |
74 | | |
75 | | DECL_READ(read_packed, const int elems) |
76 | 0 | { |
77 | 0 | SWS_LOOP |
78 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
79 | 0 | x[i] = in0[elems * i + 0]; |
80 | 0 | if (elems > 1) |
81 | 0 | y[i] = in0[elems * i + 1]; |
82 | 0 | if (elems > 2) |
83 | 0 | z[i] = in0[elems * i + 2]; |
84 | 0 | if (elems > 3) |
85 | 0 | w[i] = in0[elems * i + 3]; |
86 | 0 | } |
87 | |
|
88 | 0 | CONTINUE(block_t, x, y, z, w); |
89 | 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 |
90 | | |
91 | | DECL_WRITE(write_planar, const int elems) |
92 | 0 | { |
93 | 0 | SWS_LOOP |
94 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
95 | 0 | out0[i] = x[i]; |
96 | 0 | if (elems > 1) |
97 | 0 | out1[i] = y[i]; |
98 | 0 | if (elems > 2) |
99 | 0 | out2[i] = z[i]; |
100 | 0 | if (elems > 3) |
101 | 0 | out3[i] = w[i]; |
102 | 0 | } |
103 | 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 |
104 | | |
105 | | DECL_WRITE(write_packed, const int elems) |
106 | 0 | { |
107 | 0 | SWS_LOOP |
108 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
109 | 0 | out0[elems * i + 0] = x[i]; |
110 | 0 | if (elems > 1) |
111 | 0 | out0[elems * i + 1] = y[i]; |
112 | 0 | if (elems > 2) |
113 | 0 | out0[elems * i + 2] = z[i]; |
114 | 0 | if (elems > 3) |
115 | 0 | out0[elems * i + 3] = w[i]; |
116 | 0 | } |
117 | 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 |
118 | | |
119 | | #define WRAP_READ(FUNC, ELEMS, FRAC, PACKED) \ |
120 | 0 | DECL_IMPL(FUNC##ELEMS) \ |
121 | 0 | { \ |
122 | 0 | CALL_READ(FUNC, ELEMS); \ |
123 | 0 | for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \ |
124 | 0 | iter->in[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \ |
125 | 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 |
126 | | \ |
127 | | DECL_ENTRY(FUNC##ELEMS, \ |
128 | | .op = SWS_OP_READ, \ |
129 | | .rw = { \ |
130 | | .elems = ELEMS, \ |
131 | | .packed = PACKED, \ |
132 | | .frac = FRAC, \ |
133 | | }, \ |
134 | | ); |
135 | | |
136 | | WRAP_READ(read_planar, 1, 0, false) |
137 | | WRAP_READ(read_planar, 2, 0, false) |
138 | | WRAP_READ(read_planar, 3, 0, false) |
139 | | WRAP_READ(read_planar, 4, 0, false) |
140 | | WRAP_READ(read_packed, 2, 0, true) |
141 | | WRAP_READ(read_packed, 3, 0, true) |
142 | | WRAP_READ(read_packed, 4, 0, true) |
143 | | |
144 | | #define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED) \ |
145 | 0 | DECL_IMPL(FUNC##ELEMS) \ |
146 | 0 | { \ |
147 | 0 | CALL_WRITE(FUNC, ELEMS); \ |
148 | 0 | for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \ |
149 | 0 | iter->out[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \ |
150 | 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 |
151 | | \ |
152 | | DECL_ENTRY(FUNC##ELEMS, \ |
153 | | .op = SWS_OP_WRITE, \ |
154 | | .rw = { \ |
155 | | .elems = ELEMS, \ |
156 | | .packed = PACKED, \ |
157 | | .frac = FRAC, \ |
158 | | }, \ |
159 | | ); |
160 | | |
161 | | WRAP_WRITE(write_planar, 1, 0, false) |
162 | | WRAP_WRITE(write_planar, 2, 0, false) |
163 | | WRAP_WRITE(write_planar, 3, 0, false) |
164 | | WRAP_WRITE(write_planar, 4, 0, false) |
165 | | WRAP_WRITE(write_packed, 2, 0, true) |
166 | | WRAP_WRITE(write_packed, 3, 0, true) |
167 | | WRAP_WRITE(write_packed, 4, 0, true) |
168 | | |
169 | | #if BIT_DEPTH == 8 |
170 | | DECL_READ(read_nibbles, const int elems) |
171 | 0 | { |
172 | 0 | SWS_LOOP |
173 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 2) { |
174 | 0 | const pixel_t val = ((const pixel_t *) in0)[i >> 1]; |
175 | 0 | x[i + 0] = val >> 4; /* high nibble */ |
176 | 0 | x[i + 1] = val & 0xF; /* low nibble */ |
177 | 0 | } |
178 | |
|
179 | 0 | CONTINUE(block_t, x, y, z, w); |
180 | 0 | } |
181 | | |
182 | | DECL_READ(read_bits, const int elems) |
183 | 0 | { |
184 | 0 | SWS_LOOP |
185 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) { |
186 | 0 | const pixel_t val = ((const pixel_t *) in0)[i >> 3]; |
187 | 0 | x[i + 0] = (val >> 7) & 1; |
188 | 0 | x[i + 1] = (val >> 6) & 1; |
189 | 0 | x[i + 2] = (val >> 5) & 1; |
190 | 0 | x[i + 3] = (val >> 4) & 1; |
191 | 0 | x[i + 4] = (val >> 3) & 1; |
192 | 0 | x[i + 5] = (val >> 2) & 1; |
193 | 0 | x[i + 6] = (val >> 1) & 1; |
194 | 0 | x[i + 7] = (val >> 0) & 1; |
195 | 0 | } |
196 | |
|
197 | 0 | CONTINUE(block_t, x, y, z, w); |
198 | 0 | } |
199 | | |
200 | | WRAP_READ(read_nibbles, 1, 1, false) |
201 | | WRAP_READ(read_bits, 1, 3, false) |
202 | | |
203 | | DECL_WRITE(write_nibbles, const int elems) |
204 | 0 | { |
205 | 0 | SWS_LOOP |
206 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 2) |
207 | 0 | out0[i >> 1] = x[i] << 4 | x[i + 1]; |
208 | 0 | } |
209 | | |
210 | | DECL_WRITE(write_bits, const int elems) |
211 | 0 | { |
212 | 0 | SWS_LOOP |
213 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i += 8) { |
214 | 0 | out0[i >> 3] = x[i + 0] << 7 | |
215 | 0 | x[i + 1] << 6 | |
216 | 0 | x[i + 2] << 5 | |
217 | 0 | x[i + 3] << 4 | |
218 | 0 | x[i + 4] << 3 | |
219 | 0 | x[i + 5] << 2 | |
220 | 0 | x[i + 6] << 1 | |
221 | 0 | x[i + 7]; |
222 | 0 | } |
223 | 0 | } |
224 | | |
225 | | WRAP_WRITE(write_nibbles, 1, 1, false) |
226 | | WRAP_WRITE(write_bits, 1, 3, false) |
227 | | #endif /* BIT_DEPTH == 8 */ |
228 | | |
229 | | #ifdef SWAP_BYTES |
230 | | DECL_PATTERN(swap_bytes) |
231 | 0 | { |
232 | 0 | SWS_LOOP |
233 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
234 | 0 | if (X) |
235 | 0 | x[i] = SWAP_BYTES(x[i]); |
236 | 0 | if (Y) |
237 | 0 | y[i] = SWAP_BYTES(y[i]); |
238 | 0 | if (Z) |
239 | 0 | z[i] = SWAP_BYTES(z[i]); |
240 | 0 | if (W) |
241 | 0 | w[i] = SWAP_BYTES(w[i]); |
242 | 0 | } |
243 | |
|
244 | 0 | CONTINUE(block_t, x, y, z, w); |
245 | 0 | } Unexecuted instantiation: ops_backend.c:swap_bytes_u16 Unexecuted instantiation: ops_backend.c:swap_bytes_u32 |
246 | | |
247 | | WRAP_COMMON_PATTERNS(swap_bytes, .op = SWS_OP_SWAP_BYTES); |
248 | | #endif /* SWAP_BYTES */ |
249 | | |
250 | | #if BIT_DEPTH == 8 |
251 | | DECL_PATTERN(expand16) |
252 | 0 | { |
253 | 0 | u16block_t x16, y16, z16, w16; |
254 | |
|
255 | 0 | SWS_LOOP |
256 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
257 | 0 | if (X) |
258 | 0 | x16[i] = x[i] << 8 | x[i]; |
259 | 0 | if (Y) |
260 | 0 | y16[i] = y[i] << 8 | y[i]; |
261 | 0 | if (Z) |
262 | 0 | z16[i] = z[i] << 8 | z[i]; |
263 | 0 | if (W) |
264 | 0 | w16[i] = w[i] << 8 | w[i]; |
265 | 0 | } |
266 | |
|
267 | 0 | CONTINUE(u16block_t, x16, y16, z16, w16); |
268 | 0 | } |
269 | | |
270 | | WRAP_COMMON_PATTERNS(expand16, |
271 | | .op = SWS_OP_CONVERT, |
272 | | .convert.to = SWS_PIXEL_U16, |
273 | | .convert.expand = true, |
274 | | ); |
275 | | |
276 | | DECL_PATTERN(expand32) |
277 | 0 | { |
278 | 0 | u32block_t x32, y32, z32, w32; |
279 | |
|
280 | 0 | SWS_LOOP |
281 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
282 | 0 | x32[i] = (uint32_t)x[i] << 24 | x[i] << 16 | x[i] << 8 | x[i]; |
283 | 0 | y32[i] = (uint32_t)y[i] << 24 | y[i] << 16 | y[i] << 8 | y[i]; |
284 | 0 | z32[i] = (uint32_t)z[i] << 24 | z[i] << 16 | z[i] << 8 | z[i]; |
285 | 0 | w32[i] = (uint32_t)w[i] << 24 | w[i] << 16 | w[i] << 8 | w[i]; |
286 | 0 | } |
287 | |
|
288 | 0 | CONTINUE(u32block_t, x32, y32, z32, w32); |
289 | 0 | } |
290 | | |
291 | | WRAP_COMMON_PATTERNS(expand32, |
292 | | .op = SWS_OP_CONVERT, |
293 | | .convert.to = SWS_PIXEL_U32, |
294 | | .convert.expand = true, |
295 | | ); |
296 | | #endif |
297 | | |
298 | | #define WRAP_PACK_UNPACK(X, Y, Z, W) \ |
299 | 0 | inline DECL_IMPL(pack_##X##Y##Z##W) \ |
300 | 0 | { \ |
301 | 0 | SWS_LOOP \ |
302 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \ |
303 | 0 | x[i] = x[i] << (Y+Z+W); \ |
304 | 0 | if (Y) \ |
305 | 0 | x[i] |= y[i] << (Z+W); \ |
306 | 0 | if (Z) \ |
307 | 0 | x[i] |= z[i] << W; \ |
308 | 0 | if (W) \ |
309 | 0 | x[i] |= w[i]; \ |
310 | 0 | } \ |
311 | 0 | \ |
312 | 0 | CONTINUE(block_t, x, y, z, w); \ |
313 | 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 |
314 | | \ |
315 | | DECL_ENTRY(pack_##X##Y##Z##W, \ |
316 | | .op = SWS_OP_PACK, \ |
317 | | .pack.pattern = { X, Y, Z, W }, \ |
318 | | ); \ |
319 | | \ |
320 | 0 | inline DECL_IMPL(unpack_##X##Y##Z##W) \ |
321 | 0 | { \ |
322 | 0 | SWS_LOOP \ |
323 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \ |
324 | 0 | const pixel_t val = x[i]; \ |
325 | 0 | x[i] = val >> (Y+Z+W); \ |
326 | 0 | if (Y) \ |
327 | 0 | y[i] = (val >> (Z+W)) & ((1 << Y) - 1); \ |
328 | 0 | if (Z) \ |
329 | 0 | z[i] = (val >> W) & ((1 << Z) - 1); \ |
330 | 0 | if (W) \ |
331 | 0 | w[i] = val & ((1 << W) - 1); \ |
332 | 0 | } \ |
333 | 0 | \ |
334 | 0 | CONTINUE(block_t, x, y, z, w); \ |
335 | 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 |
336 | | \ |
337 | | DECL_ENTRY(unpack_##X##Y##Z##W, \ |
338 | | .op = SWS_OP_UNPACK, \ |
339 | | .pack.pattern = { X, Y, Z, W }, \ |
340 | | ); |
341 | | |
342 | | WRAP_PACK_UNPACK( 3, 3, 2, 0) |
343 | | WRAP_PACK_UNPACK( 2, 3, 3, 0) |
344 | | WRAP_PACK_UNPACK( 1, 2, 1, 0) |
345 | | WRAP_PACK_UNPACK( 5, 6, 5, 0) |
346 | | WRAP_PACK_UNPACK( 5, 5, 5, 0) |
347 | | WRAP_PACK_UNPACK( 4, 4, 4, 0) |
348 | | WRAP_PACK_UNPACK( 2, 10, 10, 10) |
349 | | WRAP_PACK_UNPACK(10, 10, 10, 2) |
350 | | |
351 | | #if BIT_DEPTH != 8 |
352 | | DECL_PATTERN(lshift) |
353 | 0 | { |
354 | 0 | const uint8_t amount = impl->priv.u8[0]; |
355 | |
|
356 | 0 | SWS_LOOP |
357 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
358 | 0 | x[i] <<= amount; |
359 | 0 | y[i] <<= amount; |
360 | 0 | z[i] <<= amount; |
361 | 0 | w[i] <<= amount; |
362 | 0 | } |
363 | |
|
364 | 0 | CONTINUE(block_t, x, y, z, w); |
365 | 0 | } Unexecuted instantiation: ops_backend.c:lshift_u16 Unexecuted instantiation: ops_backend.c:lshift_u32 |
366 | | |
367 | | DECL_PATTERN(rshift) |
368 | 0 | { |
369 | 0 | const uint8_t amount = impl->priv.u8[0]; |
370 | |
|
371 | 0 | SWS_LOOP |
372 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
373 | 0 | x[i] >>= amount; |
374 | 0 | y[i] >>= amount; |
375 | 0 | z[i] >>= amount; |
376 | 0 | w[i] >>= amount; |
377 | 0 | } |
378 | |
|
379 | 0 | CONTINUE(block_t, x, y, z, w); |
380 | 0 | } Unexecuted instantiation: ops_backend.c:rshift_u16 Unexecuted instantiation: ops_backend.c:rshift_u32 |
381 | | |
382 | | WRAP_COMMON_PATTERNS(lshift, |
383 | | .op = SWS_OP_LSHIFT, |
384 | | .setup = ff_sws_setup_u8, |
385 | | .flexible = true, |
386 | | ); |
387 | | |
388 | | WRAP_COMMON_PATTERNS(rshift, |
389 | | .op = SWS_OP_RSHIFT, |
390 | | .setup = ff_sws_setup_u8, |
391 | | .flexible = true, |
392 | | ); |
393 | | #endif /* BIT_DEPTH != 8 */ |
394 | | |
395 | | DECL_PATTERN(convert_float) |
396 | 0 | { |
397 | 0 | f32block_t xf, yf, zf, wf; |
398 | |
|
399 | 0 | SWS_LOOP |
400 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) { |
401 | 0 | xf[i] = x[i]; |
402 | 0 | yf[i] = y[i]; |
403 | 0 | zf[i] = z[i]; |
404 | 0 | wf[i] = w[i]; |
405 | 0 | } |
406 | |
|
407 | 0 | CONTINUE(f32block_t, xf, yf, zf, wf); |
408 | 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 |
409 | | |
410 | | WRAP_COMMON_PATTERNS(convert_float, |
411 | | .op = SWS_OP_CONVERT, |
412 | | .convert.to = SWS_PIXEL_F32, |
413 | | ); |
414 | | |
415 | | /** |
416 | | * Swizzle by directly swapping the order of arguments to the continuation. |
417 | | * Note that this is only safe to do if no arguments are duplicated. |
418 | | */ |
419 | | #define DECL_SWIZZLE(X, Y, Z, W) \ |
420 | | static SWS_FUNC void \ |
421 | | fn(swizzle_##X##Y##Z##W)(SwsOpIter *restrict iter, \ |
422 | | const SwsOpImpl *restrict impl, \ |
423 | 0 | block_t c0, block_t c1, block_t c2, block_t c3) \ |
424 | 0 | { \ |
425 | 0 | CONTINUE(block_t, c##X, c##Y, c##Z, c##W); \ |
426 | 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 |
427 | | \ |
428 | | DECL_ENTRY(swizzle_##X##Y##Z##W, \ |
429 | | .op = SWS_OP_SWIZZLE, \ |
430 | | .swizzle.in = { X, Y, Z, W }, \ |
431 | | ); |
432 | | |
433 | | DECL_SWIZZLE(3, 0, 1, 2) |
434 | | DECL_SWIZZLE(3, 0, 2, 1) |
435 | | DECL_SWIZZLE(2, 1, 0, 3) |
436 | | DECL_SWIZZLE(3, 2, 1, 0) |
437 | | DECL_SWIZZLE(3, 1, 0, 2) |
438 | | DECL_SWIZZLE(3, 2, 0, 1) |
439 | | DECL_SWIZZLE(1, 2, 0, 3) |
440 | | DECL_SWIZZLE(1, 0, 2, 3) |
441 | | DECL_SWIZZLE(2, 0, 1, 3) |
442 | | DECL_SWIZZLE(2, 3, 1, 0) |
443 | | DECL_SWIZZLE(2, 1, 3, 0) |
444 | | DECL_SWIZZLE(1, 2, 3, 0) |
445 | | DECL_SWIZZLE(1, 3, 2, 0) |
446 | | DECL_SWIZZLE(0, 2, 1, 3) |
447 | | DECL_SWIZZLE(0, 2, 3, 1) |
448 | | DECL_SWIZZLE(0, 3, 1, 2) |
449 | | DECL_SWIZZLE(3, 1, 2, 0) |
450 | | DECL_SWIZZLE(0, 3, 2, 1) |
451 | | |
452 | | /* Broadcast luma -> rgb (only used for y(a) -> rgb(a)) */ |
453 | | #define DECL_EXPAND_LUMA(X, W, T0, T1) \ |
454 | | static SWS_FUNC void \ |
455 | | fn(expand_luma_##X##W)(SwsOpIter *restrict iter, \ |
456 | | const SwsOpImpl *restrict impl, \ |
457 | 0 | block_t c0, block_t c1, block_t c2, block_t c3) \ |
458 | 0 | { \ |
459 | 0 | SWS_LOOP \ |
460 | 0 | for (int i = 0; i < SWS_BLOCK_SIZE; i++) \ |
461 | 0 | T0[i] = T1[i] = c0[i]; \ |
462 | 0 | \ |
463 | 0 | CONTINUE(block_t, c##X, T0, T1, c##W); \ |
464 | 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 |
465 | | \ |
466 | | DECL_ENTRY(expand_luma_##X##W, \ |
467 | | .op = SWS_OP_SWIZZLE, \ |
468 | | .swizzle.in = { X, 0, 0, W }, \ |
469 | | ); |
470 | | |
471 | | DECL_EXPAND_LUMA(0, 3, c1, c2) |
472 | | DECL_EXPAND_LUMA(3, 0, c1, c2) |
473 | | DECL_EXPAND_LUMA(1, 0, c2, c3) |
474 | | DECL_EXPAND_LUMA(0, 1, c2, c3) |
475 | | |
476 | | static const SwsOpTable fn(op_table_int) = { |
477 | | .block_size = SWS_BLOCK_SIZE, |
478 | | .entries = { |
479 | | &fn(op_read_planar1), |
480 | | &fn(op_read_planar2), |
481 | | &fn(op_read_planar3), |
482 | | &fn(op_read_planar4), |
483 | | &fn(op_read_packed2), |
484 | | &fn(op_read_packed3), |
485 | | &fn(op_read_packed4), |
486 | | |
487 | | &fn(op_write_planar1), |
488 | | &fn(op_write_planar2), |
489 | | &fn(op_write_planar3), |
490 | | &fn(op_write_planar4), |
491 | | &fn(op_write_packed2), |
492 | | &fn(op_write_packed3), |
493 | | &fn(op_write_packed4), |
494 | | |
495 | | #if BIT_DEPTH == 8 |
496 | | &fn(op_read_bits1), |
497 | | &fn(op_read_nibbles1), |
498 | | &fn(op_write_bits1), |
499 | | &fn(op_write_nibbles1), |
500 | | |
501 | | &fn(op_pack_1210), |
502 | | &fn(op_pack_2330), |
503 | | &fn(op_pack_3320), |
504 | | |
505 | | &fn(op_unpack_1210), |
506 | | &fn(op_unpack_2330), |
507 | | &fn(op_unpack_3320), |
508 | | |
509 | | REF_COMMON_PATTERNS(expand16), |
510 | | REF_COMMON_PATTERNS(expand32), |
511 | | #elif BIT_DEPTH == 16 |
512 | | &fn(op_pack_4440), |
513 | | &fn(op_pack_5550), |
514 | | &fn(op_pack_5650), |
515 | | &fn(op_unpack_4440), |
516 | | &fn(op_unpack_5550), |
517 | | &fn(op_unpack_5650), |
518 | | #elif BIT_DEPTH == 32 |
519 | | &fn(op_pack_2101010), |
520 | | &fn(op_pack_1010102), |
521 | | &fn(op_unpack_2101010), |
522 | | &fn(op_unpack_1010102), |
523 | | #endif |
524 | | |
525 | | #ifdef SWAP_BYTES |
526 | | REF_COMMON_PATTERNS(swap_bytes), |
527 | | #endif |
528 | | |
529 | | REF_COMMON_PATTERNS(min), |
530 | | REF_COMMON_PATTERNS(max), |
531 | | REF_COMMON_PATTERNS(scale), |
532 | | REF_COMMON_PATTERNS(convert_float), |
533 | | |
534 | | &fn(op_clear_1110), |
535 | | &fn(op_clear_0111), |
536 | | &fn(op_clear_0011), |
537 | | &fn(op_clear_1011), |
538 | | &fn(op_clear_1001), |
539 | | &fn(op_clear_1100), |
540 | | &fn(op_clear_0101), |
541 | | &fn(op_clear_1010), |
542 | | &fn(op_clear_1000), |
543 | | &fn(op_clear_0100), |
544 | | &fn(op_clear_0010), |
545 | | |
546 | | &fn(op_swizzle_3012), |
547 | | &fn(op_swizzle_3021), |
548 | | &fn(op_swizzle_2103), |
549 | | &fn(op_swizzle_3210), |
550 | | &fn(op_swizzle_3102), |
551 | | &fn(op_swizzle_3201), |
552 | | &fn(op_swizzle_1203), |
553 | | &fn(op_swizzle_1023), |
554 | | &fn(op_swizzle_2013), |
555 | | &fn(op_swizzle_2310), |
556 | | &fn(op_swizzle_2130), |
557 | | &fn(op_swizzle_1230), |
558 | | &fn(op_swizzle_1320), |
559 | | &fn(op_swizzle_0213), |
560 | | &fn(op_swizzle_0231), |
561 | | &fn(op_swizzle_0312), |
562 | | &fn(op_swizzle_3120), |
563 | | &fn(op_swizzle_0321), |
564 | | |
565 | | &fn(op_expand_luma_03), |
566 | | &fn(op_expand_luma_30), |
567 | | &fn(op_expand_luma_10), |
568 | | &fn(op_expand_luma_01), |
569 | | |
570 | | #if BIT_DEPTH != 8 |
571 | | REF_COMMON_PATTERNS(lshift), |
572 | | REF_COMMON_PATTERNS(rshift), |
573 | | REF_COMMON_PATTERNS(convert_uint8), |
574 | | #endif /* BIT_DEPTH != 8 */ |
575 | | |
576 | | #if BIT_DEPTH != 16 |
577 | | REF_COMMON_PATTERNS(convert_uint16), |
578 | | #endif |
579 | | #if BIT_DEPTH != 32 |
580 | | REF_COMMON_PATTERNS(convert_uint32), |
581 | | #endif |
582 | | |
583 | | NULL |
584 | | }, |
585 | | }; |
586 | | |
587 | | #undef PIXEL_TYPE |
588 | | #undef PIXEL_MAX |
589 | | #undef PIXEL_MIN |
590 | | #undef SWAP_BYTES |
591 | | #undef pixel_t |
592 | | #undef block_t |
593 | | #undef px |
594 | | |
595 | | #undef FMT_CHAR |
596 | | #undef IS_FLOAT |