1 /*
2 * Copyright (C) 2001-2012 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <math.h>
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <string.h>
25
26 #include "libavutil/avutil.h"
27 #include "libavutil/bswap.h"
28 #include "libavutil/cpu.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/mathematics.h"
31 #include "libavutil/pixdesc.h"
32 #include "libavutil/avassert.h"
33 #include "config.h"
34 #include "rgb2rgb.h"
35 #include "swscale.h"
36 #include "swscale_internal.h"
37
38 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
39
40 #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? b_r : r_b)
41 #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? r_b : b_r)
42
43 static av_always_inline void
rgb64ToY_c_template(uint16_t * dst,const uint16_t * src,int width,enum AVPixelFormat origin,int32_t * rgb2yuv)44 rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
45 enum AVPixelFormat origin, int32_t *rgb2yuv)
46 {
47 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
48 int i;
49 for (i = 0; i < width; i++) {
50 unsigned int r_b = input_pixel(&src[i*4+0]);
51 unsigned int g = input_pixel(&src[i*4+1]);
52 unsigned int b_r = input_pixel(&src[i*4+2]);
53
54 dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
55 }
56 }
57
58 static av_always_inline void
rgb64ToUV_c_template(uint16_t * dstU,uint16_t * dstV,const uint16_t * src1,const uint16_t * src2,int width,enum AVPixelFormat origin,int32_t * rgb2yuv)59 rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
60 const uint16_t *src1, const uint16_t *src2,
61 int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
62 {
63 int i;
64 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
65 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
66 av_assert1(src1==src2);
67 for (i = 0; i < width; i++) {
68 int r_b = input_pixel(&src1[i*4+0]);
69 int g = input_pixel(&src1[i*4+1]);
70 int b_r = input_pixel(&src1[i*4+2]);
71
72 dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
73 dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
74 }
75 }
76
77 static av_always_inline void
rgb64ToUV_half_c_template(uint16_t * dstU,uint16_t * dstV,const uint16_t * src1,const uint16_t * src2,int width,enum AVPixelFormat origin,int32_t * rgb2yuv)78 rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
79 const uint16_t *src1, const uint16_t *src2,
80 int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
81 {
82 int i;
83 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
84 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
85 av_assert1(src1==src2);
86 for (i = 0; i < width; i++) {
87 int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
88 int g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
89 int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
90
91 dstU[i]= (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
92 dstV[i]= (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
93 }
94 }
95
96 #define rgb64funcs(pattern, BE_LE, origin) \
97 static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
98 int width, uint32_t *rgb2yuv) \
99 { \
100 const uint16_t *src = (const uint16_t *) _src; \
101 uint16_t *dst = (uint16_t *) _dst; \
102 rgb64ToY_c_template(dst, src, width, origin, rgb2yuv); \
103 } \
104 \
105 static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
106 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
107 int width, uint32_t *rgb2yuv) \
108 { \
109 const uint16_t *src1 = (const uint16_t *) _src1, \
110 *src2 = (const uint16_t *) _src2; \
111 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
112 rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
113 } \
114 \
115 static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
116 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
117 int width, uint32_t *rgb2yuv) \
118 { \
119 const uint16_t *src1 = (const uint16_t *) _src1, \
120 *src2 = (const uint16_t *) _src2; \
121 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
122 rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
123 }
124
rgb64funcs(rgb,LE,AV_PIX_FMT_RGBA64LE)125 rgb64funcs(rgb, LE, AV_PIX_FMT_RGBA64LE)
126 rgb64funcs(rgb, BE, AV_PIX_FMT_RGBA64BE)
127 rgb64funcs(bgr, LE, AV_PIX_FMT_BGRA64LE)
128 rgb64funcs(bgr, BE, AV_PIX_FMT_BGRA64BE)
129
130 static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
131 const uint16_t *src, int width,
132 enum AVPixelFormat origin,
133 int32_t *rgb2yuv)
134 {
135 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
136 int i;
137 for (i = 0; i < width; i++) {
138 unsigned int r_b = input_pixel(&src[i * 3 + 0]);
139 unsigned int g = input_pixel(&src[i * 3 + 1]);
140 unsigned int b_r = input_pixel(&src[i * 3 + 2]);
141
142 dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
143 }
144 }
145
rgb48ToUV_c_template(uint16_t * dstU,uint16_t * dstV,const uint16_t * src1,const uint16_t * src2,int width,enum AVPixelFormat origin,int32_t * rgb2yuv)146 static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
147 uint16_t *dstV,
148 const uint16_t *src1,
149 const uint16_t *src2,
150 int width,
151 enum AVPixelFormat origin,
152 int32_t *rgb2yuv)
153 {
154 int i;
155 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
156 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
157 av_assert1(src1 == src2);
158 for (i = 0; i < width; i++) {
159 int r_b = input_pixel(&src1[i * 3 + 0]);
160 int g = input_pixel(&src1[i * 3 + 1]);
161 int b_r = input_pixel(&src1[i * 3 + 2]);
162
163 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
164 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
165 }
166 }
167
rgb48ToUV_half_c_template(uint16_t * dstU,uint16_t * dstV,const uint16_t * src1,const uint16_t * src2,int width,enum AVPixelFormat origin,int32_t * rgb2yuv)168 static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
169 uint16_t *dstV,
170 const uint16_t *src1,
171 const uint16_t *src2,
172 int width,
173 enum AVPixelFormat origin,
174 int32_t *rgb2yuv)
175 {
176 int i;
177 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
178 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
179 av_assert1(src1 == src2);
180 for (i = 0; i < width; i++) {
181 int r_b = (input_pixel(&src1[6 * i + 0]) +
182 input_pixel(&src1[6 * i + 3]) + 1) >> 1;
183 int g = (input_pixel(&src1[6 * i + 1]) +
184 input_pixel(&src1[6 * i + 4]) + 1) >> 1;
185 int b_r = (input_pixel(&src1[6 * i + 2]) +
186 input_pixel(&src1[6 * i + 5]) + 1) >> 1;
187
188 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
189 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
190 }
191 }
192
193 #undef r
194 #undef b
195 #undef input_pixel
196
197 #define rgb48funcs(pattern, BE_LE, origin) \
198 static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
199 const uint8_t *_src, \
200 const uint8_t *unused0, const uint8_t *unused1,\
201 int width, \
202 uint32_t *rgb2yuv) \
203 { \
204 const uint16_t *src = (const uint16_t *)_src; \
205 uint16_t *dst = (uint16_t *)_dst; \
206 rgb48ToY_c_template(dst, src, width, origin, rgb2yuv); \
207 } \
208 \
209 static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
210 uint8_t *_dstV, \
211 const uint8_t *unused0, \
212 const uint8_t *_src1, \
213 const uint8_t *_src2, \
214 int width, \
215 uint32_t *rgb2yuv) \
216 { \
217 const uint16_t *src1 = (const uint16_t *)_src1, \
218 *src2 = (const uint16_t *)_src2; \
219 uint16_t *dstU = (uint16_t *)_dstU, \
220 *dstV = (uint16_t *)_dstV; \
221 rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
222 } \
223 \
224 static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
225 uint8_t *_dstV, \
226 const uint8_t *unused0, \
227 const uint8_t *_src1, \
228 const uint8_t *_src2, \
229 int width, \
230 uint32_t *rgb2yuv) \
231 { \
232 const uint16_t *src1 = (const uint16_t *)_src1, \
233 *src2 = (const uint16_t *)_src2; \
234 uint16_t *dstU = (uint16_t *)_dstU, \
235 *dstV = (uint16_t *)_dstV; \
236 rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
237 }
238
rgb48funcs(rgb,LE,AV_PIX_FMT_RGB48LE)239 rgb48funcs(rgb, LE, AV_PIX_FMT_RGB48LE)
240 rgb48funcs(rgb, BE, AV_PIX_FMT_RGB48BE)
241 rgb48funcs(bgr, LE, AV_PIX_FMT_BGR48LE)
242 rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
243
244 #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
245 origin == AV_PIX_FMT_BGRA || \
246 origin == AV_PIX_FMT_ARGB || \
247 origin == AV_PIX_FMT_ABGR) \
248 ? AV_RN32A(&src[(i) * 4]) \
249 : ((origin == AV_PIX_FMT_X2RGB10LE) \
250 ? AV_RL32(&src[(i) * 4]) \
251 : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
252 : AV_RL16(&src[(i) * 2]))))
253
254 static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
255 const uint8_t *src,
256 int width,
257 enum AVPixelFormat origin,
258 int shr, int shg,
259 int shb, int shp,
260 int maskr, int maskg,
261 int maskb, int rsh,
262 int gsh, int bsh, int S,
263 int32_t *rgb2yuv)
264 {
265 const int ry = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
266 const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
267 int i;
268
269 for (i = 0; i < width; i++) {
270 int px = input_pixel(i) >> shp;
271 int b = (px & maskb) >> shb;
272 int g = (px & maskg) >> shg;
273 int r = (px & maskr) >> shr;
274
275 dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
276 }
277 }
278
rgb16_32ToUV_c_template(int16_t * dstU,int16_t * dstV,const uint8_t * src,int width,enum AVPixelFormat origin,int shr,int shg,int shb,int shp,int maskr,int maskg,int maskb,int rsh,int gsh,int bsh,int S,int32_t * rgb2yuv)279 static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
280 int16_t *dstV,
281 const uint8_t *src,
282 int width,
283 enum AVPixelFormat origin,
284 int shr, int shg,
285 int shb, int shp,
286 int maskr, int maskg,
287 int maskb, int rsh,
288 int gsh, int bsh, int S,
289 int32_t *rgb2yuv)
290 {
291 const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
292 rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh);
293 const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
294 int i;
295
296 for (i = 0; i < width; i++) {
297 int px = input_pixel(i) >> shp;
298 int b = (px & maskb) >> shb;
299 int g = (px & maskg) >> shg;
300 int r = (px & maskr) >> shr;
301
302 dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
303 dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
304 }
305 }
306
rgb16_32ToUV_half_c_template(int16_t * dstU,int16_t * dstV,const uint8_t * src,int width,enum AVPixelFormat origin,int shr,int shg,int shb,int shp,int maskr,int maskg,int maskb,int rsh,int gsh,int bsh,int S,int32_t * rgb2yuv)307 static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
308 int16_t *dstV,
309 const uint8_t *src,
310 int width,
311 enum AVPixelFormat origin,
312 int shr, int shg,
313 int shb, int shp,
314 int maskr, int maskg,
315 int maskb, int rsh,
316 int gsh, int bsh, int S,
317 int32_t *rgb2yuv)
318 {
319 const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
320 rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh),
321 maskgx = ~(maskr | maskb);
322 const unsigned rnd = (256U<<(S)) + (1<<(S-6));
323 int i;
324
325 maskr |= maskr << 1;
326 maskb |= maskb << 1;
327 maskg |= maskg << 1;
328 for (i = 0; i < width; i++) {
329 unsigned px0 = input_pixel(2 * i + 0) >> shp;
330 unsigned px1 = input_pixel(2 * i + 1) >> shp;
331 int b, r, g = (px0 & maskgx) + (px1 & maskgx);
332 int rb = px0 + px1 - g;
333
334 b = (rb & maskb) >> shb;
335 if (shp ||
336 origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
337 origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
338 g >>= shg;
339 } else {
340 g = (g & maskg) >> shg;
341 }
342 r = (rb & maskr) >> shr;
343
344 dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
345 dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
346 }
347 }
348
349 #undef input_pixel
350
351 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
352 maskg, maskb, rsh, gsh, bsh, S) \
353 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
354 int width, uint32_t *tab) \
355 { \
356 rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
357 maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
358 } \
359 \
360 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
361 const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
362 int width, uint32_t *tab) \
363 { \
364 rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
365 shr, shg, shb, shp, \
366 maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
367 } \
368 \
369 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
370 const uint8_t *unused0, const uint8_t *src, \
371 const uint8_t *dummy, \
372 int width, uint32_t *tab) \
373 { \
374 rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
375 shr, shg, shb, shp, \
376 maskr, maskg, maskb, \
377 rsh, gsh, bsh, S, tab); \
378 }
379
380 rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
381 rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
382 rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
383 rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
384 rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
385 rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
386 rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
387 rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
388 rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
389 rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
390 rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
391 rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
392 rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
393 rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
394 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
395 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
396 rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
397
gbr24pToUV_half_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * gsrc,const uint8_t * bsrc,const uint8_t * rsrc,int width,uint32_t * rgb2yuv)398 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
399 const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
400 int width, uint32_t *rgb2yuv)
401 {
402 uint16_t *dstU = (uint16_t *)_dstU;
403 uint16_t *dstV = (uint16_t *)_dstV;
404 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
405 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
406
407 int i;
408 for (i = 0; i < width; i++) {
409 unsigned int g = gsrc[2*i] + gsrc[2*i+1];
410 unsigned int b = bsrc[2*i] + bsrc[2*i+1];
411 unsigned int r = rsrc[2*i] + rsrc[2*i+1];
412
413 dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
414 dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
415 }
416 }
417
rgba64leToA_c(uint8_t * _dst,const uint8_t * _src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)418 static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
419 const uint8_t *unused2, int width, uint32_t *unused)
420 {
421 int16_t *dst = (int16_t *)_dst;
422 const uint16_t *src = (const uint16_t *)_src;
423 int i;
424 for (i = 0; i < width; i++)
425 dst[i] = AV_RL16(src + 4 * i + 3);
426 }
427
rgba64beToA_c(uint8_t * _dst,const uint8_t * _src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)428 static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
429 const uint8_t *unused2, int width, uint32_t *unused)
430 {
431 int16_t *dst = (int16_t *)_dst;
432 const uint16_t *src = (const uint16_t *)_src;
433 int i;
434 for (i = 0; i < width; i++)
435 dst[i] = AV_RB16(src + 4 * i + 3);
436 }
437
abgrToA_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)438 static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
439 {
440 int16_t *dst = (int16_t *)_dst;
441 int i;
442 for (i=0; i<width; i++) {
443 dst[i]= src[4*i]<<6 | src[4*i]>>2;
444 }
445 }
446
rgbaToA_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)447 static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
448 {
449 int16_t *dst = (int16_t *)_dst;
450 int i;
451 for (i=0; i<width; i++) {
452 dst[i]= src[4*i+3]<<6 | src[4*i+3]>>2;
453 }
454 }
455
palToA_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * pal)456 static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
457 {
458 int16_t *dst = (int16_t *)_dst;
459 int i;
460 for (i=0; i<width; i++) {
461 int d= src[i];
462
463 dst[i]= (pal[d] >> 24)<<6 | pal[d]>>26;
464 }
465 }
466
palToY_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * pal)467 static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
468 {
469 int16_t *dst = (int16_t *)_dst;
470 int i;
471 for (i = 0; i < width; i++) {
472 int d = src[i];
473
474 dst[i] = (pal[d] & 0xFF)<<6;
475 }
476 }
477
palToUV_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * pal)478 static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
479 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
480 int width, uint32_t *pal)
481 {
482 uint16_t *dstU = (uint16_t *)_dstU;
483 int16_t *dstV = (int16_t *)_dstV;
484 int i;
485 av_assert1(src1 == src2);
486 for (i = 0; i < width; i++) {
487 int p = pal[src1[i]];
488
489 dstU[i] = (uint8_t)(p>> 8)<<6;
490 dstV[i] = (uint8_t)(p>>16)<<6;
491 }
492 }
493
monowhite2Y_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)494 static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
495 {
496 int16_t *dst = (int16_t *)_dst;
497 int i, j;
498 width = (width + 7) >> 3;
499 for (i = 0; i < width; i++) {
500 int d = ~src[i];
501 for (j = 0; j < 8; j++)
502 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
503 }
504 if(width&7){
505 int d= ~src[i];
506 for (j = 0; j < (width&7); j++)
507 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
508 }
509 }
510
monoblack2Y_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)511 static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
512 {
513 int16_t *dst = (int16_t *)_dst;
514 int i, j;
515 width = (width + 7) >> 3;
516 for (i = 0; i < width; i++) {
517 int d = src[i];
518 for (j = 0; j < 8; j++)
519 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
520 }
521 if(width&7){
522 int d = src[i];
523 for (j = 0; j < (width&7); j++)
524 dst[8*i+j] = ((d>>(7-j))&1) * 16383;
525 }
526 }
527
yuy2ToY_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)528 static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
529 uint32_t *unused)
530 {
531 int i;
532 for (i = 0; i < width; i++)
533 dst[i] = src[2 * i];
534 }
535
yuy2ToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)536 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
537 const uint8_t *src2, int width, uint32_t *unused)
538 {
539 int i;
540 for (i = 0; i < width; i++) {
541 dstU[i] = src1[4 * i + 1];
542 dstV[i] = src1[4 * i + 3];
543 }
544 av_assert1(src1 == src2);
545 }
546
yvy2ToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)547 static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
548 const uint8_t *src2, int width, uint32_t *unused)
549 {
550 int i;
551 for (i = 0; i < width; i++) {
552 dstV[i] = src1[4 * i + 1];
553 dstU[i] = src1[4 * i + 3];
554 }
555 av_assert1(src1 == src2);
556 }
557
y210le_UV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src,const uint8_t * unused1,int width,uint32_t * unused2)558 static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
559 const uint8_t *unused1, int width, uint32_t *unused2)
560 {
561 int i;
562 for (i = 0; i < width; i++) {
563 AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
564 AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
565 }
566 }
567
y210le_Y_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused0,const uint8_t * unused1,int width,uint32_t * unused2)568 static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
569 const uint8_t *unused1, int width, uint32_t *unused2)
570 {
571 int i;
572 for (i = 0; i < width; i++)
573 AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
574 }
575
bswap16Y_c(uint8_t * _dst,const uint8_t * _src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)576 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
577 uint32_t *unused)
578 {
579 int i;
580 const uint16_t *src = (const uint16_t *)_src;
581 uint16_t *dst = (uint16_t *)_dst;
582 for (i = 0; i < width; i++)
583 dst[i] = av_bswap16(src[i]);
584 }
585
bswap16UV_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * _src1,const uint8_t * _src2,int width,uint32_t * unused)586 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
587 const uint8_t *_src2, int width, uint32_t *unused)
588 {
589 int i;
590 const uint16_t *src1 = (const uint16_t *)_src1,
591 *src2 = (const uint16_t *)_src2;
592 uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
593 for (i = 0; i < width; i++) {
594 dstU[i] = av_bswap16(src1[i]);
595 dstV[i] = av_bswap16(src2[i]);
596 }
597 }
598
read_ya16le_gray_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)599 static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
600 uint32_t *unused)
601 {
602 int i;
603 for (i = 0; i < width; i++)
604 AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
605 }
606
read_ya16le_alpha_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)607 static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
608 uint32_t *unused)
609 {
610 int i;
611 for (i = 0; i < width; i++)
612 AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
613 }
614
read_ya16be_gray_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)615 static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
616 uint32_t *unused)
617 {
618 int i;
619 for (i = 0; i < width; i++)
620 AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
621 }
622
read_ya16be_alpha_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)623 static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
624 uint32_t *unused)
625 {
626 int i;
627 for (i = 0; i < width; i++)
628 AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
629 }
630
read_ayuv64le_Y_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused0,const uint8_t * unused1,int width,uint32_t * unused2)631 static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
632 uint32_t *unused2)
633 {
634 int i;
635 for (i = 0; i < width; i++)
636 AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2));
637 }
638
639
read_ayuv64le_UV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src,const uint8_t * unused1,int width,uint32_t * unused2)640 static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
641 const uint8_t *unused1, int width, uint32_t *unused2)
642 {
643 int i;
644 for (i = 0; i < width; i++) {
645 AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4));
646 AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6));
647 }
648 }
649
read_ayuv64le_A_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused0,const uint8_t * unused1,int width,uint32_t * unused2)650 static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
651 uint32_t *unused2)
652 {
653 int i;
654 for (i = 0; i < width; i++)
655 AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
656 }
657
658 /* This is almost identical to the previous, end exists only because
659 * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
uyvyToY_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)660 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
661 uint32_t *unused)
662 {
663 int i;
664 for (i = 0; i < width; i++)
665 dst[i] = src[2 * i + 1];
666 }
667
uyvyToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)668 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
669 const uint8_t *src2, int width, uint32_t *unused)
670 {
671 int i;
672 for (i = 0; i < width; i++) {
673 dstU[i] = src1[4 * i + 0];
674 dstV[i] = src1[4 * i + 2];
675 }
676 av_assert1(src1 == src2);
677 }
678
nvXXtoUV_c(uint8_t * dst1,uint8_t * dst2,const uint8_t * src,int width)679 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
680 const uint8_t *src, int width)
681 {
682 int i;
683 for (i = 0; i < width; i++) {
684 dst1[i] = src[2 * i + 0];
685 dst2[i] = src[2 * i + 1];
686 }
687 }
688
nv12ToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)689 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
690 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
691 int width, uint32_t *unused)
692 {
693 nvXXtoUV_c(dstU, dstV, src1, width);
694 }
695
nv21ToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)696 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
697 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
698 int width, uint32_t *unused)
699 {
700 nvXXtoUV_c(dstV, dstU, src1, width);
701 }
702
p010LEToY_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)703 static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
704 const uint8_t *unused2, int width, uint32_t *unused)
705 {
706 int i;
707 for (i = 0; i < width; i++) {
708 AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6);
709 }
710 }
711
p010BEToY_c(uint8_t * dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)712 static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
713 const uint8_t *unused2, int width, uint32_t *unused)
714 {
715 int i;
716 for (i = 0; i < width; i++) {
717 AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6);
718 }
719 }
720
p010LEToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)721 static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV,
722 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
723 int width, uint32_t *unused)
724 {
725 int i;
726 for (i = 0; i < width; i++) {
727 AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6);
728 AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6);
729 }
730 }
731
p010BEToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)732 static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
733 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
734 int width, uint32_t *unused)
735 {
736 int i;
737 for (i = 0; i < width; i++) {
738 AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6);
739 AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6);
740 }
741 }
742
p016LEToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)743 static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
744 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
745 int width, uint32_t *unused)
746 {
747 int i;
748 for (i = 0; i < width; i++) {
749 AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
750 AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
751 }
752 }
753
p016BEToUV_c(uint8_t * dstU,uint8_t * dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * unused)754 static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
755 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
756 int width, uint32_t *unused)
757 {
758 int i;
759 for (i = 0; i < width; i++) {
760 AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
761 AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
762 }
763 }
764
765 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
766
bgr24ToY_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * rgb2yuv)767 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
768 int width, uint32_t *rgb2yuv)
769 {
770 int16_t *dst = (int16_t *)_dst;
771 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
772 int i;
773 for (i = 0; i < width; i++) {
774 int b = src[i * 3 + 0];
775 int g = src[i * 3 + 1];
776 int r = src[i * 3 + 2];
777
778 dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
779 }
780 }
781
bgr24ToUV_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * rgb2yuv)782 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
783 const uint8_t *src2, int width, uint32_t *rgb2yuv)
784 {
785 int16_t *dstU = (int16_t *)_dstU;
786 int16_t *dstV = (int16_t *)_dstV;
787 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
788 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
789 int i;
790 for (i = 0; i < width; i++) {
791 int b = src1[3 * i + 0];
792 int g = src1[3 * i + 1];
793 int r = src1[3 * i + 2];
794
795 dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
796 dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
797 }
798 av_assert1(src1 == src2);
799 }
800
bgr24ToUV_half_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * rgb2yuv)801 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
802 const uint8_t *src2, int width, uint32_t *rgb2yuv)
803 {
804 int16_t *dstU = (int16_t *)_dstU;
805 int16_t *dstV = (int16_t *)_dstV;
806 int i;
807 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
808 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
809 for (i = 0; i < width; i++) {
810 int b = src1[6 * i + 0] + src1[6 * i + 3];
811 int g = src1[6 * i + 1] + src1[6 * i + 4];
812 int r = src1[6 * i + 2] + src1[6 * i + 5];
813
814 dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
815 dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
816 }
817 av_assert1(src1 == src2);
818 }
819
rgb24ToY_c(uint8_t * _dst,const uint8_t * src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * rgb2yuv)820 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
821 uint32_t *rgb2yuv)
822 {
823 int16_t *dst = (int16_t *)_dst;
824 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
825 int i;
826 for (i = 0; i < width; i++) {
827 int r = src[i * 3 + 0];
828 int g = src[i * 3 + 1];
829 int b = src[i * 3 + 2];
830
831 dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
832 }
833 }
834
rgb24ToUV_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * rgb2yuv)835 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
836 const uint8_t *src2, int width, uint32_t *rgb2yuv)
837 {
838 int16_t *dstU = (int16_t *)_dstU;
839 int16_t *dstV = (int16_t *)_dstV;
840 int i;
841 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
842 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
843 av_assert1(src1 == src2);
844 for (i = 0; i < width; i++) {
845 int r = src1[3 * i + 0];
846 int g = src1[3 * i + 1];
847 int b = src1[3 * i + 2];
848
849 dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
850 dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
851 }
852 }
853
rgb24ToUV_half_c(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * unused0,const uint8_t * src1,const uint8_t * src2,int width,uint32_t * rgb2yuv)854 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
855 const uint8_t *src2, int width, uint32_t *rgb2yuv)
856 {
857 int16_t *dstU = (int16_t *)_dstU;
858 int16_t *dstV = (int16_t *)_dstV;
859 int i;
860 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
861 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
862 av_assert1(src1 == src2);
863 for (i = 0; i < width; i++) {
864 int r = src1[6 * i + 0] + src1[6 * i + 3];
865 int g = src1[6 * i + 1] + src1[6 * i + 4];
866 int b = src1[6 * i + 2] + src1[6 * i + 5];
867
868 dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
869 dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
870 }
871 }
872
planar_rgb_to_y(uint8_t * _dst,const uint8_t * src[4],int width,int32_t * rgb2yuv)873 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
874 {
875 uint16_t *dst = (uint16_t *)_dst;
876 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
877 int i;
878 for (i = 0; i < width; i++) {
879 int g = src[0][i];
880 int b = src[1][i];
881 int r = src[2][i];
882
883 dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
884 }
885 }
886
planar_rgb_to_a(uint8_t * _dst,const uint8_t * src[4],int width,int32_t * unused)887 static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
888 {
889 uint16_t *dst = (uint16_t *)_dst;
890 int i;
891 for (i = 0; i < width; i++)
892 dst[i] = src[3][i] << 6;
893 }
894
planar_rgb_to_uv(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * src[4],int width,int32_t * rgb2yuv)895 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
896 {
897 uint16_t *dstU = (uint16_t *)_dstU;
898 uint16_t *dstV = (uint16_t *)_dstV;
899 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
900 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
901 int i;
902 for (i = 0; i < width; i++) {
903 int g = src[0][i];
904 int b = src[1][i];
905 int r = src[2][i];
906
907 dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
908 dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
909 }
910 }
911
912 #define rdpx(src) \
913 is_be ? AV_RB16(src) : AV_RL16(src)
planar_rgb16_to_y(uint8_t * _dst,const uint8_t * _src[4],int width,int bpc,int is_be,int32_t * rgb2yuv)914 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
915 int width, int bpc, int is_be, int32_t *rgb2yuv)
916 {
917 int i;
918 const uint16_t **src = (const uint16_t **)_src;
919 uint16_t *dst = (uint16_t *)_dst;
920 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
921 int shift = bpc < 16 ? bpc : 14;
922 for (i = 0; i < width; i++) {
923 int g = rdpx(src[0] + i);
924 int b = rdpx(src[1] + i);
925 int r = rdpx(src[2] + i);
926
927 dst[i] = (ry*r + gy*g + by*b + (16 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
928 }
929 }
930
planar_rgb16_to_a(uint8_t * _dst,const uint8_t * _src[4],int width,int bpc,int is_be,int32_t * rgb2yuv)931 static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4],
932 int width, int bpc, int is_be, int32_t *rgb2yuv)
933 {
934 int i;
935 const uint16_t **src = (const uint16_t **)_src;
936 uint16_t *dst = (uint16_t *)_dst;
937 int shift = bpc < 16 ? bpc : 14;
938
939 for (i = 0; i < width; i++) {
940 dst[i] = rdpx(src[3] + i) << (14 - shift);
941 }
942 }
943
planar_rgb16_to_uv(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * _src[4],int width,int bpc,int is_be,int32_t * rgb2yuv)944 static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
945 const uint8_t *_src[4], int width,
946 int bpc, int is_be, int32_t *rgb2yuv)
947 {
948 int i;
949 const uint16_t **src = (const uint16_t **)_src;
950 uint16_t *dstU = (uint16_t *)_dstU;
951 uint16_t *dstV = (uint16_t *)_dstV;
952 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
953 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
954 int shift = bpc < 16 ? bpc : 14;
955 for (i = 0; i < width; i++) {
956 int g = rdpx(src[0] + i);
957 int b = rdpx(src[1] + i);
958 int r = rdpx(src[2] + i);
959
960 dstU[i] = (ru*r + gu*g + bu*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
961 dstV[i] = (rv*r + gv*g + bv*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
962 }
963 }
964 #undef rdpx
965
966 #define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)))
967
planar_rgbf32_to_a(uint8_t * _dst,const uint8_t * _src[4],int width,int is_be,int32_t * rgb2yuv)968 static av_always_inline void planar_rgbf32_to_a(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
969 {
970 int i;
971 const float **src = (const float **)_src;
972 uint16_t *dst = (uint16_t *)_dst;
973
974 for (i = 0; i < width; i++) {
975 dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src[3] + i)));
976 }
977 }
978
planar_rgbf32_to_uv(uint8_t * _dstU,uint8_t * _dstV,const uint8_t * _src[4],int width,int is_be,int32_t * rgb2yuv)979 static av_always_inline void planar_rgbf32_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
980 {
981 int i;
982 const float **src = (const float **)_src;
983 uint16_t *dstU = (uint16_t *)_dstU;
984 uint16_t *dstV = (uint16_t *)_dstV;
985 int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
986 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
987
988 for (i = 0; i < width; i++) {
989 int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
990 int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
991 int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
992
993 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
994 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
995 }
996 }
997
planar_rgbf32_to_y(uint8_t * _dst,const uint8_t * _src[4],int width,int is_be,int32_t * rgb2yuv)998 static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
999 {
1000 int i;
1001 const float **src = (const float **)_src;
1002 uint16_t *dst = (uint16_t *)_dst;
1003
1004 int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
1005
1006 for (i = 0; i < width; i++) {
1007 int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
1008 int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
1009 int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
1010
1011 dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
1012 }
1013 }
1014
1015 #undef rdpx
1016
grayf32ToY16_c(uint8_t * _dst,const uint8_t * _src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)1017 static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1018 const uint8_t *unused2, int width, uint32_t *unused)
1019 {
1020 int i;
1021 const float *src = (const float *)_src;
1022 uint16_t *dst = (uint16_t *)_dst;
1023
1024 for (i = 0; i < width; ++i){
1025 dst[i] = av_clip_uint16(lrintf(65535.0f * src[i]));
1026 }
1027 }
1028
grayf32ToY16_bswap_c(uint8_t * _dst,const uint8_t * _src,const uint8_t * unused1,const uint8_t * unused2,int width,uint32_t * unused)1029 static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1030 const uint8_t *unused2, int width, uint32_t *unused)
1031 {
1032 int i;
1033 const uint32_t *src = (const uint32_t *)_src;
1034 uint16_t *dst = (uint16_t *)_dst;
1035
1036 for (i = 0; i < width; ++i){
1037 dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]))));
1038 }
1039 }
1040
1041 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
1042 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1043 int w, int32_t *rgb2yuv) \
1044 { \
1045 planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
1046 } \
1047 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1048 const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1049 { \
1050 planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
1051 } \
1052
1053 #define rgb9plus_planar_transparency_funcs(nbits) \
1054 static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
1055 int w, int32_t *rgb2yuv) \
1056 { \
1057 planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
1058 } \
1059 static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
1060 int w, int32_t *rgb2yuv) \
1061 { \
1062 planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
1063 }
1064
1065 #define rgb9plus_planar_funcs(nbits) \
1066 rgb9plus_planar_funcs_endian(nbits, le, 0) \
1067 rgb9plus_planar_funcs_endian(nbits, be, 1)
1068
1069 rgb9plus_planar_funcs(9)
1070 rgb9plus_planar_funcs(10)
1071 rgb9plus_planar_funcs(12)
1072 rgb9plus_planar_funcs(14)
1073 rgb9plus_planar_funcs(16)
1074
1075 rgb9plus_planar_transparency_funcs(10)
1076 rgb9plus_planar_transparency_funcs(12)
1077 rgb9plus_planar_transparency_funcs(16)
1078
1079 #define rgbf32_planar_funcs_endian(endian_name, endian) \
1080 static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1081 int w, int32_t *rgb2yuv) \
1082 { \
1083 planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
1084 } \
1085 static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1086 const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1087 { \
1088 planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
1089 } \
1090 static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
1091 int w, int32_t *rgb2yuv) \
1092 { \
1093 planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1094 }
1095
1096 rgbf32_planar_funcs_endian(le, 0)
1097 rgbf32_planar_funcs_endian(be, 1)
1098
ff_sws_init_input_funcs(SwsContext * c)1099 av_cold void ff_sws_init_input_funcs(SwsContext *c)
1100 {
1101 enum AVPixelFormat srcFormat = c->srcFormat;
1102
1103 c->chrToYV12 = NULL;
1104 switch (srcFormat) {
1105 case AV_PIX_FMT_YUYV422:
1106 c->chrToYV12 = yuy2ToUV_c;
1107 break;
1108 case AV_PIX_FMT_YVYU422:
1109 c->chrToYV12 = yvy2ToUV_c;
1110 break;
1111 case AV_PIX_FMT_UYVY422:
1112 c->chrToYV12 = uyvyToUV_c;
1113 break;
1114 case AV_PIX_FMT_NV12:
1115 case AV_PIX_FMT_NV24:
1116 c->chrToYV12 = nv12ToUV_c;
1117 break;
1118 case AV_PIX_FMT_NV21:
1119 case AV_PIX_FMT_NV42:
1120 c->chrToYV12 = nv21ToUV_c;
1121 break;
1122 case AV_PIX_FMT_RGB8:
1123 case AV_PIX_FMT_BGR8:
1124 case AV_PIX_FMT_PAL8:
1125 case AV_PIX_FMT_BGR4_BYTE:
1126 case AV_PIX_FMT_RGB4_BYTE:
1127 c->chrToYV12 = palToUV_c;
1128 break;
1129 case AV_PIX_FMT_GBRP9LE:
1130 c->readChrPlanar = planar_rgb9le_to_uv;
1131 break;
1132 case AV_PIX_FMT_GBRAP10LE:
1133 case AV_PIX_FMT_GBRP10LE:
1134 c->readChrPlanar = planar_rgb10le_to_uv;
1135 break;
1136 case AV_PIX_FMT_GBRAP12LE:
1137 case AV_PIX_FMT_GBRP12LE:
1138 c->readChrPlanar = planar_rgb12le_to_uv;
1139 break;
1140 case AV_PIX_FMT_GBRP14LE:
1141 c->readChrPlanar = planar_rgb14le_to_uv;
1142 break;
1143 case AV_PIX_FMT_GBRAP16LE:
1144 case AV_PIX_FMT_GBRP16LE:
1145 c->readChrPlanar = planar_rgb16le_to_uv;
1146 break;
1147 case AV_PIX_FMT_GBRAPF32LE:
1148 case AV_PIX_FMT_GBRPF32LE:
1149 c->readChrPlanar = planar_rgbf32le_to_uv;
1150 break;
1151 case AV_PIX_FMT_GBRP9BE:
1152 c->readChrPlanar = planar_rgb9be_to_uv;
1153 break;
1154 case AV_PIX_FMT_GBRAP10BE:
1155 case AV_PIX_FMT_GBRP10BE:
1156 c->readChrPlanar = planar_rgb10be_to_uv;
1157 break;
1158 case AV_PIX_FMT_GBRAP12BE:
1159 case AV_PIX_FMT_GBRP12BE:
1160 c->readChrPlanar = planar_rgb12be_to_uv;
1161 break;
1162 case AV_PIX_FMT_GBRP14BE:
1163 c->readChrPlanar = planar_rgb14be_to_uv;
1164 break;
1165 case AV_PIX_FMT_GBRAP16BE:
1166 case AV_PIX_FMT_GBRP16BE:
1167 c->readChrPlanar = planar_rgb16be_to_uv;
1168 break;
1169 case AV_PIX_FMT_GBRAPF32BE:
1170 case AV_PIX_FMT_GBRPF32BE:
1171 c->readChrPlanar = planar_rgbf32be_to_uv;
1172 break;
1173 case AV_PIX_FMT_GBRAP:
1174 case AV_PIX_FMT_GBRP:
1175 c->readChrPlanar = planar_rgb_to_uv;
1176 break;
1177 #if HAVE_BIGENDIAN
1178 case AV_PIX_FMT_YUV420P9LE:
1179 case AV_PIX_FMT_YUV422P9LE:
1180 case AV_PIX_FMT_YUV444P9LE:
1181 case AV_PIX_FMT_YUV420P10LE:
1182 case AV_PIX_FMT_YUV422P10LE:
1183 case AV_PIX_FMT_YUV440P10LE:
1184 case AV_PIX_FMT_YUV444P10LE:
1185 case AV_PIX_FMT_YUV420P12LE:
1186 case AV_PIX_FMT_YUV422P12LE:
1187 case AV_PIX_FMT_YUV440P12LE:
1188 case AV_PIX_FMT_YUV444P12LE:
1189 case AV_PIX_FMT_YUV420P14LE:
1190 case AV_PIX_FMT_YUV422P14LE:
1191 case AV_PIX_FMT_YUV444P14LE:
1192 case AV_PIX_FMT_YUV420P16LE:
1193 case AV_PIX_FMT_YUV422P16LE:
1194 case AV_PIX_FMT_YUV444P16LE:
1195
1196 case AV_PIX_FMT_YUVA420P9LE:
1197 case AV_PIX_FMT_YUVA422P9LE:
1198 case AV_PIX_FMT_YUVA444P9LE:
1199 case AV_PIX_FMT_YUVA420P10LE:
1200 case AV_PIX_FMT_YUVA422P10LE:
1201 case AV_PIX_FMT_YUVA444P10LE:
1202 case AV_PIX_FMT_YUVA422P12LE:
1203 case AV_PIX_FMT_YUVA444P12LE:
1204 case AV_PIX_FMT_YUVA420P16LE:
1205 case AV_PIX_FMT_YUVA422P16LE:
1206 case AV_PIX_FMT_YUVA444P16LE:
1207 c->chrToYV12 = bswap16UV_c;
1208 break;
1209 #else
1210 case AV_PIX_FMT_YUV420P9BE:
1211 case AV_PIX_FMT_YUV422P9BE:
1212 case AV_PIX_FMT_YUV444P9BE:
1213 case AV_PIX_FMT_YUV420P10BE:
1214 case AV_PIX_FMT_YUV422P10BE:
1215 case AV_PIX_FMT_YUV440P10BE:
1216 case AV_PIX_FMT_YUV444P10BE:
1217 case AV_PIX_FMT_YUV420P12BE:
1218 case AV_PIX_FMT_YUV422P12BE:
1219 case AV_PIX_FMT_YUV440P12BE:
1220 case AV_PIX_FMT_YUV444P12BE:
1221 case AV_PIX_FMT_YUV420P14BE:
1222 case AV_PIX_FMT_YUV422P14BE:
1223 case AV_PIX_FMT_YUV444P14BE:
1224 case AV_PIX_FMT_YUV420P16BE:
1225 case AV_PIX_FMT_YUV422P16BE:
1226 case AV_PIX_FMT_YUV444P16BE:
1227
1228 case AV_PIX_FMT_YUVA420P9BE:
1229 case AV_PIX_FMT_YUVA422P9BE:
1230 case AV_PIX_FMT_YUVA444P9BE:
1231 case AV_PIX_FMT_YUVA420P10BE:
1232 case AV_PIX_FMT_YUVA422P10BE:
1233 case AV_PIX_FMT_YUVA444P10BE:
1234 case AV_PIX_FMT_YUVA422P12BE:
1235 case AV_PIX_FMT_YUVA444P12BE:
1236 case AV_PIX_FMT_YUVA420P16BE:
1237 case AV_PIX_FMT_YUVA422P16BE:
1238 case AV_PIX_FMT_YUVA444P16BE:
1239 c->chrToYV12 = bswap16UV_c;
1240 break;
1241 #endif
1242 case AV_PIX_FMT_AYUV64LE:
1243 c->chrToYV12 = read_ayuv64le_UV_c;
1244 break;
1245 case AV_PIX_FMT_P010LE:
1246 c->chrToYV12 = p010LEToUV_c;
1247 break;
1248 case AV_PIX_FMT_P010BE:
1249 c->chrToYV12 = p010BEToUV_c;
1250 break;
1251 case AV_PIX_FMT_P016LE:
1252 c->chrToYV12 = p016LEToUV_c;
1253 break;
1254 case AV_PIX_FMT_P016BE:
1255 c->chrToYV12 = p016BEToUV_c;
1256 break;
1257 case AV_PIX_FMT_Y210LE:
1258 c->chrToYV12 = y210le_UV_c;
1259 break;
1260 }
1261 if (c->chrSrcHSubSample) {
1262 switch (srcFormat) {
1263 case AV_PIX_FMT_RGBA64BE:
1264 c->chrToYV12 = rgb64BEToUV_half_c;
1265 break;
1266 case AV_PIX_FMT_RGBA64LE:
1267 c->chrToYV12 = rgb64LEToUV_half_c;
1268 break;
1269 case AV_PIX_FMT_BGRA64BE:
1270 c->chrToYV12 = bgr64BEToUV_half_c;
1271 break;
1272 case AV_PIX_FMT_BGRA64LE:
1273 c->chrToYV12 = bgr64LEToUV_half_c;
1274 break;
1275 case AV_PIX_FMT_RGB48BE:
1276 c->chrToYV12 = rgb48BEToUV_half_c;
1277 break;
1278 case AV_PIX_FMT_RGB48LE:
1279 c->chrToYV12 = rgb48LEToUV_half_c;
1280 break;
1281 case AV_PIX_FMT_BGR48BE:
1282 c->chrToYV12 = bgr48BEToUV_half_c;
1283 break;
1284 case AV_PIX_FMT_BGR48LE:
1285 c->chrToYV12 = bgr48LEToUV_half_c;
1286 break;
1287 case AV_PIX_FMT_RGB32:
1288 c->chrToYV12 = bgr32ToUV_half_c;
1289 break;
1290 case AV_PIX_FMT_RGB32_1:
1291 c->chrToYV12 = bgr321ToUV_half_c;
1292 break;
1293 case AV_PIX_FMT_BGR24:
1294 c->chrToYV12 = bgr24ToUV_half_c;
1295 break;
1296 case AV_PIX_FMT_BGR565LE:
1297 c->chrToYV12 = bgr16leToUV_half_c;
1298 break;
1299 case AV_PIX_FMT_BGR565BE:
1300 c->chrToYV12 = bgr16beToUV_half_c;
1301 break;
1302 case AV_PIX_FMT_BGR555LE:
1303 c->chrToYV12 = bgr15leToUV_half_c;
1304 break;
1305 case AV_PIX_FMT_BGR555BE:
1306 c->chrToYV12 = bgr15beToUV_half_c;
1307 break;
1308 case AV_PIX_FMT_GBRAP:
1309 case AV_PIX_FMT_GBRP:
1310 c->chrToYV12 = gbr24pToUV_half_c;
1311 break;
1312 case AV_PIX_FMT_BGR444LE:
1313 c->chrToYV12 = bgr12leToUV_half_c;
1314 break;
1315 case AV_PIX_FMT_BGR444BE:
1316 c->chrToYV12 = bgr12beToUV_half_c;
1317 break;
1318 case AV_PIX_FMT_BGR32:
1319 c->chrToYV12 = rgb32ToUV_half_c;
1320 break;
1321 case AV_PIX_FMT_BGR32_1:
1322 c->chrToYV12 = rgb321ToUV_half_c;
1323 break;
1324 case AV_PIX_FMT_RGB24:
1325 c->chrToYV12 = rgb24ToUV_half_c;
1326 break;
1327 case AV_PIX_FMT_RGB565LE:
1328 c->chrToYV12 = rgb16leToUV_half_c;
1329 break;
1330 case AV_PIX_FMT_RGB565BE:
1331 c->chrToYV12 = rgb16beToUV_half_c;
1332 break;
1333 case AV_PIX_FMT_RGB555LE:
1334 c->chrToYV12 = rgb15leToUV_half_c;
1335 break;
1336 case AV_PIX_FMT_RGB555BE:
1337 c->chrToYV12 = rgb15beToUV_half_c;
1338 break;
1339 case AV_PIX_FMT_RGB444LE:
1340 c->chrToYV12 = rgb12leToUV_half_c;
1341 break;
1342 case AV_PIX_FMT_RGB444BE:
1343 c->chrToYV12 = rgb12beToUV_half_c;
1344 break;
1345 case AV_PIX_FMT_X2RGB10LE:
1346 c->chrToYV12 = rgb30leToUV_half_c;
1347 break;
1348 }
1349 } else {
1350 switch (srcFormat) {
1351 case AV_PIX_FMT_RGBA64BE:
1352 c->chrToYV12 = rgb64BEToUV_c;
1353 break;
1354 case AV_PIX_FMT_RGBA64LE:
1355 c->chrToYV12 = rgb64LEToUV_c;
1356 break;
1357 case AV_PIX_FMT_BGRA64BE:
1358 c->chrToYV12 = bgr64BEToUV_c;
1359 break;
1360 case AV_PIX_FMT_BGRA64LE:
1361 c->chrToYV12 = bgr64LEToUV_c;
1362 break;
1363 case AV_PIX_FMT_RGB48BE:
1364 c->chrToYV12 = rgb48BEToUV_c;
1365 break;
1366 case AV_PIX_FMT_RGB48LE:
1367 c->chrToYV12 = rgb48LEToUV_c;
1368 break;
1369 case AV_PIX_FMT_BGR48BE:
1370 c->chrToYV12 = bgr48BEToUV_c;
1371 break;
1372 case AV_PIX_FMT_BGR48LE:
1373 c->chrToYV12 = bgr48LEToUV_c;
1374 break;
1375 case AV_PIX_FMT_RGB32:
1376 c->chrToYV12 = bgr32ToUV_c;
1377 break;
1378 case AV_PIX_FMT_RGB32_1:
1379 c->chrToYV12 = bgr321ToUV_c;
1380 break;
1381 case AV_PIX_FMT_BGR24:
1382 c->chrToYV12 = bgr24ToUV_c;
1383 break;
1384 case AV_PIX_FMT_BGR565LE:
1385 c->chrToYV12 = bgr16leToUV_c;
1386 break;
1387 case AV_PIX_FMT_BGR565BE:
1388 c->chrToYV12 = bgr16beToUV_c;
1389 break;
1390 case AV_PIX_FMT_BGR555LE:
1391 c->chrToYV12 = bgr15leToUV_c;
1392 break;
1393 case AV_PIX_FMT_BGR555BE:
1394 c->chrToYV12 = bgr15beToUV_c;
1395 break;
1396 case AV_PIX_FMT_BGR444LE:
1397 c->chrToYV12 = bgr12leToUV_c;
1398 break;
1399 case AV_PIX_FMT_BGR444BE:
1400 c->chrToYV12 = bgr12beToUV_c;
1401 break;
1402 case AV_PIX_FMT_BGR32:
1403 c->chrToYV12 = rgb32ToUV_c;
1404 break;
1405 case AV_PIX_FMT_BGR32_1:
1406 c->chrToYV12 = rgb321ToUV_c;
1407 break;
1408 case AV_PIX_FMT_RGB24:
1409 c->chrToYV12 = rgb24ToUV_c;
1410 break;
1411 case AV_PIX_FMT_RGB565LE:
1412 c->chrToYV12 = rgb16leToUV_c;
1413 break;
1414 case AV_PIX_FMT_RGB565BE:
1415 c->chrToYV12 = rgb16beToUV_c;
1416 break;
1417 case AV_PIX_FMT_RGB555LE:
1418 c->chrToYV12 = rgb15leToUV_c;
1419 break;
1420 case AV_PIX_FMT_RGB555BE:
1421 c->chrToYV12 = rgb15beToUV_c;
1422 break;
1423 case AV_PIX_FMT_RGB444LE:
1424 c->chrToYV12 = rgb12leToUV_c;
1425 break;
1426 case AV_PIX_FMT_RGB444BE:
1427 c->chrToYV12 = rgb12beToUV_c;
1428 break;
1429 case AV_PIX_FMT_X2RGB10LE:
1430 c->chrToYV12 = rgb30leToUV_c;
1431 break;
1432 }
1433 }
1434
1435 c->lumToYV12 = NULL;
1436 c->alpToYV12 = NULL;
1437 switch (srcFormat) {
1438 case AV_PIX_FMT_GBRP9LE:
1439 c->readLumPlanar = planar_rgb9le_to_y;
1440 break;
1441 case AV_PIX_FMT_GBRAP10LE:
1442 c->readAlpPlanar = planar_rgb10le_to_a;
1443 case AV_PIX_FMT_GBRP10LE:
1444 c->readLumPlanar = planar_rgb10le_to_y;
1445 break;
1446 case AV_PIX_FMT_GBRAP12LE:
1447 c->readAlpPlanar = planar_rgb12le_to_a;
1448 case AV_PIX_FMT_GBRP12LE:
1449 c->readLumPlanar = planar_rgb12le_to_y;
1450 break;
1451 case AV_PIX_FMT_GBRP14LE:
1452 c->readLumPlanar = planar_rgb14le_to_y;
1453 break;
1454 case AV_PIX_FMT_GBRAP16LE:
1455 c->readAlpPlanar = planar_rgb16le_to_a;
1456 case AV_PIX_FMT_GBRP16LE:
1457 c->readLumPlanar = planar_rgb16le_to_y;
1458 break;
1459 case AV_PIX_FMT_GBRAPF32LE:
1460 c->readAlpPlanar = planar_rgbf32le_to_a;
1461 case AV_PIX_FMT_GBRPF32LE:
1462 c->readLumPlanar = planar_rgbf32le_to_y;
1463 break;
1464 case AV_PIX_FMT_GBRP9BE:
1465 c->readLumPlanar = planar_rgb9be_to_y;
1466 break;
1467 case AV_PIX_FMT_GBRAP10BE:
1468 c->readAlpPlanar = planar_rgb10be_to_a;
1469 case AV_PIX_FMT_GBRP10BE:
1470 c->readLumPlanar = planar_rgb10be_to_y;
1471 break;
1472 case AV_PIX_FMT_GBRAP12BE:
1473 c->readAlpPlanar = planar_rgb12be_to_a;
1474 case AV_PIX_FMT_GBRP12BE:
1475 c->readLumPlanar = planar_rgb12be_to_y;
1476 break;
1477 case AV_PIX_FMT_GBRP14BE:
1478 c->readLumPlanar = planar_rgb14be_to_y;
1479 break;
1480 case AV_PIX_FMT_GBRAP16BE:
1481 c->readAlpPlanar = planar_rgb16be_to_a;
1482 case AV_PIX_FMT_GBRP16BE:
1483 c->readLumPlanar = planar_rgb16be_to_y;
1484 break;
1485 case AV_PIX_FMT_GBRAPF32BE:
1486 c->readAlpPlanar = planar_rgbf32be_to_a;
1487 case AV_PIX_FMT_GBRPF32BE:
1488 c->readLumPlanar = planar_rgbf32be_to_y;
1489 break;
1490 case AV_PIX_FMT_GBRAP:
1491 c->readAlpPlanar = planar_rgb_to_a;
1492 case AV_PIX_FMT_GBRP:
1493 c->readLumPlanar = planar_rgb_to_y;
1494 break;
1495 #if HAVE_BIGENDIAN
1496 case AV_PIX_FMT_YUV420P9LE:
1497 case AV_PIX_FMT_YUV422P9LE:
1498 case AV_PIX_FMT_YUV444P9LE:
1499 case AV_PIX_FMT_YUV420P10LE:
1500 case AV_PIX_FMT_YUV422P10LE:
1501 case AV_PIX_FMT_YUV440P10LE:
1502 case AV_PIX_FMT_YUV444P10LE:
1503 case AV_PIX_FMT_YUV420P12LE:
1504 case AV_PIX_FMT_YUV422P12LE:
1505 case AV_PIX_FMT_YUV440P12LE:
1506 case AV_PIX_FMT_YUV444P12LE:
1507 case AV_PIX_FMT_YUV420P14LE:
1508 case AV_PIX_FMT_YUV422P14LE:
1509 case AV_PIX_FMT_YUV444P14LE:
1510 case AV_PIX_FMT_YUV420P16LE:
1511 case AV_PIX_FMT_YUV422P16LE:
1512 case AV_PIX_FMT_YUV444P16LE:
1513
1514 case AV_PIX_FMT_GRAY9LE:
1515 case AV_PIX_FMT_GRAY10LE:
1516 case AV_PIX_FMT_GRAY12LE:
1517 case AV_PIX_FMT_GRAY14LE:
1518 case AV_PIX_FMT_GRAY16LE:
1519
1520 case AV_PIX_FMT_P016LE:
1521 c->lumToYV12 = bswap16Y_c;
1522 break;
1523 case AV_PIX_FMT_YUVA420P9LE:
1524 case AV_PIX_FMT_YUVA422P9LE:
1525 case AV_PIX_FMT_YUVA444P9LE:
1526 case AV_PIX_FMT_YUVA420P10LE:
1527 case AV_PIX_FMT_YUVA422P10LE:
1528 case AV_PIX_FMT_YUVA444P10LE:
1529 case AV_PIX_FMT_YUVA422P12LE:
1530 case AV_PIX_FMT_YUVA444P12LE:
1531 case AV_PIX_FMT_YUVA420P16LE:
1532 case AV_PIX_FMT_YUVA422P16LE:
1533 case AV_PIX_FMT_YUVA444P16LE:
1534 c->lumToYV12 = bswap16Y_c;
1535 c->alpToYV12 = bswap16Y_c;
1536 break;
1537 #else
1538 case AV_PIX_FMT_YUV420P9BE:
1539 case AV_PIX_FMT_YUV422P9BE:
1540 case AV_PIX_FMT_YUV444P9BE:
1541 case AV_PIX_FMT_YUV420P10BE:
1542 case AV_PIX_FMT_YUV422P10BE:
1543 case AV_PIX_FMT_YUV440P10BE:
1544 case AV_PIX_FMT_YUV444P10BE:
1545 case AV_PIX_FMT_YUV420P12BE:
1546 case AV_PIX_FMT_YUV422P12BE:
1547 case AV_PIX_FMT_YUV440P12BE:
1548 case AV_PIX_FMT_YUV444P12BE:
1549 case AV_PIX_FMT_YUV420P14BE:
1550 case AV_PIX_FMT_YUV422P14BE:
1551 case AV_PIX_FMT_YUV444P14BE:
1552 case AV_PIX_FMT_YUV420P16BE:
1553 case AV_PIX_FMT_YUV422P16BE:
1554 case AV_PIX_FMT_YUV444P16BE:
1555
1556 case AV_PIX_FMT_GRAY9BE:
1557 case AV_PIX_FMT_GRAY10BE:
1558 case AV_PIX_FMT_GRAY12BE:
1559 case AV_PIX_FMT_GRAY14BE:
1560 case AV_PIX_FMT_GRAY16BE:
1561
1562 case AV_PIX_FMT_P016BE:
1563 c->lumToYV12 = bswap16Y_c;
1564 break;
1565 case AV_PIX_FMT_YUVA420P9BE:
1566 case AV_PIX_FMT_YUVA422P9BE:
1567 case AV_PIX_FMT_YUVA444P9BE:
1568 case AV_PIX_FMT_YUVA420P10BE:
1569 case AV_PIX_FMT_YUVA422P10BE:
1570 case AV_PIX_FMT_YUVA444P10BE:
1571 case AV_PIX_FMT_YUVA422P12BE:
1572 case AV_PIX_FMT_YUVA444P12BE:
1573 case AV_PIX_FMT_YUVA420P16BE:
1574 case AV_PIX_FMT_YUVA422P16BE:
1575 case AV_PIX_FMT_YUVA444P16BE:
1576 c->lumToYV12 = bswap16Y_c;
1577 c->alpToYV12 = bswap16Y_c;
1578 break;
1579 #endif
1580 case AV_PIX_FMT_YA16LE:
1581 c->lumToYV12 = read_ya16le_gray_c;
1582 break;
1583 case AV_PIX_FMT_YA16BE:
1584 c->lumToYV12 = read_ya16be_gray_c;
1585 break;
1586 case AV_PIX_FMT_AYUV64LE:
1587 c->lumToYV12 = read_ayuv64le_Y_c;
1588 break;
1589 case AV_PIX_FMT_YUYV422:
1590 case AV_PIX_FMT_YVYU422:
1591 case AV_PIX_FMT_YA8:
1592 c->lumToYV12 = yuy2ToY_c;
1593 break;
1594 case AV_PIX_FMT_UYVY422:
1595 c->lumToYV12 = uyvyToY_c;
1596 break;
1597 case AV_PIX_FMT_BGR24:
1598 c->lumToYV12 = bgr24ToY_c;
1599 break;
1600 case AV_PIX_FMT_BGR565LE:
1601 c->lumToYV12 = bgr16leToY_c;
1602 break;
1603 case AV_PIX_FMT_BGR565BE:
1604 c->lumToYV12 = bgr16beToY_c;
1605 break;
1606 case AV_PIX_FMT_BGR555LE:
1607 c->lumToYV12 = bgr15leToY_c;
1608 break;
1609 case AV_PIX_FMT_BGR555BE:
1610 c->lumToYV12 = bgr15beToY_c;
1611 break;
1612 case AV_PIX_FMT_BGR444LE:
1613 c->lumToYV12 = bgr12leToY_c;
1614 break;
1615 case AV_PIX_FMT_BGR444BE:
1616 c->lumToYV12 = bgr12beToY_c;
1617 break;
1618 case AV_PIX_FMT_RGB24:
1619 c->lumToYV12 = rgb24ToY_c;
1620 break;
1621 case AV_PIX_FMT_RGB565LE:
1622 c->lumToYV12 = rgb16leToY_c;
1623 break;
1624 case AV_PIX_FMT_RGB565BE:
1625 c->lumToYV12 = rgb16beToY_c;
1626 break;
1627 case AV_PIX_FMT_RGB555LE:
1628 c->lumToYV12 = rgb15leToY_c;
1629 break;
1630 case AV_PIX_FMT_RGB555BE:
1631 c->lumToYV12 = rgb15beToY_c;
1632 break;
1633 case AV_PIX_FMT_RGB444LE:
1634 c->lumToYV12 = rgb12leToY_c;
1635 break;
1636 case AV_PIX_FMT_RGB444BE:
1637 c->lumToYV12 = rgb12beToY_c;
1638 break;
1639 case AV_PIX_FMT_RGB8:
1640 case AV_PIX_FMT_BGR8:
1641 case AV_PIX_FMT_PAL8:
1642 case AV_PIX_FMT_BGR4_BYTE:
1643 case AV_PIX_FMT_RGB4_BYTE:
1644 c->lumToYV12 = palToY_c;
1645 break;
1646 case AV_PIX_FMT_MONOBLACK:
1647 c->lumToYV12 = monoblack2Y_c;
1648 break;
1649 case AV_PIX_FMT_MONOWHITE:
1650 c->lumToYV12 = monowhite2Y_c;
1651 break;
1652 case AV_PIX_FMT_RGB32:
1653 c->lumToYV12 = bgr32ToY_c;
1654 break;
1655 case AV_PIX_FMT_RGB32_1:
1656 c->lumToYV12 = bgr321ToY_c;
1657 break;
1658 case AV_PIX_FMT_BGR32:
1659 c->lumToYV12 = rgb32ToY_c;
1660 break;
1661 case AV_PIX_FMT_BGR32_1:
1662 c->lumToYV12 = rgb321ToY_c;
1663 break;
1664 case AV_PIX_FMT_RGB48BE:
1665 c->lumToYV12 = rgb48BEToY_c;
1666 break;
1667 case AV_PIX_FMT_RGB48LE:
1668 c->lumToYV12 = rgb48LEToY_c;
1669 break;
1670 case AV_PIX_FMT_BGR48BE:
1671 c->lumToYV12 = bgr48BEToY_c;
1672 break;
1673 case AV_PIX_FMT_BGR48LE:
1674 c->lumToYV12 = bgr48LEToY_c;
1675 break;
1676 case AV_PIX_FMT_RGBA64BE:
1677 c->lumToYV12 = rgb64BEToY_c;
1678 break;
1679 case AV_PIX_FMT_RGBA64LE:
1680 c->lumToYV12 = rgb64LEToY_c;
1681 break;
1682 case AV_PIX_FMT_BGRA64BE:
1683 c->lumToYV12 = bgr64BEToY_c;
1684 break;
1685 case AV_PIX_FMT_BGRA64LE:
1686 c->lumToYV12 = bgr64LEToY_c;
1687 break;
1688 case AV_PIX_FMT_P010LE:
1689 c->lumToYV12 = p010LEToY_c;
1690 break;
1691 case AV_PIX_FMT_P010BE:
1692 c->lumToYV12 = p010BEToY_c;
1693 break;
1694 case AV_PIX_FMT_GRAYF32LE:
1695 #if HAVE_BIGENDIAN
1696 c->lumToYV12 = grayf32ToY16_bswap_c;
1697 #else
1698 c->lumToYV12 = grayf32ToY16_c;
1699 #endif
1700 break;
1701 case AV_PIX_FMT_GRAYF32BE:
1702 #if HAVE_BIGENDIAN
1703 c->lumToYV12 = grayf32ToY16_c;
1704 #else
1705 c->lumToYV12 = grayf32ToY16_bswap_c;
1706 #endif
1707 break;
1708 case AV_PIX_FMT_Y210LE:
1709 c->lumToYV12 = y210le_Y_c;
1710 break;
1711 case AV_PIX_FMT_X2RGB10LE:
1712 c->lumToYV12 =rgb30leToY_c;
1713 break;
1714 }
1715 if (c->needAlpha) {
1716 if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1717 if (HAVE_BIGENDIAN == !isBE(srcFormat) && !c->readAlpPlanar)
1718 c->alpToYV12 = bswap16Y_c;
1719 }
1720 switch (srcFormat) {
1721 case AV_PIX_FMT_BGRA64LE:
1722 case AV_PIX_FMT_RGBA64LE: c->alpToYV12 = rgba64leToA_c; break;
1723 case AV_PIX_FMT_BGRA64BE:
1724 case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64beToA_c; break;
1725 case AV_PIX_FMT_BGRA:
1726 case AV_PIX_FMT_RGBA:
1727 c->alpToYV12 = rgbaToA_c;
1728 break;
1729 case AV_PIX_FMT_ABGR:
1730 case AV_PIX_FMT_ARGB:
1731 c->alpToYV12 = abgrToA_c;
1732 break;
1733 case AV_PIX_FMT_YA8:
1734 c->alpToYV12 = uyvyToY_c;
1735 break;
1736 case AV_PIX_FMT_YA16LE:
1737 c->alpToYV12 = read_ya16le_alpha_c;
1738 break;
1739 case AV_PIX_FMT_YA16BE:
1740 c->alpToYV12 = read_ya16be_alpha_c;
1741 break;
1742 case AV_PIX_FMT_AYUV64LE:
1743 c->alpToYV12 = read_ayuv64le_A_c;
1744 break;
1745 case AV_PIX_FMT_PAL8 :
1746 c->alpToYV12 = palToA_c;
1747 break;
1748 }
1749 }
1750 }
1751