FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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  : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
250  : AV_RL16(&src[(i) * 2])))
251 
252 static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
253  const uint8_t *src,
254  int width,
255  enum AVPixelFormat origin,
256  int shr, int shg,
257  int shb, int shp,
258  int maskr, int maskg,
259  int maskb, int rsh,
260  int gsh, int bsh, int S,
261  int32_t *rgb2yuv)
262 {
263  const int ry = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
264  const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
265  int i;
266 
267  for (i = 0; i < width; i++) {
268  int px = input_pixel(i) >> shp;
269  int b = (px & maskb) >> shb;
270  int g = (px & maskg) >> shg;
271  int r = (px & maskr) >> shr;
272 
273  dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
274  }
275 }
276 
277 static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
278  int16_t *dstV,
279  const uint8_t *src,
280  int width,
281  enum AVPixelFormat origin,
282  int shr, int shg,
283  int shb, int shp,
284  int maskr, int maskg,
285  int maskb, int rsh,
286  int gsh, int bsh, int S,
287  int32_t *rgb2yuv)
288 {
289  const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
290  rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh;
291  const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
292  int i;
293 
294  for (i = 0; i < width; i++) {
295  int px = input_pixel(i) >> shp;
296  int b = (px & maskb) >> shb;
297  int g = (px & maskg) >> shg;
298  int r = (px & maskr) >> shr;
299 
300  dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
301  dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
302  }
303 }
304 
306  int16_t *dstV,
307  const uint8_t *src,
308  int width,
309  enum AVPixelFormat origin,
310  int shr, int shg,
311  int shb, int shp,
312  int maskr, int maskg,
313  int maskb, int rsh,
314  int gsh, int bsh, int S,
315  int32_t *rgb2yuv)
316 {
317  const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
318  rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
319  maskgx = ~(maskr | maskb);
320  const unsigned rnd = (256U<<(S)) + (1<<(S-6));
321  int i;
322 
323  maskr |= maskr << 1;
324  maskb |= maskb << 1;
325  maskg |= maskg << 1;
326  for (i = 0; i < width; i++) {
327  unsigned px0 = input_pixel(2 * i + 0) >> shp;
328  unsigned px1 = input_pixel(2 * i + 1) >> shp;
329  int b, r, g = (px0 & maskgx) + (px1 & maskgx);
330  int rb = px0 + px1 - g;
331 
332  b = (rb & maskb) >> shb;
333  if (shp ||
334  origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
335  origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
336  g >>= shg;
337  } else {
338  g = (g & maskg) >> shg;
339  }
340  r = (rb & maskr) >> shr;
341 
342  dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
343  dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
344  }
345 }
346 
347 #undef input_pixel
348 
349 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
350  maskg, maskb, rsh, gsh, bsh, S) \
351 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
352  int width, uint32_t *tab) \
353 { \
354  rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
355  maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
356 } \
357  \
358 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
359  const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
360  int width, uint32_t *tab) \
361 { \
362  rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
363  shr, shg, shb, shp, \
364  maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
365 } \
366  \
367 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
368  const uint8_t *unused0, const uint8_t *src, \
369  const uint8_t *dummy, \
370  int width, uint32_t *tab) \
371 { \
372  rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
373  shr, shg, shb, shp, \
374  maskr, maskg, maskb, \
375  rsh, gsh, bsh, S, tab); \
376 }
377 
378 rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
379 rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
380 rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
381 rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
382 rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
383 rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
384 rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
385 rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
386 rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
387 rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
388 rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
389 rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
390 rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
391 rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
392 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
393 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
394 
395 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
396  const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
397  int width, uint32_t *rgb2yuv)
398 {
399  uint16_t *dstU = (uint16_t *)_dstU;
400  uint16_t *dstV = (uint16_t *)_dstV;
401  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
402  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
403 
404  int i;
405  for (i = 0; i < width; i++) {
406  unsigned int g = gsrc[2*i] + gsrc[2*i+1];
407  unsigned int b = bsrc[2*i] + bsrc[2*i+1];
408  unsigned int r = rsrc[2*i] + rsrc[2*i+1];
409 
410  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
411  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
412  }
413 }
414 
415 static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
416  const uint8_t *unused2, int width, uint32_t *unused)
417 {
418  int16_t *dst = (int16_t *)_dst;
419  const uint16_t *src = (const uint16_t *)_src;
420  int i;
421  for (i = 0; i < width; i++)
422  dst[i] = AV_RL16(src + 4 * i + 3);
423 }
424 
425 static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
426  const uint8_t *unused2, int width, uint32_t *unused)
427 {
428  int16_t *dst = (int16_t *)_dst;
429  const uint16_t *src = (const uint16_t *)_src;
430  int i;
431  for (i = 0; i < width; i++)
432  dst[i] = AV_RB16(src + 4 * i + 3);
433 }
434 
435 static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
436 {
437  int16_t *dst = (int16_t *)_dst;
438  int i;
439  for (i=0; i<width; i++) {
440  dst[i]= src[4*i]<<6;
441  }
442 }
443 
444 static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
445 {
446  int16_t *dst = (int16_t *)_dst;
447  int i;
448  for (i=0; i<width; i++) {
449  dst[i]= src[4*i+3]<<6;
450  }
451 }
452 
453 static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
454 {
455  int16_t *dst = (int16_t *)_dst;
456  int i;
457  for (i=0; i<width; i++) {
458  int d= src[i];
459 
460  dst[i]= (pal[d] >> 24)<<6;
461  }
462 }
463 
464 static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
465 {
466  int16_t *dst = (int16_t *)_dst;
467  int i;
468  for (i = 0; i < width; i++) {
469  int d = src[i];
470 
471  dst[i] = (pal[d] & 0xFF)<<6;
472  }
473 }
474 
475 static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
476  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
477  int width, uint32_t *pal)
478 {
479  uint16_t *dstU = (uint16_t *)_dstU;
480  int16_t *dstV = (int16_t *)_dstV;
481  int i;
482  av_assert1(src1 == src2);
483  for (i = 0; i < width; i++) {
484  int p = pal[src1[i]];
485 
486  dstU[i] = (uint8_t)(p>> 8)<<6;
487  dstV[i] = (uint8_t)(p>>16)<<6;
488  }
489 }
490 
491 static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
492 {
493  int16_t *dst = (int16_t *)_dst;
494  int i, j;
495  width = (width + 7) >> 3;
496  for (i = 0; i < width; i++) {
497  int d = ~src[i];
498  for (j = 0; j < 8; j++)
499  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
500  }
501  if(width&7){
502  int d= ~src[i];
503  for (j = 0; j < (width&7); j++)
504  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
505  }
506 }
507 
508 static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
509 {
510  int16_t *dst = (int16_t *)_dst;
511  int i, j;
512  width = (width + 7) >> 3;
513  for (i = 0; i < width; i++) {
514  int d = src[i];
515  for (j = 0; j < 8; j++)
516  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
517  }
518  if(width&7){
519  int d = src[i];
520  for (j = 0; j < (width&7); j++)
521  dst[8*i+j] = ((d>>(7-j))&1) * 16383;
522  }
523 }
524 
525 static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
526  uint32_t *unused)
527 {
528  int i;
529  for (i = 0; i < width; i++)
530  dst[i] = src[2 * i];
531 }
532 
533 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
534  const uint8_t *src2, int width, uint32_t *unused)
535 {
536  int i;
537  for (i = 0; i < width; i++) {
538  dstU[i] = src1[4 * i + 1];
539  dstV[i] = src1[4 * i + 3];
540  }
541  av_assert1(src1 == src2);
542 }
543 
544 static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
545  const uint8_t *src2, int width, uint32_t *unused)
546 {
547  int i;
548  for (i = 0; i < width; i++) {
549  dstV[i] = src1[4 * i + 1];
550  dstU[i] = src1[4 * i + 3];
551  }
552  av_assert1(src1 == src2);
553 }
554 
555 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
556  uint32_t *unused)
557 {
558  int i;
559  const uint16_t *src = (const uint16_t *)_src;
560  uint16_t *dst = (uint16_t *)_dst;
561  for (i = 0; i < width; i++)
562  dst[i] = av_bswap16(src[i]);
563 }
564 
565 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
566  const uint8_t *_src2, int width, uint32_t *unused)
567 {
568  int i;
569  const uint16_t *src1 = (const uint16_t *)_src1,
570  *src2 = (const uint16_t *)_src2;
571  uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
572  for (i = 0; i < width; i++) {
573  dstU[i] = av_bswap16(src1[i]);
574  dstV[i] = av_bswap16(src2[i]);
575  }
576 }
577 
578 static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
579  uint32_t *unused)
580 {
581  int i;
582  for (i = 0; i < width; i++)
583  AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
584 }
585 
586 static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
587  uint32_t *unused)
588 {
589  int i;
590  for (i = 0; i < width; i++)
591  AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
592 }
593 
594 static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
595  uint32_t *unused)
596 {
597  int i;
598  for (i = 0; i < width; i++)
599  AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
600 }
601 
602 static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
603  uint32_t *unused)
604 {
605  int i;
606  for (i = 0; i < width; i++)
607  AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
608 }
609 
610 /* This is almost identical to the previous, end exists only because
611  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
612 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
613  uint32_t *unused)
614 {
615  int i;
616  for (i = 0; i < width; i++)
617  dst[i] = src[2 * i + 1];
618 }
619 
620 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
621  const uint8_t *src2, int width, uint32_t *unused)
622 {
623  int i;
624  for (i = 0; i < width; i++) {
625  dstU[i] = src1[4 * i + 0];
626  dstV[i] = src1[4 * i + 2];
627  }
628  av_assert1(src1 == src2);
629 }
630 
631 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
632  const uint8_t *src, int width)
633 {
634  int i;
635  for (i = 0; i < width; i++) {
636  dst1[i] = src[2 * i + 0];
637  dst2[i] = src[2 * i + 1];
638  }
639 }
640 
641 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
642  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
643  int width, uint32_t *unused)
644 {
645  nvXXtoUV_c(dstU, dstV, src1, width);
646 }
647 
648 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
649  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
650  int width, uint32_t *unused)
651 {
652  nvXXtoUV_c(dstV, dstU, src1, width);
653 }
654 
655 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
656 
657 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
658  int width, uint32_t *rgb2yuv)
659 {
660  int16_t *dst = (int16_t *)_dst;
661  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
662  int i;
663  for (i = 0; i < width; i++) {
664  int b = src[i * 3 + 0];
665  int g = src[i * 3 + 1];
666  int r = src[i * 3 + 2];
667 
668  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
669  }
670 }
671 
672 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
673  const uint8_t *src2, int width, uint32_t *rgb2yuv)
674 {
675  int16_t *dstU = (int16_t *)_dstU;
676  int16_t *dstV = (int16_t *)_dstV;
677  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
678  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
679  int i;
680  for (i = 0; i < width; i++) {
681  int b = src1[3 * i + 0];
682  int g = src1[3 * i + 1];
683  int r = src1[3 * i + 2];
684 
685  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
686  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
687  }
688  av_assert1(src1 == src2);
689 }
690 
691 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
692  const uint8_t *src2, int width, uint32_t *rgb2yuv)
693 {
694  int16_t *dstU = (int16_t *)_dstU;
695  int16_t *dstV = (int16_t *)_dstV;
696  int i;
697  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
698  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
699  for (i = 0; i < width; i++) {
700  int b = src1[6 * i + 0] + src1[6 * i + 3];
701  int g = src1[6 * i + 1] + src1[6 * i + 4];
702  int r = src1[6 * i + 2] + src1[6 * i + 5];
703 
704  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
705  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
706  }
707  av_assert1(src1 == src2);
708 }
709 
710 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
711  uint32_t *rgb2yuv)
712 {
713  int16_t *dst = (int16_t *)_dst;
714  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
715  int i;
716  for (i = 0; i < width; i++) {
717  int r = src[i * 3 + 0];
718  int g = src[i * 3 + 1];
719  int b = src[i * 3 + 2];
720 
721  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
722  }
723 }
724 
725 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
726  const uint8_t *src2, int width, uint32_t *rgb2yuv)
727 {
728  int16_t *dstU = (int16_t *)_dstU;
729  int16_t *dstV = (int16_t *)_dstV;
730  int i;
731  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
732  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
733  av_assert1(src1 == src2);
734  for (i = 0; i < width; i++) {
735  int r = src1[3 * i + 0];
736  int g = src1[3 * i + 1];
737  int b = src1[3 * i + 2];
738 
739  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
740  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
741  }
742 }
743 
744 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
745  const uint8_t *src2, int width, uint32_t *rgb2yuv)
746 {
747  int16_t *dstU = (int16_t *)_dstU;
748  int16_t *dstV = (int16_t *)_dstV;
749  int i;
750  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
751  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
752  av_assert1(src1 == src2);
753  for (i = 0; i < width; i++) {
754  int r = src1[6 * i + 0] + src1[6 * i + 3];
755  int g = src1[6 * i + 1] + src1[6 * i + 4];
756  int b = src1[6 * i + 2] + src1[6 * i + 5];
757 
758  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
759  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
760  }
761 }
762 
763 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
764 {
765  uint16_t *dst = (uint16_t *)_dst;
766  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
767  int i;
768  for (i = 0; i < width; i++) {
769  int g = src[0][i];
770  int b = src[1][i];
771  int r = src[2][i];
772 
773  dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
774  }
775 }
776 
777 static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
778 {
779  uint16_t *dst = (uint16_t *)_dst;
780  int i;
781  for (i = 0; i < width; i++)
782  dst[i] = src[3][i] << 6;
783 }
784 
785 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
786 {
787  uint16_t *dstU = (uint16_t *)_dstU;
788  uint16_t *dstV = (uint16_t *)_dstV;
789  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
790  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
791  int i;
792  for (i = 0; i < width; i++) {
793  int g = src[0][i];
794  int b = src[1][i];
795  int r = src[2][i];
796 
797  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
798  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
799  }
800 }
801 
802 #define rdpx(src) \
803  is_be ? AV_RB16(src) : AV_RL16(src)
804 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
805  int width, int bpc, int is_be, int32_t *rgb2yuv)
806 {
807  int i;
808  const uint16_t **src = (const uint16_t **)_src;
809  uint16_t *dst = (uint16_t *)_dst;
810  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
811  int shift = bpc < 16 ? bpc : 14;
812  for (i = 0; i < width; i++) {
813  int g = rdpx(src[0] + i);
814  int b = rdpx(src[1] + i);
815  int r = rdpx(src[2] + i);
816 
817  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
818  }
819 }
820 
822  const uint8_t *_src[4], int width,
823  int bpc, int is_be, int32_t *rgb2yuv)
824 {
825  int i;
826  const uint16_t **src = (const uint16_t **)_src;
827  uint16_t *dstU = (uint16_t *)_dstU;
828  uint16_t *dstV = (uint16_t *)_dstV;
829  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
830  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
831  int shift = bpc < 16 ? bpc : 14;
832  for (i = 0; i < width; i++) {
833  int g = rdpx(src[0] + i);
834  int b = rdpx(src[1] + i);
835  int r = rdpx(src[2] + i);
836 
837  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
838  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
839  }
840 }
841 #undef rdpx
842 
843 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
844 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
845  int w, int32_t *rgb2yuv) \
846 { \
847  planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
848 } \
849 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
850  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
851 { \
852  planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
853 } \
854 
855 #define rgb9plus_planar_funcs(nbits) \
856  rgb9plus_planar_funcs_endian(nbits, le, 0) \
857  rgb9plus_planar_funcs_endian(nbits, be, 1)
858 
864 
866 {
867  enum AVPixelFormat srcFormat = c->srcFormat;
868 
869  c->chrToYV12 = NULL;
870  switch (srcFormat) {
871  case AV_PIX_FMT_YUYV422:
872  c->chrToYV12 = yuy2ToUV_c;
873  break;
874  case AV_PIX_FMT_YVYU422:
875  c->chrToYV12 = yvy2ToUV_c;
876  break;
877  case AV_PIX_FMT_UYVY422:
878  c->chrToYV12 = uyvyToUV_c;
879  break;
880  case AV_PIX_FMT_NV12:
881  c->chrToYV12 = nv12ToUV_c;
882  break;
883  case AV_PIX_FMT_NV21:
884  c->chrToYV12 = nv21ToUV_c;
885  break;
886  case AV_PIX_FMT_RGB8:
887  case AV_PIX_FMT_BGR8:
888  case AV_PIX_FMT_PAL8:
891  c->chrToYV12 = palToUV_c;
892  break;
893  case AV_PIX_FMT_GBRP9LE:
894  c->readChrPlanar = planar_rgb9le_to_uv;
895  break;
896  case AV_PIX_FMT_GBRP10LE:
897  c->readChrPlanar = planar_rgb10le_to_uv;
898  break;
899  case AV_PIX_FMT_GBRP12LE:
900  c->readChrPlanar = planar_rgb12le_to_uv;
901  break;
902  case AV_PIX_FMT_GBRP14LE:
903  c->readChrPlanar = planar_rgb14le_to_uv;
904  break;
906  case AV_PIX_FMT_GBRP16LE:
907  c->readChrPlanar = planar_rgb16le_to_uv;
908  break;
909  case AV_PIX_FMT_GBRP9BE:
910  c->readChrPlanar = planar_rgb9be_to_uv;
911  break;
912  case AV_PIX_FMT_GBRP10BE:
913  c->readChrPlanar = planar_rgb10be_to_uv;
914  break;
915  case AV_PIX_FMT_GBRP12BE:
916  c->readChrPlanar = planar_rgb12be_to_uv;
917  break;
918  case AV_PIX_FMT_GBRP14BE:
919  c->readChrPlanar = planar_rgb14be_to_uv;
920  break;
922  case AV_PIX_FMT_GBRP16BE:
923  c->readChrPlanar = planar_rgb16be_to_uv;
924  break;
925  case AV_PIX_FMT_GBRAP:
926  case AV_PIX_FMT_GBRP:
927  c->readChrPlanar = planar_rgb_to_uv;
928  break;
929 #if HAVE_BIGENDIAN
947 
957  c->chrToYV12 = bswap16UV_c;
958  break;
959 #else
977 
987  c->chrToYV12 = bswap16UV_c;
988  break;
989 #endif
990  }
991  if (c->chrSrcHSubSample) {
992  switch (srcFormat) {
993  case AV_PIX_FMT_RGBA64BE:
994  c->chrToYV12 = rgb64BEToUV_half_c;
995  break;
996  case AV_PIX_FMT_RGBA64LE:
997  c->chrToYV12 = rgb64LEToUV_half_c;
998  break;
999  case AV_PIX_FMT_BGRA64BE:
1000  c->chrToYV12 = bgr64BEToUV_half_c;
1001  break;
1002  case AV_PIX_FMT_BGRA64LE:
1003  c->chrToYV12 = bgr64LEToUV_half_c;
1004  break;
1005  case AV_PIX_FMT_RGB48BE:
1006  c->chrToYV12 = rgb48BEToUV_half_c;
1007  break;
1008  case AV_PIX_FMT_RGB48LE:
1009  c->chrToYV12 = rgb48LEToUV_half_c;
1010  break;
1011  case AV_PIX_FMT_BGR48BE:
1012  c->chrToYV12 = bgr48BEToUV_half_c;
1013  break;
1014  case AV_PIX_FMT_BGR48LE:
1015  c->chrToYV12 = bgr48LEToUV_half_c;
1016  break;
1017  case AV_PIX_FMT_RGB32:
1018  c->chrToYV12 = bgr32ToUV_half_c;
1019  break;
1020  case AV_PIX_FMT_RGB32_1:
1021  c->chrToYV12 = bgr321ToUV_half_c;
1022  break;
1023  case AV_PIX_FMT_BGR24:
1024  c->chrToYV12 = bgr24ToUV_half_c;
1025  break;
1026  case AV_PIX_FMT_BGR565LE:
1027  c->chrToYV12 = bgr16leToUV_half_c;
1028  break;
1029  case AV_PIX_FMT_BGR565BE:
1030  c->chrToYV12 = bgr16beToUV_half_c;
1031  break;
1032  case AV_PIX_FMT_BGR555LE:
1033  c->chrToYV12 = bgr15leToUV_half_c;
1034  break;
1035  case AV_PIX_FMT_BGR555BE:
1036  c->chrToYV12 = bgr15beToUV_half_c;
1037  break;
1038  case AV_PIX_FMT_GBRAP:
1039  case AV_PIX_FMT_GBRP:
1040  c->chrToYV12 = gbr24pToUV_half_c;
1041  break;
1042  case AV_PIX_FMT_BGR444LE:
1043  c->chrToYV12 = bgr12leToUV_half_c;
1044  break;
1045  case AV_PIX_FMT_BGR444BE:
1046  c->chrToYV12 = bgr12beToUV_half_c;
1047  break;
1048  case AV_PIX_FMT_BGR32:
1049  c->chrToYV12 = rgb32ToUV_half_c;
1050  break;
1051  case AV_PIX_FMT_BGR32_1:
1052  c->chrToYV12 = rgb321ToUV_half_c;
1053  break;
1054  case AV_PIX_FMT_RGB24:
1055  c->chrToYV12 = rgb24ToUV_half_c;
1056  break;
1057  case AV_PIX_FMT_RGB565LE:
1058  c->chrToYV12 = rgb16leToUV_half_c;
1059  break;
1060  case AV_PIX_FMT_RGB565BE:
1061  c->chrToYV12 = rgb16beToUV_half_c;
1062  break;
1063  case AV_PIX_FMT_RGB555LE:
1064  c->chrToYV12 = rgb15leToUV_half_c;
1065  break;
1066  case AV_PIX_FMT_RGB555BE:
1067  c->chrToYV12 = rgb15beToUV_half_c;
1068  break;
1069  case AV_PIX_FMT_RGB444LE:
1070  c->chrToYV12 = rgb12leToUV_half_c;
1071  break;
1072  case AV_PIX_FMT_RGB444BE:
1073  c->chrToYV12 = rgb12beToUV_half_c;
1074  break;
1075  }
1076  } else {
1077  switch (srcFormat) {
1078  case AV_PIX_FMT_RGBA64BE:
1079  c->chrToYV12 = rgb64BEToUV_c;
1080  break;
1081  case AV_PIX_FMT_RGBA64LE:
1082  c->chrToYV12 = rgb64LEToUV_c;
1083  break;
1084  case AV_PIX_FMT_BGRA64BE:
1085  c->chrToYV12 = bgr64BEToUV_c;
1086  break;
1087  case AV_PIX_FMT_BGRA64LE:
1088  c->chrToYV12 = bgr64LEToUV_c;
1089  break;
1090  case AV_PIX_FMT_RGB48BE:
1091  c->chrToYV12 = rgb48BEToUV_c;
1092  break;
1093  case AV_PIX_FMT_RGB48LE:
1094  c->chrToYV12 = rgb48LEToUV_c;
1095  break;
1096  case AV_PIX_FMT_BGR48BE:
1097  c->chrToYV12 = bgr48BEToUV_c;
1098  break;
1099  case AV_PIX_FMT_BGR48LE:
1100  c->chrToYV12 = bgr48LEToUV_c;
1101  break;
1102  case AV_PIX_FMT_RGB32:
1103  c->chrToYV12 = bgr32ToUV_c;
1104  break;
1105  case AV_PIX_FMT_RGB32_1:
1106  c->chrToYV12 = bgr321ToUV_c;
1107  break;
1108  case AV_PIX_FMT_BGR24:
1109  c->chrToYV12 = bgr24ToUV_c;
1110  break;
1111  case AV_PIX_FMT_BGR565LE:
1112  c->chrToYV12 = bgr16leToUV_c;
1113  break;
1114  case AV_PIX_FMT_BGR565BE:
1115  c->chrToYV12 = bgr16beToUV_c;
1116  break;
1117  case AV_PIX_FMT_BGR555LE:
1118  c->chrToYV12 = bgr15leToUV_c;
1119  break;
1120  case AV_PIX_FMT_BGR555BE:
1121  c->chrToYV12 = bgr15beToUV_c;
1122  break;
1123  case AV_PIX_FMT_BGR444LE:
1124  c->chrToYV12 = bgr12leToUV_c;
1125  break;
1126  case AV_PIX_FMT_BGR444BE:
1127  c->chrToYV12 = bgr12beToUV_c;
1128  break;
1129  case AV_PIX_FMT_BGR32:
1130  c->chrToYV12 = rgb32ToUV_c;
1131  break;
1132  case AV_PIX_FMT_BGR32_1:
1133  c->chrToYV12 = rgb321ToUV_c;
1134  break;
1135  case AV_PIX_FMT_RGB24:
1136  c->chrToYV12 = rgb24ToUV_c;
1137  break;
1138  case AV_PIX_FMT_RGB565LE:
1139  c->chrToYV12 = rgb16leToUV_c;
1140  break;
1141  case AV_PIX_FMT_RGB565BE:
1142  c->chrToYV12 = rgb16beToUV_c;
1143  break;
1144  case AV_PIX_FMT_RGB555LE:
1145  c->chrToYV12 = rgb15leToUV_c;
1146  break;
1147  case AV_PIX_FMT_RGB555BE:
1148  c->chrToYV12 = rgb15beToUV_c;
1149  break;
1150  case AV_PIX_FMT_RGB444LE:
1151  c->chrToYV12 = rgb12leToUV_c;
1152  break;
1153  case AV_PIX_FMT_RGB444BE:
1154  c->chrToYV12 = rgb12beToUV_c;
1155  break;
1156  }
1157  }
1158 
1159  c->lumToYV12 = NULL;
1160  c->alpToYV12 = NULL;
1161  switch (srcFormat) {
1162  case AV_PIX_FMT_GBRP9LE:
1163  c->readLumPlanar = planar_rgb9le_to_y;
1164  break;
1165  case AV_PIX_FMT_GBRP10LE:
1166  c->readLumPlanar = planar_rgb10le_to_y;
1167  break;
1168  case AV_PIX_FMT_GBRP12LE:
1169  c->readLumPlanar = planar_rgb12le_to_y;
1170  break;
1171  case AV_PIX_FMT_GBRP14LE:
1172  c->readLumPlanar = planar_rgb14le_to_y;
1173  break;
1174  case AV_PIX_FMT_GBRAP16LE:
1175  case AV_PIX_FMT_GBRP16LE:
1176  c->readLumPlanar = planar_rgb16le_to_y;
1177  break;
1178  case AV_PIX_FMT_GBRP9BE:
1179  c->readLumPlanar = planar_rgb9be_to_y;
1180  break;
1181  case AV_PIX_FMT_GBRP10BE:
1182  c->readLumPlanar = planar_rgb10be_to_y;
1183  break;
1184  case AV_PIX_FMT_GBRP12BE:
1185  c->readLumPlanar = planar_rgb12be_to_y;
1186  break;
1187  case AV_PIX_FMT_GBRP14BE:
1188  c->readLumPlanar = planar_rgb14be_to_y;
1189  break;
1190  case AV_PIX_FMT_GBRAP16BE:
1191  case AV_PIX_FMT_GBRP16BE:
1192  c->readLumPlanar = planar_rgb16be_to_y;
1193  break;
1194  case AV_PIX_FMT_GBRAP:
1195  c->readAlpPlanar = planar_rgb_to_a;
1196  case AV_PIX_FMT_GBRP:
1197  c->readLumPlanar = planar_rgb_to_y;
1198  break;
1199 #if HAVE_BIGENDIAN
1200  case AV_PIX_FMT_YUV444P9LE:
1201  case AV_PIX_FMT_YUV422P9LE:
1202  case AV_PIX_FMT_YUV420P9LE:
1217 
1218  case AV_PIX_FMT_GRAY16LE:
1219  c->lumToYV12 = bswap16Y_c;
1220  break;
1230  c->lumToYV12 = bswap16Y_c;
1231  c->alpToYV12 = bswap16Y_c;
1232  break;
1233 #else
1234  case AV_PIX_FMT_YUV444P9BE:
1235  case AV_PIX_FMT_YUV422P9BE:
1236  case AV_PIX_FMT_YUV420P9BE:
1251 
1252  case AV_PIX_FMT_GRAY16BE:
1253  c->lumToYV12 = bswap16Y_c;
1254  break;
1264  c->lumToYV12 = bswap16Y_c;
1265  c->alpToYV12 = bswap16Y_c;
1266  break;
1267 #endif
1268  case AV_PIX_FMT_YA16LE:
1269  c->lumToYV12 = read_ya16le_gray_c;
1270  break;
1271  case AV_PIX_FMT_YA16BE:
1272  c->lumToYV12 = read_ya16be_gray_c;
1273  break;
1274  case AV_PIX_FMT_YUYV422:
1275  case AV_PIX_FMT_YVYU422:
1276  case AV_PIX_FMT_YA8:
1277  c->lumToYV12 = yuy2ToY_c;
1278  break;
1279  case AV_PIX_FMT_UYVY422:
1280  c->lumToYV12 = uyvyToY_c;
1281  break;
1282  case AV_PIX_FMT_BGR24:
1283  c->lumToYV12 = bgr24ToY_c;
1284  break;
1285  case AV_PIX_FMT_BGR565LE:
1286  c->lumToYV12 = bgr16leToY_c;
1287  break;
1288  case AV_PIX_FMT_BGR565BE:
1289  c->lumToYV12 = bgr16beToY_c;
1290  break;
1291  case AV_PIX_FMT_BGR555LE:
1292  c->lumToYV12 = bgr15leToY_c;
1293  break;
1294  case AV_PIX_FMT_BGR555BE:
1295  c->lumToYV12 = bgr15beToY_c;
1296  break;
1297  case AV_PIX_FMT_BGR444LE:
1298  c->lumToYV12 = bgr12leToY_c;
1299  break;
1300  case AV_PIX_FMT_BGR444BE:
1301  c->lumToYV12 = bgr12beToY_c;
1302  break;
1303  case AV_PIX_FMT_RGB24:
1304  c->lumToYV12 = rgb24ToY_c;
1305  break;
1306  case AV_PIX_FMT_RGB565LE:
1307  c->lumToYV12 = rgb16leToY_c;
1308  break;
1309  case AV_PIX_FMT_RGB565BE:
1310  c->lumToYV12 = rgb16beToY_c;
1311  break;
1312  case AV_PIX_FMT_RGB555LE:
1313  c->lumToYV12 = rgb15leToY_c;
1314  break;
1315  case AV_PIX_FMT_RGB555BE:
1316  c->lumToYV12 = rgb15beToY_c;
1317  break;
1318  case AV_PIX_FMT_RGB444LE:
1319  c->lumToYV12 = rgb12leToY_c;
1320  break;
1321  case AV_PIX_FMT_RGB444BE:
1322  c->lumToYV12 = rgb12beToY_c;
1323  break;
1324  case AV_PIX_FMT_RGB8:
1325  case AV_PIX_FMT_BGR8:
1326  case AV_PIX_FMT_PAL8:
1327  case AV_PIX_FMT_BGR4_BYTE:
1328  case AV_PIX_FMT_RGB4_BYTE:
1329  c->lumToYV12 = palToY_c;
1330  break;
1331  case AV_PIX_FMT_MONOBLACK:
1332  c->lumToYV12 = monoblack2Y_c;
1333  break;
1334  case AV_PIX_FMT_MONOWHITE:
1335  c->lumToYV12 = monowhite2Y_c;
1336  break;
1337  case AV_PIX_FMT_RGB32:
1338  c->lumToYV12 = bgr32ToY_c;
1339  break;
1340  case AV_PIX_FMT_RGB32_1:
1341  c->lumToYV12 = bgr321ToY_c;
1342  break;
1343  case AV_PIX_FMT_BGR32:
1344  c->lumToYV12 = rgb32ToY_c;
1345  break;
1346  case AV_PIX_FMT_BGR32_1:
1347  c->lumToYV12 = rgb321ToY_c;
1348  break;
1349  case AV_PIX_FMT_RGB48BE:
1350  c->lumToYV12 = rgb48BEToY_c;
1351  break;
1352  case AV_PIX_FMT_RGB48LE:
1353  c->lumToYV12 = rgb48LEToY_c;
1354  break;
1355  case AV_PIX_FMT_BGR48BE:
1356  c->lumToYV12 = bgr48BEToY_c;
1357  break;
1358  case AV_PIX_FMT_BGR48LE:
1359  c->lumToYV12 = bgr48LEToY_c;
1360  break;
1361  case AV_PIX_FMT_RGBA64BE:
1362  c->lumToYV12 = rgb64BEToY_c;
1363  break;
1364  case AV_PIX_FMT_RGBA64LE:
1365  c->lumToYV12 = rgb64LEToY_c;
1366  break;
1367  case AV_PIX_FMT_BGRA64BE:
1368  c->lumToYV12 = bgr64BEToY_c;
1369  break;
1370  case AV_PIX_FMT_BGRA64LE:
1371  c->lumToYV12 = bgr64LEToY_c;
1372  }
1373  if (c->alpPixBuf) {
1374  if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1375  if (HAVE_BIGENDIAN == !isBE(srcFormat))
1376  c->alpToYV12 = bswap16Y_c;
1377  }
1378  switch (srcFormat) {
1379  case AV_PIX_FMT_BGRA64LE:
1380  case AV_PIX_FMT_RGBA64LE: c->alpToYV12 = rgba64leToA_c; break;
1381  case AV_PIX_FMT_BGRA64BE:
1382  case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64beToA_c; break;
1383  case AV_PIX_FMT_BGRA:
1384  case AV_PIX_FMT_RGBA:
1385  c->alpToYV12 = rgbaToA_c;
1386  break;
1387  case AV_PIX_FMT_ABGR:
1388  case AV_PIX_FMT_ARGB:
1389  c->alpToYV12 = abgrToA_c;
1390  break;
1391  case AV_PIX_FMT_YA8:
1392  c->alpToYV12 = uyvyToY_c;
1393  break;
1394  case AV_PIX_FMT_YA16LE:
1395  c->alpToYV12 = read_ya16le_alpha_c;
1396  break;
1397  case AV_PIX_FMT_YA16BE:
1398  c->alpToYV12 = read_ya16be_alpha_c;
1399  break;
1400  case AV_PIX_FMT_PAL8 :
1401  c->alpToYV12 = palToA_c;
1402  break;
1403  }
1404  }
1405 }
static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
Definition: input.c:777
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:83
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:641
#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:307
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:281
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:657
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:648
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:533
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:274
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:620
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:383
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:278
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:159
#define BV_IDX
8bit gray, 8bit 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:262
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:65
#define rgb9plus_planar_funcs(nbits)
Definition: input.c:855
const char * g
Definition: vf_curves.c:108
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:162
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:279
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:176
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:117
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:261
#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:203
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
external API header
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:785
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:120
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:491
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:284
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:602
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:85
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:283
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:128
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:85
#define r_b
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:525
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:115
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:87
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12be
Definition: input.c:393
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:193
#define RU_IDX
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:288
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:204
uint8_t
#define av_cold
Definition: attributes.h:74
8 bit with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:74
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:112
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:672
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16le
Definition: input.c:385
#define b
Definition: input.c:41
bgr321
Definition: input.c:379
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:259
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:280
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:114
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:96
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:205
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:308
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:181
#define input_pixel(pos)
Definition: input.c:655
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:208
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:612
external API header
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:310
#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:453
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
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:177
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:344
16bit gray, 16bit alpha (big-endian)
Definition: pixfmt.h:234
#define S(s, c, i)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:133
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:97
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:196
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:161
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:91
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:277
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
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:444
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:131
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:277
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:197
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:94
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:95
#define isNBPS(x)
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:198
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:586
as above, but U and V bytes are swapped
Definition: pixfmt.h:92
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:578
#define RGB2YUV_SHIFT
#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:387
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:90
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:744
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:464
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
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:691
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:202
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:230
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:804
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:194
float u
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:66
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:272
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
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:555
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:119
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT static RGB2YUV_SHIFT void 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)
Definition: input.c:395
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:343
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:305
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:85
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:129
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:565
AVS_Value src
Definition: avisynth_c.h:482
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:508
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:381
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:179
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:206
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:341
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:64
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15be
Definition: input.c:389
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:309
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:286
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:207
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:209
Y , 16bpp, big-endian.
Definition: pixfmt.h:99
byte swapping routines
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:273
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:285
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:192
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:122
#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:415
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:201
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:116
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:132
static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Definition: input.c:763
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:73
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:276
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:72
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:821
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:287
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:178
static double c[64]
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:111
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:130
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:88
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:199
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16be
Definition: input.c:391
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:710
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:594
#define rdpx(src)
Definition: input.c:802
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:282
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:342
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:425
Y , 16bpp, little-endian.
Definition: pixfmt.h:100
#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr,maskg, maskb, rsh, gsh, bsh, S)
Definition: input.c:349
16bit gray, 16bit alpha (little-endian)
Definition: pixfmt.h:235
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:200
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:121
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:475
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:725
#define GU_IDX
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
#define av_always_inline
Definition: attributes.h:37
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:182
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:195
#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:631
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:289
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:271
#define rgb64funcs(pattern, BE_LE, origin)
Definition: input.c:96
static av_always_inline uint32_t rgb2yuv(const uint32_t *r2y, uint32_t c)
Definition: vf_hqx.c:58
#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:275
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:180
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:260
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:544
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:435
static int width
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:160