Line | Branch | Exec | 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 | 4497 | av_cold void ff_sws_rgb2rgb_init(void) | |
142 | { | ||
143 | 4497 | rgb2rgb_init_c(); | |
144 | #if ARCH_AARCH64 | ||
145 | rgb2rgb_init_aarch64(); | ||
146 | #elif ARCH_RISCV | ||
147 | rgb2rgb_init_riscv(); | ||
148 | #elif ARCH_X86 | ||
149 | 4497 | rgb2rgb_init_x86(); | |
150 | #elif ARCH_LOONGARCH64 | ||
151 | rgb2rgb_init_loongarch(); | ||
152 | #endif | ||
153 | 4497 | } | |
154 | |||
155 | 51094 | void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) | |
156 | { | ||
157 | 51094 | int i, num_pixels = src_size >> 2; | |
158 | |||
159 |
2/2✓ Branch 0 taken 119440500 times.
✓ Branch 1 taken 51094 times.
|
119491594 | 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 | 119440500 | dst[3 * i + 0] = src[4 * i + 2]; | |
167 | 119440500 | dst[3 * i + 1] = src[4 * i + 1]; | |
168 | 119440500 | dst[3 * i + 2] = src[4 * i + 0]; | |
169 | #endif | ||
170 | } | ||
171 | 51094 | } | |
172 | |||
173 | 72 | void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) | |
174 | { | ||
175 | int i; | ||
176 | |||
177 |
2/2✓ Branch 0 taken 354744 times.
✓ Branch 1 taken 72 times.
|
354816 | 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 | 354744 | dst[4 * i + 0] = src[3 * i + 2]; | |
186 | 354744 | dst[4 * i + 1] = src[3 * i + 1]; | |
187 | 354744 | dst[4 * i + 2] = src[3 * i + 0]; | |
188 | 354744 | dst[4 * i + 3] = 255; | |
189 | #endif | ||
190 | } | ||
191 | 72 | } | |
192 | |||
193 | ✗ | void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |
194 | { | ||
195 | ✗ | uint8_t *d = dst; | |
196 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
197 | ✗ | const uint16_t *end = s + src_size / 2; | |
198 | |||
199 | ✗ | while (s < end) { | |
200 | ✗ | 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 | ✗ | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | |
208 | ✗ | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |
209 | ✗ | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
210 | ✗ | *d++ = 255; | |
211 | #endif | ||
212 | } | ||
213 | ✗ | } | |
214 | |||
215 | ✗ | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) | |
216 | { | ||
217 | uint16_t rgb, r, g, b; | ||
218 | ✗ | uint16_t *d = (uint16_t *)dst; | |
219 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
220 | ✗ | const uint16_t *end = s + src_size / 2; | |
221 | |||
222 | ✗ | while (s < end) { | |
223 | ✗ | rgb = *s++; | |
224 | ✗ | r = rgb & 0xF00; | |
225 | ✗ | g = rgb & 0x0F0; | |
226 | ✗ | b = rgb & 0x00F; | |
227 | ✗ | r = (r << 3) | ((r & 0x800) >> 1); | |
228 | ✗ | g = (g << 2) | ((g & 0x080) >> 2); | |
229 | ✗ | b = (b << 1) | ( b >> 3); | |
230 | ✗ | *d++ = r | g | b; | |
231 | } | ||
232 | ✗ | } | |
233 | |||
234 | 1944 | void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) | |
235 | { | ||
236 | 1944 | uint8_t *d = dst; | |
237 | 1944 | const uint16_t *s = (const uint16_t *)src; | |
238 | 1944 | const uint16_t *end = s + src_size / 2; | |
239 | |||
240 |
2/2✓ Branch 0 taken 22091776 times.
✓ Branch 1 taken 1944 times.
|
22093720 | while (s < end) { |
241 | 22091776 | register uint16_t bgr = *s++; | |
242 | 22091776 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | |
243 | 22091776 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |
244 | 22091776 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
245 | } | ||
246 | 1944 | } | |
247 | |||
248 | ✗ | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | |
249 | { | ||
250 | ✗ | int i, num_pixels = src_size >> 1; | |
251 | |||
252 | ✗ | for (i = 0; i < num_pixels; i++) { | |
253 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
254 | ✗ | ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11); | |
255 | } | ||
256 | ✗ | } | |
257 | |||
258 | ✗ | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | |
259 | { | ||
260 | ✗ | int i, num_pixels = src_size >> 1; | |
261 | |||
262 | ✗ | for (i = 0; i < num_pixels; i++) { | |
263 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
264 | ✗ | ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10); | |
265 | } | ||
266 | ✗ | } | |
267 | |||
268 | ✗ | void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |
269 | { | ||
270 | ✗ | uint8_t *d = dst; | |
271 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
272 | ✗ | const uint16_t *end = s + src_size / 2; | |
273 | |||
274 | ✗ | while (s < end) { | |
275 | ✗ | 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 | ✗ | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | |
283 | ✗ | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |
284 | ✗ | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
285 | ✗ | *d++ = 255; | |
286 | #endif | ||
287 | } | ||
288 | ✗ | } | |
289 | |||
290 | 122434 | void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) | |
291 | { | ||
292 | 122434 | uint8_t *d = dst; | |
293 | 122434 | const uint16_t *s = (const uint16_t *)src; | |
294 | 122434 | const uint16_t *end = s + src_size / 2; | |
295 | |||
296 |
2/2✓ Branch 0 taken 124182496 times.
✓ Branch 1 taken 122434 times.
|
124304930 | while (s < end) { |
297 | 124182496 | register uint16_t bgr = *s++; | |
298 | 124182496 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | |
299 | 124182496 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |
300 | 124182496 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
301 | } | ||
302 | 122434 | } | |
303 | |||
304 | ✗ | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | |
305 | { | ||
306 | ✗ | int i, num_pixels = src_size >> 1; | |
307 | |||
308 | ✗ | for (i = 0; i < num_pixels; i++) { | |
309 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
310 | ✗ | ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11); | |
311 | } | ||
312 | ✗ | } | |
313 | |||
314 | ✗ | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | |
315 | { | ||
316 | ✗ | int i, num_pixels = src_size >> 1; | |
317 | |||
318 | ✗ | for (i = 0; i < num_pixels; i++) { | |
319 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
320 | ✗ | unsigned br = rgb & 0x7C1F; | |
321 | ✗ | ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10); | |
322 | } | ||
323 | ✗ | } | |
324 | |||
325 | ✗ | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) | |
326 | { | ||
327 | ✗ | uint16_t *d = (uint16_t *)dst; | |
328 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
329 | ✗ | int i, num_pixels = src_size >> 1; | |
330 | |||
331 | ✗ | for (i = 0; i < num_pixels; i++) { | |
332 | ✗ | unsigned rgb = s[i]; | |
333 | ✗ | d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; | |
334 | } | ||
335 | ✗ | } | |
336 | |||
337 | #define DEFINE_RGB48TOBGR48(need_bswap, swap) \ | ||
338 | void rgb48tobgr48_ ## need_bswap(const uint8_t *src, \ | ||
339 | uint8_t *dst, int src_size) \ | ||
340 | { \ | ||
341 | uint16_t *d = (uint16_t *)dst; \ | ||
342 | const uint16_t *s = (const uint16_t *)src; \ | ||
343 | int i, num_pixels = src_size >> 1; \ | ||
344 | \ | ||
345 | for (i = 0; i < num_pixels; i += 3) { \ | ||
346 | d[i ] = swap ? av_bswap16(s[i + 2]) : s[i + 2]; \ | ||
347 | d[i + 1] = swap ? av_bswap16(s[i + 1]) : s[i + 1]; \ | ||
348 | d[i + 2] = swap ? av_bswap16(s[i ]) : s[i ]; \ | ||
349 | } \ | ||
350 | } | ||
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 | uint8_t *dst, int src_size) \ | ||
358 | { \ | ||
359 | uint16_t *d = (uint16_t *)dst; \ | ||
360 | const uint16_t *s = (const uint16_t *)src; \ | ||
361 | int i, num_pixels = src_size >> 3; \ | ||
362 | \ | ||
363 | for (i = 0; i < num_pixels; i++) { \ | ||
364 | d[3 * i ] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ | ||
365 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ | ||
366 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ | ||
367 | } \ | ||
368 | } | ||
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 | uint8_t *dst, int src_size) \ | ||
376 | { \ | ||
377 | uint16_t *d = (uint16_t *)dst; \ | ||
378 | const uint16_t *s = (const uint16_t *)src; \ | ||
379 | int i, num_pixels = src_size >> 3; \ | ||
380 | \ | ||
381 | for (i = 0; i < num_pixels; i++) { \ | ||
382 | d[3 * i ] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ | ||
383 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ | ||
384 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ | ||
385 | } \ | ||
386 | } | ||
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 | uint8_t *dst, int src_size) \ | ||
394 | { \ | ||
395 | uint16_t *d = (uint16_t *)dst; \ | ||
396 | const uint16_t *s = (const uint16_t *)src; \ | ||
397 | int i, num_pixels = src_size / 6; \ | ||
398 | \ | ||
399 | for (i = 0; i < num_pixels; i++) { \ | ||
400 | d[4 * i ] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ | ||
401 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ | ||
402 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ | ||
403 | d[4 * i + 3] = 0xFFFF; \ | ||
404 | } \ | ||
405 | } | ||
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 | uint8_t *dst, int src_size) \ | ||
413 | { \ | ||
414 | uint16_t *d = (uint16_t *)dst; \ | ||
415 | const uint16_t *s = (const uint16_t *)src; \ | ||
416 | int i, num_pixels = src_size / 6; \ | ||
417 | \ | ||
418 | for (i = 0; i < num_pixels; i++) { \ | ||
419 | d[4 * i ] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ | ||
420 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ | ||
421 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ | ||
422 | d[4 * i + 3] = 0xFFFF; \ | ||
423 | } \ | ||
424 | } | ||
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 | uint8_t *dst, int src_size) \ | ||
432 | { \ | ||
433 | uint16_t *d = (uint16_t *)dst; \ | ||
434 | const uint32_t *s = (const uint32_t *)src; \ | ||
435 | int i, num_pixels = src_size >> 2; \ | ||
436 | unsigned component; \ | ||
437 | \ | ||
438 | for (i = 0; i < num_pixels; i++) { \ | ||
439 | unsigned p = AV_RL32(s + i); \ | ||
440 | component = (p >> 20) & 0x3FF; \ | ||
441 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
442 | : component << 6 | component >> 4; \ | ||
443 | component = (p >> 10) & 0x3FF; \ | ||
444 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
445 | : component << 6 | component >> 4; \ | ||
446 | component = p & 0x3FF; \ | ||
447 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
448 | : component << 6 | component >> 4; \ | ||
449 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | ||
450 | } \ | ||
451 | } | ||
452 | |||
453 |
2/2✓ Branch 0 taken 2635776 times.
✓ Branch 1 taken 234 times.
|
2636010 | 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 | uint8_t *dst, int src_size) \ | ||
461 | { \ | ||
462 | uint16_t *d = (uint16_t *)dst; \ | ||
463 | const uint32_t *s = (const uint32_t *)src; \ | ||
464 | int i, num_pixels = src_size >> 2; \ | ||
465 | unsigned component; \ | ||
466 | \ | ||
467 | for (i = 0; i < num_pixels; i++) { \ | ||
468 | unsigned p = AV_RL32(s + i); \ | ||
469 | component = p & 0x3FF; \ | ||
470 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
471 | : component << 6 | component >> 4; \ | ||
472 | component = (p >> 10) & 0x3FF; \ | ||
473 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
474 | : component << 6 | component >> 4; \ | ||
475 | component = (p >> 20) & 0x3FF; \ | ||
476 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
477 | : component << 6 | component >> 4; \ | ||
478 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | ||
479 | } \ | ||
480 | } | ||
481 | |||
482 |
2/2✓ Branch 0 taken 2635776 times.
✓ Branch 1 taken 234 times.
|
2636010 | 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) | |
486 |