/src/ffmpeg/libswscale/rgb2rgb_template.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 | | * lot of big-endian byte order fixes by Alex Beregszaszi |
9 | | * |
10 | | * This file is part of FFmpeg. |
11 | | * |
12 | | * FFmpeg is free software; you can redistribute it and/or |
13 | | * modify it under the terms of the GNU Lesser General Public |
14 | | * License as published by the Free Software Foundation; either |
15 | | * version 2.1 of the License, or (at your option) any later version. |
16 | | * |
17 | | * FFmpeg is distributed in the hope that it will be useful, |
18 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | | * Lesser General Public License for more details. |
21 | | * |
22 | | * You should have received a copy of the GNU Lesser General Public |
23 | | * License along with FFmpeg; if not, write to the Free Software |
24 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
25 | | */ |
26 | | |
27 | | #include <stddef.h> |
28 | | |
29 | | #include "libavutil/attributes.h" |
30 | | |
31 | | static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst, |
32 | | int src_size) |
33 | 837 | { |
34 | 837 | uint8_t *dest = dst; |
35 | 837 | const uint8_t *s = src; |
36 | 837 | const uint8_t *end = s + src_size; |
37 | | |
38 | 9.89k | while (s < end) { |
39 | | #if HAVE_BIGENDIAN |
40 | | /* RGB24 (= R, G, B) -> RGB32 (= A, B, G, R) */ |
41 | | *dest++ = 255; |
42 | | *dest++ = s[2]; |
43 | | *dest++ = s[1]; |
44 | | *dest++ = s[0]; |
45 | | s += 3; |
46 | | #else |
47 | 9.05k | *dest++ = *s++; |
48 | 9.05k | *dest++ = *s++; |
49 | 9.05k | *dest++ = *s++; |
50 | 9.05k | *dest++ = 255; |
51 | 9.05k | #endif |
52 | 9.05k | } |
53 | 837 | } |
54 | | |
55 | | static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst, |
56 | | int src_size) |
57 | 290 | { |
58 | 290 | uint8_t *dest = dst; |
59 | 290 | const uint8_t *s = src; |
60 | 290 | const uint8_t *end = s + src_size; |
61 | | |
62 | 6.81k | while (s < end) { |
63 | | #if HAVE_BIGENDIAN |
64 | | /* RGB32 (= A, B, G, R) -> RGB24 (= R, G, B) */ |
65 | | s++; |
66 | | dest[2] = *s++; |
67 | | dest[1] = *s++; |
68 | | dest[0] = *s++; |
69 | | dest += 3; |
70 | | #else |
71 | 6.52k | *dest++ = *s++; |
72 | 6.52k | *dest++ = *s++; |
73 | 6.52k | *dest++ = *s++; |
74 | 6.52k | s++; |
75 | 6.52k | #endif |
76 | 6.52k | } |
77 | 290 | } |
78 | | |
79 | | /* |
80 | | * original by Strepto/Astral |
81 | | * ported to gcc & bugfixed: A'rpi |
82 | | * MMXEXT, 3DNOW optimization by Nick Kurshev |
83 | | * 32-bit C version, and and&add trick by Michael Niedermayer |
84 | | */ |
85 | | static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size) |
86 | 1.04k | { |
87 | 1.04k | register uint8_t *d = dst; |
88 | 1.04k | register const uint8_t *s = src; |
89 | 1.04k | register const uint8_t *end = s + src_size; |
90 | 1.04k | const uint8_t *mm_end = end - 3; |
91 | | |
92 | 24.7k | while (s < mm_end) { |
93 | 23.6k | register unsigned x = *((const uint32_t *)s); |
94 | 23.6k | *((uint32_t *)d) = (x & 0x7FFF7FFF) + (x & 0x7FE07FE0); |
95 | 23.6k | d += 4; |
96 | 23.6k | s += 4; |
97 | 23.6k | } |
98 | 1.04k | if (s < end) { |
99 | 438 | register unsigned short x = *((const uint16_t *)s); |
100 | 438 | *((uint16_t *)d) = (x & 0x7FFF) + (x & 0x7FE0); |
101 | 438 | } |
102 | 1.04k | } |
103 | | |
104 | | static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size) |
105 | 1.93k | { |
106 | 1.93k | register uint8_t *d = dst; |
107 | 1.93k | register const uint8_t *s = src; |
108 | 1.93k | register const uint8_t *end = s + src_size; |
109 | 1.93k | const uint8_t *mm_end = end - 3; |
110 | | |
111 | 41.4k | while (s < mm_end) { |
112 | 39.5k | register uint32_t x = *((const uint32_t *)s); |
113 | 39.5k | *((uint32_t *)d) = ((x >> 1) & 0x7FE07FE0) | (x & 0x001F001F); |
114 | 39.5k | s += 4; |
115 | 39.5k | d += 4; |
116 | 39.5k | } |
117 | 1.93k | if (s < end) { |
118 | 1.12k | register uint16_t x = *((const uint16_t *)s); |
119 | 1.12k | *((uint16_t *)d) = ((x >> 1) & 0x7FE0) | (x & 0x001F); |
120 | 1.12k | } |
121 | 1.93k | } |
122 | | |
123 | | static inline void rgb32to16_c(const uint8_t *src, uint8_t *dst, int src_size) |
124 | 904 | { |
125 | 904 | uint16_t *d = (uint16_t *)dst; |
126 | 904 | const uint8_t *s = src; |
127 | 904 | const uint8_t *end = s + src_size; |
128 | | |
129 | 44.1k | while (s < end) { |
130 | 43.2k | register int rgb = *(const uint32_t *)s; |
131 | 43.2k | s += 4; |
132 | 43.2k | *d++ = ((rgb & 0xFF) >> 3) + |
133 | 43.2k | ((rgb & 0xFC00) >> 5) + |
134 | 43.2k | ((rgb & 0xF80000) >> 8); |
135 | 43.2k | } |
136 | 904 | } |
137 | | |
138 | | static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst, |
139 | | int src_size) |
140 | 635 | { |
141 | 635 | uint16_t *d = (uint16_t *)dst; |
142 | 635 | const uint8_t *s = src; |
143 | 635 | const uint8_t *end = s + src_size; |
144 | | |
145 | 45.8k | while (s < end) { |
146 | 45.1k | register int rgb = *(const uint32_t *)s; |
147 | 45.1k | s += 4; |
148 | 45.1k | *d++ = ((rgb & 0xF8) << 8) + |
149 | 45.1k | ((rgb & 0xFC00) >> 5) + |
150 | 45.1k | ((rgb & 0xF80000) >> 19); |
151 | 45.1k | } |
152 | 635 | } |
153 | | |
154 | | static inline void rgb32to15_c(const uint8_t *src, uint8_t *dst, int src_size) |
155 | 631 | { |
156 | 631 | uint16_t *d = (uint16_t *)dst; |
157 | 631 | const uint8_t *s = src; |
158 | 631 | const uint8_t *end = s + src_size; |
159 | | |
160 | 11.9k | while (s < end) { |
161 | 11.3k | register int rgb = *(const uint32_t *)s; |
162 | 11.3k | s += 4; |
163 | 11.3k | *d++ = ((rgb & 0xFF) >> 3) + |
164 | 11.3k | ((rgb & 0xF800) >> 6) + |
165 | 11.3k | ((rgb & 0xF80000) >> 9); |
166 | 11.3k | } |
167 | 631 | } |
168 | | |
169 | | static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst, |
170 | | int src_size) |
171 | 555 | { |
172 | 555 | uint16_t *d = (uint16_t *)dst; |
173 | 555 | const uint8_t *s = src; |
174 | 555 | const uint8_t *end = s + src_size; |
175 | | |
176 | 11.9k | while (s < end) { |
177 | 11.4k | register int rgb = *(const uint32_t *)s; |
178 | 11.4k | s += 4; |
179 | 11.4k | *d++ = ((rgb & 0xF8) << 7) + |
180 | 11.4k | ((rgb & 0xF800) >> 6) + |
181 | 11.4k | ((rgb & 0xF80000) >> 19); |
182 | 11.4k | } |
183 | 555 | } |
184 | | |
185 | | static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst, |
186 | | int src_size) |
187 | 293 | { |
188 | 293 | uint16_t *d = (uint16_t *)dst; |
189 | 293 | const uint8_t *s = src; |
190 | 293 | const uint8_t *end = s + src_size; |
191 | | |
192 | 42.0k | while (s < end) { |
193 | 41.7k | const int b = *s++; |
194 | 41.7k | const int g = *s++; |
195 | 41.7k | const int r = *s++; |
196 | 41.7k | *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8); |
197 | 41.7k | } |
198 | 293 | } |
199 | | |
200 | | static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size) |
201 | 786 | { |
202 | 786 | uint16_t *d = (uint16_t *)dst; |
203 | 786 | const uint8_t *s = src; |
204 | 786 | const uint8_t *end = s + src_size; |
205 | | |
206 | 30.0k | while (s < end) { |
207 | 29.2k | const int r = *s++; |
208 | 29.2k | const int g = *s++; |
209 | 29.2k | const int b = *s++; |
210 | 29.2k | *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8); |
211 | 29.2k | } |
212 | 786 | } |
213 | | |
214 | | static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst, |
215 | | int src_size) |
216 | 555 | { |
217 | 555 | uint16_t *d = (uint16_t *)dst; |
218 | 555 | const uint8_t *s = src; |
219 | 555 | const uint8_t *end = s + src_size; |
220 | | |
221 | 19.3k | while (s < end) { |
222 | 18.8k | const int b = *s++; |
223 | 18.8k | const int g = *s++; |
224 | 18.8k | const int r = *s++; |
225 | 18.8k | *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7); |
226 | 18.8k | } |
227 | 555 | } |
228 | | |
229 | | static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size) |
230 | 557 | { |
231 | 557 | uint16_t *d = (uint16_t *)dst; |
232 | 557 | const uint8_t *s = src; |
233 | 557 | const uint8_t *end = s + src_size; |
234 | | |
235 | 19.3k | while (s < end) { |
236 | 18.7k | const int r = *s++; |
237 | 18.7k | const int g = *s++; |
238 | 18.7k | const int b = *s++; |
239 | 18.7k | *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7); |
240 | 18.7k | } |
241 | 557 | } |
242 | | |
243 | | static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, |
244 | | int src_size) |
245 | 786 | { |
246 | 786 | uint8_t *d = dst; |
247 | 786 | const uint16_t *s = (const uint16_t *)src; |
248 | 786 | const uint16_t *end = s + src_size / 2; |
249 | | |
250 | 33.2k | while (s < end) { |
251 | 32.4k | register uint16_t bgr = *s++; |
252 | 32.4k | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
253 | 32.4k | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
254 | 32.4k | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
255 | 32.4k | } |
256 | 786 | } |
257 | | |
258 | | static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst, |
259 | | int src_size) |
260 | 299 | { |
261 | 299 | uint8_t *d = (uint8_t *)dst; |
262 | 299 | const uint16_t *s = (const uint16_t *)src; |
263 | 299 | const uint16_t *end = s + src_size / 2; |
264 | | |
265 | 24.6k | while (s < end) { |
266 | 24.3k | register uint16_t bgr = *s++; |
267 | 24.3k | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
268 | 24.3k | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
269 | 24.3k | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
270 | 24.3k | } |
271 | 299 | } |
272 | | |
273 | | static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size) |
274 | 1.40k | { |
275 | 1.40k | uint8_t *d = dst; |
276 | 1.40k | const uint16_t *s = (const uint16_t *)src; |
277 | 1.40k | const uint16_t *end = s + src_size / 2; |
278 | | |
279 | 65.7k | while (s < end) { |
280 | 64.3k | register uint16_t bgr = *s++; |
281 | | #if HAVE_BIGENDIAN |
282 | | *d++ = 255; |
283 | | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
284 | | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
285 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
286 | | #else |
287 | 64.3k | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
288 | 64.3k | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); |
289 | 64.3k | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); |
290 | 64.3k | *d++ = 255; |
291 | 64.3k | #endif |
292 | 64.3k | } |
293 | 1.40k | } |
294 | | |
295 | | static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size) |
296 | 756 | { |
297 | 756 | uint8_t *d = dst; |
298 | 756 | const uint16_t *s = (const uint16_t *)src; |
299 | 756 | const uint16_t *end = s + src_size / 2; |
300 | | |
301 | 54.5k | while (s < end) { |
302 | 53.7k | register uint16_t bgr = *s++; |
303 | | #if HAVE_BIGENDIAN |
304 | | *d++ = 255; |
305 | | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
306 | | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
307 | | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
308 | | #else |
309 | 53.7k | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); |
310 | 53.7k | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); |
311 | 53.7k | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); |
312 | 53.7k | *d++ = 255; |
313 | 53.7k | #endif |
314 | 53.7k | } |
315 | 756 | } |
316 | | |
317 | | static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst, |
318 | | int src_size) |
319 | 8 | { |
320 | 8 | int idx = 15 - src_size; |
321 | 8 | const uint8_t *s = src - idx; |
322 | 8 | uint8_t *d = dst - idx; |
323 | | |
324 | 294 | for (; idx < 15; idx += 4) { |
325 | 286 | register unsigned v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00; |
326 | 286 | v &= 0xff00ff; |
327 | 286 | *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16); |
328 | 286 | } |
329 | 8 | } |
330 | | |
331 | | static inline void shuffle_bytes_0321_c(const uint8_t *src, uint8_t *dst, |
332 | | int src_size) |
333 | 8 | { |
334 | 8 | int idx = 15 - src_size; |
335 | 8 | const uint8_t *s = src - idx; |
336 | 8 | uint8_t *d = dst - idx; |
337 | | |
338 | 9.34k | for (; idx < 15; idx += 4) { |
339 | 9.33k | register unsigned v = *(const uint32_t *)&s[idx], g = v & 0x00ff00ff; |
340 | 9.33k | v &= 0xff00ff00; |
341 | 9.33k | *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16); |
342 | 9.33k | } |
343 | 8 | } |
344 | | |
345 | | #define DEFINE_SHUFFLE_BYTES(name, a, b, c, d) \ |
346 | | static void shuffle_bytes_##name (const uint8_t *src, \ |
347 | 2.16k | uint8_t *dst, int src_size) \ |
348 | 2.16k | { \ |
349 | 2.16k | int i; \ |
350 | 2.16k | \ |
351 | 114k | for (i = 0; i < src_size; i += 4) { \ |
352 | 112k | dst[i + 0] = src[i + a]; \ |
353 | 112k | dst[i + 1] = src[i + b]; \ |
354 | 112k | dst[i + 2] = src[i + c]; \ |
355 | 112k | dst[i + 3] = src[i + d]; \ |
356 | 112k | } \ |
357 | 2.16k | } rgb2rgb.c:shuffle_bytes_1230_c Line | Count | Source | 347 | 8 | uint8_t *dst, int src_size) \ | 348 | 8 | { \ | 349 | 8 | int i; \ | 350 | 8 | \ | 351 | 13.8k | for (i = 0; i < src_size; i += 4) { \ | 352 | 13.8k | dst[i + 0] = src[i + a]; \ | 353 | 13.8k | dst[i + 1] = src[i + b]; \ | 354 | 13.8k | dst[i + 2] = src[i + c]; \ | 355 | 13.8k | dst[i + 3] = src[i + d]; \ | 356 | 13.8k | } \ | 357 | 8 | } |
rgb2rgb.c:shuffle_bytes_3012_c Line | Count | Source | 347 | 8 | uint8_t *dst, int src_size) \ | 348 | 8 | { \ | 349 | 8 | int i; \ | 350 | 8 | \ | 351 | 7.79k | for (i = 0; i < src_size; i += 4) { \ | 352 | 7.79k | dst[i + 0] = src[i + a]; \ | 353 | 7.79k | dst[i + 1] = src[i + b]; \ | 354 | 7.79k | dst[i + 2] = src[i + c]; \ | 355 | 7.79k | dst[i + 3] = src[i + d]; \ | 356 | 7.79k | } \ | 357 | 8 | } |
rgb2rgb.c:shuffle_bytes_3210_c Line | Count | Source | 347 | 792 | uint8_t *dst, int src_size) \ | 348 | 792 | { \ | 349 | 792 | int i; \ | 350 | 792 | \ | 351 | 42.4k | for (i = 0; i < src_size; i += 4) { \ | 352 | 41.6k | dst[i + 0] = src[i + a]; \ | 353 | 41.6k | dst[i + 1] = src[i + b]; \ | 354 | 41.6k | dst[i + 2] = src[i + c]; \ | 355 | 41.6k | dst[i + 3] = src[i + d]; \ | 356 | 41.6k | } \ | 357 | 792 | } |
rgb2rgb.c:shuffle_bytes_3102_c Line | Count | Source | 347 | 8 | uint8_t *dst, int src_size) \ | 348 | 8 | { \ | 349 | 8 | int i; \ | 350 | 8 | \ | 351 | 875 | for (i = 0; i < src_size; i += 4) { \ | 352 | 867 | dst[i + 0] = src[i + a]; \ | 353 | 867 | dst[i + 1] = src[i + b]; \ | 354 | 867 | dst[i + 2] = src[i + c]; \ | 355 | 867 | dst[i + 3] = src[i + d]; \ | 356 | 867 | } \ | 357 | 8 | } |
rgb2rgb.c:shuffle_bytes_2013_c Line | Count | Source | 347 | 1.33k | uint8_t *dst, int src_size) \ | 348 | 1.33k | { \ | 349 | 1.33k | int i; \ | 350 | 1.33k | \ | 351 | 40.5k | for (i = 0; i < src_size; i += 4) { \ | 352 | 39.1k | dst[i + 0] = src[i + a]; \ | 353 | 39.1k | dst[i + 1] = src[i + b]; \ | 354 | 39.1k | dst[i + 2] = src[i + c]; \ | 355 | 39.1k | dst[i + 3] = src[i + d]; \ | 356 | 39.1k | } \ | 357 | 1.33k | } |
rgb2rgb.c:shuffle_bytes_2130_c Line | Count | Source | 347 | 8 | uint8_t *dst, int src_size) \ | 348 | 8 | { \ | 349 | 8 | int i; \ | 350 | 8 | \ | 351 | 8.53k | for (i = 0; i < src_size; i += 4) { \ | 352 | 8.52k | dst[i + 0] = src[i + a]; \ | 353 | 8.52k | dst[i + 1] = src[i + b]; \ | 354 | 8.52k | dst[i + 2] = src[i + c]; \ | 355 | 8.52k | dst[i + 3] = src[i + d]; \ | 356 | 8.52k | } \ | 357 | 8 | } |
rgb2rgb.c:shuffle_bytes_1203_c Line | Count | Source | 347 | 8 | uint8_t *dst, int src_size) \ | 348 | 8 | { \ | 349 | 8 | int i; \ | 350 | 8 | \ | 351 | 342 | for (i = 0; i < src_size; i += 4) { \ | 352 | 334 | dst[i + 0] = src[i + a]; \ | 353 | 334 | dst[i + 1] = src[i + b]; \ | 354 | 334 | dst[i + 2] = src[i + c]; \ | 355 | 334 | dst[i + 3] = src[i + d]; \ | 356 | 334 | } \ | 357 | 8 | } |
|
358 | | |
359 | | DEFINE_SHUFFLE_BYTES(1230_c, 1, 2, 3, 0) |
360 | | DEFINE_SHUFFLE_BYTES(3012_c, 3, 0, 1, 2) |
361 | | DEFINE_SHUFFLE_BYTES(3210_c, 3, 2, 1, 0) |
362 | | DEFINE_SHUFFLE_BYTES(3102_c, 3, 1, 0, 2) |
363 | | DEFINE_SHUFFLE_BYTES(2013_c, 2, 0, 1, 3) |
364 | | DEFINE_SHUFFLE_BYTES(2130_c, 2, 1, 3, 0) |
365 | | DEFINE_SHUFFLE_BYTES(1203_c, 1, 2, 0, 3) |
366 | | |
367 | | static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size) |
368 | 541 | { |
369 | 541 | unsigned i; |
370 | | |
371 | 12.0k | for (i = 0; i < src_size; i += 3) { |
372 | 11.5k | register uint8_t x = src[i + 2]; |
373 | 11.5k | dst[i + 1] = src[i + 1]; |
374 | 11.5k | dst[i + 2] = src[i + 0]; |
375 | 11.5k | dst[i + 0] = x; |
376 | 11.5k | } |
377 | 541 | } |
378 | | |
379 | | static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc, |
380 | | const uint8_t *vsrc, uint8_t *dst, |
381 | | int width, int height, |
382 | | int lumStride, int chromStride, |
383 | | int dstStride, int vertLumPerChroma) |
384 | 35 | { |
385 | 35 | int y, i; |
386 | 35 | const int chromWidth = width >> 1; |
387 | | |
388 | 1.85k | for (y = 0; y < height; y++) { |
389 | | #if HAVE_FAST_64BIT |
390 | | uint64_t *ldst = (uint64_t *)dst; |
391 | | const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; |
392 | | for (i = 0; i < chromWidth; i += 2) { |
393 | | uint64_t k = yc[0] + (uc[0] << 8) + |
394 | | (yc[1] << 16) + ((unsigned) vc[0] << 24); |
395 | | uint64_t l = yc[2] + (uc[1] << 8) + |
396 | | (yc[3] << 16) + ((unsigned) vc[1] << 24); |
397 | | *ldst++ = k + (l << 32); |
398 | | yc += 4; |
399 | | uc += 2; |
400 | | vc += 2; |
401 | | } |
402 | | |
403 | | #else |
404 | 1.82k | int *idst = (int32_t *)dst; |
405 | 1.82k | const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; |
406 | | |
407 | 46.8k | for (i = 0; i < chromWidth; i++) { |
408 | | #if HAVE_BIGENDIAN |
409 | | *idst++ = (yc[0] << 24) + (uc[0] << 16) + |
410 | | (yc[1] << 8) + (vc[0] << 0); |
411 | | #else |
412 | 45.0k | *idst++ = yc[0] + (uc[0] << 8) + |
413 | 45.0k | (yc[1] << 16) + (vc[0] << 24); |
414 | 45.0k | #endif |
415 | 45.0k | yc += 2; |
416 | 45.0k | uc++; |
417 | 45.0k | vc++; |
418 | 45.0k | } |
419 | 1.82k | #endif |
420 | 1.82k | if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) { |
421 | 1.23k | usrc += chromStride; |
422 | 1.23k | vsrc += chromStride; |
423 | 1.23k | } |
424 | 1.82k | ysrc += lumStride; |
425 | 1.82k | dst += dstStride; |
426 | 1.82k | } |
427 | 35 | } |
428 | | |
429 | | /** |
430 | | * Height should be a multiple of 2 and width should be a multiple of 16. |
431 | | * (If this is a problem for anyone then tell me, and I will fix it.) |
432 | | */ |
433 | | static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc, |
434 | | const uint8_t *vsrc, uint8_t *dst, |
435 | | int width, int height, int lumStride, |
436 | | int chromStride, int dstStride) |
437 | 17 | { |
438 | | //FIXME interpolate chroma |
439 | 17 | yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride, |
440 | 17 | chromStride, dstStride, 2); |
441 | 17 | } |
442 | | |
443 | | static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc, |
444 | | const uint8_t *vsrc, uint8_t *dst, |
445 | | int width, int height, |
446 | | int lumStride, int chromStride, |
447 | | int dstStride, int vertLumPerChroma) |
448 | 38 | { |
449 | 38 | int y, i; |
450 | 38 | const int chromWidth = width >> 1; |
451 | | |
452 | 18.1k | for (y = 0; y < height; y++) { |
453 | | #if HAVE_FAST_64BIT |
454 | | uint64_t *ldst = (uint64_t *)dst; |
455 | | const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; |
456 | | for (i = 0; i < chromWidth; i += 2) { |
457 | | uint64_t k = uc[0] + (yc[0] << 8) + |
458 | | (vc[0] << 16) + ((unsigned) yc[1] << 24); |
459 | | uint64_t l = uc[1] + (yc[2] << 8) + |
460 | | (vc[1] << 16) + ((unsigned) yc[3] << 24); |
461 | | *ldst++ = k + (l << 32); |
462 | | yc += 4; |
463 | | uc += 2; |
464 | | vc += 2; |
465 | | } |
466 | | |
467 | | #else |
468 | 18.0k | int *idst = (int32_t *)dst; |
469 | 18.0k | const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; |
470 | | |
471 | 66.5k | for (i = 0; i < chromWidth; i++) { |
472 | | #if HAVE_BIGENDIAN |
473 | | *idst++ = (uc[0] << 24) + (yc[0] << 16) + |
474 | | (vc[0] << 8) + (yc[1] << 0); |
475 | | #else |
476 | 48.4k | *idst++ = uc[0] + (yc[0] << 8) + |
477 | 48.4k | (vc[0] << 16) + (yc[1] << 24); |
478 | 48.4k | #endif |
479 | 48.4k | yc += 2; |
480 | 48.4k | uc++; |
481 | 48.4k | vc++; |
482 | 48.4k | } |
483 | 18.0k | #endif |
484 | 18.0k | if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) { |
485 | 9.60k | usrc += chromStride; |
486 | 9.60k | vsrc += chromStride; |
487 | 9.60k | } |
488 | 18.0k | ysrc += lumStride; |
489 | 18.0k | dst += dstStride; |
490 | 18.0k | } |
491 | 38 | } |
492 | | |
493 | | /** |
494 | | * Height should be a multiple of 2 and width should be a multiple of 16 |
495 | | * (If this is a problem for anyone then tell me, and I will fix it.) |
496 | | */ |
497 | | static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc, |
498 | | const uint8_t *vsrc, uint8_t *dst, |
499 | | int width, int height, int lumStride, |
500 | | int chromStride, int dstStride) |
501 | 18 | { |
502 | | //FIXME interpolate chroma |
503 | 18 | yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride, |
504 | 18 | chromStride, dstStride, 2); |
505 | 18 | } |
506 | | |
507 | | /** |
508 | | * Width should be a multiple of 16. |
509 | | */ |
510 | | static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc, |
511 | | const uint8_t *vsrc, uint8_t *dst, |
512 | | int width, int height, int lumStride, |
513 | | int chromStride, int dstStride) |
514 | 20 | { |
515 | 20 | yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride, |
516 | 20 | chromStride, dstStride, 1); |
517 | 20 | } |
518 | | |
519 | | /** |
520 | | * Width should be a multiple of 16. |
521 | | */ |
522 | | static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc, |
523 | | const uint8_t *vsrc, uint8_t *dst, |
524 | | int width, int height, int lumStride, |
525 | | int chromStride, int dstStride) |
526 | 18 | { |
527 | 18 | yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride, |
528 | 18 | chromStride, dstStride, 1); |
529 | 18 | } |
530 | | |
531 | | /** |
532 | | * Height should be a multiple of 2 and width should be a multiple of 16. |
533 | | * (If this is a problem for anyone then tell me, and I will fix it.) |
534 | | */ |
535 | | static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst, |
536 | | uint8_t *udst, uint8_t *vdst, |
537 | | int width, int height, int lumStride, |
538 | | int chromStride, int srcStride) |
539 | 0 | { |
540 | 0 | int y; |
541 | 0 | const int chromWidth = width >> 1; |
542 | |
|
543 | 0 | for (y = 0; y < height; y += 2) { |
544 | 0 | int i; |
545 | 0 | for (i = 0; i < chromWidth; i++) { |
546 | 0 | ydst[2 * i + 0] = src[4 * i + 0]; |
547 | 0 | udst[i] = src[4 * i + 1]; |
548 | 0 | ydst[2 * i + 1] = src[4 * i + 2]; |
549 | 0 | vdst[i] = src[4 * i + 3]; |
550 | 0 | } |
551 | 0 | ydst += lumStride; |
552 | 0 | src += srcStride; |
553 | |
|
554 | 0 | for (i = 0; i < chromWidth; i++) { |
555 | 0 | ydst[2 * i + 0] = src[4 * i + 0]; |
556 | 0 | ydst[2 * i + 1] = src[4 * i + 2]; |
557 | 0 | } |
558 | 0 | udst += chromStride; |
559 | 0 | vdst += chromStride; |
560 | 0 | ydst += lumStride; |
561 | 0 | src += srcStride; |
562 | 0 | } |
563 | 0 | } |
564 | | |
565 | | static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth, |
566 | | int srcHeight, int srcStride, int dstStride) |
567 | 34 | { |
568 | 34 | int x, y; |
569 | | |
570 | 34 | dst[0] = src[0]; |
571 | | |
572 | | // first line |
573 | 3.08k | for (x = 0; x < srcWidth - 1; x++) { |
574 | 3.04k | dst[2 * x + 1] = (3 * src[x] + src[x + 1]) >> 2; |
575 | 3.04k | dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2; |
576 | 3.04k | } |
577 | 34 | dst[2 * srcWidth - 1] = src[srcWidth - 1]; |
578 | | |
579 | 34 | dst += dstStride; |
580 | | |
581 | 2.01k | for (y = 1; y < srcHeight; y++) { |
582 | 1.98k | const int mmxSize = 1; |
583 | | |
584 | 1.98k | dst[0] = (src[0] * 3 + src[srcStride]) >> 2; |
585 | 1.98k | dst[dstStride] = (src[0] + 3 * src[srcStride]) >> 2; |
586 | | |
587 | 6.93k | for (x = mmxSize - 1; x < srcWidth - 1; x++) { |
588 | 4.95k | dst[2 * x + 1] = (src[x + 0] * 3 + src[x + srcStride + 1]) >> 2; |
589 | 4.95k | dst[2 * x + dstStride + 2] = (src[x + 0] + 3 * src[x + srcStride + 1]) >> 2; |
590 | 4.95k | dst[2 * x + dstStride + 1] = (src[x + 1] + 3 * src[x + srcStride]) >> 2; |
591 | 4.95k | dst[2 * x + 2] = (src[x + 1] * 3 + src[x + srcStride]) >> 2; |
592 | 4.95k | } |
593 | 1.98k | dst[srcWidth * 2 - 1] = (src[srcWidth - 1] * 3 + src[srcWidth - 1 + srcStride]) >> 2; |
594 | 1.98k | dst[srcWidth * 2 - 1 + dstStride] = (src[srcWidth - 1] + 3 * src[srcWidth - 1 + srcStride]) >> 2; |
595 | | |
596 | 1.98k | dst += dstStride * 2; |
597 | 1.98k | src += srcStride; |
598 | 1.98k | } |
599 | | |
600 | | // last line |
601 | 34 | dst[0] = src[0]; |
602 | | |
603 | 3.08k | for (x = 0; x < srcWidth - 1; x++) { |
604 | 3.04k | dst[2 * x + 1] = (src[x] * 3 + src[x + 1]) >> 2; |
605 | 3.04k | dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2; |
606 | 3.04k | } |
607 | 34 | dst[2 * srcWidth - 1] = src[srcWidth - 1]; |
608 | 34 | } |
609 | | |
610 | | /** |
611 | | * Height should be a multiple of 2 and width should be a multiple of 16. |
612 | | * (If this is a problem for anyone then tell me, and I will fix it.) |
613 | | * Chrominance data is only taken from every second line, others are ignored. |
614 | | * FIXME: Write HQ version. |
615 | | */ |
616 | | static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst, |
617 | | uint8_t *udst, uint8_t *vdst, |
618 | | int width, int height, int lumStride, |
619 | | int chromStride, int srcStride) |
620 | 0 | { |
621 | 0 | int y; |
622 | 0 | const int chromWidth = width >> 1; |
623 | 0 |
|
624 | 0 | for (y = 0; y < height; y += 2) { |
625 | 0 | int i; |
626 | 0 | for (i = 0; i < chromWidth; i++) { |
627 | 0 | udst[i] = src[4 * i + 0]; |
628 | 0 | ydst[2 * i + 0] = src[4 * i + 1]; |
629 | 0 | vdst[i] = src[4 * i + 2]; |
630 | 0 | ydst[2 * i + 1] = src[4 * i + 3]; |
631 | 0 | } |
632 | 0 | ydst += lumStride; |
633 | 0 | src += srcStride; |
634 | 0 |
|
635 | 0 | for (i = 0; i < chromWidth; i++) { |
636 | 0 | ydst[2 * i + 0] = src[4 * i + 1]; |
637 | 0 | ydst[2 * i + 1] = src[4 * i + 3]; |
638 | 0 | } |
639 | 0 | udst += chromStride; |
640 | 0 | vdst += chromStride; |
641 | 0 | ydst += lumStride; |
642 | 0 | src += srcStride; |
643 | 0 | } |
644 | 0 | } |
645 | | |
646 | | /** |
647 | | * width should be a multiple of 2. |
648 | | * (If this is a problem for anyone then tell me, and I will fix it.) |
649 | | */ |
650 | | void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst, |
651 | | uint8_t *vdst, int width, int height, int lumStride, |
652 | | int chromStride, int srcStride, const int32_t *rgb2yuv) |
653 | 217k | { |
654 | 217k | int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX]; |
655 | 217k | int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; |
656 | 217k | int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX]; |
657 | 217k | int y; |
658 | 217k | const int chromWidth = width >> 1; |
659 | 217k | const uint8_t *src1 = src; |
660 | 217k | const uint8_t *src2 = src1 + srcStride; |
661 | 217k | uint8_t *ydst1 = ydst; |
662 | 217k | uint8_t *ydst2 = ydst + lumStride; |
663 | | |
664 | 435k | for (y = 0; y < height; y += 2) { |
665 | 218k | int i; |
666 | 218k | if (y + 1 == height) { |
667 | 8 | ydst2 = ydst1; |
668 | 8 | src2 = src1; |
669 | 8 | } |
670 | | |
671 | 455k | for (i = 0; i < chromWidth; i++) { |
672 | 236k | unsigned int b11 = src1[6 * i + 0]; |
673 | 236k | unsigned int g11 = src1[6 * i + 1]; |
674 | 236k | unsigned int r11 = src1[6 * i + 2]; |
675 | 236k | unsigned int b12 = src1[6 * i + 3]; |
676 | 236k | unsigned int g12 = src1[6 * i + 4]; |
677 | 236k | unsigned int r12 = src1[6 * i + 5]; |
678 | 236k | unsigned int b21 = src2[6 * i + 0]; |
679 | 236k | unsigned int g21 = src2[6 * i + 1]; |
680 | 236k | unsigned int r21 = src2[6 * i + 2]; |
681 | 236k | unsigned int b22 = src2[6 * i + 3]; |
682 | 236k | unsigned int g22 = src2[6 * i + 4]; |
683 | 236k | unsigned int r22 = src2[6 * i + 5]; |
684 | | |
685 | 236k | unsigned int Y11 = ((ry * r11 + gy * g11 + by * b11) >> RGB2YUV_SHIFT) + 16; |
686 | 236k | unsigned int Y12 = ((ry * r12 + gy * g12 + by * b12) >> RGB2YUV_SHIFT) + 16; |
687 | 236k | unsigned int Y21 = ((ry * r21 + gy * g21 + by * b21) >> RGB2YUV_SHIFT) + 16; |
688 | 236k | unsigned int Y22 = ((ry * r22 + gy * g22 + by * b22) >> RGB2YUV_SHIFT) + 16; |
689 | | |
690 | 236k | unsigned int bx = (b11 + b12 + b21 + b22) >> 2; |
691 | 236k | unsigned int gx = (g11 + g12 + g21 + g22) >> 2; |
692 | 236k | unsigned int rx = (r11 + r12 + r21 + r22) >> 2; |
693 | | |
694 | 236k | unsigned int U = ((ru * rx + gu * gx + bu * bx) >> RGB2YUV_SHIFT) + 128; |
695 | 236k | unsigned int V = ((rv * rx + gv * gx + bv * bx) >> RGB2YUV_SHIFT) + 128; |
696 | | |
697 | 236k | ydst1[2 * i + 0] = Y11; |
698 | 236k | ydst1[2 * i + 1] = Y12; |
699 | 236k | ydst2[2 * i + 0] = Y21; |
700 | 236k | ydst2[2 * i + 1] = Y22; |
701 | 236k | udst[i] = U; |
702 | 236k | vdst[i] = V; |
703 | 236k | } |
704 | 218k | src1 += srcStride * 2; |
705 | 218k | src2 += srcStride * 2; |
706 | 218k | ydst1 += lumStride * 2; |
707 | 218k | ydst2 += lumStride * 2; |
708 | 218k | udst += chromStride; |
709 | 218k | vdst += chromStride; |
710 | 218k | } |
711 | 217k | } |
712 | | |
713 | | static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2, |
714 | | uint8_t *dest, int width, int height, |
715 | | int src1Stride, int src2Stride, int dstStride) |
716 | 12 | { |
717 | 12 | int h; |
718 | | |
719 | 338 | for (h = 0; h < height; h++) { |
720 | 326 | int w; |
721 | 13.1k | for (w = 0; w < width; w++) { |
722 | 12.8k | dest[2 * w + 0] = src1[w]; |
723 | 12.8k | dest[2 * w + 1] = src2[w]; |
724 | 12.8k | } |
725 | 326 | dest += dstStride; |
726 | 326 | src1 += src1Stride; |
727 | 326 | src2 += src2Stride; |
728 | 326 | } |
729 | 12 | } |
730 | | |
731 | | static void deinterleaveBytes_c(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, |
732 | | int width, int height, int srcStride, |
733 | | int dst1Stride, int dst2Stride) |
734 | 11 | { |
735 | 11 | int h; |
736 | | |
737 | 278 | for (h = 0; h < height; h++) { |
738 | 267 | int w; |
739 | 6.28k | for (w = 0; w < width; w++) { |
740 | 6.01k | dst1[w] = src[2 * w + 0]; |
741 | 6.01k | dst2[w] = src[2 * w + 1]; |
742 | 6.01k | } |
743 | 267 | src += srcStride; |
744 | 267 | dst1 += dst1Stride; |
745 | 267 | dst2 += dst2Stride; |
746 | 267 | } |
747 | 11 | } |
748 | | |
749 | | static inline void vu9_to_vu12_c(const uint8_t *src1, const uint8_t *src2, |
750 | | uint8_t *dst1, uint8_t *dst2, |
751 | | int width, int height, |
752 | | int srcStride1, int srcStride2, |
753 | | int dstStride1, int dstStride2) |
754 | 0 | { |
755 | 0 | int x, y; |
756 | 0 | int w = width / 2; |
757 | 0 | int h = height / 2; |
758 | |
|
759 | 0 | for (y = 0; y < h; y++) { |
760 | 0 | const uint8_t *s1 = src1 + srcStride1 * (y >> 1); |
761 | 0 | uint8_t *d = dst1 + dstStride1 * y; |
762 | 0 | for (x = 0; x < w; x++) |
763 | 0 | d[2 * x] = d[2 * x + 1] = s1[x]; |
764 | 0 | } |
765 | 0 | for (y = 0; y < h; y++) { |
766 | 0 | const uint8_t *s2 = src2 + srcStride2 * (y >> 1); |
767 | 0 | uint8_t *d = dst2 + dstStride2 * y; |
768 | 0 | for (x = 0; x < w; x++) |
769 | 0 | d[2 * x] = d[2 * x + 1] = s2[x]; |
770 | 0 | } |
771 | 0 | } |
772 | | |
773 | | static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2, |
774 | | const uint8_t *src3, uint8_t *dst, |
775 | | int width, int height, |
776 | | int srcStride1, int srcStride2, |
777 | | int srcStride3, int dstStride) |
778 | 0 | { |
779 | 0 | int x, y; |
780 | 0 | int w = width / 2; |
781 | 0 | int h = height; |
782 | |
|
783 | 0 | for (y = 0; y < h; y++) { |
784 | 0 | const uint8_t *yp = src1 + srcStride1 * y; |
785 | 0 | const uint8_t *up = src2 + srcStride2 * (y >> 2); |
786 | 0 | const uint8_t *vp = src3 + srcStride3 * (y >> 2); |
787 | 0 | uint8_t *d = dst + dstStride * y; |
788 | 0 | for (x = 0; x < w; x++) { |
789 | 0 | const int x2 = x << 2; |
790 | 0 | d[8 * x + 0] = yp[x2]; |
791 | 0 | d[8 * x + 1] = up[x]; |
792 | 0 | d[8 * x + 2] = yp[x2 + 1]; |
793 | 0 | d[8 * x + 3] = vp[x]; |
794 | 0 | d[8 * x + 4] = yp[x2 + 2]; |
795 | 0 | d[8 * x + 5] = up[x]; |
796 | 0 | d[8 * x + 6] = yp[x2 + 3]; |
797 | 0 | d[8 * x + 7] = vp[x]; |
798 | 0 | } |
799 | 0 | } |
800 | 0 | } |
801 | | |
802 | | static void extract_even_c(const uint8_t *src, uint8_t *dst, int count) |
803 | 5.13k | { |
804 | 5.13k | dst += count; |
805 | 5.13k | src += count * 2; |
806 | 5.13k | count = -count; |
807 | 158k | while (count < 0) { |
808 | 153k | dst[count] = src[2 * count]; |
809 | 153k | count++; |
810 | 153k | } |
811 | 5.13k | } |
812 | | |
813 | | static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, |
814 | | int count) |
815 | 1.29k | { |
816 | 1.29k | dst0 += count; |
817 | 1.29k | dst1 += count; |
818 | 1.29k | src += count * 4; |
819 | 1.29k | count = -count; |
820 | 24.2k | while (count < 0) { |
821 | 22.9k | dst0[count] = src[4 * count + 0]; |
822 | 22.9k | dst1[count] = src[4 * count + 2]; |
823 | 22.9k | count++; |
824 | 22.9k | } |
825 | 1.29k | } |
826 | | |
827 | | static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1, |
828 | | uint8_t *dst0, uint8_t *dst1, int count) |
829 | 658 | { |
830 | 658 | dst0 += count; |
831 | 658 | dst1 += count; |
832 | 658 | src0 += count * 4; |
833 | 658 | src1 += count * 4; |
834 | 658 | count = -count; |
835 | 16.4k | while (count < 0) { |
836 | 15.8k | dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1; |
837 | 15.8k | dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1; |
838 | 15.8k | count++; |
839 | 15.8k | } |
840 | 658 | } |
841 | | |
842 | | static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, |
843 | | int count) |
844 | 1.33k | { |
845 | 1.33k | dst0 += count; |
846 | 1.33k | dst1 += count; |
847 | 1.33k | src += count * 4; |
848 | 1.33k | count = -count; |
849 | 1.33k | src++; |
850 | 18.3k | while (count < 0) { |
851 | 17.0k | dst0[count] = src[4 * count + 0]; |
852 | 17.0k | dst1[count] = src[4 * count + 2]; |
853 | 17.0k | count++; |
854 | 17.0k | } |
855 | 1.33k | } |
856 | | |
857 | | static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1, |
858 | | uint8_t *dst0, uint8_t *dst1, int count) |
859 | 589 | { |
860 | 589 | dst0 += count; |
861 | 589 | dst1 += count; |
862 | 589 | src0 += count * 4; |
863 | 589 | src1 += count * 4; |
864 | 589 | count = -count; |
865 | 589 | src0++; |
866 | 589 | src1++; |
867 | 2.38k | while (count < 0) { |
868 | 1.79k | dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1; |
869 | 1.79k | dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1; |
870 | 1.79k | count++; |
871 | 1.79k | } |
872 | 589 | } |
873 | | |
874 | | static void yuyvtoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
875 | | const uint8_t *src, int width, int height, |
876 | | int lumStride, int chromStride, int srcStride) |
877 | 17 | { |
878 | 17 | int y; |
879 | 17 | const int chromWidth = AV_CEIL_RSHIFT(width, 1); |
880 | | |
881 | 1.20k | for (y = 0; y < height; y++) { |
882 | 1.18k | extract_even_c(src, ydst, width); |
883 | 1.18k | if (y & 1) { |
884 | 589 | extract_odd2avg_c(src - srcStride, src, udst, vdst, chromWidth); |
885 | 589 | udst += chromStride; |
886 | 589 | vdst += chromStride; |
887 | 589 | } |
888 | | |
889 | 1.18k | src += srcStride; |
890 | 1.18k | ydst += lumStride; |
891 | 1.18k | } |
892 | 17 | } |
893 | | |
894 | | static void yuyvtoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
895 | | const uint8_t *src, int width, int height, |
896 | | int lumStride, int chromStride, int srcStride) |
897 | 14 | { |
898 | 14 | int y; |
899 | 14 | const int chromWidth = AV_CEIL_RSHIFT(width, 1); |
900 | | |
901 | 1.35k | for (y = 0; y < height; y++) { |
902 | 1.33k | extract_even_c(src, ydst, width); |
903 | 1.33k | extract_odd2_c(src, udst, vdst, chromWidth); |
904 | | |
905 | 1.33k | src += srcStride; |
906 | 1.33k | ydst += lumStride; |
907 | 1.33k | udst += chromStride; |
908 | 1.33k | vdst += chromStride; |
909 | 1.33k | } |
910 | 14 | } |
911 | | |
912 | | static void uyvytoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
913 | | const uint8_t *src, int width, int height, |
914 | | int lumStride, int chromStride, int srcStride) |
915 | 20 | { |
916 | 20 | int y; |
917 | 20 | const int chromWidth = AV_CEIL_RSHIFT(width, 1); |
918 | | |
919 | 1.34k | for (y = 0; y < height; y++) { |
920 | 1.32k | extract_even_c(src + 1, ydst, width); |
921 | 1.32k | if (y & 1) { |
922 | 658 | extract_even2avg_c(src - srcStride, src, udst, vdst, chromWidth); |
923 | 658 | udst += chromStride; |
924 | 658 | vdst += chromStride; |
925 | 658 | } |
926 | | |
927 | 1.32k | src += srcStride; |
928 | 1.32k | ydst += lumStride; |
929 | 1.32k | } |
930 | 20 | } |
931 | | |
932 | | static void uyvytoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
933 | | const uint8_t *src, int width, int height, |
934 | | int lumStride, int chromStride, int srcStride) |
935 | 14 | { |
936 | 14 | int y; |
937 | 14 | const int chromWidth = AV_CEIL_RSHIFT(width, 1); |
938 | | |
939 | 1.30k | for (y = 0; y < height; y++) { |
940 | 1.29k | extract_even_c(src + 1, ydst, width); |
941 | 1.29k | extract_even2_c(src, udst, vdst, chromWidth); |
942 | | |
943 | 1.29k | src += srcStride; |
944 | 1.29k | ydst += lumStride; |
945 | 1.29k | udst += chromStride; |
946 | 1.29k | vdst += chromStride; |
947 | 1.29k | } |
948 | 14 | } |
949 | | |
950 | | static av_cold void rgb2rgb_init_c(void) |
951 | 1 | { |
952 | 1 | rgb15to16 = rgb15to16_c; |
953 | 1 | rgb15tobgr24 = rgb15tobgr24_c; |
954 | 1 | rgb15to32 = rgb15to32_c; |
955 | 1 | rgb16tobgr24 = rgb16tobgr24_c; |
956 | 1 | rgb16to32 = rgb16to32_c; |
957 | 1 | rgb16to15 = rgb16to15_c; |
958 | 1 | rgb24tobgr16 = rgb24tobgr16_c; |
959 | 1 | rgb24tobgr15 = rgb24tobgr15_c; |
960 | 1 | rgb24tobgr32 = rgb24tobgr32_c; |
961 | 1 | rgb32to16 = rgb32to16_c; |
962 | 1 | rgb32to15 = rgb32to15_c; |
963 | 1 | rgb32tobgr24 = rgb32tobgr24_c; |
964 | 1 | rgb24to15 = rgb24to15_c; |
965 | 1 | rgb24to16 = rgb24to16_c; |
966 | 1 | rgb24tobgr24 = rgb24tobgr24_c; |
967 | | #if HAVE_BIGENDIAN |
968 | | shuffle_bytes_0321 = shuffle_bytes_2103_c; |
969 | | shuffle_bytes_2103 = shuffle_bytes_0321_c; |
970 | | #else |
971 | 1 | shuffle_bytes_0321 = shuffle_bytes_0321_c; |
972 | 1 | shuffle_bytes_2103 = shuffle_bytes_2103_c; |
973 | 1 | #endif |
974 | 1 | shuffle_bytes_1230 = shuffle_bytes_1230_c; |
975 | 1 | shuffle_bytes_3012 = shuffle_bytes_3012_c; |
976 | 1 | shuffle_bytes_3210 = shuffle_bytes_3210_c; |
977 | 1 | shuffle_bytes_3102 = shuffle_bytes_3102_c; |
978 | 1 | shuffle_bytes_2013 = shuffle_bytes_2013_c; |
979 | 1 | shuffle_bytes_2130 = shuffle_bytes_2130_c; |
980 | 1 | shuffle_bytes_1203 = shuffle_bytes_1203_c; |
981 | 1 | rgb32tobgr16 = rgb32tobgr16_c; |
982 | 1 | rgb32tobgr15 = rgb32tobgr15_c; |
983 | 1 | yv12toyuy2 = yv12toyuy2_c; |
984 | 1 | yv12touyvy = yv12touyvy_c; |
985 | 1 | yuv422ptoyuy2 = yuv422ptoyuy2_c; |
986 | 1 | yuv422ptouyvy = yuv422ptouyvy_c; |
987 | 1 | yuy2toyv12 = yuy2toyv12_c; |
988 | 1 | planar2x = planar2x_c; |
989 | 1 | ff_rgb24toyv12 = ff_rgb24toyv12_c; |
990 | 1 | interleaveBytes = interleaveBytes_c; |
991 | 1 | deinterleaveBytes = deinterleaveBytes_c; |
992 | 1 | vu9_to_vu12 = vu9_to_vu12_c; |
993 | 1 | yvu9_to_yuy2 = yvu9_to_yuy2_c; |
994 | | |
995 | 1 | uyvytoyuv420 = uyvytoyuv420_c; |
996 | 1 | uyvytoyuv422 = uyvytoyuv422_c; |
997 | 1 | yuyvtoyuv420 = yuyvtoyuv420_c; |
998 | 1 | yuyvtoyuv422 = yuyvtoyuv422_c; |
999 | 1 | } |