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 <assert.h>
22 #include <math.h>
23 #include <stdint.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "libavutil/avutil.h"
28 #include "libavutil/bswap.h"
29 #include "libavutil/cpu.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/mathematics.h"
32 #include "libavutil/pixdesc.h"
33 #include "libavutil/avassert.h"
34 #include "config.h"
35 #include "rgb2rgb.h"
36 #include "swscale.h"
37 #include "swscale_internal.h"
38 
39 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
40 
41 #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? b_r : r_b)
42 #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? r_b : b_r)
43 
44 static av_always_inline void
45 rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
46  enum AVPixelFormat origin, int32_t *rgb2yuv)
47 {
48  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
49  int i;
50  for (i = 0; i < width; i++) {
51  unsigned int r_b = input_pixel(&src[i*4+0]);
52  unsigned int g = input_pixel(&src[i*4+1]);
53  unsigned int b_r = input_pixel(&src[i*4+2]);
54 
55  dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
56  }
57 }
58 
59 static av_always_inline void
60 rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
61  const uint16_t *src1, const uint16_t *src2,
62  int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
63 {
64  int i;
65  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
66  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
67  av_assert1(src1==src2);
68  for (i = 0; i < width; i++) {
69  int r_b = input_pixel(&src1[i*4+0]);
70  int g = input_pixel(&src1[i*4+1]);
71  int b_r = input_pixel(&src1[i*4+2]);
72 
73  dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
74  dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
75  }
76 }
77 
78 static av_always_inline void
79 rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
80  const uint16_t *src1, const uint16_t *src2,
81  int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
82 {
83  int i;
84  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
85  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
86  av_assert1(src1==src2);
87  for (i = 0; i < width; i++) {
88  int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
89  int g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
90  int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
91 
92  dstU[i]= (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
93  dstV[i]= (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
94  }
95 }
96 
97 #define rgb64funcs(pattern, BE_LE, origin) \
98 static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
99  int width, uint32_t *rgb2yuv) \
100 { \
101  const uint16_t *src = (const uint16_t *) _src; \
102  uint16_t *dst = (uint16_t *) _dst; \
103  rgb64ToY_c_template(dst, src, width, origin, rgb2yuv); \
104 } \
105  \
106 static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
107  const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
108  int width, uint32_t *rgb2yuv) \
109 { \
110  const uint16_t *src1 = (const uint16_t *) _src1, \
111  *src2 = (const uint16_t *) _src2; \
112  uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
113  rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
114 } \
115  \
116 static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
117  const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
118  int width, uint32_t *rgb2yuv) \
119 { \
120  const uint16_t *src1 = (const uint16_t *) _src1, \
121  *src2 = (const uint16_t *) _src2; \
122  uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
123  rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
124 }
125 
128 
129 static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
130  const uint16_t *src, int width,
131  enum AVPixelFormat origin,
132  int32_t *rgb2yuv)
133 {
134  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
135  int i;
136  for (i = 0; i < width; i++) {
137  unsigned int r_b = input_pixel(&src[i * 3 + 0]);
138  unsigned int g = input_pixel(&src[i * 3 + 1]);
139  unsigned int b_r = input_pixel(&src[i * 3 + 2]);
140 
141  dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
142  }
143 }
144 
145 static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
146  uint16_t *dstV,
147  const uint16_t *src1,
148  const uint16_t *src2,
149  int width,
150  enum AVPixelFormat origin,
151  int32_t *rgb2yuv)
152 {
153  int i;
154  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
155  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
156  av_assert1(src1 == src2);
157  for (i = 0; i < width; i++) {
158  int r_b = input_pixel(&src1[i * 3 + 0]);
159  int g = input_pixel(&src1[i * 3 + 1]);
160  int b_r = input_pixel(&src1[i * 3 + 2]);
161 
162  dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
163  dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
164  }
165 }
166 
167 static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
168  uint16_t *dstV,
169  const uint16_t *src1,
170  const uint16_t *src2,
171  int width,
172  enum AVPixelFormat origin,
173  int32_t *rgb2yuv)
174 {
175  int i;
176  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
177  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
178  av_assert1(src1 == src2);
179  for (i = 0; i < width; i++) {
180  int r_b = (input_pixel(&src1[6 * i + 0]) +
181  input_pixel(&src1[6 * i + 3]) + 1) >> 1;
182  int g = (input_pixel(&src1[6 * i + 1]) +
183  input_pixel(&src1[6 * i + 4]) + 1) >> 1;
184  int b_r = (input_pixel(&src1[6 * i + 2]) +
185  input_pixel(&src1[6 * i + 5]) + 1) >> 1;
186 
187  dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
188  dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
189  }
190 }
191 
192 #undef r
193 #undef b
194 #undef input_pixel
195 
196 #define rgb48funcs(pattern, BE_LE, origin) \
197 static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
198  const uint8_t *_src, \
199  const uint8_t *unused0, const uint8_t *unused1,\
200  int width, \
201  uint32_t *rgb2yuv) \
202 { \
203  const uint16_t *src = (const uint16_t *)_src; \
204  uint16_t *dst = (uint16_t *)_dst; \
205  rgb48ToY_c_template(dst, src, width, origin, rgb2yuv); \
206 } \
207  \
208 static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
209  uint8_t *_dstV, \
210  const uint8_t *unused0, \
211  const uint8_t *_src1, \
212  const uint8_t *_src2, \
213  int width, \
214  uint32_t *rgb2yuv) \
215 { \
216  const uint16_t *src1 = (const uint16_t *)_src1, \
217  *src2 = (const uint16_t *)_src2; \
218  uint16_t *dstU = (uint16_t *)_dstU, \
219  *dstV = (uint16_t *)_dstV; \
220  rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
221 } \
222  \
223 static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
224  uint8_t *_dstV, \
225  const uint8_t *unused0, \
226  const uint8_t *_src1, \
227  const uint8_t *_src2, \
228  int width, \
229  uint32_t *rgb2yuv) \
230 { \
231  const uint16_t *src1 = (const uint16_t *)_src1, \
232  *src2 = (const uint16_t *)_src2; \
233  uint16_t *dstU = (uint16_t *)_dstU, \
234  *dstV = (uint16_t *)_dstV; \
235  rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
236 }
237 
242 
243 #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
244  origin == AV_PIX_FMT_BGRA || \
245  origin == AV_PIX_FMT_ARGB || \
246  origin == AV_PIX_FMT_ABGR) \
247  ? AV_RN32A(&src[(i) * 4]) \
248  : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
249  : AV_RL16(&src[(i) * 2])))
250 
251 static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
252  const uint8_t *src,
253  int width,
254  enum AVPixelFormat origin,
255  int shr, int shg,
256  int shb, int shp,
257  int maskr, int maskg,
258  int maskb, int rsh,
259  int gsh, int bsh, int S,
260  int32_t *rgb2yuv)
261 {
262  const int ry = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
263  const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
264  int i;
265 
266  for (i = 0; i < width; i++) {
267  int px = input_pixel(i) >> shp;
268  int b = (px & maskb) >> shb;
269  int g = (px & maskg) >> shg;
270  int r = (px & maskr) >> shr;
271 
272  dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
273  }
274 }
275 
276 static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
277  int16_t *dstV,
278  const uint8_t *src,
279  int width,
280  enum AVPixelFormat origin,
281  int shr, int shg,
282  int shb, int shp,
283  int maskr, int maskg,
284  int maskb, int rsh,
285  int gsh, int bsh, int S,
286  int32_t *rgb2yuv)
287 {
288  const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
289  rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh;
290  const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
291  int i;
292 
293  for (i = 0; i < width; i++) {
294  int px = input_pixel(i) >> shp;
295  int b = (px & maskb) >> shb;
296  int g = (px & maskg) >> shg;
297  int r = (px & maskr) >> shr;
298 
299  dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
300  dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
301  }
302 }
303 
305  int16_t *dstV,
306  const uint8_t *src,
307  int width,
308  enum AVPixelFormat origin,
309  int shr, int shg,
310  int shb, int shp,
311  int maskr, int maskg,
312  int maskb, int rsh,
313  int gsh, int bsh, int S,
314  int32_t *rgb2yuv)
315 {
316  const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
317  rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
318  maskgx = ~(maskr | maskb);
319  const unsigned rnd = (256U<<(S)) + (1<<(S-6));
320  int i;
321 
322  maskr |= maskr << 1;
323  maskb |= maskb << 1;
324  maskg |= maskg << 1;
325  for (i = 0; i < width; i++) {
326  int px0 = input_pixel(2 * i + 0) >> shp;
327  int px1 = input_pixel(2 * i + 1) >> shp;
328  int b, r, g = (px0 & maskgx) + (px1 & maskgx);
329  int rb = px0 + px1 - g;
330 
331  b = (rb & maskb) >> shb;
332  if (shp ||
333  origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
334  origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
335  g >>= shg;
336  } else {
337  g = (g & maskg) >> shg;
338  }
339  r = (rb & maskr) >> shr;
340 
341  dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
342  dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
343  }
344 }
345 
346 #undef input_pixel
347 
348 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
349  maskg, maskb, rsh, gsh, bsh, S) \
350 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
351  int width, uint32_t *tab) \
352 { \
353  rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
354  maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
355 } \
356  \
357 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
358  const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
359  int width, uint32_t *tab) \
360 { \
361  rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
362  shr, shg, shb, shp, \
363  maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
364 } \
365  \
366 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
367  const uint8_t *unused0, const uint8_t *src, \
368  const uint8_t *dummy, \
369  int width, uint32_t *tab) \
370 { \
371  rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
372  shr, shg, shb, shp, \
373  maskr, maskg, maskb, \
374  rsh, gsh, bsh, S, tab); \
375 }
376 
377 rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
378 rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
379 rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
380 rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
381 rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
382 rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
383 rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
384 rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
385 rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
386 rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
387 rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
388 rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
389 rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
390 rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
391 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
392 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
393 
394 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
395  const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
396  int width, uint32_t *rgb2yuv)
397 {
398  uint16_t *dstU = (uint16_t *)_dstU;
399  uint16_t *dstV = (uint16_t *)_dstV;
400  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
401  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
402 
403  int i;
404  for (i = 0; i < width; i++) {
405  unsigned int g = gsrc[2*i] + gsrc[2*i+1];
406  unsigned int b = bsrc[2*i] + bsrc[2*i+1];
407  unsigned int r = rsrc[2*i] + rsrc[2*i+1];
408 
409  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
410  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
411  }
412 }
413 
414 static void rgba64ToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
415  const uint8_t *unused2, int width, uint32_t *unused)
416 {
417  int16_t *dst = (int16_t *)_dst;
418  const uint16_t *src = (const uint16_t *)_src;
419  int i;
420  for (i = 0; i < width; i++)
421  dst[i] = src[4 * i + 3];
422 }
423 
424 static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
425 {
426  int16_t *dst = (int16_t *)_dst;
427  int i;
428  for (i=0; i<width; i++) {
429  dst[i]= src[4*i]<<6;
430  }
431 }
432 
433 static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
434 {
435  int16_t *dst = (int16_t *)_dst;
436  int i;
437  for (i=0; i<width; i++) {
438  dst[i]= src[4*i+3]<<6;
439  }
440 }
441 
442 static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
443 {
444  int16_t *dst = (int16_t *)_dst;
445  int i;
446  for (i=0; i<width; i++) {
447  int d= src[i];
448 
449  dst[i]= (pal[d] >> 24)<<6;
450  }
451 }
452 
453 static void palToY_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] & 0xFF)<<6;
461  }
462 }
463 
464 static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
465  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
466  int width, uint32_t *pal)
467 {
468  uint16_t *dstU = (uint16_t *)_dstU;
469  int16_t *dstV = (int16_t *)_dstV;
470  int i;
471  av_assert1(src1 == src2);
472  for (i = 0; i < width; i++) {
473  int p = pal[src1[i]];
474 
475  dstU[i] = (uint8_t)(p>> 8)<<6;
476  dstV[i] = (uint8_t)(p>>16)<<6;
477  }
478 }
479 
480 static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
481 {
482  int16_t *dst = (int16_t *)_dst;
483  int i, j;
484  width = (width + 7) >> 3;
485  for (i = 0; i < width; i++) {
486  int d = ~src[i];
487  for (j = 0; j < 8; j++)
488  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
489  }
490  if(width&7){
491  int d= ~src[i];
492  for (j = 0; j < (width&7); j++)
493  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
494  }
495 }
496 
497 static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
498 {
499  int16_t *dst = (int16_t *)_dst;
500  int i, j;
501  width = (width + 7) >> 3;
502  for (i = 0; i < width; i++) {
503  int d = src[i];
504  for (j = 0; j < 8; j++)
505  dst[8*i+j]= ((d>>(7-j))&1) * 16383;
506  }
507  if(width&7){
508  int d = src[i];
509  for (j = 0; j < (width&7); j++)
510  dst[8*i+j] = ((d>>(7-j))&1) * 16383;
511  }
512 }
513 
514 static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
515  uint32_t *unused)
516 {
517  int i;
518  for (i = 0; i < width; i++)
519  dst[i] = src[2 * i];
520 }
521 
522 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
523  const uint8_t *src2, int width, uint32_t *unused)
524 {
525  int i;
526  for (i = 0; i < width; i++) {
527  dstU[i] = src1[4 * i + 1];
528  dstV[i] = src1[4 * i + 3];
529  }
530  av_assert1(src1 == src2);
531 }
532 
533 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
534  uint32_t *unused)
535 {
536  int i;
537  const uint16_t *src = (const uint16_t *)_src;
538  uint16_t *dst = (uint16_t *)_dst;
539  for (i = 0; i < width; i++)
540  dst[i] = av_bswap16(src[i]);
541 }
542 
543 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
544  const uint8_t *_src2, int width, uint32_t *unused)
545 {
546  int i;
547  const uint16_t *src1 = (const uint16_t *)_src1,
548  *src2 = (const uint16_t *)_src2;
549  uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
550  for (i = 0; i < width; i++) {
551  dstU[i] = av_bswap16(src1[i]);
552  dstV[i] = av_bswap16(src2[i]);
553  }
554 }
555 
556 /* This is almost identical to the previous, end exists only because
557  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
558 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
559  uint32_t *unused)
560 {
561  int i;
562  for (i = 0; i < width; i++)
563  dst[i] = src[2 * i + 1];
564 }
565 
566 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
567  const uint8_t *src2, int width, uint32_t *unused)
568 {
569  int i;
570  for (i = 0; i < width; i++) {
571  dstU[i] = src1[4 * i + 0];
572  dstV[i] = src1[4 * i + 2];
573  }
574  av_assert1(src1 == src2);
575 }
576 
577 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
578  const uint8_t *src, int width)
579 {
580  int i;
581  for (i = 0; i < width; i++) {
582  dst1[i] = src[2 * i + 0];
583  dst2[i] = src[2 * i + 1];
584  }
585 }
586 
587 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
588  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
589  int width, uint32_t *unused)
590 {
591  nvXXtoUV_c(dstU, dstV, src1, width);
592 }
593 
594 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
595  const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
596  int width, uint32_t *unused)
597 {
598  nvXXtoUV_c(dstV, dstU, src1, width);
599 }
600 
601 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
602 
603 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
604  int width, uint32_t *rgb2yuv)
605 {
606  int16_t *dst = (int16_t *)_dst;
607  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
608  int i;
609  for (i = 0; i < width; i++) {
610  int b = src[i * 3 + 0];
611  int g = src[i * 3 + 1];
612  int r = src[i * 3 + 2];
613 
614  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
615  }
616 }
617 
618 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
619  const uint8_t *src2, int width, uint32_t *rgb2yuv)
620 {
621  int16_t *dstU = (int16_t *)_dstU;
622  int16_t *dstV = (int16_t *)_dstV;
623  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
624  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
625  int i;
626  for (i = 0; i < width; i++) {
627  int b = src1[3 * i + 0];
628  int g = src1[3 * i + 1];
629  int r = src1[3 * i + 2];
630 
631  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
632  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
633  }
634  av_assert1(src1 == src2);
635 }
636 
637 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
638  const uint8_t *src2, int width, uint32_t *rgb2yuv)
639 {
640  int16_t *dstU = (int16_t *)_dstU;
641  int16_t *dstV = (int16_t *)_dstV;
642  int i;
643  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
644  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
645  for (i = 0; i < width; i++) {
646  int b = src1[6 * i + 0] + src1[6 * i + 3];
647  int g = src1[6 * i + 1] + src1[6 * i + 4];
648  int r = src1[6 * i + 2] + src1[6 * i + 5];
649 
650  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
651  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
652  }
653  av_assert1(src1 == src2);
654 }
655 
656 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
657  uint32_t *rgb2yuv)
658 {
659  int16_t *dst = (int16_t *)_dst;
660  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
661  int i;
662  for (i = 0; i < width; i++) {
663  int r = src[i * 3 + 0];
664  int g = src[i * 3 + 1];
665  int b = src[i * 3 + 2];
666 
667  dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
668  }
669 }
670 
671 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
672  const uint8_t *src2, int width, uint32_t *rgb2yuv)
673 {
674  int16_t *dstU = (int16_t *)_dstU;
675  int16_t *dstV = (int16_t *)_dstV;
676  int i;
677  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
678  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
679  av_assert1(src1 == src2);
680  for (i = 0; i < width; i++) {
681  int r = src1[3 * i + 0];
682  int g = src1[3 * i + 1];
683  int b = src1[3 * i + 2];
684 
685  dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
686  dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
687  }
688 }
689 
690 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
691  const uint8_t *src2, int width, uint32_t *rgb2yuv)
692 {
693  int16_t *dstU = (int16_t *)_dstU;
694  int16_t *dstV = (int16_t *)_dstV;
695  int i;
696  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
697  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
698  av_assert1(src1 == src2);
699  for (i = 0; i < width; i++) {
700  int r = src1[6 * i + 0] + src1[6 * i + 3];
701  int g = src1[6 * i + 1] + src1[6 * i + 4];
702  int b = src1[6 * i + 2] + src1[6 * i + 5];
703 
704  dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
705  dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
706  }
707 }
708 
709 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
710 {
711  uint16_t *dst = (uint16_t *)_dst;
712  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
713  int i;
714  for (i = 0; i < width; i++) {
715  int g = src[0][i];
716  int b = src[1][i];
717  int r = src[2][i];
718 
719  dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
720  }
721 }
722 
723 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
724 {
725  uint16_t *dstU = (uint16_t *)_dstU;
726  uint16_t *dstV = (uint16_t *)_dstV;
727  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
728  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
729  int i;
730  for (i = 0; i < width; i++) {
731  int g = src[0][i];
732  int b = src[1][i];
733  int r = src[2][i];
734 
735  dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
736  dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
737  }
738 }
739 
740 #define rdpx(src) \
741  is_be ? AV_RB16(src) : AV_RL16(src)
742 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
743  int width, int bpc, int is_be, int32_t *rgb2yuv)
744 {
745  int i;
746  const uint16_t **src = (const uint16_t **)_src;
747  uint16_t *dst = (uint16_t *)_dst;
748  int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
749  for (i = 0; i < width; i++) {
750  int g = rdpx(src[0] + i);
751  int b = rdpx(src[1] + i);
752  int r = rdpx(src[2] + i);
753 
754  dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14));
755  }
756 }
757 
758 static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
759 {
760  planar_rgb16_to_y(dst, src, w, 9, 0, rgb2yuv);
761 }
762 
763 static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
764 {
765  planar_rgb16_to_y(dst, src, w, 9, 1, rgb2yuv);
766 }
767 
768 static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
769 {
770  planar_rgb16_to_y(dst, src, w, 10, 0, rgb2yuv);
771 }
772 
773 static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
774 {
775  planar_rgb16_to_y(dst, src, w, 10, 1, rgb2yuv);
776 }
777 
778 static void planar_rgb12le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
779 {
780  planar_rgb16_to_y(dst, src, w, 12, 0, rgb2yuv);
781 }
782 
783 static void planar_rgb12be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
784 {
785  planar_rgb16_to_y(dst, src, w, 12, 1, rgb2yuv);
786 }
787 
788 static void planar_rgb14le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
789 {
790  planar_rgb16_to_y(dst, src, w, 14, 0, rgb2yuv);
791 }
792 
793 static void planar_rgb14be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
794 {
795  planar_rgb16_to_y(dst, src, w, 14, 1, rgb2yuv);
796 }
797 
798 static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
799 {
800  planar_rgb16_to_y(dst, src, w, 16, 0, rgb2yuv);
801 }
802 
803 static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
804 {
805  planar_rgb16_to_y(dst, src, w, 16, 1, rgb2yuv);
806 }
807 
809  const uint8_t *_src[4], int width,
810  int bpc, int is_be, int32_t *rgb2yuv)
811 {
812  int i;
813  const uint16_t **src = (const uint16_t **)_src;
814  uint16_t *dstU = (uint16_t *)_dstU;
815  uint16_t *dstV = (uint16_t *)_dstV;
816  int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
817  int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
818  for (i = 0; i < width; i++) {
819  int g = rdpx(src[0] + i);
820  int b = rdpx(src[1] + i);
821  int r = rdpx(src[2] + i);
822 
823  dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
824  dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
825  }
826 }
827 #undef rdpx
828 
829 static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV,
830  const uint8_t *src[4], int w, int32_t *rgb2yuv)
831 {
832  planar_rgb16_to_uv(dstU, dstV, src, w, 9, 0, rgb2yuv);
833 }
834 
835 static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV,
836  const uint8_t *src[4], int w, int32_t *rgb2yuv)
837 {
838  planar_rgb16_to_uv(dstU, dstV, src, w, 9, 1, rgb2yuv);
839 }
840 
841 static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV,
842  const uint8_t *src[4], int w, int32_t *rgb2yuv)
843 {
844  planar_rgb16_to_uv(dstU, dstV, src, w, 10, 0, rgb2yuv);
845 }
846 
847 static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
848  const uint8_t *src[4], int w, int32_t *rgb2yuv)
849 {
850  planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1, rgb2yuv);
851 }
852 
853 static void planar_rgb12le_to_uv(uint8_t *dstU, uint8_t *dstV,
854  const uint8_t *src[4], int w, int32_t *rgb2yuv)
855 {
856  planar_rgb16_to_uv(dstU, dstV, src, w, 12, 0, rgb2yuv);
857 }
858 
859 static void planar_rgb12be_to_uv(uint8_t *dstU, uint8_t *dstV,
860  const uint8_t *src[4], int w, int32_t *rgb2yuv)
861 {
862  planar_rgb16_to_uv(dstU, dstV, src, w, 12, 1, rgb2yuv);
863 }
864 
865 static void planar_rgb14le_to_uv(uint8_t *dstU, uint8_t *dstV,
866  const uint8_t *src[4], int w, int32_t *rgb2yuv)
867 {
868  planar_rgb16_to_uv(dstU, dstV, src, w, 14, 0, rgb2yuv);
869 }
870 
871 static void planar_rgb14be_to_uv(uint8_t *dstU, uint8_t *dstV,
872  const uint8_t *src[4], int w, int32_t *rgb2yuv)
873 {
874  planar_rgb16_to_uv(dstU, dstV, src, w, 14, 1, rgb2yuv);
875 }
876 
877 static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
878  const uint8_t *src[4], int w, int32_t *rgb2yuv)
879 {
880  planar_rgb16_to_uv(dstU, dstV, src, w, 16, 0, rgb2yuv);
881 }
882 
883 static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV,
884  const uint8_t *src[4], int w, int32_t *rgb2yuv)
885 {
886  planar_rgb16_to_uv(dstU, dstV, src, w, 16, 1, rgb2yuv);
887 }
888 
890 {
891  enum AVPixelFormat srcFormat = c->srcFormat;
892 
893  c->chrToYV12 = NULL;
894  switch (srcFormat) {
895  case AV_PIX_FMT_YUYV422:
896  c->chrToYV12 = yuy2ToUV_c;
897  break;
898  case AV_PIX_FMT_UYVY422:
899  c->chrToYV12 = uyvyToUV_c;
900  break;
901  case AV_PIX_FMT_NV12:
902  c->chrToYV12 = nv12ToUV_c;
903  break;
904  case AV_PIX_FMT_NV21:
905  c->chrToYV12 = nv21ToUV_c;
906  break;
907  case AV_PIX_FMT_RGB8:
908  case AV_PIX_FMT_BGR8:
909  case AV_PIX_FMT_PAL8:
912  c->chrToYV12 = palToUV_c;
913  break;
914  case AV_PIX_FMT_GBRP9LE:
916  break;
917  case AV_PIX_FMT_GBRP10LE:
919  break;
920  case AV_PIX_FMT_GBRP12LE:
922  break;
923  case AV_PIX_FMT_GBRP14LE:
925  break;
926  case AV_PIX_FMT_GBRP16LE:
928  break;
929  case AV_PIX_FMT_GBRP9BE:
931  break;
932  case AV_PIX_FMT_GBRP10BE:
934  break;
935  case AV_PIX_FMT_GBRP12BE:
937  break;
938  case AV_PIX_FMT_GBRP14BE:
940  break;
941  case AV_PIX_FMT_GBRP16BE:
943  break;
944  case AV_PIX_FMT_GBRP:
946  break;
947 #if HAVE_BIGENDIAN
963 
973  c->chrToYV12 = bswap16UV_c;
974  break;
975 #else
991 
1001  c->chrToYV12 = bswap16UV_c;
1002  break;
1003 #endif
1004  }
1005  if (c->chrSrcHSubSample) {
1006  switch (srcFormat) {
1007  case AV_PIX_FMT_RGBA64BE:
1008  c->chrToYV12 = rgb64BEToUV_half_c;
1009  break;
1010  case AV_PIX_FMT_RGBA64LE:
1011  c->chrToYV12 = rgb64LEToUV_half_c;
1012  break;
1013  case AV_PIX_FMT_RGB48BE:
1014  c->chrToYV12 = rgb48BEToUV_half_c;
1015  break;
1016  case AV_PIX_FMT_RGB48LE:
1017  c->chrToYV12 = rgb48LEToUV_half_c;
1018  break;
1019  case AV_PIX_FMT_BGR48BE:
1020  c->chrToYV12 = bgr48BEToUV_half_c;
1021  break;
1022  case AV_PIX_FMT_BGR48LE:
1023  c->chrToYV12 = bgr48LEToUV_half_c;
1024  break;
1025  case AV_PIX_FMT_RGB32:
1026  c->chrToYV12 = bgr32ToUV_half_c;
1027  break;
1028  case AV_PIX_FMT_RGB32_1:
1029  c->chrToYV12 = bgr321ToUV_half_c;
1030  break;
1031  case AV_PIX_FMT_BGR24:
1033  break;
1034  case AV_PIX_FMT_BGR565LE:
1035  c->chrToYV12 = bgr16leToUV_half_c;
1036  break;
1037  case AV_PIX_FMT_BGR565BE:
1038  c->chrToYV12 = bgr16beToUV_half_c;
1039  break;
1040  case AV_PIX_FMT_BGR555LE:
1041  c->chrToYV12 = bgr15leToUV_half_c;
1042  break;
1043  case AV_PIX_FMT_BGR555BE:
1044  c->chrToYV12 = bgr15beToUV_half_c;
1045  break;
1046  case AV_PIX_FMT_GBR24P :
1048  break;
1049  case AV_PIX_FMT_BGR444LE:
1050  c->chrToYV12 = bgr12leToUV_half_c;
1051  break;
1052  case AV_PIX_FMT_BGR444BE:
1053  c->chrToYV12 = bgr12beToUV_half_c;
1054  break;
1055  case AV_PIX_FMT_BGR32:
1056  c->chrToYV12 = rgb32ToUV_half_c;
1057  break;
1058  case AV_PIX_FMT_BGR32_1:
1059  c->chrToYV12 = rgb321ToUV_half_c;
1060  break;
1061  case AV_PIX_FMT_RGB24:
1063  break;
1064  case AV_PIX_FMT_RGB565LE:
1065  c->chrToYV12 = rgb16leToUV_half_c;
1066  break;
1067  case AV_PIX_FMT_RGB565BE:
1068  c->chrToYV12 = rgb16beToUV_half_c;
1069  break;
1070  case AV_PIX_FMT_RGB555LE:
1071  c->chrToYV12 = rgb15leToUV_half_c;
1072  break;
1073  case AV_PIX_FMT_RGB555BE:
1074  c->chrToYV12 = rgb15beToUV_half_c;
1075  break;
1076  case AV_PIX_FMT_RGB444LE:
1077  c->chrToYV12 = rgb12leToUV_half_c;
1078  break;
1079  case AV_PIX_FMT_RGB444BE:
1080  c->chrToYV12 = rgb12beToUV_half_c;
1081  break;
1082  }
1083  } else {
1084  switch (srcFormat) {
1085  case AV_PIX_FMT_RGBA64BE:
1086  c->chrToYV12 = rgb64BEToUV_c;
1087  break;
1088  case AV_PIX_FMT_RGBA64LE:
1089  c->chrToYV12 = rgb64LEToUV_c;
1090  break;
1091  case AV_PIX_FMT_RGB48BE:
1092  c->chrToYV12 = rgb48BEToUV_c;
1093  break;
1094  case AV_PIX_FMT_RGB48LE:
1095  c->chrToYV12 = rgb48LEToUV_c;
1096  break;
1097  case AV_PIX_FMT_BGR48BE:
1098  c->chrToYV12 = bgr48BEToUV_c;
1099  break;
1100  case AV_PIX_FMT_BGR48LE:
1101  c->chrToYV12 = bgr48LEToUV_c;
1102  break;
1103  case AV_PIX_FMT_RGB32:
1104  c->chrToYV12 = bgr32ToUV_c;
1105  break;
1106  case AV_PIX_FMT_RGB32_1:
1107  c->chrToYV12 = bgr321ToUV_c;
1108  break;
1109  case AV_PIX_FMT_BGR24:
1110  c->chrToYV12 = bgr24ToUV_c;
1111  break;
1112  case AV_PIX_FMT_BGR565LE:
1113  c->chrToYV12 = bgr16leToUV_c;
1114  break;
1115  case AV_PIX_FMT_BGR565BE:
1116  c->chrToYV12 = bgr16beToUV_c;
1117  break;
1118  case AV_PIX_FMT_BGR555LE:
1119  c->chrToYV12 = bgr15leToUV_c;
1120  break;
1121  case AV_PIX_FMT_BGR555BE:
1122  c->chrToYV12 = bgr15beToUV_c;
1123  break;
1124  case AV_PIX_FMT_BGR444LE:
1125  c->chrToYV12 = bgr12leToUV_c;
1126  break;
1127  case AV_PIX_FMT_BGR444BE:
1128  c->chrToYV12 = bgr12beToUV_c;
1129  break;
1130  case AV_PIX_FMT_BGR32:
1131  c->chrToYV12 = rgb32ToUV_c;
1132  break;
1133  case AV_PIX_FMT_BGR32_1:
1134  c->chrToYV12 = rgb321ToUV_c;
1135  break;
1136  case AV_PIX_FMT_RGB24:
1137  c->chrToYV12 = rgb24ToUV_c;
1138  break;
1139  case AV_PIX_FMT_RGB565LE:
1140  c->chrToYV12 = rgb16leToUV_c;
1141  break;
1142  case AV_PIX_FMT_RGB565BE:
1143  c->chrToYV12 = rgb16beToUV_c;
1144  break;
1145  case AV_PIX_FMT_RGB555LE:
1146  c->chrToYV12 = rgb15leToUV_c;
1147  break;
1148  case AV_PIX_FMT_RGB555BE:
1149  c->chrToYV12 = rgb15beToUV_c;
1150  break;
1151  case AV_PIX_FMT_RGB444LE:
1152  c->chrToYV12 = rgb12leToUV_c;
1153  break;
1154  case AV_PIX_FMT_RGB444BE:
1155  c->chrToYV12 = rgb12beToUV_c;
1156  break;
1157  }
1158  }
1159 
1160  c->lumToYV12 = NULL;
1161  c->alpToYV12 = NULL;
1162  switch (srcFormat) {
1163  case AV_PIX_FMT_GBRP9LE:
1165  break;
1166  case AV_PIX_FMT_GBRP10LE:
1168  break;
1169  case AV_PIX_FMT_GBRP12LE:
1171  break;
1172  case AV_PIX_FMT_GBRP14LE:
1174  break;
1175  case AV_PIX_FMT_GBRP16LE:
1177  break;
1178  case AV_PIX_FMT_GBRP9BE:
1180  break;
1181  case AV_PIX_FMT_GBRP10BE:
1183  break;
1184  case AV_PIX_FMT_GBRP12BE:
1186  break;
1187  case AV_PIX_FMT_GBRP14BE:
1189  break;
1190  case AV_PIX_FMT_GBRP16BE:
1192  break;
1193  case AV_PIX_FMT_GBRP:
1195  break;
1196 #if HAVE_BIGENDIAN
1197  case AV_PIX_FMT_YUV444P9LE:
1198  case AV_PIX_FMT_YUV422P9LE:
1199  case AV_PIX_FMT_YUV420P9LE:
1212 
1213  case AV_PIX_FMT_GRAY16LE:
1214  c->lumToYV12 = bswap16Y_c;
1215  break;
1225  c->lumToYV12 = bswap16Y_c;
1226  c->alpToYV12 = bswap16Y_c;
1227  break;
1228 #else
1229  case AV_PIX_FMT_YUV444P9BE:
1230  case AV_PIX_FMT_YUV422P9BE:
1231  case AV_PIX_FMT_YUV420P9BE:
1244 
1245  case AV_PIX_FMT_GRAY16BE:
1246  c->lumToYV12 = bswap16Y_c;
1247  break;
1257  c->lumToYV12 = bswap16Y_c;
1258  c->alpToYV12 = bswap16Y_c;
1259  break;
1260 #endif
1261  case AV_PIX_FMT_YUYV422:
1262  case AV_PIX_FMT_Y400A:
1263  c->lumToYV12 = yuy2ToY_c;
1264  break;
1265  case AV_PIX_FMT_UYVY422:
1266  c->lumToYV12 = uyvyToY_c;
1267  break;
1268  case AV_PIX_FMT_BGR24:
1269  c->lumToYV12 = bgr24ToY_c;
1270  break;
1271  case AV_PIX_FMT_BGR565LE:
1272  c->lumToYV12 = bgr16leToY_c;
1273  break;
1274  case AV_PIX_FMT_BGR565BE:
1275  c->lumToYV12 = bgr16beToY_c;
1276  break;
1277  case AV_PIX_FMT_BGR555LE:
1278  c->lumToYV12 = bgr15leToY_c;
1279  break;
1280  case AV_PIX_FMT_BGR555BE:
1281  c->lumToYV12 = bgr15beToY_c;
1282  break;
1283  case AV_PIX_FMT_BGR444LE:
1284  c->lumToYV12 = bgr12leToY_c;
1285  break;
1286  case AV_PIX_FMT_BGR444BE:
1287  c->lumToYV12 = bgr12beToY_c;
1288  break;
1289  case AV_PIX_FMT_RGB24:
1290  c->lumToYV12 = rgb24ToY_c;
1291  break;
1292  case AV_PIX_FMT_RGB565LE:
1293  c->lumToYV12 = rgb16leToY_c;
1294  break;
1295  case AV_PIX_FMT_RGB565BE:
1296  c->lumToYV12 = rgb16beToY_c;
1297  break;
1298  case AV_PIX_FMT_RGB555LE:
1299  c->lumToYV12 = rgb15leToY_c;
1300  break;
1301  case AV_PIX_FMT_RGB555BE:
1302  c->lumToYV12 = rgb15beToY_c;
1303  break;
1304  case AV_PIX_FMT_RGB444LE:
1305  c->lumToYV12 = rgb12leToY_c;
1306  break;
1307  case AV_PIX_FMT_RGB444BE:
1308  c->lumToYV12 = rgb12beToY_c;
1309  break;
1310  case AV_PIX_FMT_RGB8:
1311  case AV_PIX_FMT_BGR8:
1312  case AV_PIX_FMT_PAL8:
1313  case AV_PIX_FMT_BGR4_BYTE:
1314  case AV_PIX_FMT_RGB4_BYTE:
1315  c->lumToYV12 = palToY_c;
1316  break;
1317  case AV_PIX_FMT_MONOBLACK:
1318  c->lumToYV12 = monoblack2Y_c;
1319  break;
1320  case AV_PIX_FMT_MONOWHITE:
1321  c->lumToYV12 = monowhite2Y_c;
1322  break;
1323  case AV_PIX_FMT_RGB32:
1324  c->lumToYV12 = bgr32ToY_c;
1325  break;
1326  case AV_PIX_FMT_RGB32_1:
1327  c->lumToYV12 = bgr321ToY_c;
1328  break;
1329  case AV_PIX_FMT_BGR32:
1330  c->lumToYV12 = rgb32ToY_c;
1331  break;
1332  case AV_PIX_FMT_BGR32_1:
1333  c->lumToYV12 = rgb321ToY_c;
1334  break;
1335  case AV_PIX_FMT_RGB48BE:
1336  c->lumToYV12 = rgb48BEToY_c;
1337  break;
1338  case AV_PIX_FMT_RGB48LE:
1339  c->lumToYV12 = rgb48LEToY_c;
1340  break;
1341  case AV_PIX_FMT_BGR48BE:
1342  c->lumToYV12 = bgr48BEToY_c;
1343  break;
1344  case AV_PIX_FMT_BGR48LE:
1345  c->lumToYV12 = bgr48LEToY_c;
1346  break;
1347  case AV_PIX_FMT_RGBA64BE:
1348  c->lumToYV12 = rgb64BEToY_c;
1349  break;
1350  case AV_PIX_FMT_RGBA64LE:
1351  c->lumToYV12 = rgb64LEToY_c;
1352  break;
1353  }
1354  if (c->alpPixBuf) {
1355  if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
1356  if (HAVE_BIGENDIAN == !isBE(srcFormat))
1357  c->alpToYV12 = bswap16Y_c;
1358  }
1359  switch (srcFormat) {
1360  case AV_PIX_FMT_RGBA64LE:
1361  case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
1362  case AV_PIX_FMT_BGRA:
1363  case AV_PIX_FMT_RGBA:
1364  c->alpToYV12 = rgbaToA_c;
1365  break;
1366  case AV_PIX_FMT_ABGR:
1367  case AV_PIX_FMT_ARGB:
1368  c->alpToYV12 = abgrToA_c;
1369  break;
1370  case AV_PIX_FMT_Y400A:
1371  c->alpToYV12 = uyvyToY_c;
1372  break;
1373  case AV_PIX_FMT_PAL8 :
1374  c->alpToYV12 = palToA_c;
1375  break;
1376  }
1377  }
1378 }
static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:803
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:85
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
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:587
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:158
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:231
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:603
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:594
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:522
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:224
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:566
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:79
#define RV_IDX
RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15le
Definition: input.c:382
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:228
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:151
#define BV_IDX
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:154
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:229
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
Definition: pixfmt.h:117
void(* chrToYV12)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
Unscaled conversion of chroma planes to YV12 for horizontal scaler.
#define GV_IDX
#define av_bswap16
Definition: sh4/bswap.h:31
void(* alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
Unscaled conversion of alpha plane to YV12 for horizontal scaler.
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:195
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
external API header
static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Definition: input.c:723
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:120
static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:480
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:234
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:148
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
Definition: pixfmt.h:138
static void rgba64ToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
Definition: input.c:414
static void planar_rgb12be_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:859
including without damages for loss of work computer failure or loss of data or any commercial damage and lost revenue or even if the UPF has been advised of the possibility of such damage the UPF will be liable under statutory product liability laws as far such laws apply to the Software The foregoing limitations will apply even if the above stated warranty disclaimer fails of its essential purpose Some jurisdictions do not allow the exclusion of indirect or consequential so some of the terms above may not be applicable to you AUDIT Upon days written UPF or a professional designated by UPF may audit your use of the Software You agree to cooperate with UPF s audit and provide reasonable assistance and access to information You agree to pay within days of written notification any fees applicable to your use of the Software in breach of your license rights If you do not UPF can end your license You agree that UPF shall not be responsible for any of your costs incurred in cooperating with the audit TERMINATION This Agreement is effective until terminated You may terminate this Agreement at any time by destroying all copies of Software This Agreement will terminate immediately without notice from UPF if you fail to comply with any provision of this Agreement Either party may terminate this Agreement immediately should any Software or in either party s opinion be likely to the subject of a claim of infringement of any intellectual or industrial property right Upon you must destroy all copies of Software Provisions that survive termination or expiration include those relating to limitation of liability limitation and others which by their nature are intended to and apply to both parties respective successors and assignees EXPORT REGULATIONS Software and technical data delivered under this Agreement may be subject to export or import regulations You agree to comply strictly with all such laws and regulations and acknowledge that you have the responsibility to obtain such licenses to re or import as may be required after delivery to you TRADEMARKS This Licence does not grant permission to use the trade service or names of the except as required for reasonable and customary use in describing the origin of the Software and reproducing the content of the copyright notice GOVERNING LAW JURISDICTION Any action related to this Agreement will be governed by Spanish law No choice of law rules of any jurisdiction will apply Any conflict or dispute resulting from this License and use of the Software will be subject to the exclusive jurisdiction of the courts of the City of Spain SEVERABILITY If any provision of the Licence is invalid or unenforceable under applicable this will not affect the validity or enforceability of the Licence as a whole Such provision will be construed and or reformed so as necessary to make it valid and enforceable If this is not the License will terminate ASSIGNMENT You may not assign this agreement or give or transfer the Software or an interest in it to another individual or entity If you grant a security interest in the the secured party has no right to use or transfer the Software FORCE nor is UPF responsible for any third party claims against Licensee PRIVACY desenvolupament i under the responsibility of Universitat Pompeu Fabra works or projects In but without the data is processed for the purpose of communicating with Licensee regarding any administrative and legal judicial purposes Collection We collect personal data including affiliation and email address Only the data marked with a star is obligatory Users must provide true and accurate personal profile data Users must NOT upload any sensitive data regarding racial origin
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:233
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:128
#define r_b
output residual component w
#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:514
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:115
set threshold d
static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:829
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:89
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12be
Definition: input.c:392
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:185
#define RU_IDX
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:196
static void planar_rgb14be_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:871
uint8_t
#define av_cold
Definition: attributes.h:78
8 bit with PIX_FMT_RGB32 palette
Definition: pixfmt.h:79
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:112
static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *rgb2yuv)
Definition: input.c:618
static void planar_rgb14le_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:865
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16le
Definition: input.c:384
#define b
Definition: input.c:42
bgr321
Definition: input.c:378
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:209
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
Definition: pixfmt.h:137
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:230
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:114
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:98
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:197
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:173
static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:758
static void planar_rgb14be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:793
#define input_pixel(pos)
Definition: input.c:601
static void planar_rgb12le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:778
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:200
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:558
external API header
av_cold void ff_sws_init_input_funcs(SwsContext *c)
Definition: input.c:889
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
#define r
Definition: input.c:41
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:442
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:149
static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:798
#define U(x)
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:169
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:157
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:262
static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:763
#define S(s, c, i)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:133
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:99
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:188
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:153
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:93
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:227
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:145
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:433
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:131
static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU, int16_t *dstV, const uint8_t *src, int width, enum AVPixelFormat origin, int shr, int shg, int shb, int shp, int maskr, int maskg, int maskb, int rsh, int gsh, int bsh, int S, int32_t *rgb2yuv)
Definition: input.c:276
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:189
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:96
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:143
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:97
#define isNBPS(x)
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:190
static void planar_rgb14le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:788
as above, but U and V bytes are swapped
Definition: pixfmt.h:94
#define RGB2YUV_SHIFT
FFT buffer for g
Definition: stft_peak.m:17
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:841
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb12le
Definition: input.c:386
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:92
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:690
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:453
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:167
void(* readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:768
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:637
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:194
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:742
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:186
float u
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:222
static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:835
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:150
#define rgb48funcs(pattern, BE_LE, origin)
Definition: input.c:196
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:533
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:159
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:142
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:119
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT static RGB2YUV_SHIFT void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc, int width, uint32_t *rgb2yuv)
Definition: input.c:394
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:261
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:304
NULL
Definition: eval.c:55
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:87
static int width
Definition: tests/utils.c:158
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:129
static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, int width, uint32_t *unused)
Definition: input.c:543
AVS_Value src
Definition: avisynth_c.h:523
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:497
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:60
RGB2YUV_SHIFT rgb321
Definition: input.c:380
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:171
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:198
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:259
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:69
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT bgr15be
Definition: input.c:388
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:236
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:199
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:201
Y , 16bpp, big-endian.
Definition: pixfmt.h:101
synthesis window for stochastic i
byte swapping routines
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:223
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:235
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:184
static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:773
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
Definition: pixfmt.h:122
#define AV_PIX_FMT_GBR24P
Definition: pixfmt.h:251
#define GY_IDX
#define AV_PIX_FMT_Y400A
Definition: pixfmt.h:250
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:193
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
Definition: pixfmt.h:116
static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:877
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
Definition: pixfmt.h:140
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:155
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:132
static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Definition: input.c:709
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:78
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:226
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:77
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:808
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:170
static double c[64]
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:111
enum AVPixelFormat srcFormat
Source pixel format.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:130
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:90
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:191
void(* readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
Functions to read planar input, such as planar RGB, and convert internally to Y/UV.
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT rgb16be
Definition: input.c:390
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:656
static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:883
#define rdpx(src)
Definition: input.c:740
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:232
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:260
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
static void planar_rgb12le_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:853
Y , 16bpp, little-endian.
Definition: pixfmt.h:102
#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr,maskg, maskb, rsh, gsh, bsh, S)
Definition: input.c:348
void(* lumToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
Unscaled conversion of luma plane to YV12 for horizontal scaler.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:192
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
Definition: pixfmt.h:121
static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *pal)
Definition: input.c:464
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:671
#define GU_IDX
#define av_always_inline
Definition: attributes.h:41
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:174
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
Definition: pixfmt.h:139
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:45
#define HAVE_BIGENDIAN
Definition: config.h:116
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:187
static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:847
#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:577
static void planar_rgb12be_to_y(uint8_t *dst, const uint8_t *src[4], int w, int32_t *rgb2yuv)
Definition: input.c:783
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:221
#define rgb64funcs(pattern, BE_LE, origin)
Definition: input.c:97
#define BU_IDX
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:156
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:225
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:172
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:210
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:424
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:152