/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 (*ff_rgb24toyv12)(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 | | const int32_t *rgb2yuv); |
86 | | void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, |
87 | | int srcStride, int dstStride); |
88 | | void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, |
89 | | int width, int height, int src1Stride, |
90 | | int src2Stride, int dstStride); |
91 | | void (*deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, |
92 | | int width, int height, int srcStride, |
93 | | int dst1Stride, int dst2Stride); |
94 | | void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
95 | | const uint8_t *src, int width, int height, |
96 | | int lumStride, int chromStride, int srcStride); |
97 | | void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
98 | | const uint8_t *src, int width, int height, |
99 | | int lumStride, int chromStride, int srcStride); |
100 | | void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
101 | | const uint8_t *src, int width, int height, |
102 | | int lumStride, int chromStride, int srcStride); |
103 | | void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
104 | | const uint8_t *src, int width, int height, |
105 | | int lumStride, int chromStride, int srcStride); |
106 | | |
107 | | #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5)) |
108 | | #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5)) |
109 | | #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) |
110 | | #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5)) |
111 | | #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5)) |
112 | | #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5)) |
113 | | #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5)) |
114 | | #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) |
115 | | #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5)) |
116 | | |
117 | | //plain C versions |
118 | | #include "rgb2rgb_template.c" |
119 | | |
120 | | /* |
121 | | * RGB15->RGB16 original by Strepto/Astral |
122 | | * ported to gcc & bugfixed : A'rpi |
123 | | * MMXEXT, 3DNOW optimization by Nick Kurshev |
124 | | * 32-bit C version, and and&add trick by Michael Niedermayer |
125 | | */ |
126 | | |
127 | | av_cold void ff_sws_rgb2rgb_init(void) |
128 | 0 | { |
129 | 0 | rgb2rgb_init_c(); |
130 | | #if ARCH_AARCH64 |
131 | | rgb2rgb_init_aarch64(); |
132 | | #elif ARCH_RISCV |
133 | | rgb2rgb_init_riscv(); |
134 | | #elif ARCH_X86 |
135 | | rgb2rgb_init_x86(); |
136 | | #elif ARCH_LOONGARCH64 |
137 | | rgb2rgb_init_loongarch(); |
138 | | #endif |
139 | 0 | } |
140 | | |
141 | | void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) |
142 | 0 | { |
143 | 0 | int i, num_pixels = src_size >> 2; |
144 | |
|
145 | 0 | for (i = 0; i < num_pixels; i++) { |
146 | | #if HAVE_BIGENDIAN |
147 | | /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ |
148 | | dst[3 * i + 0] = src[4 * i + 1]; |
149 | | dst[3 * i + 1] = src[4 * i + 2]; |
150 | | dst[3 * i + 2] = src[4 * i + 3]; |
151 | | #else |
152 | 0 | dst[3 * i + 0] = src[4 * i + 2]; |
153 | 0 | dst[3 * i + 1] = src[4 * i + 1]; |
154 | 0 | dst[3 * i + 2] = src[4 * i + 0]; |
155 | 0 | #endif |
156 | 0 | } |
157 | 0 | } |
158 | | |
159 | | void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) |
160 | 0 | { |
161 | 0 | int i; |
162 | |
|
163 | 0 | for (i = 0; 3 * i < src_size; i++) { |
164 | | #if HAVE_BIGENDIAN |
165 | | /* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */ |
166 | | dst[4 * i + 0] = 255; |
167 | | dst[4 * i + 1] = src[3 * i + 0]; |
168 | | dst[4 * i + 2] = src[3 * i + 1]; |
169 | | dst[4 * i + 3] = src[3 * i + 2]; |
170 | | #else |
171 | 0 | dst[4 * i + 0] = src[3 * i + 2]; |
172 | 0 | dst[4 * i + 1] = src[3 * i + 1]; |
173 | 0 | dst[4 * i + 2] = src[3 * i + 0]; |
174 | 0 | dst[4 * i + 3] = 255; |
175 | 0 | #endif |
176 | 0 | } |
177 | 0 | } |
178 | | |
179 | | void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) |
180 | 0 | { |
181 | 0 | uint8_t *d = dst; |
182 | 0 | const uint16_t *s = (const uint16_t *)src; |
183 | 0 | const uint16_t *end = s + src_size / 2; |
184 | |
|
185 | 0 | while (s < end) { |
186 | 0 | register uint16_t bgr = *s++; |
187 | | #if HAVE_BIGENDIAN |
188 | | *d++ = 255; |
189 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
190 | | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
191 | | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
192 | | #else |
193 | 0 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
194 | 0 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
195 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
196 | 0 | *d++ = 255; |
197 | 0 | #endif |
198 | 0 | } |
199 | 0 | } |
200 | | |
201 | | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) |
202 | 0 | { |
203 | 0 | uint16_t rgb, r, g, b; |
204 | 0 | uint16_t *d = (uint16_t *)dst; |
205 | 0 | const uint16_t *s = (const uint16_t *)src; |
206 | 0 | const uint16_t *end = s + src_size / 2; |
207 | |
|
208 | 0 | while (s < end) { |
209 | 0 | rgb = *s++; |
210 | 0 | r = rgb & 0xF00; |
211 | 0 | g = rgb & 0x0F0; |
212 | 0 | b = rgb & 0x00F; |
213 | 0 | r = (r << 3) | ((r & 0x800) >> 1); |
214 | 0 | g = (g << 2) | ((g & 0x080) >> 2); |
215 | 0 | b = (b << 1) | ( b >> 3); |
216 | 0 | *d++ = r | g | b; |
217 | 0 | } |
218 | 0 | } |
219 | | |
220 | | void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) |
221 | 0 | { |
222 | 0 | uint8_t *d = dst; |
223 | 0 | const uint16_t *s = (const uint16_t *)src; |
224 | 0 | const uint16_t *end = s + src_size / 2; |
225 | |
|
226 | 0 | while (s < end) { |
227 | 0 | register uint16_t bgr = *s++; |
228 | 0 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
229 | 0 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
230 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
231 | 0 | } |
232 | 0 | } |
233 | | |
234 | | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) |
235 | 0 | { |
236 | 0 | int i, num_pixels = src_size >> 1; |
237 | |
|
238 | 0 | for (i = 0; i < num_pixels; i++) { |
239 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
240 | 0 | ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11); |
241 | 0 | } |
242 | 0 | } |
243 | | |
244 | | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) |
245 | 0 | { |
246 | 0 | int i, num_pixels = src_size >> 1; |
247 | |
|
248 | 0 | for (i = 0; i < num_pixels; i++) { |
249 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
250 | 0 | ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10); |
251 | 0 | } |
252 | 0 | } |
253 | | |
254 | | void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) |
255 | 0 | { |
256 | 0 | uint8_t *d = dst; |
257 | 0 | const uint16_t *s = (const uint16_t *)src; |
258 | 0 | const uint16_t *end = s + src_size / 2; |
259 | |
|
260 | 0 | while (s < end) { |
261 | 0 | register uint16_t bgr = *s++; |
262 | | #if HAVE_BIGENDIAN |
263 | | *d++ = 255; |
264 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
265 | | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
266 | | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
267 | | #else |
268 | 0 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
269 | 0 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
270 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
271 | 0 | *d++ = 255; |
272 | 0 | #endif |
273 | 0 | } |
274 | 0 | } |
275 | | |
276 | | void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) |
277 | 0 | { |
278 | 0 | uint8_t *d = dst; |
279 | 0 | const uint16_t *s = (const uint16_t *)src; |
280 | 0 | const uint16_t *end = s + src_size / 2; |
281 | |
|
282 | 0 | while (s < end) { |
283 | 0 | register uint16_t bgr = *s++; |
284 | 0 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
285 | 0 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
286 | 0 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
287 | 0 | } |
288 | 0 | } |
289 | | |
290 | | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) |
291 | 0 | { |
292 | 0 | int i, num_pixels = src_size >> 1; |
293 | |
|
294 | 0 | for (i = 0; i < num_pixels; i++) { |
295 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
296 | 0 | ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11); |
297 | 0 | } |
298 | 0 | } |
299 | | |
300 | | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) |
301 | 0 | { |
302 | 0 | int i, num_pixels = src_size >> 1; |
303 | |
|
304 | 0 | for (i = 0; i < num_pixels; i++) { |
305 | 0 | unsigned rgb = ((const uint16_t *)src)[i]; |
306 | 0 | unsigned br = rgb & 0x7C1F; |
307 | 0 | ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10); |
308 | 0 | } |
309 | 0 | } |
310 | | |
311 | | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) |
312 | 0 | { |
313 | 0 | uint16_t *d = (uint16_t *)dst; |
314 | 0 | const uint16_t *s = (const uint16_t *)src; |
315 | 0 | int i, num_pixels = src_size >> 1; |
316 | |
|
317 | 0 | for (i = 0; i < num_pixels; i++) { |
318 | 0 | unsigned rgb = s[i]; |
319 | 0 | d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; |
320 | 0 | } |
321 | 0 | } |
322 | | |
323 | | #define DEFINE_RGB48TOBGR48(need_bswap, swap) \ |
324 | | void rgb48tobgr48_ ## need_bswap(const uint8_t *src, \ |
325 | 0 | 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 | 0 | \ |
331 | 0 | for (i = 0; i < num_pixels; i += 3) { \ |
332 | 0 | d[i ] = swap ? av_bswap16(s[i + 2]) : s[i + 2]; \ |
333 | 0 | d[i + 1] = swap ? av_bswap16(s[i + 1]) : s[i + 1]; \ |
334 | 0 | d[i + 2] = swap ? av_bswap16(s[i ]) : s[i ]; \ |
335 | 0 | } \ |
336 | 0 | } Unexecuted instantiation: rgb48tobgr48_nobswap Unexecuted instantiation: rgb48tobgr48_bswap |
337 | | |
338 | | DEFINE_RGB48TOBGR48(nobswap, 0) |
339 | | DEFINE_RGB48TOBGR48(bswap, 1) |
340 | | |
341 | | #define DEFINE_RGB64TOBGR48(need_bswap, swap) \ |
342 | | void rgb64tobgr48_ ## need_bswap(const uint8_t *src, \ |
343 | 0 | uint8_t *dst, int src_size) \ |
344 | 0 | { \ |
345 | 0 | uint16_t *d = (uint16_t *)dst; \ |
346 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
347 | 0 | int i, num_pixels = src_size >> 3; \ |
348 | 0 | \ |
349 | 0 | for (i = 0; i < num_pixels; i++) { \ |
350 | 0 | d[3 * i ] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ |
351 | 0 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ |
352 | 0 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ |
353 | 0 | } \ |
354 | 0 | } Unexecuted instantiation: rgb64tobgr48_nobswap Unexecuted instantiation: rgb64tobgr48_bswap |
355 | | |
356 | | DEFINE_RGB64TOBGR48(nobswap, 0) |
357 | | DEFINE_RGB64TOBGR48(bswap, 1) |
358 | | |
359 | | #define DEFINE_RGB64TO48(need_bswap, swap) \ |
360 | | void rgb64to48_ ## need_bswap(const uint8_t *src, \ |
361 | 0 | uint8_t *dst, int src_size) \ |
362 | 0 | { \ |
363 | 0 | uint16_t *d = (uint16_t *)dst; \ |
364 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
365 | 0 | int i, num_pixels = src_size >> 3; \ |
366 | 0 | \ |
367 | 0 | for (i = 0; i < num_pixels; i++) { \ |
368 | 0 | d[3 * i ] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ |
369 | 0 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ |
370 | 0 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ |
371 | 0 | } \ |
372 | 0 | } Unexecuted instantiation: rgb64to48_nobswap Unexecuted instantiation: rgb64to48_bswap |
373 | | |
374 | | DEFINE_RGB64TO48(nobswap, 0) |
375 | | DEFINE_RGB64TO48(bswap, 1) |
376 | | |
377 | | #define DEFINE_RGB48TOBGR64(need_bswap, swap) \ |
378 | | void rgb48tobgr64_ ## need_bswap(const uint8_t *src, \ |
379 | 0 | uint8_t *dst, int src_size) \ |
380 | 0 | { \ |
381 | 0 | uint16_t *d = (uint16_t *)dst; \ |
382 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
383 | 0 | int i, num_pixels = src_size / 6; \ |
384 | 0 | \ |
385 | 0 | for (i = 0; i < num_pixels; i++) { \ |
386 | 0 | d[4 * i ] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ |
387 | 0 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ |
388 | 0 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ |
389 | 0 | d[4 * i + 3] = 0xFFFF; \ |
390 | 0 | } \ |
391 | 0 | } Unexecuted instantiation: rgb48tobgr64_nobswap Unexecuted instantiation: rgb48tobgr64_bswap |
392 | | |
393 | | DEFINE_RGB48TOBGR64(nobswap, 0) |
394 | | DEFINE_RGB48TOBGR64(bswap, 1) |
395 | | |
396 | | #define DEFINE_RGB48TO64(need_bswap, swap) \ |
397 | | void rgb48to64_ ## need_bswap(const uint8_t *src, \ |
398 | 0 | uint8_t *dst, int src_size) \ |
399 | 0 | { \ |
400 | 0 | uint16_t *d = (uint16_t *)dst; \ |
401 | 0 | const uint16_t *s = (const uint16_t *)src; \ |
402 | 0 | int i, num_pixels = src_size / 6; \ |
403 | 0 | \ |
404 | 0 | for (i = 0; i < num_pixels; i++) { \ |
405 | 0 | d[4 * i ] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ |
406 | 0 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ |
407 | 0 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ |
408 | 0 | d[4 * i + 3] = 0xFFFF; \ |
409 | 0 | } \ |
410 | 0 | } Unexecuted instantiation: rgb48to64_nobswap Unexecuted instantiation: rgb48to64_bswap |
411 | | |
412 | | DEFINE_RGB48TO64(nobswap, 0) |
413 | | DEFINE_RGB48TO64(bswap, 1) |
414 | | |
415 | | #define DEFINE_X2RGB10TO16(need_bswap, swap, bits, alpha) \ |
416 | | void x2rgb10to ## bits ## _ ## need_bswap(const uint8_t *src, \ |
417 | 0 | uint8_t *dst, int src_size) \ |
418 | 0 | { \ |
419 | 0 | uint16_t *d = (uint16_t *)dst; \ |
420 | 0 | const uint32_t *s = (const uint32_t *)src; \ |
421 | 0 | int i, num_pixels = src_size >> 2; \ |
422 | 0 | unsigned component; \ |
423 | 0 | \ |
424 | 0 | for (i = 0; i < num_pixels; i++) { \ |
425 | 0 | unsigned p = AV_RL32(s + i); \ |
426 | 0 | component = (p >> 20) & 0x3FF; \ |
427 | 0 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ |
428 | 0 | : component << 6 | component >> 4; \ |
429 | 0 | component = (p >> 10) & 0x3FF; \ |
430 | 0 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ |
431 | 0 | : component << 6 | component >> 4; \ |
432 | 0 | component = p & 0x3FF; \ |
433 | 0 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ |
434 | 0 | : component << 6 | component >> 4; \ |
435 | 0 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ |
436 | 0 | } \ |
437 | 0 | } Unexecuted instantiation: x2rgb10to48_nobswap Unexecuted instantiation: x2rgb10to48_bswap Unexecuted instantiation: x2rgb10to64_nobswap Unexecuted instantiation: x2rgb10to64_bswap |
438 | | |
439 | | DEFINE_X2RGB10TO16(nobswap, 0, 48, 0) |
440 | | DEFINE_X2RGB10TO16(bswap, 1, 48, 0) |
441 | | DEFINE_X2RGB10TO16(nobswap, 0, 64, 1) |
442 | | DEFINE_X2RGB10TO16(bswap, 1, 64, 1) |
443 | | |
444 | | #define DEFINE_X2RGB10TOBGR16(need_bswap, swap, bits, alpha) \ |
445 | | void x2rgb10tobgr ## bits ## _ ## need_bswap(const uint8_t *src, \ |
446 | 0 | uint8_t *dst, int src_size) \ |
447 | 0 | { \ |
448 | 0 | uint16_t *d = (uint16_t *)dst; \ |
449 | 0 | const uint32_t *s = (const uint32_t *)src; \ |
450 | 0 | int i, num_pixels = src_size >> 2; \ |
451 | 0 | unsigned component; \ |
452 | 0 | \ |
453 | 0 | for (i = 0; i < num_pixels; i++) { \ |
454 | 0 | unsigned p = AV_RL32(s + i); \ |
455 | 0 | component = p & 0x3FF; \ |
456 | 0 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ |
457 | 0 | : component << 6 | component >> 4; \ |
458 | 0 | component = (p >> 10) & 0x3FF; \ |
459 | 0 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ |
460 | 0 | : component << 6 | component >> 4; \ |
461 | 0 | component = (p >> 20) & 0x3FF; \ |
462 | 0 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ |
463 | 0 | : component << 6 | component >> 4; \ |
464 | 0 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ |
465 | 0 | } \ |
466 | 0 | } Unexecuted instantiation: x2rgb10tobgr48_nobswap Unexecuted instantiation: x2rgb10tobgr48_bswap Unexecuted instantiation: x2rgb10tobgr64_nobswap Unexecuted instantiation: x2rgb10tobgr64_bswap |
467 | | |
468 | | DEFINE_X2RGB10TOBGR16(nobswap, 0, 48, 0) |
469 | | DEFINE_X2RGB10TOBGR16(bswap, 1, 48, 0) |
470 | | DEFINE_X2RGB10TOBGR16(nobswap, 0, 64, 1) |
471 | | DEFINE_X2RGB10TOBGR16(bswap, 1, 64, 1) |