FFmpeg
input.c
Go to the documentation of this file.
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
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
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
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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. */
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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)
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 + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
928  }
929 }
930 
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 
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 + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
961  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (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 
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 
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  int bpc = 16;
988  int shift = 14;
989  for (i = 0; i < width; i++) {
990  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
991  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
992  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
993 
994  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
995  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
996  }
997 }
998 
999 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)
1000 {
1001  int i;
1002  const float **src = (const float **)_src;
1003  uint16_t *dst = (uint16_t *)_dst;
1004 
1005  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
1006  int bpc = 16;
1007  int shift = 14;
1008  for (i = 0; i < width; i++) {
1009  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
1010  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
1011  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
1012 
1013  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
1014  }
1015 }
1016 
1017 #undef rdpx
1018 
1019 static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1020  const uint8_t *unused2, int width, uint32_t *unused)
1021 {
1022  int i;
1023  const float *src = (const float *)_src;
1024  uint16_t *dst = (uint16_t *)_dst;
1025 
1026  for (i = 0; i < width; ++i){
1027  dst[i] = av_clip_uint16(lrintf(65535.0f * src[i]));
1028  }
1029 }
1030 
1031 static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1032  const uint8_t *unused2, int width, uint32_t *unused)
1033 {
1034  int i;
1035  const uint32_t *src = (const uint32_t *)_src;
1036  uint16_t *dst = (uint16_t *)_dst;
1037 
1038  for (i = 0; i < width; ++i){
1039  dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]))));
1040  }
1041 }
1042 
1043 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
1044 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1045  int w, int32_t *rgb2yuv) \
1046 { \
1047  planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
1048 } \
1049 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1050  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1051 { \
1052  planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
1053 } \
1054 
1055 #define rgb9plus_planar_transparency_funcs(nbits) \
1056 static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
1057  int w, int32_t *rgb2yuv) \
1058 { \
1059  planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
1060 } \
1061 static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
1062  int w, int32_t *rgb2yuv) \
1063 { \
1064  planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
1065 }
1066 
1067 #define rgb9plus_planar_funcs(nbits) \
1068  rgb9plus_planar_funcs_endian(nbits, le, 0) \
1069  rgb9plus_planar_funcs_endian(nbits, be, 1)
1070 
1076 
1080 
1081 #define rgbf32_planar_funcs_endian(endian_name, endian) \
1082 static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1083  int w, int32_t *rgb2yuv) \
1084 { \
1085  planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
1086 } \
1087 static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1088  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1089 { \
1090  planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
1091 } \
1092 static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
1093  int w, int32_t *rgb2yuv) \
1094 { \
1095  planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1096 }
1097 
1100 
1102 {
1103  enum AVPixelFormat srcFormat = c->srcFormat;
1104 
1105  c->chrToYV12 = NULL;
1106  switch (srcFormat) {
1107  case AV_PIX_FMT_YUYV422:
1108  c->chrToYV12 = yuy2ToUV_c;
1109  break;
1110  case AV_PIX_FMT_YVYU422:
1111  c->chrToYV12 = yvy2ToUV_c;
1112  break;
1113  case AV_PIX_FMT_UYVY422:
1114  c->chrToYV12 = uyvyToUV_c;
1115  break;
1116  case AV_PIX_FMT_NV12:
1117  case AV_PIX_FMT_NV24:
1118  c->chrToYV12 = nv12ToUV_c;
1119  break;
1120  case AV_PIX_FMT_NV21:
1121  case AV_PIX_FMT_NV42:
1122  c->chrToYV12 = nv21ToUV_c;
1123  break;
1124  case AV_PIX_FMT_RGB8:
1125  case AV_PIX_FMT_BGR8:
1126  case AV_PIX_FMT_PAL8:
1127  case AV_PIX_FMT_BGR4_BYTE:
1128  case AV_PIX_FMT_RGB4_BYTE:
1129  c->chrToYV12 = palToUV_c;
1130  break;
1131  case AV_PIX_FMT_GBRP9LE:
1132  c->readChrPlanar = planar_rgb9le_to_uv;
1133  break;
1134  case AV_PIX_FMT_GBRAP10LE:
1135  case AV_PIX_FMT_GBRP10LE:
1136  c->readChrPlanar = planar_rgb10le_to_uv;
1137  break;
1138  case AV_PIX_FMT_GBRAP12LE:
1139  case AV_PIX_FMT_GBRP12LE:
1140  c->readChrPlanar = planar_rgb12le_to_uv;
1141  break;
1142  case AV_PIX_FMT_GBRP14LE:
1143  c->readChrPlanar = planar_rgb14le_to_uv;
1144  break;
1145  case AV_PIX_FMT_GBRAP16LE:
1146  case AV_PIX_FMT_GBRP16LE:
1147  c->readChrPlanar = planar_rgb16le_to_uv;
1148  break;
1149  case AV_PIX_FMT_GBRAPF32LE:
1150  case AV_PIX_FMT_GBRPF32LE:
1151  c->readChrPlanar = planar_rgbf32le_to_uv;
1152  break;
1153  case AV_PIX_FMT_GBRP9BE:
1154  c->readChrPlanar = planar_rgb9be_to_uv;
1155  break;
1156  case AV_PIX_FMT_GBRAP10BE:
1157  case AV_PIX_FMT_GBRP10BE:
1158  c->readChrPlanar = planar_rgb10be_to_uv;
1159  break;
1160  case AV_PIX_FMT_GBRAP12BE:
1161  case AV_PIX_FMT_GBRP12BE:
1162  c->readChrPlanar = planar_rgb12be_to_uv;
1163  break;
1164  case AV_PIX_FMT_GBRP14BE:
1165  c->readChrPlanar = planar_rgb14be_to_uv;
1166  break;
1167  case AV_PIX_FMT_GBRAP16BE:
1168  case AV_PIX_FMT_GBRP16BE:
1169  c->readChrPlanar = planar_rgb16be_to_uv;
1170  break;
1171  case AV_PIX_FMT_GBRAPF32BE:
1172  case AV_PIX_FMT_GBRPF32BE:
1173  c->readChrPlanar = planar_rgbf32be_to_uv;
1174  break;
1175  case AV_PIX_FMT_GBRAP:
1176  case AV_PIX_FMT_GBRP:
1177  c->readChrPlanar = planar_rgb_to_uv;
1178  break;
1179 #if HAVE_BIGENDIAN
1180  case AV_PIX_FMT_YUV420P9LE:
1181  case AV_PIX_FMT_YUV422P9LE:
1182  case AV_PIX_FMT_YUV444P9LE:
1197 
1209  c->chrToYV12 = bswap16UV_c;
1210  break;
1211 #else
1212  case AV_PIX_FMT_YUV420P9BE:
1213  case AV_PIX_FMT_YUV422P9BE:
1214  case AV_PIX_FMT_YUV444P9BE:
1229 
1241  c->chrToYV12 = bswap16UV_c;
1242  break;
1243 #endif
1244  case AV_PIX_FMT_AYUV64LE:
1245  c->chrToYV12 = read_ayuv64le_UV_c;
1246  break;
1247  case AV_PIX_FMT_P010LE:
1248  c->chrToYV12 = p010LEToUV_c;
1249  break;
1250  case AV_PIX_FMT_P010BE:
1251  c->chrToYV12 = p010BEToUV_c;
1252  break;
1253  case AV_PIX_FMT_P016LE:
1254  c->chrToYV12 = p016LEToUV_c;
1255  break;
1256  case AV_PIX_FMT_P016BE:
1257  c->chrToYV12 = p016BEToUV_c;
1258  break;
1259  case AV_PIX_FMT_Y210LE:
1260  c->chrToYV12 = y210le_UV_c;
1261  break;
1262  }
1263  if (c->chrSrcHSubSample) {
1264  switch (srcFormat) {
1265  case AV_PIX_FMT_RGBA64BE:
1266  c->chrToYV12 = rgb64BEToUV_half_c;
1267  break;
1268  case AV_PIX_FMT_RGBA64LE:
1269  c->chrToYV12 = rgb64LEToUV_half_c;
1270  break;
1271  case AV_PIX_FMT_BGRA64BE:
1272  c->chrToYV12 = bgr64BEToUV_half_c;
1273  break;
1274  case AV_PIX_FMT_BGRA64LE:
1275  c->chrToYV12 = bgr64LEToUV_half_c;
1276  break;
1277  case AV_PIX_FMT_RGB48BE:
1278  c->chrToYV12 = rgb48BEToUV_half_c;
1279  break;
1280  case AV_PIX_FMT_RGB48LE:
1281  c->chrToYV12 = rgb48LEToUV_half_c;
1282  break;
1283  case AV_PIX_FMT_BGR48BE:
1284  c->chrToYV12 = bgr48BEToUV_half_c;
1285  break;
1286  case AV_PIX_FMT_BGR48LE:
1287  c->chrToYV12 = bgr48LEToUV_half_c;
1288  break;
1289  case AV_PIX_FMT_RGB32:
1290  c->chrToYV12 = bgr32ToUV_half_c;
1291  break;
1292  case AV_PIX_FMT_RGB32_1:
1293  c->chrToYV12 = bgr321ToUV_half_c;
1294  break;
1295  case AV_PIX_FMT_BGR24:
1296  c->chrToYV12 = bgr24ToUV_half_c;
1297  break;
1298  case AV_PIX_FMT_BGR565LE:
1299  c->chrToYV12 = bgr16leToUV_half_c;
1300  break;
1301  case AV_PIX_FMT_BGR565BE:
1302  c->chrToYV12 = bgr16beToUV_half_c;
1303  break;
1304  case AV_PIX_FMT_BGR555LE:
1305  c->chrToYV12 = bgr15leToUV_half_c;
1306  break;
1307  case AV_PIX_FMT_BGR555BE:
1308  c->chrToYV12 = bgr15beToUV_half_c;
1309  break;
1310  case AV_PIX_FMT_GBRAP:
1311  case AV_PIX_FMT_GBRP:
1312  c->chrToYV12 = gbr24pToUV_half_c;
1313  break;
1314  case AV_PIX_FMT_BGR444LE:
1315  c->chrToYV12 = bgr12leToUV_half_c;
1316  break;
1317  case AV_PIX_FMT_BGR444BE:
1318  c->chrToYV12 = bgr12beToUV_half_c;
1319  break;
1320  case AV_PIX_FMT_BGR32:
1321  c->chrToYV12 = rgb32ToUV_half_c;
1322  break;
1323  case AV_PIX_FMT_BGR32_1:
1324  c->chrToYV12 = rgb321ToUV_half_c;
1325  break;
1326  case AV_PIX_FMT_RGB24:
1327  c->chrToYV12 = rgb24ToUV_half_c;
1328  break;
1329  case AV_PIX_FMT_RGB565LE:
1330  c->chrToYV12 = rgb16leToUV_half_c;
1331  break;
1332  case AV_PIX_FMT_RGB565BE:
1333  c->chrToYV12 = rgb16beToUV_half_c;
1334  break;
1335  case AV_PIX_FMT_RGB555LE:
1336  c->chrToYV12 = rgb15leToUV_half_c;
1337  break;
1338  case AV_PIX_FMT_RGB555BE:
1339  c->chrToYV12 = rgb15beToUV_half_c;
1340  break;
1341  case AV_PIX_FMT_RGB444LE:
1342  c->chrToYV12 = rgb12leToUV_half_c;
1343  break;
1344  case AV_PIX_FMT_RGB444BE:
1345  c->chrToYV12 = rgb12beToUV_half_c;
1346  break;
1347  case AV_PIX_FMT_X2RGB10LE:
1348  c->chrToYV12 = rgb30leToUV_half_c;
1349  break;
1350  }
1351  } else {
1352  switch (srcFormat) {
1353  case AV_PIX_FMT_RGBA64BE:
1354  c->chrToYV12 = rgb64BEToUV_c;
1355  break;
1356  case AV_PIX_FMT_RGBA64LE:
1357  c->chrToYV12 = rgb64LEToUV_c;
1358  break;
1359  case AV_PIX_FMT_BGRA64BE:
1360  c->chrToYV12 = bgr64BEToUV_c;
1361  break;
1362  case AV_PIX_FMT_BGRA64LE:
1363  c->chrToYV12 = bgr64LEToUV_c;
1364  break;
1365  case AV_PIX_FMT_RGB48BE:
1366  c->chrToYV12 = rgb48BEToUV_c;
1367  break;
1368  case AV_PIX_FMT_RGB48LE:
1369  c->chrToYV12 = rgb48LEToUV_c;
1370  break;
1371  case AV_PIX_FMT_BGR48BE:
1372  c->chrToYV12 = bgr48BEToUV_c;
1373  break;
1374  case AV_PIX_FMT_BGR48LE:
1375  c->chrToYV12 = bgr48LEToUV_c;
1376  break;
1377  case AV_PIX_FMT_RGB32:
1378  c->chrToYV12 = bgr32ToUV_c;
1379  break;
1380  case AV_PIX_FMT_RGB32_1:
1381  c->chrToYV12 = bgr321ToUV_c;
1382  break;
1383  case AV_PIX_FMT_BGR24:
1384  c->chrToYV12 = bgr24ToUV_c;
1385  break;
1386  case AV_PIX_FMT_BGR565LE:
1387  c->chrToYV12 = bgr16leToUV_c;
1388  break;
1389  case AV_PIX_FMT_BGR565BE:
1390  c->chrToYV12 = bgr16beToUV_c;
1391  break;
1392  case AV_PIX_FMT_BGR555LE:
1393  c->chrToYV12 = bgr15leToUV_c;
1394  break;
1395  case AV_PIX_FMT_BGR555BE:
1396  c->chrToYV12 = bgr15beToUV_c;
1397  break;
1398  case AV_PIX_FMT_BGR444LE:
1399  c->chrToYV12 = bgr12leToUV_c;
1400  break;
1401  case AV_PIX_FMT_BGR444BE:
1402  c->chrToYV12 = bgr12beToUV_c;
1403  break;
1404  case AV_PIX_FMT_BGR32:
1405  c->chrToYV12 = rgb32ToUV_c;
1406  break;
1407  case AV_PIX_FMT_BGR32_1:
1408  c->chrToYV12 = rgb321ToUV_c;
1409  break;
1410  case AV_PIX_FMT_RGB24:
1411  c->chrToYV12 = rgb24ToUV_c;
1412  break;
1413  case AV_PIX_FMT_RGB565LE:
1414  c->chrToYV12 = rgb16leToUV_c;
1415  break;
1416  case AV_PIX_FMT_RGB565BE:
1417  c->chrToYV12 = rgb16beToUV_c;
1418  break;
1419  case AV_PIX_FMT_RGB555LE:
1420  c->chrToYV12 = rgb15leToUV_c;
1421  break;
1422  case AV_PIX_FMT_RGB555BE:
1423  c->chrToYV12 = rgb15beToUV_c;
1424  break;
1425  case AV_PIX_FMT_RGB444LE:
1426  c->chrToYV12 = rgb12leToUV_c;
1427  break;
1428  case AV_PIX_FMT_RGB444BE:
1429  c->chrToYV12 = rgb12beToUV_c;
1430  break;
1431  case AV_PIX_FMT_X2RGB10LE:
1432  c->chrToYV12 = rgb30leToUV_c;
1433  break;
1434  }
1435  }
1436 
1437  c->lumToYV12 = NULL;
1438  c->alpToYV12 = NULL;
1439  switch (srcFormat) {
1440  case AV_PIX_FMT_GBRP9LE:
1441  c->readLumPlanar = planar_rgb9le_to_y;
1442  break;
1443  case AV_PIX_FMT_GBRAP10LE:
1444  c->readAlpPlanar = planar_rgb10le_to_a;
1445  case AV_PIX_FMT_GBRP10LE:
1446  c->readLumPlanar = planar_rgb10le_to_y;
1447  break;
1448  case AV_PIX_FMT_GBRAP12LE:
1449  c->readAlpPlanar = planar_rgb12le_to_a;
1450  case AV_PIX_FMT_GBRP12LE:
1451  c->readLumPlanar = planar_rgb12le_to_y;
1452  break;
1453  case AV_PIX_FMT_GBRP14LE:
1454  c->readLumPlanar = planar_rgb14le_to_y;
1455  break;
1456  case AV_PIX_FMT_GBRAP16LE:
1457  c->readAlpPlanar = planar_rgb16le_to_a;
1458  case AV_PIX_FMT_GBRP16LE:
1459  c->readLumPlanar = planar_rgb16le_to_y;
1460  break;
1461  case AV_PIX_FMT_GBRAPF32LE:
1462  c->readAlpPlanar = planar_rgbf32le_to_a;
1463  case AV_PIX_FMT_GBRPF32LE:
1464  c->readLumPlanar = planar_rgbf32le_to_y;
1465  break;
1466  case AV_PIX_FMT_GBRP9BE:
1467  c->readLumPlanar = planar_rgb9be_to_y;
1468  break;
1469  case AV_PIX_FMT_GBRAP10BE:
1470  c->readAlpPlanar = planar_rgb10be_to_a;
1471  case AV_PIX_FMT_GBRP10BE:
1472  c->readLumPlanar = planar_rgb10be_to_y;
1473  break;
1474  case AV_PIX_FMT_GBRAP12BE:
1475  c->readAlpPlanar = planar_rgb12be_to_a;
1476  case AV_PIX_FMT_GBRP12BE:
1477  c->readLumPlanar = planar_rgb12be_to_y;
1478  break;
1479  case AV_PIX_FMT_GBRP14BE:
1480  c->readLumPlanar = planar_rgb14be_to_y;
1481  break;
1482  case AV_PIX_FMT_GBRAP16BE:
1483  c->readAlpPlanar = planar_rgb16be_to_a;
1484  case AV_PIX_FMT_GBRP16BE:
1485  c->readLumPlanar = planar_rgb16be_to_y;
1486  break;
1487  case AV_PIX_FMT_GBRAPF32BE:
1488  c->readAlpPlanar = planar_rgbf32be_to_a;
1489  case AV_PIX_FMT_GBRPF32BE:
1490  c->readLumPlanar = planar_rgbf32be_to_y;
1491  break;
1492  case AV_PIX_FMT_GBRAP:
1493  c->readAlpPlanar = planar_rgb_to_a;
1494  case AV_PIX_FMT_GBRP:
1495  c->readLumPlanar = planar_rgb_to_y;
1496  break;
1497 #if HAVE_BIGENDIAN
1498  case AV_PIX_FMT_YUV420P9LE:
1499  case AV_PIX_FMT_YUV422P9LE:
1500  case AV_PIX_FMT_YUV444P9LE:
1515 
1516  case AV_PIX_FMT_GRAY9LE:
1517  case AV_PIX_FMT_GRAY10LE:
1518  case AV_PIX_FMT_GRAY12LE:
1519  case AV_PIX_FMT_GRAY14LE:
1520  case AV_PIX_FMT_GRAY16LE:
1521 
1522  case AV_PIX_FMT_P016LE:
1523  c->lumToYV12 = bswap16Y_c;
1524  break;
1536  c->lumToYV12 = bswap16Y_c;
1537  c->alpToYV12 = bswap16Y_c;
1538  break;
1539 #else
1540  case AV_PIX_FMT_YUV420P9BE:
1541  case AV_PIX_FMT_YUV422P9BE:
1542  case AV_PIX_FMT_YUV444P9BE:
1557 
1558  case AV_PIX_FMT_GRAY9BE:
1559  case AV_PIX_FMT_GRAY10BE:
1560  case AV_PIX_FMT_GRAY12BE:
1561  case AV_PIX_FMT_GRAY14BE:
1562  case AV_PIX_FMT_GRAY16BE:
1563 
1564  case AV_PIX_FMT_P016BE:
1565  c->lumToYV12 = bswap16Y_c;
1566  break;
1578  c->lumToYV12 = bswap16Y_c;
1579  c->alpToYV12 = bswap16Y_c;
1580  break;
1581 #endif
1582  case AV_PIX_FMT_YA16LE:
1583  c->lumToYV12 = read_ya16le_gray_c;
1584  break;
1585  case AV_PIX_FMT_YA16BE:
1586  c->lumToYV12 = read_ya16be_gray_c;
1587  break;
1588  case AV_PIX_FMT_AYUV64LE:
1589  c->lumToYV12 = read_ayuv64le_Y_c;
1590  break;
1591  case AV_PIX_FMT_YUYV422:
1592  case AV_PIX_FMT_YVYU422:
1593  case AV_PIX_FMT_YA8:
1594  c->lumToYV12 = yuy2ToY_c;
1595  break;
1596  case AV_PIX_FMT_UYVY422:
1597  c->lumToYV12 = uyvyToY_c;
1598  break;
1599  case AV_PIX_FMT_BGR24:
1600  c->lumToYV12 = bgr24ToY_c;
1601  break;
1602  case AV_PIX_FMT_BGR565LE:
1603  c->lumToYV12 = bgr16leToY_c;
1604  break;
1605  case AV_PIX_FMT_BGR565BE:
1606  c->lumToYV12 = bgr16beToY_c;
1607  break;
1608  case AV_PIX_FMT_BGR555LE:
1609  c->lumToYV12 = bgr15leToY_c;
1610  break;
1611  case AV_PIX_FMT_BGR555BE:
1612  c->lumToYV12 = bgr15beToY_c;
1613  break;
1614  case AV_PIX_FMT_BGR444LE:
1615  c->lumToYV12 = bgr12leToY_c;
1616  break;
1617  case AV_PIX_FMT_BGR444BE:
1618  c->lumToYV12 = bgr12beToY_c;
1619  break;
1620  case AV_PIX_FMT_RGB24:
1621  c->lumToYV12 = rgb24ToY_c;
1622  break;
1623  case AV_PIX_FMT_RGB565LE:
1624  c->lumToYV12 = rgb16leToY_c;
1625  break;
1626  case AV_PIX_FMT_RGB565BE:
1627  c->lumToYV12 = rgb16beToY_c;
1628  break;
1629  case AV_PIX_FMT_RGB555LE:
1630  c->lumToYV12 = rgb15leToY_c;
1631  break;
1632  case AV_PIX_FMT_RGB555BE:
1633  c->lumToYV12 = rgb15beToY_c;
1634  break;
1635  case AV_PIX_FMT_RGB444LE:
1636  c->lumToYV12 = rgb12leToY_c;
1637  break;
1638  case AV_PIX_FMT_RGB444BE:
1639  c->lumToYV12 = rgb12beToY_c;
1640  break;
1641  case AV_PIX_FMT_RGB8:
1642  case AV_PIX_FMT_BGR8:
1643  case AV_PIX_FMT_PAL8:
1644  case AV_PIX_FMT_BGR4_BYTE:
1645  case AV_PIX_FMT_RGB4_BYTE:
1646  c->lumToYV12 = palToY_c;
1647  break;
1648  case AV_PIX_FMT_MONOBLACK:
1649  c->lumToYV12 = monoblack2Y_c;
1650  break;
1651  case AV_PIX_FMT_MONOWHITE:
1652  c->lumToYV12 = monowhite2Y_c;
1653  break;
1654  case AV_PIX_FMT_RGB32:
1655  c->lumToYV12 = bgr32ToY_c;
1656  break;
1657  case AV_PIX_FMT_RGB32_1:
1658  c->lumToYV12 = bgr321ToY_c;
1659  break;
1660  case AV_PIX_FMT_BGR32:
1661  c->lumToYV12 = rgb32ToY_c;
1662  break;
1663  case AV_PIX_FMT_BGR32_1:
1664  c->lumToYV12 = rgb321ToY_c;
1665  break;
1666  case AV_PIX_FMT_RGB48BE:
1667  c->lumToYV12 = rgb48BEToY_c;
1668  break;
1669  case AV_PIX_FMT_RGB48LE:
1670  c->lumToYV12 = rgb48LEToY_c;
1671  break;
1672  case AV_PIX_FMT_BGR48BE:
1673  c->lumToYV12 = bgr48BEToY_c;
1674  break;
1675  case AV_PIX_FMT_BGR48LE:
1676  c->lumToYV12 = bgr48LEToY_c;
1677  break;
1678  case AV_PIX_FMT_RGBA64BE:
1679  c->lumToYV12 = rgb64BEToY_c;
1680  break;
1681  case AV_PIX_FMT_RGBA64LE:
1682  c->lumToYV12 = rgb64LEToY_c;
1683  break;
1684  case AV_PIX_FMT_BGRA64BE:
1685  c->lumToYV12 = bgr64BEToY_c;
1686  break;
1687  case AV_PIX_FMT_BGRA64LE:
1688  c->lumToYV12 = bgr64LEToY_c;
1689  break;
1690  case AV_PIX_FMT_P010LE:
1691  c->lumToYV12 = p010LEToY_c;
1692  break;
1693  case AV_PIX_FMT_P010BE:
1694  c->lumToYV12 = p010BEToY_c;
1695  break;
1696  case AV_PIX_FMT_GRAYF32LE:
1697 #if HAVE_BIGENDIAN
1698  c->lumToYV12 = grayf32ToY16_bswap_c;
1699 #else
1700  c->lumToYV12 = grayf32ToY16_c;
1701 #endif
1702  break;
1703  case AV_PIX_FMT_GRAYF32BE:
1704 #if HAVE_BIGENDIAN
1705  c->lumToYV12 = grayf32ToY16_c;
1706 #else
1707  c->lumToYV12 = grayf32ToY16_bswap_c;
1708 #endif
1709  break;
1710  case AV_PIX_FMT_Y210LE:
1711  c->lumToYV12 = y210le_Y_c;
1712  break;
1713  case AV_PIX_FMT_X2RGB10LE:
1714  c->lumToYV12 =rgb30leToY_c;
1715  break;
1716  }
1717  if (c->needAlpha) {
1718  if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1719  if (HAVE_BIGENDIAN == !isBE(srcFormat) && !c->readAlpPlanar)
1720  c->alpToYV12 = bswap16Y_c;
1721  }
1722  switch (srcFormat) {
1723  case AV_PIX_FMT_BGRA64LE:
1724  case AV_PIX_FMT_RGBA64LE: c->alpToYV12 = rgba64leToA_c; break;
1725  case AV_PIX_FMT_BGRA64BE:
1726  case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64beToA_c; break;
1727  case AV_PIX_FMT_BGRA:
1728  case AV_PIX_FMT_RGBA:
1729  c->alpToYV12 = rgbaToA_c;
1730  break;
1731  case AV_PIX_FMT_ABGR:
1732  case AV_PIX_FMT_ARGB:
1733  c->alpToYV12 = abgrToA_c;
1734  break;
1735  case AV_PIX_FMT_YA8:
1736  c->alpToYV12 = uyvyToY_c;
1737  break;
1738  case AV_PIX_FMT_YA16LE:
1739  c->alpToYV12 = read_ya16le_alpha_c;
1740  break;
1741  case AV_PIX_FMT_YA16BE:
1742  c->alpToYV12 = read_ya16be_alpha_c;
1743  break;
1744  case AV_PIX_FMT_AYUV64LE:
1745  c->alpToYV12 = read_ayuv64le_A_c;
1746  break;
1747  case AV_PIX_FMT_PAL8 :
1748  c->alpToYV12 = palToA_c;
1749  break;
1750  }
1751  }
1752 }
static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
Definition: input.c:887
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:340
packed YUV 4:2:2 like YUYV422, 20bpp, data in the high bits, little-endian
Definition: pixfmt.h:359
planar GBR 4:4:4:4 40bpp, little-endian
Definition: pixfmt.h:291
static void 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)
Definition: input.c:689
#define NULL
Definition: coverity.c:32
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:166
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:275
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:252
static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *rgb2yuv)
Definition: input.c:767
static void 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)
Definition: input.c:696
static void 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)
Definition: input.c:536
static int shift(int a, int b)
Definition: sonic.c:82
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:245
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)
Definition: input.c:979
static void 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)
Definition: input.c:754
static void 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)
Definition: input.c:668
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)
Definition: input.c:78
#define RV_IDX
RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15le
Definition: input.c:385
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:249
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:159
#define BV_IDX
8 bits gray, 8 bits alpha
Definition: pixfmt.h:143
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:208
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian ...
Definition: pixfmt.h:346
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
#define rgb9plus_planar_funcs(nbits)
Definition: input.c:1067
const char * g
Definition: vf_curves.c:115
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:162
int32_t bv
Definition: input.c:405
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
Definition: intfloat.h:40
static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2)
Definition: input.c:568
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:250
#define rgbf32_planar_funcs_endian(endian_name, endian)
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:108
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:207
#define GV_IDX
#define av_bswap16
Definition: bswap.h:31
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:189
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
Convenience header that includes libavutil&#39;s core.
static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Definition: input.c:895
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:111
static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2)
Definition: input.c:631
static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:494
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:255
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition: pixfmt.h:156
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:140
static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:623
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:87
int32_t bu
Definition: input.c:404
Y , 12bpp, little-endian.
Definition: pixfmt.h:296
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:254
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:131
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
#define r_b
static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:1031
void ff_sws_init_input_funcs(SwsContext *c)
#define b_r
static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:528
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:106
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:85
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t * bsrc
Definition: input.c:398
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12be
Definition: input.c:395
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:179
#define RU_IDX
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:216
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:190
static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:703
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian ...
Definition: pixfmt.h:344
uint8_t
#define av_cold
Definition: attributes.h:88
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:103
static void 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)
Definition: input.c:782
#define f(width, name)
Definition: cbs_vp9.c:255
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16le
Definition: input.c:387
bgr321
Definition: input.c:381
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:205
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:139
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:251
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:262
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:105
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:191
static void 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)
Definition: input.c:732
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:276
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:174
Y , 9bpp, little-endian.
Definition: pixfmt.h:316
#define input_pixel(pos)
Definition: input.c:765
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:194
#define lrintf(x)
Definition: libm_mips.h:70
static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:660
Y , 10bpp, little-endian.
Definition: pixfmt.h:298
external API header
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:278
static void 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)
Definition: input.c:721
#define r
Definition: input.c:40
static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
Definition: input.c:456
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t * gsrc
Definition: input.c:398
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:157
#define U(x)
Definition: vp56_arith.h:37
#define src
Definition: vp8dsp.c:254
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:170
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:165
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:375
16 bits gray, 16 bits alpha (big-endian)
Definition: pixfmt.h:212
#define S(s, c, i)
like NV12, with 16bpp per component, big-endian
Definition: pixfmt.h:301
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:136
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:182
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:161
int32_t gu
Definition: input.c:404
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:248
static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4], int width, int bpc, int is_be, int32_t *rgb2yuv)
Definition: input.c:931
static av_always_inline void 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)
Definition: input.c:146
like NV12, with 16bpp per component, little-endian
Definition: pixfmt.h:300
static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:447
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:134
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian
Definition: pixfmt.h:285
static av_always_inline void 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)
Definition: input.c:279
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:183
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:149
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:184
static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:607
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:348
as above, but U and V bytes are swapped
Definition: pixfmt.h:90
static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:599
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:287
#define RGB2YUV_SHIFT
#define b
Definition: input.c:41
planar GBR 4:4:4:4 40bpp, big-endian
Definition: pixfmt.h:290
IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian.
Definition: pixfmt.h:319
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12le
Definition: input.c:389
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:88
static void 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)
Definition: input.c:854
static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
Definition: input.c:467
static av_always_inline void 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)
Definition: input.c:168
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t * rsrc
Definition: input.c:398
static void 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)
Definition: input.c:743
static void 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)
Definition: input.c:801
int32_t
#define RY_IDX
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:188
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:210
static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4], int width, int bpc, int is_be, int32_t *rgb2yuv)
Definition: input.c:914
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:180
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:243
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:158
#define rgb48funcs(pattern, BE_LE, origin)
Definition: input.c:197
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
Definition: pixfmt.h:284
static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:1019
static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:576
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:167
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:148
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:110
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:361
int32_t gv
Definition: input.c:405
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t int width
Definition: input.c:398
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:288
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:374
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
static av_always_inline void 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)
Definition: input.c:307
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:83
#define src1
Definition: h264pred.c:139
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:132
#define av_bswap32
Definition: bswap.h:33
static void 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)
Definition: input.c:586
static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:511
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)
Definition: input.c:59
RGB2YUV_SHIFT rgb321
Definition: input.c:383
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:172
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:192
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:372
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now.Options-------Then comes the options array.This is what will define the user accessible options.For example
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15be
Definition: input.c:391
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:277
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:257
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:193
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:195
Y , 16bpp, big-endian.
Definition: pixfmt.h:97
as above, but U and V bytes are swapped
Definition: pixfmt.h:349
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
Definition: pixfmt.h:318
static void 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)
Definition: input.c:640
byte swapping routines
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:244
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian ...
Definition: pixfmt.h:345
Y , 9bpp, big-endian.
Definition: pixfmt.h:315
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:256
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:178
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:113
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t * _dstV
Definition: input.c:398
Y , 14bpp, little-endian.
Definition: pixfmt.h:338
#define GY_IDX
static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:418
uint16_t * dstV
Definition: input.c:403
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:187
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:107
Y , 10bpp, big-endian.
Definition: pixfmt.h:297
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:142
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:163
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:135
static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Definition: input.c:873
static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2)
Definition: input.c:650
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:76
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:247
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:75
static av_always_inline void 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)
Definition: input.c:944
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian.
Definition: pixfmt.h:321
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:171
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:102
#define rnd()
Definition: checkasm.h:107
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:133
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)
Definition: input.c:968
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:86
static void 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)
Definition: input.c:558
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:185
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16be
Definition: input.c:393
static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *rgb2yuv)
Definition: input.c:820
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian.
Definition: pixfmt.h:320
static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:615
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)
Definition: input.c:999
#define rdpx(src)
Definition: input.c:966
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:253
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:373
static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:428
Y , 14bpp, big-endian.
Definition: pixfmt.h:337
Y , 16bpp, little-endian.
Definition: pixfmt.h:98
#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr,maskg, maskb, rsh, gsh, bsh, S)
Definition: input.c:351
16 bits gray, 16 bits alpha (little-endian)
Definition: pixfmt.h:213
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:186
Y , 12bpp, big-endian.
Definition: pixfmt.h:295
static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:712
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:112
static void 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)
Definition: input.c:478
static void 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)
Definition: input.c:835
#define GU_IDX
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t int uint32_t * rgb2yuv
Definition: input.c:401
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
#define av_always_inline
Definition: attributes.h:45
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:175
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:141
static av_always_inline void rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
Definition: input.c:44
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:181
int32_t ru
Definition: input.c:404
#define BY_IDX
static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width)
Definition: input.c:679
int32_t rv
Definition: input.c:405
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:341
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:217
#define rgb9plus_planar_transparency_funcs(nbits)
Definition: input.c:1055
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:242
#define rgb64funcs(pattern, BE_LE, origin)
Definition: input.c:96
#define BU_IDX
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:164
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:246
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
int i
Definition: input.c:407
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:173
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:206
static void 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)
Definition: input.c:547
packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:279
static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:438
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian ...
Definition: pixfmt.h:343
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:160