/src/ffmpeg/libswscale/rgb2rgb.c
Line | Count | Source |
1 | | /* |
2 | | * software RGB to RGB converter |
3 | | * pluralize by software PAL8 to RGB converter |
4 | | * software YUV to YUV converter |
5 | | * software YUV to RGB converter |
6 | | * Written by Nick Kurshev. |
7 | | * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at) |
8 | | * |
9 | | * This file is part of FFmpeg. |
10 | | * |
11 | | * FFmpeg is free software; you can redistribute it and/or |
12 | | * modify it under the terms of the GNU Lesser General Public |
13 | | * License as published by the Free Software Foundation; either |
14 | | * version 2.1 of the License, or (at your option) any later version. |
15 | | * |
16 | | * FFmpeg is distributed in the hope that it will be useful, |
17 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | | * Lesser General Public License for more details. |
20 | | * |
21 | | * You should have received a copy of the GNU Lesser General Public |
22 | | * License along with FFmpeg; if not, write to the Free Software |
23 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | | */ |
25 | | |
26 | | #include <inttypes.h> |
27 | | |
28 | | #include "libavutil/attributes.h" |
29 | | #include "libavutil/bswap.h" |
30 | | #include "config.h" |
31 | | #include "rgb2rgb.h" |
32 | | #include "swscale.h" |
33 | | #include "swscale_internal.h" |
34 | | |
35 | | void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); |
36 | | void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); |
37 | | void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); |
38 | | void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size); |
39 | | void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); |
40 | | void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); |
41 | | void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); |
42 | | void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); |
43 | | void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); |
44 | | |
45 | | void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size); |
46 | | void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size); |
47 | | void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size); |
48 | | void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size); |
49 | | void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size); |
50 | | void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size); |
51 | | void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size); |
52 | | void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size); |
53 | | |
54 | | void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size); |
55 | | void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); |
56 | | void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size); |
57 | | void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size); |
58 | | void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size); |
59 | | void (*shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size); |
60 | | void (*shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size); |
61 | | void (*shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size); |
62 | | void (*shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size); |
63 | | |
64 | | |
65 | | void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, |
66 | | const uint8_t *vsrc, uint8_t *dst, |
67 | | int width, int height, |
68 | | int lumStride, int chromStride, int dstStride); |
69 | | void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, |
70 | | const uint8_t *vsrc, uint8_t *dst, |
71 | | int width, int height, |
72 | | int lumStride, int chromStride, int dstStride); |
73 | | void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, |
74 | | const uint8_t *vsrc, uint8_t *dst, |
75 | | int width, int height, |
76 | | int lumStride, int chromStride, int dstStride); |
77 | | void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, |
78 | | const uint8_t *vsrc, uint8_t *dst, |
79 | | int width, int height, |
80 | | int lumStride, int chromStride, int dstStride); |
81 | | void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, |
82 | | uint8_t *udst, uint8_t *vdst, |
83 | | int width, int height, |
84 | | int lumStride, int chromStride, int srcStride); |
85 | | void (*ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, |
86 | | uint8_t *udst, uint8_t *vdst, |
87 | | int width, int height, |
88 | | int lumStride, int chromStride, int srcStride, |
89 | | const int32_t *rgb2yuv); |
90 | | void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, |
91 | | int srcStride, int dstStride); |
92 | | void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, |
93 | | int width, int height, int src1Stride, |
94 | | int src2Stride, int dstStride); |
95 | | void (*deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, |
96 | | int width, int height, int srcStride, |
97 | | int dst1Stride, int dst2Stride); |
98 | | void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, |
99 | | uint8_t *dst1, uint8_t *dst2, |
100 | | int width, int height, |
101 | | int srcStride1, int srcStride2, |
102 | | int dstStride1, int dstStride2); |
103 | | void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, |
104 | | const uint8_t *src3, uint8_t *dst, |
105 | | int width, int height, |
106 | | int srcStride1, int srcStride2, |
107 | | int srcStride3, int dstStride); |
108 | | void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
109 | | const uint8_t *src, int width, int height, |
110 | | int lumStride, int chromStride, int srcStride); |
111 | | void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
112 | | const uint8_t *src, int width, int height, |
113 | | int lumStride, int chromStride, int srcStride); |
114 | | void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
115 | | const uint8_t *src, int width, int height, |
116 | | int lumStride, int chromStride, int srcStride); |
117 | | void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
118 | | const uint8_t *src, int width, int height, |
119 | | int lumStride, int chromStride, int srcStride); |
120 | | |
121 | | #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5)) |
122 | | #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5)) |
123 | | #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) |
124 | | #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5)) |
125 | | #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5)) |
126 | | #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5)) |
127 | | #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5)) |
128 | | #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) |
129 | | #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5)) |
130 | | |
131 | | //plain C versions |
132 | | #include "rgb2rgb_template.c" |
133 | | |
134 | | /* |
135 | | * RGB15->RGB16 original by Strepto/Astral |
136 | | * ported to gcc & bugfixed : A'rpi |
137 | | * MMXEXT, 3DNOW optimization by Nick Kurshev |
138 | | * 32-bit C version, and and&add trick by Michael Niedermayer |
139 | | */ |
140 | | |
141 | | av_cold void ff_sws_rgb2rgb_init(void) |
142 | 0 | { |
143 | 0 | rgb2rgb_init_c(); |
144 | | #if ARCH_AARCH64 |
145 | | rgb2rgb_init_aarch64(); |
146 | | #elif ARCH_RISCV |
147 | | rgb2rgb_init_riscv(); |
148 | | #elif ARCH_X86 |
149 | | rgb2rgb_init_x86(); |
150 | | #elif ARCH_LOONGARCH64 |
151 | | rgb2rgb_init_loongarch(); |
152 | | #endif |
153 | 0 | } |
154 | | |
155 | | void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) |
156 | 0 | { |
157 | 0 | int i, num_pixels = src_size >> 2; |
158 | |
|
159 | 0 | for (i = 0; i < num_pixels; i++) { |
160 | | #if HAVE_BIGENDIAN |
161 | | /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ |
162 | | dst[3 * i + 0] = src[4 * i + 1]; |
163 | | dst[3 * i + 1] = src[4 * i + 2]; |
164 | | dst[3 * i + 2] = src[4 * i + 3]; |
165 | | #else |
166 | 0 | dst[3 * i + 0] = src[4 * i + 2]; |
167 | 0 | dst[3 * i + 1] = src[4 * i + 1]; |
168 | 0 | dst[3 * i + 2] = src[4 * i + 0]; |
169 | 0 | #endif |
170 | 0 | } |
171 | 0 | } |
172 | | |
173 | | void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) |
174 | 0 | { |
175 | 0 | int i; |
176 | |
|
177 | 0 | for (i = 0; 3 * i < src_size; i++) { |
178 | | #if HAVE_BIGENDIAN |
179 | | /* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */ |
180 | | dst[4 * i + 0] = 255; |
181 | | dst[4 * i + 1] = src[3 * i + 0]; |
182 | | dst[4 * i + 2] = src[3 * i + 1]; |
183 | | dst[4 * i + 3] = src[3 * i + 2]; |
184 | | #else |
185 | 0 | dst[4 * i + 0] = src[3 * i + 2]; |
186 | 0 | dst[4 * i + 1] = src[3 * i + 1]; |
187 | 0 | dst[4 * i + 2] = src[3 * i + 0]; |
188 | 0 | dst[4 * i + 3] = 255; |
189 | 0 | #endif |
190 | 0 | } |
191 | 0 | } |
192 | | |
193 | | void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) |
194 | 0 | { |
195 | 0 | uint8_t *d = dst; |
196 | 0 | const uint16_t *s = (const uint16_t *)src; |
197 | 0 | const uint16_t *end = s + src_size / 2; |
198 | |
|
199 | 0 | while (s < end) { |
200 | 0 | register uint16_t bgr = *s++; |
201 | | #if HAVE_BIGENDIAN |
202 | | *d++ = 255; |
203 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
204 | | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
205 | | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
206 | | #else |
207 | 0 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
208 | 0 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
209 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
210 | 0 | *d++ = 255; |
211 | 0 | #endif |
212 | 0 | } |
213 | 0 | } |
214 | | |
215 | | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) |
216 | 0 | { |
217 | 0 | uint16_t rgb, r, g, b; |
218 | 0 | uint16_t *d = (uint16_t *)dst; |
219 | 0 | const uint16_t *s = (const uint16_t *)src; |
220 | 0 | const uint16_t *end = s + src_size / 2; |
221 | |
|
222 | 0 | while (s < end) { |
223 | 0 | rgb = *s++; |
224 | 0 | r = rgb & 0xF00; |
225 | 0 | g = rgb & 0x0F0; |
226 | 0 | b = rgb & 0x00F; |
227 | 0 | r = (r << 3) | ((r & 0x800) >> 1); |
228 | 0 | g = (g << 2) | ((g & 0x080) >> 2); |
229 | 0 | b = (b << 1) | ( b >> 3); |
230 | 0 | *d++ = r | g | b; |
231 | 0 | } |
232 | 0 | } |
233 | | |
234 | | void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) |
235 | 0 | { |
236 | 0 | uint8_t *d = dst; |
237 | 0 | const uint16_t *s = (const uint16_t *)src; |
238 | 0 | const uint16_t *end = s + src_size / 2; |
239 | |
|
240 | 0 | while (s < end) { |
241 | 0 | register uint16_t bgr = *s++; |
242 | 0 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
243 | 0 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
244 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
245 | 0 | } |
246 | 0 | } |
247 | | |
248 | | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) |
249 | 0 | { |
250 | 0 | int i, num_pixels = src_size >> 1; |
251 | |
|
252 | 0 | for (i = 0; i < num_pixels; i++) { |
253 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
254 | 0 | ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11); |
255 | 0 | } |
256 | 0 | } |
257 | | |
258 | | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) |
259 | 0 | { |
260 | 0 | int i, num_pixels = src_size >> 1; |
261 | |
|
262 | 0 | for (i = 0; i < num_pixels; i++) { |
263 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
264 | 0 | ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10); |
265 | 0 | } |
266 | 0 | } |
267 | | |
268 | | void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) |
269 | 0 | { |
270 | 0 | uint8_t *d = dst; |
271 | 0 | const uint16_t *s = (const uint16_t *)src; |
272 | 0 | const uint16_t *end = s + src_size / 2; |
273 | |
|
274 | 0 | while (s < end) { |
275 | 0 | register uint16_t bgr = *s++; |
276 | | #if HAVE_BIGENDIAN |
277 | | *d++ = 255; |
278 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
279 | | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
280 | | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
281 | | #else |
282 | 0 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
283 | 0 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
284 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
285 | 0 | *d++ = 255; |
286 | 0 | #endif |
287 | 0 | } |
288 | 0 | } |
289 | | |
290 | | void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) |
291 | 0 | { |
292 | 0 | uint8_t *d = dst; |
293 | 0 | const uint16_t *s = (const uint16_t *)src; |
294 | 0 | const uint16_t *end = s + src_size / 2; |
295 | |
|
296 | 0 | while (s < end) { |
297 | 0 | register uint16_t bgr = *s++; |
298 | 0 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
299 | 0 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
300 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
301 | 0 | } |
302 | 0 | } |
303 | | |
304 | | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) |
305 | 0 | { |
306 | 0 | int i, num_pixels = src_size >> 1; |
307 | |
|
308 | 0 | for (i = 0; i < num_pixels; i++) { |
309 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
310 | 0 | ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11); |
311 | 0 | } |
312 | 0 | } |
313 | | |
314 | | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) |
315 | 0 | { |
316 | 0 | int i, num_pixels = src_size >> 1; |
317 | |
|
318 | 0 | for (i = 0; i < num_pixels; i++) { |
319 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
320 | 0 | unsigned br = rgb & 0x7C1F; |
321 | 0 | ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10); |
322 | 0 | } |
323 | 0 | } |
324 | | |
325 | | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) |
326 | 0 | { |
327 | 0 | uint16_t *d = (uint16_t *)dst; |
328 | 0 | const uint16_t *s = (const uint16_t *)src; |
329 | 0 | int i, num_pixels = src_size >> 1; |
330 | |
|
331 | 0 | for (i = 0; i < num_pixels; i++) { |
332 | 0 | unsigned rgb = s[i]; |
333 | 0 | d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; |
334 | 0 | } |
335 | 0 | } |
336 | | |
337 | | #define DEFINE_RGB48TOBGR48(need_bswap, swap) \ |
338 | | void rgb48tobgr48_ ## need_bswap(const uint8_t *src, \ |
339 | 0 | uint8_t *dst, int src_size) \ |
340 | 0 | { \ |
341 | 0 | uint16_t *d = (uint16_t *)dst; \ |
342 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
343 | 0 | int i, num_pixels = src_size >> 1; \ |
344 | 0 | \ |
345 | 0 | for (i = 0; i < num_pixels; i += 3) { \ |
346 | 0 | d[i ] = swap ? av_bswap16(s[i + 2]) : s[i + 2]; \ |
347 | 0 | d[i + 1] = swap ? av_bswap16(s[i + 1]) : s[i + 1]; \ |
348 | 0 | d[i + 2] = swap ? av_bswap16(s[i ]) : s[i ]; \ |
349 | 0 | } \ |
350 | 0 | } Unexecuted instantiation: rgb48tobgr48_nobswap Unexecuted instantiation: rgb48tobgr48_bswap |
351 | | |
352 | | DEFINE_RGB48TOBGR48(nobswap, 0) |
353 | | DEFINE_RGB48TOBGR48(bswap, 1) |
354 | | |
355 | | #define DEFINE_RGB64TOBGR48(need_bswap, swap) \ |
356 | | void rgb64tobgr48_ ## need_bswap(const uint8_t *src, \ |
357 | 0 | uint8_t *dst, int src_size) \ |
358 | 0 | { \ |
359 | 0 | uint16_t *d = (uint16_t *)dst; \ |
360 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
361 | 0 | int i, num_pixels = src_size >> 3; \ |
362 | 0 | \ |
363 | 0 | for (i = 0; i < num_pixels; i++) { \ |
364 | 0 | d[3 * i ] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ |
365 | 0 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ |
366 | 0 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ |
367 | 0 | } \ |
368 | 0 | } Unexecuted instantiation: rgb64tobgr48_nobswap Unexecuted instantiation: rgb64tobgr48_bswap |
369 | | |
370 | | DEFINE_RGB64TOBGR48(nobswap, 0) |
371 | | DEFINE_RGB64TOBGR48(bswap, 1) |
372 | | |
373 | | #define DEFINE_RGB64TO48(need_bswap, swap) \ |
374 | | void rgb64to48_ ## need_bswap(const uint8_t *src, \ |
375 | 0 | uint8_t *dst, int src_size) \ |
376 | 0 | { \ |
377 | 0 | uint16_t *d = (uint16_t *)dst; \ |
378 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
379 | 0 | int i, num_pixels = src_size >> 3; \ |
380 | 0 | \ |
381 | 0 | for (i = 0; i < num_pixels; i++) { \ |
382 | 0 | d[3 * i ] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ |
383 | 0 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ |
384 | 0 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ |
385 | 0 | } \ |
386 | 0 | } Unexecuted instantiation: rgb64to48_nobswap Unexecuted instantiation: rgb64to48_bswap |
387 | | |
388 | | DEFINE_RGB64TO48(nobswap, 0) |
389 | | DEFINE_RGB64TO48(bswap, 1) |
390 | | |
391 | | #define DEFINE_RGB48TOBGR64(need_bswap, swap) \ |
392 | | void rgb48tobgr64_ ## need_bswap(const uint8_t *src, \ |
393 | 0 | uint8_t *dst, int src_size) \ |
394 | 0 | { \ |
395 | 0 | uint16_t *d = (uint16_t *)dst; \ |
396 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
397 | 0 | int i, num_pixels = src_size / 6; \ |
398 | 0 | \ |
399 | 0 | for (i = 0; i < num_pixels; i++) { \ |
400 | 0 | d[4 * i ] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ |
401 | 0 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ |
402 | 0 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ |
403 | 0 | d[4 * i + 3] = 0xFFFF; \ |
404 | 0 | } \ |
405 | 0 | } Unexecuted instantiation: rgb48tobgr64_nobswap Unexecuted instantiation: rgb48tobgr64_bswap |
406 | | |
407 | | DEFINE_RGB48TOBGR64(nobswap, 0) |
408 | | DEFINE_RGB48TOBGR64(bswap, 1) |
409 | | |
410 | | #define DEFINE_RGB48TO64(need_bswap, swap) \ |
411 | | void rgb48to64_ ## need_bswap(const uint8_t *src, \ |
412 | 0 | uint8_t *dst, int src_size) \ |
413 | 0 | { \ |
414 | 0 | uint16_t *d = (uint16_t *)dst; \ |
415 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
416 | 0 | int i, num_pixels = src_size / 6; \ |
417 | 0 | \ |
418 | 0 | for (i = 0; i < num_pixels; i++) { \ |
419 | 0 | d[4 * i ] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ |
420 | 0 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ |
421 | 0 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ |
422 | 0 | d[4 * i + 3] = 0xFFFF; \ |
423 | 0 | } \ |
424 | 0 | } Unexecuted instantiation: rgb48to64_nobswap Unexecuted instantiation: rgb48to64_bswap |
425 | | |
426 | | DEFINE_RGB48TO64(nobswap, 0) |
427 | | DEFINE_RGB48TO64(bswap, 1) |
428 | | |
429 | | #define DEFINE_X2RGB10TO16(need_bswap, swap, bits, alpha) \ |
430 | | void x2rgb10to ## bits ## _ ## need_bswap(const uint8_t *src, \ |
431 | 0 | uint8_t *dst, int src_size) \ |
432 | 0 | { \ |
433 | 0 | uint16_t *d = (uint16_t *)dst; \ |
434 | 0 | const uint32_t *s = (const uint32_t *)src; \ |
435 | 0 | int i, num_pixels = src_size >> 2; \ |
436 | 0 | unsigned component; \ |
437 | 0 | \ |
438 | 0 | for (i = 0; i < num_pixels; i++) { \ |
439 | 0 | unsigned p = AV_RL32(s + i); \ |
440 | 0 | component = (p >> 20) & 0x3FF; \ |
441 | 0 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ |
442 | 0 | : component << 6 | component >> 4; \ |
443 | 0 | component = (p >> 10) & 0x3FF; \ |
444 | 0 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ |
445 | 0 | : component << 6 | component >> 4; \ |
446 | 0 | component = p & 0x3FF; \ |
447 | 0 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ |
448 | 0 | : component << 6 | component >> 4; \ |
449 | 0 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ |
450 | 0 | } \ |
451 | 0 | } Unexecuted instantiation: x2rgb10to48_nobswap Unexecuted instantiation: x2rgb10to48_bswap Unexecuted instantiation: x2rgb10to64_nobswap Unexecuted instantiation: x2rgb10to64_bswap |
452 | | |
453 | | DEFINE_X2RGB10TO16(nobswap, 0, 48, 0) |
454 | | DEFINE_X2RGB10TO16(bswap, 1, 48, 0) |
455 | | DEFINE_X2RGB10TO16(nobswap, 0, 64, 1) |
456 | | DEFINE_X2RGB10TO16(bswap, 1, 64, 1) |
457 | | |
458 | | #define DEFINE_X2RGB10TOBGR16(need_bswap, swap, bits, alpha) \ |
459 | | void x2rgb10tobgr ## bits ## _ ## need_bswap(const uint8_t *src, \ |
460 | 0 | uint8_t *dst, int src_size) \ |
461 | 0 | { \ |
462 | 0 | uint16_t *d = (uint16_t *)dst; \ |
463 | 0 | const uint32_t *s = (const uint32_t *)src; \ |
464 | 0 | int i, num_pixels = src_size >> 2; \ |
465 | 0 | unsigned component; \ |
466 | 0 | \ |
467 | 0 | for (i = 0; i < num_pixels; i++) { \ |
468 | 0 | unsigned p = AV_RL32(s + i); \ |
469 | 0 | component = p & 0x3FF; \ |
470 | 0 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ |
471 | 0 | : component << 6 | component >> 4; \ |
472 | 0 | component = (p >> 10) & 0x3FF; \ |
473 | 0 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ |
474 | 0 | : component << 6 | component >> 4; \ |
475 | 0 | component = (p >> 20) & 0x3FF; \ |
476 | 0 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ |
477 | 0 | : component << 6 | component >> 4; \ |
478 | 0 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ |
479 | 0 | } \ |
480 | 0 | } Unexecuted instantiation: x2rgb10tobgr48_nobswap Unexecuted instantiation: x2rgb10tobgr48_bswap Unexecuted instantiation: x2rgb10tobgr64_nobswap Unexecuted instantiation: x2rgb10tobgr64_bswap |
481 | | |
482 | | DEFINE_X2RGB10TOBGR16(nobswap, 0, 48, 0) |
483 | | DEFINE_X2RGB10TOBGR16(bswap, 1, 48, 0) |
484 | | DEFINE_X2RGB10TOBGR16(nobswap, 0, 64, 1) |
485 | | DEFINE_X2RGB10TOBGR16(bswap, 1, 64, 1) |