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  origin == AV_PIX_FMT_X2RGB10) \
249  ? AV_RN32A(&src[(i) * 4]) \
250  : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
251  : AV_RL16(&src[(i) * 2])))
252 
253 static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
254  const uint8_t *src,
255  int width,
256  enum AVPixelFormat origin,
257  int shr, int shg,
258  int shb, int shp,
259  int maskr, int maskg,
260  int maskb, int rsh,
261  int gsh, int bsh, int S,
262  int32_t *rgb2yuv)
263 {
264  const int ry = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
265  const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
266  int i;
267 
268  for (i = 0; i < width; i++) {
269  int px = input_pixel(i) >> shp;
270  int b = (px & maskb) >> shb;
271  int g = (px & maskg) >> shg;
272  int r = (px & maskr) >> shr;
273 
274  dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
275  }
276 }
277 
278 static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
279  int16_t *dstV,
280  const uint8_t *src,
281  int width,
282  enum AVPixelFormat origin,
283  int shr, int shg,
284  int shb, int shp,
285  int maskr, int maskg,
286  int maskb, int rsh,
287  int gsh, int bsh, int S,
288  int32_t *rgb2yuv)
289 {
290  const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
291  rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh);
292  const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
293  int i;
294 
295  for (i = 0; i < width; i++) {
296  int px = input_pixel(i) >> shp;
297  int b = (px & maskb) >> shb;
298  int g = (px & maskg) >> shg;
299  int r = (px & maskr) >> shr;
300 
301  dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
302  dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
303  }
304 }
305 
307  int16_t *dstV,
308  const uint8_t *src,
309  int width,
310  enum AVPixelFormat origin,
311  int shr, int shg,
312  int shb, int shp,
313  int maskr, int maskg,
314  int maskb, int rsh,
315  int gsh, int bsh, int S,
316  int32_t *rgb2yuv)
317 {
318  const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
319  rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh),
320  maskgx = ~(maskr | maskb);
321  const unsigned rnd = (256U<<(S)) + (1<<(S-6));
322  int i;
323 
324  maskr |= maskr << 1;
325  maskb |= maskb << 1;
326  maskg |= maskg << 1;
327  for (i = 0; i < width; i++) {
328  unsigned px0 = input_pixel(2 * i + 0) >> shp;
329  unsigned px1 = input_pixel(2 * i + 1) >> shp;
330  int b, r, g = (px0 & maskgx) + (px1 & maskgx);
331  int rb = px0 + px1 - g;
332 
333  b = (rb & maskb) >> shb;
334  if (shp ||
335  origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
336  origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
337  g >>= shg;
338  } else {
339  g = (g & maskg) >> shg;
340  }
341  r = (rb & maskr) >> shr;
342 
343  dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
344  dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
345  }
346 }
347 
348 #undef input_pixel
349 
350 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
351  maskg, maskb, rsh, gsh, bsh, S) \
352 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
353  int width, uint32_t *tab) \
354 { \
355  rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
356  maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
357 } \
358  \
359 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
360  const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
361  int width, uint32_t *tab) \
362 { \
363  rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
364  shr, shg, shb, shp, \
365  maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
366 } \
367  \
368 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
369  const uint8_t *unused0, const uint8_t *src, \
370  const uint8_t *dummy, \
371  int width, uint32_t *tab) \
372 { \
373  rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
374  shr, shg, shb, shp, \
375  maskr, maskg, maskb, \
376  rsh, gsh, bsh, S, tab); \
377 }
378 
379 rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
380 rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
381 rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
382 rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
383 rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
384 rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
385 rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
386 rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
387 rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
388 rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
389 rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
390 rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
391 rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
392 rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
393 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
394 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
395 rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
396 
397 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
398  const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
399  int width, uint32_t *rgb2yuv)
400 {
401  uint16_t *dstU = (uint16_t *)_dstU;
402  uint16_t *dstV = (uint16_t *)_dstV;
403  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
404  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
405 
406  int i;
407  for (i = 0; i < width; i++) {
408  unsigned int g = gsrc[2*i] + gsrc[2*i+1];
409  unsigned int b = bsrc[2*i] + bsrc[2*i+1];
410  unsigned int r = rsrc[2*i] + rsrc[2*i+1];
411 
412  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
413  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
414  }
415 }
416 
417 static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
418  const uint8_t *unused2, int width, uint32_t *unused)
419 {
420  int16_t *dst = (int16_t *)_dst;
421  const uint16_t *src = (const uint16_t *)_src;
422  int i;
423  for (i = 0; i < width; i++)
424  dst[i] = AV_RL16(src + 4 * i + 3);
425 }
426 
427 static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
428  const uint8_t *unused2, int width, uint32_t *unused)
429 {
430  int16_t *dst = (int16_t *)_dst;
431  const uint16_t *src = (const uint16_t *)_src;
432  int i;
433  for (i = 0; i < width; i++)
434  dst[i] = AV_RB16(src + 4 * i + 3);
435 }
436 
437 static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
438 {
439  int16_t *dst = (int16_t *)_dst;
440  int i;
441  for (i=0; i<width; i++) {
442  dst[i]= src[4*i]<<6 | src[4*i]>>2;
443  }
444 }
445 
446 static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
447 {
448  int16_t *dst = (int16_t *)_dst;
449  int i;
450  for (i=0; i<width; i++) {
451  dst[i]= src[4*i+3]<<6 | src[4*i+3]>>2;
452  }
453 }
454 
455 static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
456 {
457  int16_t *dst = (int16_t *)_dst;
458  int i;
459  for (i=0; i<width; i++) {
460  int d= src[i];
461 
462  dst[i]= (pal[d] >> 24)<<6 | pal[d]>>26;
463  }
464 }
465 
466 static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
467 {
468  int16_t *dst = (int16_t *)_dst;
469  int i;
470  for (i = 0; i < width; i++) {
471  int d = src[i];
472 
473  dst[i] = (pal[d] & 0xFF)<<6;
474  }
475 }
476 
477 static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
478  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
479  int width, uint32_t *pal)
480 {
481  uint16_t *dstU = (uint16_t *)_dstU;
482  int16_t *dstV = (int16_t *)_dstV;
483  int i;
484  av_assert1(src1 == src2);
485  for (i = 0; i < width; i++) {
486  int p = pal[src1[i]];
487 
488  dstU[i] = (uint8_t)(p>> 8)<<6;
489  dstV[i] = (uint8_t)(p>>16)<<6;
490  }
491 }
492 
493 static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
494 {
495  int16_t *dst = (int16_t *)_dst;
496  int i, j;
497  width = (width + 7) >> 3;
498  for (i = 0; i < width; i++) {
499  int d = ~src[i];
500  for (j = 0; j < 8; j++)
501  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
502  }
503  if(width&7){
504  int d= ~src[i];
505  for (j = 0; j < (width&7); j++)
506  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
507  }
508 }
509 
510 static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
511 {
512  int16_t *dst = (int16_t *)_dst;
513  int i, j;
514  width = (width + 7) >> 3;
515  for (i = 0; i < width; i++) {
516  int d = src[i];
517  for (j = 0; j < 8; j++)
518  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
519  }
520  if(width&7){
521  int d = src[i];
522  for (j = 0; j < (width&7); j++)
523  dst[8*i+j] = ((d>>(7-j))&1) * 16383;
524  }
525 }
526 
527 static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
528  uint32_t *unused)
529 {
530  int i;
531  for (i = 0; i < width; i++)
532  dst[i] = src[2 * i];
533 }
534 
535 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
536  const uint8_t *src2, int width, uint32_t *unused)
537 {
538  int i;
539  for (i = 0; i < width; i++) {
540  dstU[i] = src1[4 * i + 1];
541  dstV[i] = src1[4 * i + 3];
542  }
543  av_assert1(src1 == src2);
544 }
545 
546 static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
547  const uint8_t *src2, int width, uint32_t *unused)
548 {
549  int i;
550  for (i = 0; i < width; i++) {
551  dstV[i] = src1[4 * i + 1];
552  dstU[i] = src1[4 * i + 3];
553  }
554  av_assert1(src1 == src2);
555 }
556 
557 static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
558  const uint8_t *unused1, int width, uint32_t *unused2)
559 {
560  int i;
561  for (i = 0; i < width; i++) {
562  AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
563  AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
564  }
565 }
566 
567 static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
568  const uint8_t *unused1, int width, uint32_t *unused2)
569 {
570  int i;
571  for (i = 0; i < width; i++)
572  AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
573 }
574 
575 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
576  uint32_t *unused)
577 {
578  int i;
579  const uint16_t *src = (const uint16_t *)_src;
580  uint16_t *dst = (uint16_t *)_dst;
581  for (i = 0; i < width; i++)
582  dst[i] = av_bswap16(src[i]);
583 }
584 
585 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
586  const uint8_t *_src2, int width, uint32_t *unused)
587 {
588  int i;
589  const uint16_t *src1 = (const uint16_t *)_src1,
590  *src2 = (const uint16_t *)_src2;
591  uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
592  for (i = 0; i < width; i++) {
593  dstU[i] = av_bswap16(src1[i]);
594  dstV[i] = av_bswap16(src2[i]);
595  }
596 }
597 
598 static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
599  uint32_t *unused)
600 {
601  int i;
602  for (i = 0; i < width; i++)
603  AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
604 }
605 
606 static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
607  uint32_t *unused)
608 {
609  int i;
610  for (i = 0; i < width; i++)
611  AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
612 }
613 
614 static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
615  uint32_t *unused)
616 {
617  int i;
618  for (i = 0; i < width; i++)
619  AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
620 }
621 
622 static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
623  uint32_t *unused)
624 {
625  int i;
626  for (i = 0; i < width; i++)
627  AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
628 }
629 
630 static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
631  uint32_t *unused2)
632 {
633  int i;
634  for (i = 0; i < width; i++)
635  AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2));
636 }
637 
638 
639 static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
640  const uint8_t *unused1, int width, uint32_t *unused2)
641 {
642  int i;
643  for (i = 0; i < width; i++) {
644  AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4));
645  AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6));
646  }
647 }
648 
649 static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
650  uint32_t *unused2)
651 {
652  int i;
653  for (i = 0; i < width; i++)
654  AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
655 }
656 
657 /* This is almost identical to the previous, end exists only because
658  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
659 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
660  uint32_t *unused)
661 {
662  int i;
663  for (i = 0; i < width; i++)
664  dst[i] = src[2 * i + 1];
665 }
666 
667 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
668  const uint8_t *src2, int width, uint32_t *unused)
669 {
670  int i;
671  for (i = 0; i < width; i++) {
672  dstU[i] = src1[4 * i + 0];
673  dstV[i] = src1[4 * i + 2];
674  }
675  av_assert1(src1 == src2);
676 }
677 
678 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
679  const uint8_t *src, int width)
680 {
681  int i;
682  for (i = 0; i < width; i++) {
683  dst1[i] = src[2 * i + 0];
684  dst2[i] = src[2 * i + 1];
685  }
686 }
687 
688 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
689  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
690  int width, uint32_t *unused)
691 {
692  nvXXtoUV_c(dstU, dstV, src1, width);
693 }
694 
695 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
696  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
697  int width, uint32_t *unused)
698 {
699  nvXXtoUV_c(dstV, dstU, src1, width);
700 }
701 
702 static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
703  const uint8_t *unused2, int width, uint32_t *unused)
704 {
705  int i;
706  for (i = 0; i < width; i++) {
707  AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6);
708  }
709 }
710 
711 static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
712  const uint8_t *unused2, int width, uint32_t *unused)
713 {
714  int i;
715  for (i = 0; i < width; i++) {
716  AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6);
717  }
718 }
719 
720 static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV,
721  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
722  int width, uint32_t *unused)
723 {
724  int i;
725  for (i = 0; i < width; i++) {
726  AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6);
727  AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6);
728  }
729 }
730 
731 static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
732  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
733  int width, uint32_t *unused)
734 {
735  int i;
736  for (i = 0; i < width; i++) {
737  AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6);
738  AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6);
739  }
740 }
741 
742 static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
743  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
744  int width, uint32_t *unused)
745 {
746  int i;
747  for (i = 0; i < width; i++) {
748  AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
749  AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
750  }
751 }
752 
753 static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
754  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
755  int width, uint32_t *unused)
756 {
757  int i;
758  for (i = 0; i < width; i++) {
759  AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
760  AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
761  }
762 }
763 
764 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
765 
766 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
767  int width, uint32_t *rgb2yuv)
768 {
769  int16_t *dst = (int16_t *)_dst;
770  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
771  int i;
772  for (i = 0; i < width; i++) {
773  int b = src[i * 3 + 0];
774  int g = src[i * 3 + 1];
775  int r = src[i * 3 + 2];
776 
777  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
778  }
779 }
780 
781 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
782  const uint8_t *src2, int width, uint32_t *rgb2yuv)
783 {
784  int16_t *dstU = (int16_t *)_dstU;
785  int16_t *dstV = (int16_t *)_dstV;
786  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
787  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
788  int i;
789  for (i = 0; i < width; i++) {
790  int b = src1[3 * i + 0];
791  int g = src1[3 * i + 1];
792  int r = src1[3 * i + 2];
793 
794  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
795  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
796  }
797  av_assert1(src1 == src2);
798 }
799 
800 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
801  const uint8_t *src2, int width, uint32_t *rgb2yuv)
802 {
803  int16_t *dstU = (int16_t *)_dstU;
804  int16_t *dstV = (int16_t *)_dstV;
805  int i;
806  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
807  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
808  for (i = 0; i < width; i++) {
809  int b = src1[6 * i + 0] + src1[6 * i + 3];
810  int g = src1[6 * i + 1] + src1[6 * i + 4];
811  int r = src1[6 * i + 2] + src1[6 * i + 5];
812 
813  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
814  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
815  }
816  av_assert1(src1 == src2);
817 }
818 
819 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
820  uint32_t *rgb2yuv)
821 {
822  int16_t *dst = (int16_t *)_dst;
823  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
824  int i;
825  for (i = 0; i < width; i++) {
826  int r = src[i * 3 + 0];
827  int g = src[i * 3 + 1];
828  int b = src[i * 3 + 2];
829 
830  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
831  }
832 }
833 
834 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
835  const uint8_t *src2, int width, uint32_t *rgb2yuv)
836 {
837  int16_t *dstU = (int16_t *)_dstU;
838  int16_t *dstV = (int16_t *)_dstV;
839  int i;
840  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
841  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
842  av_assert1(src1 == src2);
843  for (i = 0; i < width; i++) {
844  int r = src1[3 * i + 0];
845  int g = src1[3 * i + 1];
846  int b = src1[3 * i + 2];
847 
848  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
849  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
850  }
851 }
852 
853 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
854  const uint8_t *src2, int width, uint32_t *rgb2yuv)
855 {
856  int16_t *dstU = (int16_t *)_dstU;
857  int16_t *dstV = (int16_t *)_dstV;
858  int i;
859  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
860  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
861  av_assert1(src1 == src2);
862  for (i = 0; i < width; i++) {
863  int r = src1[6 * i + 0] + src1[6 * i + 3];
864  int g = src1[6 * i + 1] + src1[6 * i + 4];
865  int b = src1[6 * i + 2] + src1[6 * i + 5];
866 
867  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
868  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
869  }
870 }
871 
872 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
873 {
874  uint16_t *dst = (uint16_t *)_dst;
875  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
876  int i;
877  for (i = 0; i < width; i++) {
878  int g = src[0][i];
879  int b = src[1][i];
880  int r = src[2][i];
881 
882  dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
883  }
884 }
885 
886 static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
887 {
888  uint16_t *dst = (uint16_t *)_dst;
889  int i;
890  for (i = 0; i < width; i++)
891  dst[i] = src[3][i] << 6;
892 }
893 
894 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
895 {
896  uint16_t *dstU = (uint16_t *)_dstU;
897  uint16_t *dstV = (uint16_t *)_dstV;
898  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
899  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
900  int i;
901  for (i = 0; i < width; i++) {
902  int g = src[0][i];
903  int b = src[1][i];
904  int r = src[2][i];
905 
906  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
907  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
908  }
909 }
910 
911 #define rdpx(src) \
912  is_be ? AV_RB16(src) : AV_RL16(src)
913 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
914  int width, int bpc, int is_be, int32_t *rgb2yuv)
915 {
916  int i;
917  const uint16_t **src = (const uint16_t **)_src;
918  uint16_t *dst = (uint16_t *)_dst;
919  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
920  int shift = bpc < 16 ? bpc : 14;
921  for (i = 0; i < width; i++) {
922  int g = rdpx(src[0] + i);
923  int b = rdpx(src[1] + i);
924  int r = rdpx(src[2] + i);
925 
926  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
927  }
928 }
929 
930 static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4],
931  int width, int bpc, int is_be, int32_t *rgb2yuv)
932 {
933  int i;
934  const uint16_t **src = (const uint16_t **)_src;
935  uint16_t *dst = (uint16_t *)_dst;
936  int shift = bpc < 16 ? bpc : 14;
937 
938  for (i = 0; i < width; i++) {
939  dst[i] = rdpx(src[3] + i) << (14 - shift);
940  }
941 }
942 
944  const uint8_t *_src[4], int width,
945  int bpc, int is_be, int32_t *rgb2yuv)
946 {
947  int i;
948  const uint16_t **src = (const uint16_t **)_src;
949  uint16_t *dstU = (uint16_t *)_dstU;
950  uint16_t *dstV = (uint16_t *)_dstV;
951  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
952  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
953  int shift = bpc < 16 ? bpc : 14;
954  for (i = 0; i < width; i++) {
955  int g = rdpx(src[0] + i);
956  int b = rdpx(src[1] + i);
957  int r = rdpx(src[2] + i);
958 
959  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
960  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
961  }
962 }
963 #undef rdpx
964 
965 #define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)))
966 
967 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)
968 {
969  int i;
970  const float **src = (const float **)_src;
971  uint16_t *dst = (uint16_t *)_dst;
972 
973  for (i = 0; i < width; i++) {
974  dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src[3] + i)));
975  }
976 }
977 
978 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)
979 {
980  int i;
981  const float **src = (const float **)_src;
982  uint16_t *dstU = (uint16_t *)_dstU;
983  uint16_t *dstV = (uint16_t *)_dstV;
984  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
985  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
986  int bpc = 16;
987  int shift = 14;
988  for (i = 0; i < width; i++) {
989  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
990  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
991  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
992 
993  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
994  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
995  }
996 }
997 
998 static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
999 {
1000  int i;
1001  const float **src = (const float **)_src;
1002  uint16_t *dst = (uint16_t *)_dst;
1003 
1004  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
1005  int bpc = 16;
1006  int shift = 14;
1007  for (i = 0; i < width; i++) {
1008  int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
1009  int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
1010  int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
1011 
1012  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
1013  }
1014 }
1015 
1016 #undef rdpx
1017 
1018 static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1019  const uint8_t *unused2, int width, uint32_t *unused)
1020 {
1021  int i;
1022  const float *src = (const float *)_src;
1023  uint16_t *dst = (uint16_t *)_dst;
1024 
1025  for (i = 0; i < width; ++i){
1026  dst[i] = av_clip_uint16(lrintf(65535.0f * src[i]));
1027  }
1028 }
1029 
1030 static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
1031  const uint8_t *unused2, int width, uint32_t *unused)
1032 {
1033  int i;
1034  const uint32_t *src = (const uint32_t *)_src;
1035  uint16_t *dst = (uint16_t *)_dst;
1036 
1037  for (i = 0; i < width; ++i){
1038  dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]))));
1039  }
1040 }
1041 
1042 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
1043 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1044  int w, int32_t *rgb2yuv) \
1045 { \
1046  planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
1047 } \
1048 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1049  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1050 { \
1051  planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
1052 } \
1053 
1054 #define rgb9plus_planar_transparency_funcs(nbits) \
1055 static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
1056  int w, int32_t *rgb2yuv) \
1057 { \
1058  planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
1059 } \
1060 static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
1061  int w, int32_t *rgb2yuv) \
1062 { \
1063  planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
1064 }
1065 
1066 #define rgb9plus_planar_funcs(nbits) \
1067  rgb9plus_planar_funcs_endian(nbits, le, 0) \
1068  rgb9plus_planar_funcs_endian(nbits, be, 1)
1069 
1075 
1079 
1080 #define rgbf32_planar_funcs_endian(endian_name, endian) \
1081 static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1082  int w, int32_t *rgb2yuv) \
1083 { \
1084  planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
1085 } \
1086 static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1087  const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1088 { \
1089  planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
1090 } \
1091 static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
1092  int w, int32_t *rgb2yuv) \
1093 { \
1094  planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1095 }
1096 
1099 
1101 {
1102  enum AVPixelFormat srcFormat = c->srcFormat;
1103 
1104  c->chrToYV12 = NULL;
1105  switch (srcFormat) {
1106  case AV_PIX_FMT_YUYV422:
1107  c->chrToYV12 = yuy2ToUV_c;
1108  break;
1109  case AV_PIX_FMT_YVYU422:
1110  c->chrToYV12 = yvy2ToUV_c;
1111  break;
1112  case AV_PIX_FMT_UYVY422:
1113  c->chrToYV12 = uyvyToUV_c;
1114  break;
1115  case AV_PIX_FMT_NV12:
1116  case AV_PIX_FMT_NV24:
1117  c->chrToYV12 = nv12ToUV_c;
1118  break;
1119  case AV_PIX_FMT_NV21:
1120  case AV_PIX_FMT_NV42:
1121  c->chrToYV12 = nv21ToUV_c;
1122  break;
1123  case AV_PIX_FMT_RGB8:
1124  case AV_PIX_FMT_BGR8:
1125  case AV_PIX_FMT_PAL8:
1126  case AV_PIX_FMT_BGR4_BYTE:
1127  case AV_PIX_FMT_RGB4_BYTE:
1128  c->chrToYV12 = palToUV_c;
1129  break;
1130  case AV_PIX_FMT_GBRP9LE:
1131  c->readChrPlanar = planar_rgb9le_to_uv;
1132  break;
1133  case AV_PIX_FMT_GBRAP10LE:
1134  case AV_PIX_FMT_GBRP10LE:
1135  c->readChrPlanar = planar_rgb10le_to_uv;
1136  break;
1137  case AV_PIX_FMT_GBRAP12LE:
1138  case AV_PIX_FMT_GBRP12LE:
1139  c->readChrPlanar = planar_rgb12le_to_uv;
1140  break;
1141  case AV_PIX_FMT_GBRP14LE:
1142  c->readChrPlanar = planar_rgb14le_to_uv;
1143  break;
1144  case AV_PIX_FMT_GBRAP16LE:
1145  case AV_PIX_FMT_GBRP16LE:
1146  c->readChrPlanar = planar_rgb16le_to_uv;
1147  break;
1148  case AV_PIX_FMT_GBRAPF32LE:
1149  case AV_PIX_FMT_GBRPF32LE:
1150  c->readChrPlanar = planar_rgbf32le_to_uv;
1151  break;
1152  case AV_PIX_FMT_GBRP9BE:
1153  c->readChrPlanar = planar_rgb9be_to_uv;
1154  break;
1155  case AV_PIX_FMT_GBRAP10BE:
1156  case AV_PIX_FMT_GBRP10BE:
1157  c->readChrPlanar = planar_rgb10be_to_uv;
1158  break;
1159  case AV_PIX_FMT_GBRAP12BE:
1160  case AV_PIX_FMT_GBRP12BE:
1161  c->readChrPlanar = planar_rgb12be_to_uv;
1162  break;
1163  case AV_PIX_FMT_GBRP14BE:
1164  c->readChrPlanar = planar_rgb14be_to_uv;
1165  break;
1166  case AV_PIX_FMT_GBRAP16BE:
1167  case AV_PIX_FMT_GBRP16BE:
1168  c->readChrPlanar = planar_rgb16be_to_uv;
1169  break;
1170  case AV_PIX_FMT_GBRAPF32BE:
1171  case AV_PIX_FMT_GBRPF32BE:
1172  c->readChrPlanar = planar_rgbf32be_to_uv;
1173  break;
1174  case AV_PIX_FMT_GBRAP:
1175  case AV_PIX_FMT_GBRP:
1176  c->readChrPlanar = planar_rgb_to_uv;
1177  break;
1178 #if HAVE_BIGENDIAN
1179  case AV_PIX_FMT_YUV420P9LE:
1180  case AV_PIX_FMT_YUV422P9LE:
1181  case AV_PIX_FMT_YUV444P9LE:
1196 
1208  c->chrToYV12 = bswap16UV_c;
1209  break;
1210 #else
1211  case AV_PIX_FMT_YUV420P9BE:
1212  case AV_PIX_FMT_YUV422P9BE:
1213  case AV_PIX_FMT_YUV444P9BE:
1228 
1240  c->chrToYV12 = bswap16UV_c;
1241  break;
1242 #endif
1243  case AV_PIX_FMT_AYUV64LE:
1244  c->chrToYV12 = read_ayuv64le_UV_c;
1245  break;
1246  case AV_PIX_FMT_P010LE:
1247  c->chrToYV12 = p010LEToUV_c;
1248  break;
1249  case AV_PIX_FMT_P010BE:
1250  c->chrToYV12 = p010BEToUV_c;
1251  break;
1252  case AV_PIX_FMT_P016LE:
1253  c->chrToYV12 = p016LEToUV_c;
1254  break;
1255  case AV_PIX_FMT_P016BE:
1256  c->chrToYV12 = p016BEToUV_c;
1257  break;
1258  case AV_PIX_FMT_Y210LE:
1259  c->chrToYV12 = y210le_UV_c;
1260  break;
1261  }
1262  if (c->chrSrcHSubSample) {
1263  switch (srcFormat) {
1264  case AV_PIX_FMT_RGBA64BE:
1265  c->chrToYV12 = rgb64BEToUV_half_c;
1266  break;
1267  case AV_PIX_FMT_RGBA64LE:
1268  c->chrToYV12 = rgb64LEToUV_half_c;
1269  break;
1270  case AV_PIX_FMT_BGRA64BE:
1271  c->chrToYV12 = bgr64BEToUV_half_c;
1272  break;
1273  case AV_PIX_FMT_BGRA64LE:
1274  c->chrToYV12 = bgr64LEToUV_half_c;
1275  break;
1276  case AV_PIX_FMT_RGB48BE:
1277  c->chrToYV12 = rgb48BEToUV_half_c;
1278  break;
1279  case AV_PIX_FMT_RGB48LE:
1280  c->chrToYV12 = rgb48LEToUV_half_c;
1281  break;
1282  case AV_PIX_FMT_BGR48BE:
1283  c->chrToYV12 = bgr48BEToUV_half_c;
1284  break;
1285  case AV_PIX_FMT_BGR48LE:
1286  c->chrToYV12 = bgr48LEToUV_half_c;
1287  break;
1288  case AV_PIX_FMT_RGB32:
1289  c->chrToYV12 = bgr32ToUV_half_c;
1290  break;
1291  case AV_PIX_FMT_RGB32_1:
1292  c->chrToYV12 = bgr321ToUV_half_c;
1293  break;
1294  case AV_PIX_FMT_BGR24:
1295  c->chrToYV12 = bgr24ToUV_half_c;
1296  break;
1297  case AV_PIX_FMT_BGR565LE:
1298  c->chrToYV12 = bgr16leToUV_half_c;
1299  break;
1300  case AV_PIX_FMT_BGR565BE:
1301  c->chrToYV12 = bgr16beToUV_half_c;
1302  break;
1303  case AV_PIX_FMT_BGR555LE:
1304  c->chrToYV12 = bgr15leToUV_half_c;
1305  break;
1306  case AV_PIX_FMT_BGR555BE:
1307  c->chrToYV12 = bgr15beToUV_half_c;
1308  break;
1309  case AV_PIX_FMT_GBRAP:
1310  case AV_PIX_FMT_GBRP:
1311  c->chrToYV12 = gbr24pToUV_half_c;
1312  break;
1313  case AV_PIX_FMT_BGR444LE:
1314  c->chrToYV12 = bgr12leToUV_half_c;
1315  break;
1316  case AV_PIX_FMT_BGR444BE:
1317  c->chrToYV12 = bgr12beToUV_half_c;
1318  break;
1319  case AV_PIX_FMT_BGR32:
1320  c->chrToYV12 = rgb32ToUV_half_c;
1321  break;
1322  case AV_PIX_FMT_BGR32_1:
1323  c->chrToYV12 = rgb321ToUV_half_c;
1324  break;
1325  case AV_PIX_FMT_RGB24:
1326  c->chrToYV12 = rgb24ToUV_half_c;
1327  break;
1328  case AV_PIX_FMT_RGB565LE:
1329  c->chrToYV12 = rgb16leToUV_half_c;
1330  break;
1331  case AV_PIX_FMT_RGB565BE:
1332  c->chrToYV12 = rgb16beToUV_half_c;
1333  break;
1334  case AV_PIX_FMT_RGB555LE:
1335  c->chrToYV12 = rgb15leToUV_half_c;
1336  break;
1337  case AV_PIX_FMT_RGB555BE:
1338  c->chrToYV12 = rgb15beToUV_half_c;
1339  break;
1340  case AV_PIX_FMT_RGB444LE:
1341  c->chrToYV12 = rgb12leToUV_half_c;
1342  break;
1343  case AV_PIX_FMT_RGB444BE:
1344  c->chrToYV12 = rgb12beToUV_half_c;
1345  break;
1346  case AV_PIX_FMT_X2RGB10LE:
1347  c->chrToYV12 = rgb30leToUV_half_c;
1348  break;
1349  }
1350  } else {
1351  switch (srcFormat) {
1352  case AV_PIX_FMT_RGBA64BE:
1353  c->chrToYV12 = rgb64BEToUV_c;
1354  break;
1355  case AV_PIX_FMT_RGBA64LE:
1356  c->chrToYV12 = rgb64LEToUV_c;
1357  break;
1358  case AV_PIX_FMT_BGRA64BE:
1359  c->chrToYV12 = bgr64BEToUV_c;
1360  break;
1361  case AV_PIX_FMT_BGRA64LE:
1362  c->chrToYV12 = bgr64LEToUV_c;
1363  break;
1364  case AV_PIX_FMT_RGB48BE:
1365  c->chrToYV12 = rgb48BEToUV_c;
1366  break;
1367  case AV_PIX_FMT_RGB48LE:
1368  c->chrToYV12 = rgb48LEToUV_c;
1369  break;
1370  case AV_PIX_FMT_BGR48BE:
1371  c->chrToYV12 = bgr48BEToUV_c;
1372  break;
1373  case AV_PIX_FMT_BGR48LE:
1374  c->chrToYV12 = bgr48LEToUV_c;
1375  break;
1376  case AV_PIX_FMT_RGB32:
1377  c->chrToYV12 = bgr32ToUV_c;
1378  break;
1379  case AV_PIX_FMT_RGB32_1:
1380  c->chrToYV12 = bgr321ToUV_c;
1381  break;
1382  case AV_PIX_FMT_BGR24:
1383  c->chrToYV12 = bgr24ToUV_c;
1384  break;
1385  case AV_PIX_FMT_BGR565LE:
1386  c->chrToYV12 = bgr16leToUV_c;
1387  break;
1388  case AV_PIX_FMT_BGR565BE:
1389  c->chrToYV12 = bgr16beToUV_c;
1390  break;
1391  case AV_PIX_FMT_BGR555LE:
1392  c->chrToYV12 = bgr15leToUV_c;
1393  break;
1394  case AV_PIX_FMT_BGR555BE:
1395  c->chrToYV12 = bgr15beToUV_c;
1396  break;
1397  case AV_PIX_FMT_BGR444LE:
1398  c->chrToYV12 = bgr12leToUV_c;
1399  break;
1400  case AV_PIX_FMT_BGR444BE:
1401  c->chrToYV12 = bgr12beToUV_c;
1402  break;
1403  case AV_PIX_FMT_BGR32:
1404  c->chrToYV12 = rgb32ToUV_c;
1405  break;
1406  case AV_PIX_FMT_BGR32_1:
1407  c->chrToYV12 = rgb321ToUV_c;
1408  break;
1409  case AV_PIX_FMT_RGB24:
1410  c->chrToYV12 = rgb24ToUV_c;
1411  break;
1412  case AV_PIX_FMT_RGB565LE:
1413  c->chrToYV12 = rgb16leToUV_c;
1414  break;
1415  case AV_PIX_FMT_RGB565BE:
1416  c->chrToYV12 = rgb16beToUV_c;
1417  break;
1418  case AV_PIX_FMT_RGB555LE:
1419  c->chrToYV12 = rgb15leToUV_c;
1420  break;
1421  case AV_PIX_FMT_RGB555BE:
1422  c->chrToYV12 = rgb15beToUV_c;
1423  break;
1424  case AV_PIX_FMT_RGB444LE:
1425  c->chrToYV12 = rgb12leToUV_c;
1426  break;
1427  case AV_PIX_FMT_RGB444BE:
1428  c->chrToYV12 = rgb12beToUV_c;
1429  break;
1430  case AV_PIX_FMT_X2RGB10LE:
1431  c->chrToYV12 = rgb30leToUV_c;
1432  break;
1433  }
1434  }
1435 
1436  c->lumToYV12 = NULL;
1437  c->alpToYV12 = NULL;
1438  switch (srcFormat) {
1439  case AV_PIX_FMT_GBRP9LE:
1440  c->readLumPlanar = planar_rgb9le_to_y;
1441  break;
1442  case AV_PIX_FMT_GBRAP10LE:
1443  c->readAlpPlanar = planar_rgb10le_to_a;
1444  case AV_PIX_FMT_GBRP10LE:
1445  c->readLumPlanar = planar_rgb10le_to_y;
1446  break;
1447  case AV_PIX_FMT_GBRAP12LE:
1448  c->readAlpPlanar = planar_rgb12le_to_a;
1449  case AV_PIX_FMT_GBRP12LE:
1450  c->readLumPlanar = planar_rgb12le_to_y;
1451  break;
1452  case AV_PIX_FMT_GBRP14LE:
1453  c->readLumPlanar = planar_rgb14le_to_y;
1454  break;
1455  case AV_PIX_FMT_GBRAP16LE:
1456  c->readAlpPlanar = planar_rgb16le_to_a;
1457  case AV_PIX_FMT_GBRP16LE:
1458  c->readLumPlanar = planar_rgb16le_to_y;
1459  break;
1460  case AV_PIX_FMT_GBRAPF32LE:
1461  c->readAlpPlanar = planar_rgbf32le_to_a;
1462  case AV_PIX_FMT_GBRPF32LE:
1463  c->readLumPlanar = planar_rgbf32le_to_y;
1464  break;
1465  case AV_PIX_FMT_GBRP9BE:
1466  c->readLumPlanar = planar_rgb9be_to_y;
1467  break;
1468  case AV_PIX_FMT_GBRAP10BE:
1469  c->readAlpPlanar = planar_rgb10be_to_a;
1470  case AV_PIX_FMT_GBRP10BE:
1471  c->readLumPlanar = planar_rgb10be_to_y;
1472  break;
1473  case AV_PIX_FMT_GBRAP12BE:
1474  c->readAlpPlanar = planar_rgb12be_to_a;
1475  case AV_PIX_FMT_GBRP12BE:
1476  c->readLumPlanar = planar_rgb12be_to_y;
1477  break;
1478  case AV_PIX_FMT_GBRP14BE:
1479  c->readLumPlanar = planar_rgb14be_to_y;
1480  break;
1481  case AV_PIX_FMT_GBRAP16BE:
1482  c->readAlpPlanar = planar_rgb16be_to_a;
1483  case AV_PIX_FMT_GBRP16BE:
1484  c->readLumPlanar = planar_rgb16be_to_y;
1485  break;
1486  case AV_PIX_FMT_GBRAPF32BE:
1487  c->readAlpPlanar = planar_rgbf32be_to_a;
1488  case AV_PIX_FMT_GBRPF32BE:
1489  c->readLumPlanar = planar_rgbf32be_to_y;
1490  break;
1491  case AV_PIX_FMT_GBRAP:
1492  c->readAlpPlanar = planar_rgb_to_a;
1493  case AV_PIX_FMT_GBRP:
1494  c->readLumPlanar = planar_rgb_to_y;
1495  break;
1496 #if HAVE_BIGENDIAN
1497  case AV_PIX_FMT_YUV420P9LE:
1498  case AV_PIX_FMT_YUV422P9LE:
1499  case AV_PIX_FMT_YUV444P9LE:
1514 
1515  case AV_PIX_FMT_GRAY9LE:
1516  case AV_PIX_FMT_GRAY10LE:
1517  case AV_PIX_FMT_GRAY12LE:
1518  case AV_PIX_FMT_GRAY14LE:
1519  case AV_PIX_FMT_GRAY16LE:
1520 
1521  case AV_PIX_FMT_P016LE:
1522  c->lumToYV12 = bswap16Y_c;
1523  break;
1535  c->lumToYV12 = bswap16Y_c;
1536  c->alpToYV12 = bswap16Y_c;
1537  break;
1538 #else
1539  case AV_PIX_FMT_YUV420P9BE:
1540  case AV_PIX_FMT_YUV422P9BE:
1541  case AV_PIX_FMT_YUV444P9BE:
1556 
1557  case AV_PIX_FMT_GRAY9BE:
1558  case AV_PIX_FMT_GRAY10BE:
1559  case AV_PIX_FMT_GRAY12BE:
1560  case AV_PIX_FMT_GRAY14BE:
1561  case AV_PIX_FMT_GRAY16BE:
1562 
1563  case AV_PIX_FMT_P016BE:
1564  c->lumToYV12 = bswap16Y_c;
1565  break;
1577  c->lumToYV12 = bswap16Y_c;
1578  c->alpToYV12 = bswap16Y_c;
1579  break;
1580 #endif
1581  case AV_PIX_FMT_YA16LE:
1582  c->lumToYV12 = read_ya16le_gray_c;
1583  break;
1584  case AV_PIX_FMT_YA16BE:
1585  c->lumToYV12 = read_ya16be_gray_c;
1586  break;
1587  case AV_PIX_FMT_AYUV64LE:
1588  c->lumToYV12 = read_ayuv64le_Y_c;
1589  break;
1590  case AV_PIX_FMT_YUYV422:
1591  case AV_PIX_FMT_YVYU422:
1592  case AV_PIX_FMT_YA8:
1593  c->lumToYV12 = yuy2ToY_c;
1594  break;
1595  case AV_PIX_FMT_UYVY422:
1596  c->lumToYV12 = uyvyToY_c;
1597  break;
1598  case AV_PIX_FMT_BGR24:
1599  c->lumToYV12 = bgr24ToY_c;
1600  break;
1601  case AV_PIX_FMT_BGR565LE:
1602  c->lumToYV12 = bgr16leToY_c;
1603  break;
1604  case AV_PIX_FMT_BGR565BE:
1605  c->lumToYV12 = bgr16beToY_c;
1606  break;
1607  case AV_PIX_FMT_BGR555LE:
1608  c->lumToYV12 = bgr15leToY_c;
1609  break;
1610  case AV_PIX_FMT_BGR555BE:
1611  c->lumToYV12 = bgr15beToY_c;
1612  break;
1613  case AV_PIX_FMT_BGR444LE:
1614  c->lumToYV12 = bgr12leToY_c;
1615  break;
1616  case AV_PIX_FMT_BGR444BE:
1617  c->lumToYV12 = bgr12beToY_c;
1618  break;
1619  case AV_PIX_FMT_RGB24:
1620  c->lumToYV12 = rgb24ToY_c;
1621  break;
1622  case AV_PIX_FMT_RGB565LE:
1623  c->lumToYV12 = rgb16leToY_c;
1624  break;
1625  case AV_PIX_FMT_RGB565BE:
1626  c->lumToYV12 = rgb16beToY_c;
1627  break;
1628  case AV_PIX_FMT_RGB555LE:
1629  c->lumToYV12 = rgb15leToY_c;
1630  break;
1631  case AV_PIX_FMT_RGB555BE:
1632  c->lumToYV12 = rgb15beToY_c;
1633  break;
1634  case AV_PIX_FMT_RGB444LE:
1635  c->lumToYV12 = rgb12leToY_c;
1636  break;
1637  case AV_PIX_FMT_RGB444BE:
1638  c->lumToYV12 = rgb12beToY_c;
1639  break;
1640  case AV_PIX_FMT_RGB8:
1641  case AV_PIX_FMT_BGR8:
1642  case AV_PIX_FMT_PAL8:
1643  case AV_PIX_FMT_BGR4_BYTE:
1644  case AV_PIX_FMT_RGB4_BYTE:
1645  c->lumToYV12 = palToY_c;
1646  break;
1647  case AV_PIX_FMT_MONOBLACK:
1648  c->lumToYV12 = monoblack2Y_c;
1649  break;
1650  case AV_PIX_FMT_MONOWHITE:
1651  c->lumToYV12 = monowhite2Y_c;
1652  break;
1653  case AV_PIX_FMT_RGB32:
1654  c->lumToYV12 = bgr32ToY_c;
1655  break;
1656  case AV_PIX_FMT_RGB32_1:
1657  c->lumToYV12 = bgr321ToY_c;
1658  break;
1659  case AV_PIX_FMT_BGR32:
1660  c->lumToYV12 = rgb32ToY_c;
1661  break;
1662  case AV_PIX_FMT_BGR32_1:
1663  c->lumToYV12 = rgb321ToY_c;
1664  break;
1665  case AV_PIX_FMT_RGB48BE:
1666  c->lumToYV12 = rgb48BEToY_c;
1667  break;
1668  case AV_PIX_FMT_RGB48LE:
1669  c->lumToYV12 = rgb48LEToY_c;
1670  break;
1671  case AV_PIX_FMT_BGR48BE:
1672  c->lumToYV12 = bgr48BEToY_c;
1673  break;
1674  case AV_PIX_FMT_BGR48LE:
1675  c->lumToYV12 = bgr48LEToY_c;
1676  break;
1677  case AV_PIX_FMT_RGBA64BE:
1678  c->lumToYV12 = rgb64BEToY_c;
1679  break;
1680  case AV_PIX_FMT_RGBA64LE:
1681  c->lumToYV12 = rgb64LEToY_c;
1682  break;
1683  case AV_PIX_FMT_BGRA64BE:
1684  c->lumToYV12 = bgr64BEToY_c;
1685  break;
1686  case AV_PIX_FMT_BGRA64LE:
1687  c->lumToYV12 = bgr64LEToY_c;
1688  break;
1689  case AV_PIX_FMT_P010LE:
1690  c->lumToYV12 = p010LEToY_c;
1691  break;
1692  case AV_PIX_FMT_P010BE:
1693  c->lumToYV12 = p010BEToY_c;
1694  break;
1695  case AV_PIX_FMT_GRAYF32LE:
1696 #if HAVE_BIGENDIAN
1697  c->lumToYV12 = grayf32ToY16_bswap_c;
1698 #else
1699  c->lumToYV12 = grayf32ToY16_c;
1700 #endif
1701  break;
1702  case AV_PIX_FMT_GRAYF32BE:
1703 #if HAVE_BIGENDIAN
1704  c->lumToYV12 = grayf32ToY16_c;
1705 #else
1706  c->lumToYV12 = grayf32ToY16_bswap_c;
1707 #endif
1708  break;
1709  case AV_PIX_FMT_Y210LE:
1710  c->lumToYV12 = y210le_Y_c;
1711  break;
1712  case AV_PIX_FMT_X2RGB10LE:
1713  c->lumToYV12 =rgb30leToY_c;
1714  break;
1715  }
1716  if (c->needAlpha) {
1717  if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1718  if (HAVE_BIGENDIAN == !isBE(srcFormat) && !c->readAlpPlanar)
1719  c->alpToYV12 = bswap16Y_c;
1720  }
1721  switch (srcFormat) {
1722  case AV_PIX_FMT_BGRA64LE:
1723  case AV_PIX_FMT_RGBA64LE: c->alpToYV12 = rgba64leToA_c; break;
1724  case AV_PIX_FMT_BGRA64BE:
1725  case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64beToA_c; break;
1726  case AV_PIX_FMT_BGRA:
1727  case AV_PIX_FMT_RGBA:
1728  c->alpToYV12 = rgbaToA_c;
1729  break;
1730  case AV_PIX_FMT_ABGR:
1731  case AV_PIX_FMT_ARGB:
1732  c->alpToYV12 = abgrToA_c;
1733  break;
1734  case AV_PIX_FMT_YA8:
1735  c->alpToYV12 = uyvyToY_c;
1736  break;
1737  case AV_PIX_FMT_YA16LE:
1738  c->alpToYV12 = read_ya16le_alpha_c;
1739  break;
1740  case AV_PIX_FMT_YA16BE:
1741  c->alpToYV12 = read_ya16be_alpha_c;
1742  break;
1743  case AV_PIX_FMT_AYUV64LE:
1744  c->alpToYV12 = read_ayuv64le_A_c;
1745  break;
1746  case AV_PIX_FMT_PAL8 :
1747  c->alpToYV12 = palToA_c;
1748  break;
1749  }
1750  }
1751 }
static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
Definition: input.c:886
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:688
#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:766
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:695
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:535
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:978
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:753
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:667
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:384
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:1066
const char * g
Definition: vf_curves.c:115
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:162
int32_t bv
Definition: input.c:404
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:567
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:894
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:630
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:493
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:622
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:87
int32_t bu
Definition: input.c:403
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:1030
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:527
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:106
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:85
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t * bsrc
Definition: input.c:397
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12be
Definition: input.c:394
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:179
#define RU_IDX
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:216
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:190
static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:702
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian ...
Definition: pixfmt.h:344
uint8_t
#define av_cold
Definition: attributes.h:88
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:103
static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *rgb2yuv)
Definition: input.c:781
#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:386
bgr321
Definition: input.c:380
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:731
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:764
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:659
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:720
#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:455
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t * gsrc
Definition: input.c:397
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:157
#define U(x)
Definition: vp56_arith.h:37
#define src
Definition: vp8dsp.c:254
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:170
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:165
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:375
16 bits gray, 16 bits alpha (big-endian)
Definition: pixfmt.h:212
#define S(s, c, i)
like NV12, with 16bpp per component, big-endian
Definition: pixfmt.h:301
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:136
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:182
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:161
int32_t gu
Definition: input.c:403
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:930
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:446
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:278
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:606
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:598
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:388
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:853
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:466
static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, const uint16_t *src1, const uint16_t *src2, int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
Definition: input.c:168
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t * rsrc
Definition: input.c:397
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:742
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:800
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:913
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:1018
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:575
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:167
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:148
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:110
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:361
int32_t gv
Definition: input.c:404
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t int width
Definition: input.c:397
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:288
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:374
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU, int16_t *dstV, const uint8_t *src, int width, enum AVPixelFormat origin, int shr, int shg, int shb, int shp, int maskr, int maskg, int maskb, int rsh, int gsh, int bsh, int S, int32_t *rgb2yuv)
Definition: input.c:306
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:585
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:510
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:382
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:172
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:192
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:372
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now.Options-------Then comes the options array.This is what will define the user accessible options.For example
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15be
Definition: input.c:390
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:639
byte swapping routines
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:244
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian ...
Definition: pixfmt.h:345
Y , 9bpp, big-endian.
Definition: pixfmt.h:315
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:256
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:178
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:113
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t * _dstV
Definition: input.c:397
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:417
uint16_t * dstV
Definition: input.c:402
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:872
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:649
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:943
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:967
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:557
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:392
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:819
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:614
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:998
#define rdpx(src)
Definition: input.c:965
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:253
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:373
static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:427
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:350
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:711
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:477
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:834
#define GU_IDX
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t int uint32_t * rgb2yuv
Definition: input.c:400
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
#define av_always_inline
Definition: attributes.h:45
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:175
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:141
static av_always_inline void rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
Definition: input.c:44
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:181
int32_t ru
Definition: input.c:403
#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:678
int32_t rv
Definition: input.c:404
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:1054
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:242
#define rgb64funcs(pattern, BE_LE, origin)
Definition: input.c:96
#define BU_IDX
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:164
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:246
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
int i
Definition: input.c:406
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:546
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:437
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