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  : (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] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
290  rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << 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] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
318  rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << 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 | src[4*i]>>2;
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 | src[4*i+3]>>2;
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 | pal[d]>>26;
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 y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
556  const uint8_t *unused1, int width, uint32_t *unused2)
557 {
558  int i;
559  for (i = 0; i < width; i++) {
560  AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
561  AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
562  }
563 }
564 
565 static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
566  const uint8_t *unused1, int width, uint32_t *unused2)
567 {
568  int i;
569  for (i = 0; i < width; i++)
570  AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
571 }
572 
573 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
574  uint32_t *unused)
575 {
576  int i;
577  const uint16_t *src = (const uint16_t *)_src;
578  uint16_t *dst = (uint16_t *)_dst;
579  for (i = 0; i < width; i++)
580  dst[i] = av_bswap16(src[i]);
581 }
582 
583 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
584  const uint8_t *_src2, int width, uint32_t *unused)
585 {
586  int i;
587  const uint16_t *src1 = (const uint16_t *)_src1,
588  *src2 = (const uint16_t *)_src2;
589  uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
590  for (i = 0; i < width; i++) {
591  dstU[i] = av_bswap16(src1[i]);
592  dstV[i] = av_bswap16(src2[i]);
593  }
594 }
595 
596 static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
597  uint32_t *unused)
598 {
599  int i;
600  for (i = 0; i < width; i++)
601  AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
602 }
603 
604 static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
605  uint32_t *unused)
606 {
607  int i;
608  for (i = 0; i < width; i++)
609  AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
610 }
611 
612 static void read_ya16be_gray_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  AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
618 }
619 
620 static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
621  uint32_t *unused)
622 {
623  int i;
624  for (i = 0; i < width; i++)
625  AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
626 }
627 
628 static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
629  uint32_t *unused2)
630 {
631  int i;
632  for (i = 0; i < width; i++)
633  AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2));
634 }
635 
636 
637 static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
638  const uint8_t *unused1, int width, uint32_t *unused2)
639 {
640  int i;
641  for (i = 0; i < width; i++) {
642  AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4));
643  AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6));
644  }
645 }
646 
647 static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
648  uint32_t *unused2)
649 {
650  int i;
651  for (i = 0; i < width; i++)
652  AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
653 }
654 
655 /* This is almost identical to the previous, end exists only because
656  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
657 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
658  uint32_t *unused)
659 {
660  int i;
661  for (i = 0; i < width; i++)
662  dst[i] = src[2 * i + 1];
663 }
664 
665 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
666  const uint8_t *src2, int width, uint32_t *unused)
667 {
668  int i;
669  for (i = 0; i < width; i++) {
670  dstU[i] = src1[4 * i + 0];
671  dstV[i] = src1[4 * i + 2];
672  }
673  av_assert1(src1 == src2);
674 }
675 
676 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
677  const uint8_t *src, int width)
678 {
679  int i;
680  for (i = 0; i < width; i++) {
681  dst1[i] = src[2 * i + 0];
682  dst2[i] = src[2 * i + 1];
683  }
684 }
685 
686 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
687  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
688  int width, uint32_t *unused)
689 {
690  nvXXtoUV_c(dstU, dstV, src1, width);
691 }
692 
693 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
694  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
695  int width, uint32_t *unused)
696 {
697  nvXXtoUV_c(dstV, dstU, src1, width);
698 }
699 
700 static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
701  const uint8_t *unused2, int width, uint32_t *unused)
702 {
703  int i;
704  for (i = 0; i < width; i++) {
705  AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6);
706  }
707 }
708 
709 static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
710  const uint8_t *unused2, int width, uint32_t *unused)
711 {
712  int i;
713  for (i = 0; i < width; i++) {
714  AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6);
715  }
716 }
717 
718 static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV,
719  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
720  int width, uint32_t *unused)
721 {
722  int i;
723  for (i = 0; i < width; i++) {
724  AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6);
725  AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6);
726  }
727 }
728 
729 static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
730  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
731  int width, uint32_t *unused)
732 {
733  int i;
734  for (i = 0; i < width; i++) {
735  AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6);
736  AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6);
737  }
738 }
739 
740 static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
741  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
742  int width, uint32_t *unused)
743 {
744  int i;
745  for (i = 0; i < width; i++) {
746  AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
747  AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
748  }
749 }
750 
751 static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
752  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
753  int width, uint32_t *unused)
754 {
755  int i;
756  for (i = 0; i < width; i++) {
757  AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
758  AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
759  }
760 }
761 
762 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
763 
764 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
765  int width, uint32_t *rgb2yuv)
766 {
767  int16_t *dst = (int16_t *)_dst;
768  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
769  int i;
770  for (i = 0; i < width; i++) {
771  int b = src[i * 3 + 0];
772  int g = src[i * 3 + 1];
773  int r = src[i * 3 + 2];
774 
775  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
776  }
777 }
778 
779 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
780  const uint8_t *src2, int width, uint32_t *rgb2yuv)
781 {
782  int16_t *dstU = (int16_t *)_dstU;
783  int16_t *dstV = (int16_t *)_dstV;
784  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
785  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
786  int i;
787  for (i = 0; i < width; i++) {
788  int b = src1[3 * i + 0];
789  int g = src1[3 * i + 1];
790  int r = src1[3 * i + 2];
791 
792  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
793  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
794  }
795  av_assert1(src1 == src2);
796 }
797 
798 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
799  const uint8_t *src2, int width, uint32_t *rgb2yuv)
800 {
801  int16_t *dstU = (int16_t *)_dstU;
802  int16_t *dstV = (int16_t *)_dstV;
803  int i;
804  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
805  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
806  for (i = 0; i < width; i++) {
807  int b = src1[6 * i + 0] + src1[6 * i + 3];
808  int g = src1[6 * i + 1] + src1[6 * i + 4];
809  int r = src1[6 * i + 2] + src1[6 * i + 5];
810 
811  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
812  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
813  }
814  av_assert1(src1 == src2);
815 }
816 
817 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
818  uint32_t *rgb2yuv)
819 {
820  int16_t *dst = (int16_t *)_dst;
821  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
822  int i;
823  for (i = 0; i < width; i++) {
824  int r = src[i * 3 + 0];
825  int g = src[i * 3 + 1];
826  int b = src[i * 3 + 2];
827 
828  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
829  }
830 }
831 
832 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
833  const uint8_t *src2, int width, uint32_t *rgb2yuv)
834 {
835  int16_t *dstU = (int16_t *)_dstU;
836  int16_t *dstV = (int16_t *)_dstV;
837  int i;
838  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
839  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
840  av_assert1(src1 == src2);
841  for (i = 0; i < width; i++) {
842  int r = src1[3 * i + 0];
843  int g = src1[3 * i + 1];
844  int b = src1[3 * i + 2];
845 
846  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
847  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
848  }
849 }
850 
851 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
852  const uint8_t *src2, int width, uint32_t *rgb2yuv)
853 {
854  int16_t *dstU = (int16_t *)_dstU;
855  int16_t *dstV = (int16_t *)_dstV;
856  int i;
857  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
858  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
859  av_assert1(src1 == src2);
860  for (i = 0; i < width; i++) {
861  int r = src1[6 * i + 0] + src1[6 * i + 3];
862  int g = src1[6 * i + 1] + src1[6 * i + 4];
863  int b = src1[6 * i + 2] + src1[6 * i + 5];
864 
865  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
866  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
867  }
868 }
869 
870 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
871 {
872  uint16_t *dst = (uint16_t *)_dst;
873  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
874  int i;
875  for (i = 0; i < width; i++) {
876  int g = src[0][i];
877  int b = src[1][i];
878  int r = src[2][i];
879 
880  dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
881  }
882 }
883 
884 static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
885 {
886  uint16_t *dst = (uint16_t *)_dst;
887  int i;
888  for (i = 0; i < width; i++)
889  dst[i] = src[3][i] << 6;
890 }
891 
892 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
893 {
894  uint16_t *dstU = (uint16_t *)_dstU;
895  uint16_t *dstV = (uint16_t *)_dstV;
896  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
897  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
898  int i;
899  for (i = 0; i < width; i++) {
900  int g = src[0][i];
901  int b = src[1][i];
902  int r = src[2][i];
903 
904  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
905  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
906  }
907 }
908 
909 #define rdpx(src) \
910  is_be ? AV_RB16(src) : AV_RL16(src)
911 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
912  int width, int bpc, int is_be, int32_t *rgb2yuv)
913 {
914  int i;
915  const uint16_t **src = (const uint16_t **)_src;
916  uint16_t *dst = (uint16_t *)_dst;
917  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
918  int shift = bpc < 16 ? bpc : 14;
919  for (i = 0; i < width; i++) {
920  int g = rdpx(src[0] + i);
921  int b = rdpx(src[1] + i);
922  int r = rdpx(src[2] + i);
923 
924  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
925  }
926 }
927 
928 static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4],
929  int width, int bpc, int is_be, int32_t *rgb2yuv)
930 {
931  int i;
932  const uint16_t **src = (const uint16_t **)_src;
933  uint16_t *dst = (uint16_t *)_dst;
934  int shift = bpc < 16 ? bpc : 14;
935 
936  for (i = 0; i < width; i++) {
937  dst[i] = rdpx(src[3] + i) << (14 - shift);
938  }
939 }
940 
942  const uint8_t *_src[4], int width,
943  int bpc, int is_be, int32_t *rgb2yuv)
944 {
945  int i;
946  const uint16_t **src = (const uint16_t **)_src;
947  uint16_t *dstU = (uint16_t *)_dstU;
948  uint16_t *dstV = (uint16_t *)_dstV;
949  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
950  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
951  int shift = bpc < 16 ? bpc : 14;
952  for (i = 0; i < width; i++) {
953  int g = rdpx(src[0] + i);
954  int b = rdpx(src[1] + i);
955  int r = rdpx(src[2] + i);
956 
957  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
958  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
959  }
960 }
961 #undef rdpx
962 
963 #define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)))
964 
965 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)
966 {
967  int i;
968  const float **src = (const float **)_src;
969  uint16_t *dst = (uint16_t *)_dst;
970 
971  for (i = 0; i < width; i++) {
972  dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src[3] + i)));
973  }
974 }
975 
976 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)
977 {
978  int i;
979  const float **src = (const float **)_src;
980  uint16_t *dstU = (uint16_t *)_dstU;
981  uint16_t *dstV = (uint16_t *)_dstV;
982  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
983  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
984  int bpc = 16;
985  int shift = 14;
986  for (i = 0; i < width; i++) {
987  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
988  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
989  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
990 
991  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
992  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
993  }
994 }
995 
996 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)
997 {
998  int i;
999  const float **src = (const float **)_src;
1000  uint16_t *dst = (uint16_t *)_dst;
1001 
1002  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
1003  int bpc = 16;
1004  int shift = 14;
1005  for (i = 0; i < width; i++) {
1006  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
1007  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
1008  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
1009 
1010  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
1011  }
1012 }
1013 
1014 #undef rdpx
1015 
1016 static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1017  const uint8_t *unused2, int width, uint32_t *unused)
1018 {
1019  int i;
1020  const float *src = (const float *)_src;
1021  uint16_t *dst = (uint16_t *)_dst;
1022 
1023  for (i = 0; i < width; ++i){
1024  dst[i] = av_clip_uint16(lrintf(65535.0f * src[i]));
1025  }
1026 }
1027 
1028 static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1029  const uint8_t *unused2, int width, uint32_t *unused)
1030 {
1031  int i;
1032  const uint32_t *src = (const uint32_t *)_src;
1033  uint16_t *dst = (uint16_t *)_dst;
1034 
1035  for (i = 0; i < width; ++i){
1036  dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]))));
1037  }
1038 }
1039 
1040 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
1041 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1042  int w, int32_t *rgb2yuv) \
1043 { \
1044  planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
1045 } \
1046 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1047  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1048 { \
1049  planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
1050 } \
1051 
1052 #define rgb9plus_planar_transparency_funcs(nbits) \
1053 static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
1054  int w, int32_t *rgb2yuv) \
1055 { \
1056  planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
1057 } \
1058 static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
1059  int w, int32_t *rgb2yuv) \
1060 { \
1061  planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
1062 }
1063 
1064 #define rgb9plus_planar_funcs(nbits) \
1065  rgb9plus_planar_funcs_endian(nbits, le, 0) \
1066  rgb9plus_planar_funcs_endian(nbits, be, 1)
1067 
1073 
1077 
1078 #define rgbf32_planar_funcs_endian(endian_name, endian) \
1079 static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1080  int w, int32_t *rgb2yuv) \
1081 { \
1082  planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
1083 } \
1084 static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1085  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1086 { \
1087  planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
1088 } \
1089 static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
1090  int w, int32_t *rgb2yuv) \
1091 { \
1092  planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1093 }
1094 
1097 
1099 {
1100  enum AVPixelFormat srcFormat = c->srcFormat;
1101 
1102  c->chrToYV12 = NULL;
1103  switch (srcFormat) {
1104  case AV_PIX_FMT_YUYV422:
1105  c->chrToYV12 = yuy2ToUV_c;
1106  break;
1107  case AV_PIX_FMT_YVYU422:
1108  c->chrToYV12 = yvy2ToUV_c;
1109  break;
1110  case AV_PIX_FMT_UYVY422:
1111  c->chrToYV12 = uyvyToUV_c;
1112  break;
1113  case AV_PIX_FMT_NV12:
1114  case AV_PIX_FMT_NV24:
1115  c->chrToYV12 = nv12ToUV_c;
1116  break;
1117  case AV_PIX_FMT_NV21:
1118  case AV_PIX_FMT_NV42:
1119  c->chrToYV12 = nv21ToUV_c;
1120  break;
1121  case AV_PIX_FMT_RGB8:
1122  case AV_PIX_FMT_BGR8:
1123  case AV_PIX_FMT_PAL8:
1124  case AV_PIX_FMT_BGR4_BYTE:
1125  case AV_PIX_FMT_RGB4_BYTE:
1126  c->chrToYV12 = palToUV_c;
1127  break;
1128  case AV_PIX_FMT_GBRP9LE:
1129  c->readChrPlanar = planar_rgb9le_to_uv;
1130  break;
1131  case AV_PIX_FMT_GBRAP10LE:
1132  case AV_PIX_FMT_GBRP10LE:
1133  c->readChrPlanar = planar_rgb10le_to_uv;
1134  break;
1135  case AV_PIX_FMT_GBRAP12LE:
1136  case AV_PIX_FMT_GBRP12LE:
1137  c->readChrPlanar = planar_rgb12le_to_uv;
1138  break;
1139  case AV_PIX_FMT_GBRP14LE:
1140  c->readChrPlanar = planar_rgb14le_to_uv;
1141  break;
1142  case AV_PIX_FMT_GBRAP16LE:
1143  case AV_PIX_FMT_GBRP16LE:
1144  c->readChrPlanar = planar_rgb16le_to_uv;
1145  break;
1146  case AV_PIX_FMT_GBRAPF32LE:
1147  case AV_PIX_FMT_GBRPF32LE:
1148  c->readChrPlanar = planar_rgbf32le_to_uv;
1149  break;
1150  case AV_PIX_FMT_GBRP9BE:
1151  c->readChrPlanar = planar_rgb9be_to_uv;
1152  break;
1153  case AV_PIX_FMT_GBRAP10BE:
1154  case AV_PIX_FMT_GBRP10BE:
1155  c->readChrPlanar = planar_rgb10be_to_uv;
1156  break;
1157  case AV_PIX_FMT_GBRAP12BE:
1158  case AV_PIX_FMT_GBRP12BE:
1159  c->readChrPlanar = planar_rgb12be_to_uv;
1160  break;
1161  case AV_PIX_FMT_GBRP14BE:
1162  c->readChrPlanar = planar_rgb14be_to_uv;
1163  break;
1164  case AV_PIX_FMT_GBRAP16BE:
1165  case AV_PIX_FMT_GBRP16BE:
1166  c->readChrPlanar = planar_rgb16be_to_uv;
1167  break;
1168  case AV_PIX_FMT_GBRAPF32BE:
1169  case AV_PIX_FMT_GBRPF32BE:
1170  c->readChrPlanar = planar_rgbf32be_to_uv;
1171  break;
1172  case AV_PIX_FMT_GBRAP:
1173  case AV_PIX_FMT_GBRP:
1174  c->readChrPlanar = planar_rgb_to_uv;
1175  break;
1176 #if HAVE_BIGENDIAN
1177  case AV_PIX_FMT_YUV420P9LE:
1178  case AV_PIX_FMT_YUV422P9LE:
1179  case AV_PIX_FMT_YUV444P9LE:
1194 
1206  c->chrToYV12 = bswap16UV_c;
1207  break;
1208 #else
1209  case AV_PIX_FMT_YUV420P9BE:
1210  case AV_PIX_FMT_YUV422P9BE:
1211  case AV_PIX_FMT_YUV444P9BE:
1226 
1238  c->chrToYV12 = bswap16UV_c;
1239  break;
1240 #endif
1241  case AV_PIX_FMT_AYUV64LE:
1242  c->chrToYV12 = read_ayuv64le_UV_c;
1243  break;
1244  case AV_PIX_FMT_P010LE:
1245  c->chrToYV12 = p010LEToUV_c;
1246  break;
1247  case AV_PIX_FMT_P010BE:
1248  c->chrToYV12 = p010BEToUV_c;
1249  break;
1250  case AV_PIX_FMT_P016LE:
1251  c->chrToYV12 = p016LEToUV_c;
1252  break;
1253  case AV_PIX_FMT_P016BE:
1254  c->chrToYV12 = p016BEToUV_c;
1255  break;
1256  case AV_PIX_FMT_Y210LE:
1257  c->chrToYV12 = y210le_UV_c;
1258  break;
1259  }
1260  if (c->chrSrcHSubSample) {
1261  switch (srcFormat) {
1262  case AV_PIX_FMT_RGBA64BE:
1263  c->chrToYV12 = rgb64BEToUV_half_c;
1264  break;
1265  case AV_PIX_FMT_RGBA64LE:
1266  c->chrToYV12 = rgb64LEToUV_half_c;
1267  break;
1268  case AV_PIX_FMT_BGRA64BE:
1269  c->chrToYV12 = bgr64BEToUV_half_c;
1270  break;
1271  case AV_PIX_FMT_BGRA64LE:
1272  c->chrToYV12 = bgr64LEToUV_half_c;
1273  break;
1274  case AV_PIX_FMT_RGB48BE:
1275  c->chrToYV12 = rgb48BEToUV_half_c;
1276  break;
1277  case AV_PIX_FMT_RGB48LE:
1278  c->chrToYV12 = rgb48LEToUV_half_c;
1279  break;
1280  case AV_PIX_FMT_BGR48BE:
1281  c->chrToYV12 = bgr48BEToUV_half_c;
1282  break;
1283  case AV_PIX_FMT_BGR48LE:
1284  c->chrToYV12 = bgr48LEToUV_half_c;
1285  break;
1286  case AV_PIX_FMT_RGB32:
1287  c->chrToYV12 = bgr32ToUV_half_c;
1288  break;
1289  case AV_PIX_FMT_RGB32_1:
1290  c->chrToYV12 = bgr321ToUV_half_c;
1291  break;
1292  case AV_PIX_FMT_BGR24:
1293  c->chrToYV12 = bgr24ToUV_half_c;
1294  break;
1295  case AV_PIX_FMT_BGR565LE:
1296  c->chrToYV12 = bgr16leToUV_half_c;
1297  break;
1298  case AV_PIX_FMT_BGR565BE:
1299  c->chrToYV12 = bgr16beToUV_half_c;
1300  break;
1301  case AV_PIX_FMT_BGR555LE:
1302  c->chrToYV12 = bgr15leToUV_half_c;
1303  break;
1304  case AV_PIX_FMT_BGR555BE:
1305  c->chrToYV12 = bgr15beToUV_half_c;
1306  break;
1307  case AV_PIX_FMT_GBRAP:
1308  case AV_PIX_FMT_GBRP:
1309  c->chrToYV12 = gbr24pToUV_half_c;
1310  break;
1311  case AV_PIX_FMT_BGR444LE:
1312  c->chrToYV12 = bgr12leToUV_half_c;
1313  break;
1314  case AV_PIX_FMT_BGR444BE:
1315  c->chrToYV12 = bgr12beToUV_half_c;
1316  break;
1317  case AV_PIX_FMT_BGR32:
1318  c->chrToYV12 = rgb32ToUV_half_c;
1319  break;
1320  case AV_PIX_FMT_BGR32_1:
1321  c->chrToYV12 = rgb321ToUV_half_c;
1322  break;
1323  case AV_PIX_FMT_RGB24:
1324  c->chrToYV12 = rgb24ToUV_half_c;
1325  break;
1326  case AV_PIX_FMT_RGB565LE:
1327  c->chrToYV12 = rgb16leToUV_half_c;
1328  break;
1329  case AV_PIX_FMT_RGB565BE:
1330  c->chrToYV12 = rgb16beToUV_half_c;
1331  break;
1332  case AV_PIX_FMT_RGB555LE:
1333  c->chrToYV12 = rgb15leToUV_half_c;
1334  break;
1335  case AV_PIX_FMT_RGB555BE:
1336  c->chrToYV12 = rgb15beToUV_half_c;
1337  break;
1338  case AV_PIX_FMT_RGB444LE:
1339  c->chrToYV12 = rgb12leToUV_half_c;
1340  break;
1341  case AV_PIX_FMT_RGB444BE:
1342  c->chrToYV12 = rgb12beToUV_half_c;
1343  break;
1344  }
1345  } else {
1346  switch (srcFormat) {
1347  case AV_PIX_FMT_RGBA64BE:
1348  c->chrToYV12 = rgb64BEToUV_c;
1349  break;
1350  case AV_PIX_FMT_RGBA64LE:
1351  c->chrToYV12 = rgb64LEToUV_c;
1352  break;
1353  case AV_PIX_FMT_BGRA64BE:
1354  c->chrToYV12 = bgr64BEToUV_c;
1355  break;
1356  case AV_PIX_FMT_BGRA64LE:
1357  c->chrToYV12 = bgr64LEToUV_c;
1358  break;
1359  case AV_PIX_FMT_RGB48BE:
1360  c->chrToYV12 = rgb48BEToUV_c;
1361  break;
1362  case AV_PIX_FMT_RGB48LE:
1363  c->chrToYV12 = rgb48LEToUV_c;
1364  break;
1365  case AV_PIX_FMT_BGR48BE:
1366  c->chrToYV12 = bgr48BEToUV_c;
1367  break;
1368  case AV_PIX_FMT_BGR48LE:
1369  c->chrToYV12 = bgr48LEToUV_c;
1370  break;
1371  case AV_PIX_FMT_RGB32:
1372  c->chrToYV12 = bgr32ToUV_c;
1373  break;
1374  case AV_PIX_FMT_RGB32_1:
1375  c->chrToYV12 = bgr321ToUV_c;
1376  break;
1377  case AV_PIX_FMT_BGR24:
1378  c->chrToYV12 = bgr24ToUV_c;
1379  break;
1380  case AV_PIX_FMT_BGR565LE:
1381  c->chrToYV12 = bgr16leToUV_c;
1382  break;
1383  case AV_PIX_FMT_BGR565BE:
1384  c->chrToYV12 = bgr16beToUV_c;
1385  break;
1386  case AV_PIX_FMT_BGR555LE:
1387  c->chrToYV12 = bgr15leToUV_c;
1388  break;
1389  case AV_PIX_FMT_BGR555BE:
1390  c->chrToYV12 = bgr15beToUV_c;
1391  break;
1392  case AV_PIX_FMT_BGR444LE:
1393  c->chrToYV12 = bgr12leToUV_c;
1394  break;
1395  case AV_PIX_FMT_BGR444BE:
1396  c->chrToYV12 = bgr12beToUV_c;
1397  break;
1398  case AV_PIX_FMT_BGR32:
1399  c->chrToYV12 = rgb32ToUV_c;
1400  break;
1401  case AV_PIX_FMT_BGR32_1:
1402  c->chrToYV12 = rgb321ToUV_c;
1403  break;
1404  case AV_PIX_FMT_RGB24:
1405  c->chrToYV12 = rgb24ToUV_c;
1406  break;
1407  case AV_PIX_FMT_RGB565LE:
1408  c->chrToYV12 = rgb16leToUV_c;
1409  break;
1410  case AV_PIX_FMT_RGB565BE:
1411  c->chrToYV12 = rgb16beToUV_c;
1412  break;
1413  case AV_PIX_FMT_RGB555LE:
1414  c->chrToYV12 = rgb15leToUV_c;
1415  break;
1416  case AV_PIX_FMT_RGB555BE:
1417  c->chrToYV12 = rgb15beToUV_c;
1418  break;
1419  case AV_PIX_FMT_RGB444LE:
1420  c->chrToYV12 = rgb12leToUV_c;
1421  break;
1422  case AV_PIX_FMT_RGB444BE:
1423  c->chrToYV12 = rgb12beToUV_c;
1424  break;
1425  }
1426  }
1427 
1428  c->lumToYV12 = NULL;
1429  c->alpToYV12 = NULL;
1430  switch (srcFormat) {
1431  case AV_PIX_FMT_GBRP9LE:
1432  c->readLumPlanar = planar_rgb9le_to_y;
1433  break;
1434  case AV_PIX_FMT_GBRAP10LE:
1435  c->readAlpPlanar = planar_rgb10le_to_a;
1436  case AV_PIX_FMT_GBRP10LE:
1437  c->readLumPlanar = planar_rgb10le_to_y;
1438  break;
1439  case AV_PIX_FMT_GBRAP12LE:
1440  c->readAlpPlanar = planar_rgb12le_to_a;
1441  case AV_PIX_FMT_GBRP12LE:
1442  c->readLumPlanar = planar_rgb12le_to_y;
1443  break;
1444  case AV_PIX_FMT_GBRP14LE:
1445  c->readLumPlanar = planar_rgb14le_to_y;
1446  break;
1447  case AV_PIX_FMT_GBRAP16LE:
1448  c->readAlpPlanar = planar_rgb16le_to_a;
1449  case AV_PIX_FMT_GBRP16LE:
1450  c->readLumPlanar = planar_rgb16le_to_y;
1451  break;
1452  case AV_PIX_FMT_GBRAPF32LE:
1453  c->readAlpPlanar = planar_rgbf32le_to_a;
1454  case AV_PIX_FMT_GBRPF32LE:
1455  c->readLumPlanar = planar_rgbf32le_to_y;
1456  break;
1457  case AV_PIX_FMT_GBRP9BE:
1458  c->readLumPlanar = planar_rgb9be_to_y;
1459  break;
1460  case AV_PIX_FMT_GBRAP10BE:
1461  c->readAlpPlanar = planar_rgb10be_to_a;
1462  case AV_PIX_FMT_GBRP10BE:
1463  c->readLumPlanar = planar_rgb10be_to_y;
1464  break;
1465  case AV_PIX_FMT_GBRAP12BE:
1466  c->readAlpPlanar = planar_rgb12be_to_a;
1467  case AV_PIX_FMT_GBRP12BE:
1468  c->readLumPlanar = planar_rgb12be_to_y;
1469  break;
1470  case AV_PIX_FMT_GBRP14BE:
1471  c->readLumPlanar = planar_rgb14be_to_y;
1472  break;
1473  case AV_PIX_FMT_GBRAP16BE:
1474  c->readAlpPlanar = planar_rgb16be_to_a;
1475  case AV_PIX_FMT_GBRP16BE:
1476  c->readLumPlanar = planar_rgb16be_to_y;
1477  break;
1478  case AV_PIX_FMT_GBRAPF32BE:
1479  c->readAlpPlanar = planar_rgbf32be_to_a;
1480  case AV_PIX_FMT_GBRPF32BE:
1481  c->readLumPlanar = planar_rgbf32be_to_y;
1482  break;
1483  case AV_PIX_FMT_GBRAP:
1484  c->readAlpPlanar = planar_rgb_to_a;
1485  case AV_PIX_FMT_GBRP:
1486  c->readLumPlanar = planar_rgb_to_y;
1487  break;
1488 #if HAVE_BIGENDIAN
1489  case AV_PIX_FMT_YUV420P9LE:
1490  case AV_PIX_FMT_YUV422P9LE:
1491  case AV_PIX_FMT_YUV444P9LE:
1506 
1507  case AV_PIX_FMT_GRAY9LE:
1508  case AV_PIX_FMT_GRAY10LE:
1509  case AV_PIX_FMT_GRAY12LE:
1510  case AV_PIX_FMT_GRAY14LE:
1511  case AV_PIX_FMT_GRAY16LE:
1512 
1513  case AV_PIX_FMT_P016LE:
1514  c->lumToYV12 = bswap16Y_c;
1515  break;
1527  c->lumToYV12 = bswap16Y_c;
1528  c->alpToYV12 = bswap16Y_c;
1529  break;
1530 #else
1531  case AV_PIX_FMT_YUV420P9BE:
1532  case AV_PIX_FMT_YUV422P9BE:
1533  case AV_PIX_FMT_YUV444P9BE:
1548 
1549  case AV_PIX_FMT_GRAY9BE:
1550  case AV_PIX_FMT_GRAY10BE:
1551  case AV_PIX_FMT_GRAY12BE:
1552  case AV_PIX_FMT_GRAY14BE:
1553  case AV_PIX_FMT_GRAY16BE:
1554 
1555  case AV_PIX_FMT_P016BE:
1556  c->lumToYV12 = bswap16Y_c;
1557  break;
1569  c->lumToYV12 = bswap16Y_c;
1570  c->alpToYV12 = bswap16Y_c;
1571  break;
1572 #endif
1573  case AV_PIX_FMT_YA16LE:
1574  c->lumToYV12 = read_ya16le_gray_c;
1575  break;
1576  case AV_PIX_FMT_YA16BE:
1577  c->lumToYV12 = read_ya16be_gray_c;
1578  break;
1579  case AV_PIX_FMT_AYUV64LE:
1580  c->lumToYV12 = read_ayuv64le_Y_c;
1581  break;
1582  case AV_PIX_FMT_YUYV422:
1583  case AV_PIX_FMT_YVYU422:
1584  case AV_PIX_FMT_YA8:
1585  c->lumToYV12 = yuy2ToY_c;
1586  break;
1587  case AV_PIX_FMT_UYVY422:
1588  c->lumToYV12 = uyvyToY_c;
1589  break;
1590  case AV_PIX_FMT_BGR24:
1591  c->lumToYV12 = bgr24ToY_c;
1592  break;
1593  case AV_PIX_FMT_BGR565LE:
1594  c->lumToYV12 = bgr16leToY_c;
1595  break;
1596  case AV_PIX_FMT_BGR565BE:
1597  c->lumToYV12 = bgr16beToY_c;
1598  break;
1599  case AV_PIX_FMT_BGR555LE:
1600  c->lumToYV12 = bgr15leToY_c;
1601  break;
1602  case AV_PIX_FMT_BGR555BE:
1603  c->lumToYV12 = bgr15beToY_c;
1604  break;
1605  case AV_PIX_FMT_BGR444LE:
1606  c->lumToYV12 = bgr12leToY_c;
1607  break;
1608  case AV_PIX_FMT_BGR444BE:
1609  c->lumToYV12 = bgr12beToY_c;
1610  break;
1611  case AV_PIX_FMT_RGB24:
1612  c->lumToYV12 = rgb24ToY_c;
1613  break;
1614  case AV_PIX_FMT_RGB565LE:
1615  c->lumToYV12 = rgb16leToY_c;
1616  break;
1617  case AV_PIX_FMT_RGB565BE:
1618  c->lumToYV12 = rgb16beToY_c;
1619  break;
1620  case AV_PIX_FMT_RGB555LE:
1621  c->lumToYV12 = rgb15leToY_c;
1622  break;
1623  case AV_PIX_FMT_RGB555BE:
1624  c->lumToYV12 = rgb15beToY_c;
1625  break;
1626  case AV_PIX_FMT_RGB444LE:
1627  c->lumToYV12 = rgb12leToY_c;
1628  break;
1629  case AV_PIX_FMT_RGB444BE:
1630  c->lumToYV12 = rgb12beToY_c;
1631  break;
1632  case AV_PIX_FMT_RGB8:
1633  case AV_PIX_FMT_BGR8:
1634  case AV_PIX_FMT_PAL8:
1635  case AV_PIX_FMT_BGR4_BYTE:
1636  case AV_PIX_FMT_RGB4_BYTE:
1637  c->lumToYV12 = palToY_c;
1638  break;
1639  case AV_PIX_FMT_MONOBLACK:
1640  c->lumToYV12 = monoblack2Y_c;
1641  break;
1642  case AV_PIX_FMT_MONOWHITE:
1643  c->lumToYV12 = monowhite2Y_c;
1644  break;
1645  case AV_PIX_FMT_RGB32:
1646  c->lumToYV12 = bgr32ToY_c;
1647  break;
1648  case AV_PIX_FMT_RGB32_1:
1649  c->lumToYV12 = bgr321ToY_c;
1650  break;
1651  case AV_PIX_FMT_BGR32:
1652  c->lumToYV12 = rgb32ToY_c;
1653  break;
1654  case AV_PIX_FMT_BGR32_1:
1655  c->lumToYV12 = rgb321ToY_c;
1656  break;
1657  case AV_PIX_FMT_RGB48BE:
1658  c->lumToYV12 = rgb48BEToY_c;
1659  break;
1660  case AV_PIX_FMT_RGB48LE:
1661  c->lumToYV12 = rgb48LEToY_c;
1662  break;
1663  case AV_PIX_FMT_BGR48BE:
1664  c->lumToYV12 = bgr48BEToY_c;
1665  break;
1666  case AV_PIX_FMT_BGR48LE:
1667  c->lumToYV12 = bgr48LEToY_c;
1668  break;
1669  case AV_PIX_FMT_RGBA64BE:
1670  c->lumToYV12 = rgb64BEToY_c;
1671  break;
1672  case AV_PIX_FMT_RGBA64LE:
1673  c->lumToYV12 = rgb64LEToY_c;
1674  break;
1675  case AV_PIX_FMT_BGRA64BE:
1676  c->lumToYV12 = bgr64BEToY_c;
1677  break;
1678  case AV_PIX_FMT_BGRA64LE:
1679  c->lumToYV12 = bgr64LEToY_c;
1680  break;
1681  case AV_PIX_FMT_P010LE:
1682  c->lumToYV12 = p010LEToY_c;
1683  break;
1684  case AV_PIX_FMT_P010BE:
1685  c->lumToYV12 = p010BEToY_c;
1686  break;
1687  case AV_PIX_FMT_GRAYF32LE:
1688 #if HAVE_BIGENDIAN
1689  c->lumToYV12 = grayf32ToY16_bswap_c;
1690 #else
1691  c->lumToYV12 = grayf32ToY16_c;
1692 #endif
1693  break;
1694  case AV_PIX_FMT_GRAYF32BE:
1695 #if HAVE_BIGENDIAN
1696  c->lumToYV12 = grayf32ToY16_c;
1697 #else
1698  c->lumToYV12 = grayf32ToY16_bswap_c;
1699 #endif
1700  break;
1701  case AV_PIX_FMT_Y210LE:
1702  c->lumToYV12 = y210le_Y_c;
1703  break;
1704  }
1705  if (c->needAlpha) {
1706  if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1707  if (HAVE_BIGENDIAN == !isBE(srcFormat) && !c->readAlpPlanar)
1708  c->alpToYV12 = bswap16Y_c;
1709  }
1710  switch (srcFormat) {
1711  case AV_PIX_FMT_BGRA64LE:
1712  case AV_PIX_FMT_RGBA64LE: c->alpToYV12 = rgba64leToA_c; break;
1713  case AV_PIX_FMT_BGRA64BE:
1714  case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64beToA_c; break;
1715  case AV_PIX_FMT_BGRA:
1716  case AV_PIX_FMT_RGBA:
1717  c->alpToYV12 = rgbaToA_c;
1718  break;
1719  case AV_PIX_FMT_ABGR:
1720  case AV_PIX_FMT_ARGB:
1721  c->alpToYV12 = abgrToA_c;
1722  break;
1723  case AV_PIX_FMT_YA8:
1724  c->alpToYV12 = uyvyToY_c;
1725  break;
1726  case AV_PIX_FMT_YA16LE:
1727  c->alpToYV12 = read_ya16le_alpha_c;
1728  break;
1729  case AV_PIX_FMT_YA16BE:
1730  c->alpToYV12 = read_ya16be_alpha_c;
1731  break;
1732  case AV_PIX_FMT_AYUV64LE:
1733  c->alpToYV12 = read_ayuv64le_A_c;
1734  break;
1735  case AV_PIX_FMT_PAL8 :
1736  c->alpToYV12 = palToA_c;
1737  break;
1738  }
1739  }
1740 }
static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
Definition: input.c:884
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:686
#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:764
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:693
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: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:976
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:751
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:665
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: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:1064
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
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:565
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:892
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:628
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: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:620
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
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:1028
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: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 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: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 const char rgb2yuv[]
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:700
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:82
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:779
#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:385
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: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:729
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:762
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:657
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:718
#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
#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 i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:373
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
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:928
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:444
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:277
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:604
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:596
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:387
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:851
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
#define width
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 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:740
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:798
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:911
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:1016
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:573
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
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:288
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:372
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: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:583
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: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:370
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:389
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:637
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
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:415
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:870
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:647
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:941
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:965
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:555
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: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:817
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:612
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:996
#define rdpx(src)
Definition: input.c:963
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:371
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 , 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:349
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:709
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: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:832
#define GU_IDX
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
#define av_always_inline
Definition: attributes.h:39
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
#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:676
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:1052
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)
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:544
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:435
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