FFmpeg
Loading...
Searching...
No Matches
swscale_unscaled.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2001-2011 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 <inttypes.h>
22#include <string.h>
23#include <math.h>
24#include <stdio.h>
25#include "config.h"
27#include "swscale.h"
28#include "swscale_internal.h"
29#include "rgb2rgb.h"
31#include "libavutil/avutil.h"
34#include "libavutil/bswap.h"
35#include "libavutil/pixdesc.h"
36#include "libavutil/avassert.h"
37#include "libavutil/avconfig.h"
38
39DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={
40{
41 { 0, 1, 0, 1, 0, 1, 0, 1,},
42 { 1, 0, 1, 0, 1, 0, 1, 0,},
43 { 0, 1, 0, 1, 0, 1, 0, 1,},
44 { 1, 0, 1, 0, 1, 0, 1, 0,},
45 { 0, 1, 0, 1, 0, 1, 0, 1,},
46 { 1, 0, 1, 0, 1, 0, 1, 0,},
47 { 0, 1, 0, 1, 0, 1, 0, 1,},
48 { 1, 0, 1, 0, 1, 0, 1, 0,},
49},{
50 { 1, 2, 1, 2, 1, 2, 1, 2,},
51 { 3, 0, 3, 0, 3, 0, 3, 0,},
52 { 1, 2, 1, 2, 1, 2, 1, 2,},
53 { 3, 0, 3, 0, 3, 0, 3, 0,},
54 { 1, 2, 1, 2, 1, 2, 1, 2,},
55 { 3, 0, 3, 0, 3, 0, 3, 0,},
56 { 1, 2, 1, 2, 1, 2, 1, 2,},
57 { 3, 0, 3, 0, 3, 0, 3, 0,},
58},{
59 { 2, 4, 3, 5, 2, 4, 3, 5,},
60 { 6, 0, 7, 1, 6, 0, 7, 1,},
61 { 3, 5, 2, 4, 3, 5, 2, 4,},
62 { 7, 1, 6, 0, 7, 1, 6, 0,},
63 { 2, 4, 3, 5, 2, 4, 3, 5,},
64 { 6, 0, 7, 1, 6, 0, 7, 1,},
65 { 3, 5, 2, 4, 3, 5, 2, 4,},
66 { 7, 1, 6, 0, 7, 1, 6, 0,},
67},{
68 { 4, 8, 7, 11, 4, 8, 7, 11,},
69 { 12, 0, 15, 3, 12, 0, 15, 3,},
70 { 6, 10, 5, 9, 6, 10, 5, 9,},
71 { 14, 2, 13, 1, 14, 2, 13, 1,},
72 { 4, 8, 7, 11, 4, 8, 7, 11,},
73 { 12, 0, 15, 3, 12, 0, 15, 3,},
74 { 6, 10, 5, 9, 6, 10, 5, 9,},
75 { 14, 2, 13, 1, 14, 2, 13, 1,},
76},{
77 { 9, 17, 15, 23, 8, 16, 14, 22,},
78 { 25, 1, 31, 7, 24, 0, 30, 6,},
79 { 13, 21, 11, 19, 12, 20, 10, 18,},
80 { 29, 5, 27, 3, 28, 4, 26, 2,},
81 { 8, 16, 14, 22, 9, 17, 15, 23,},
82 { 24, 0, 30, 6, 25, 1, 31, 7,},
83 { 12, 20, 10, 18, 13, 21, 11, 19,},
84 { 28, 4, 26, 2, 29, 5, 27, 3,},
85},{
86 { 18, 34, 30, 46, 17, 33, 29, 45,},
87 { 50, 2, 62, 14, 49, 1, 61, 13,},
88 { 26, 42, 22, 38, 25, 41, 21, 37,},
89 { 58, 10, 54, 6, 57, 9, 53, 5,},
90 { 16, 32, 28, 44, 19, 35, 31, 47,},
91 { 48, 0, 60, 12, 51, 3, 63, 15,},
92 { 24, 40, 20, 36, 27, 43, 23, 39,},
93 { 56, 8, 52, 4, 59, 11, 55, 7,},
94},{
95 { 18, 34, 30, 46, 17, 33, 29, 45,},
96 { 50, 2, 62, 14, 49, 1, 61, 13,},
97 { 26, 42, 22, 38, 25, 41, 21, 37,},
98 { 58, 10, 54, 6, 57, 9, 53, 5,},
99 { 16, 32, 28, 44, 19, 35, 31, 47,},
100 { 48, 0, 60, 12, 51, 3, 63, 15,},
101 { 24, 40, 20, 36, 27, 43, 23, 39,},
102 { 56, 8, 52, 4, 59, 11, 55, 7,},
103},{
104 { 36, 68, 60, 92, 34, 66, 58, 90,},
105 { 100, 4,124, 28, 98, 2,122, 26,},
106 { 52, 84, 44, 76, 50, 82, 42, 74,},
107 { 116, 20,108, 12,114, 18,106, 10,},
108 { 32, 64, 56, 88, 38, 70, 62, 94,},
109 { 96, 0,120, 24,102, 6,126, 30,},
110 { 48, 80, 40, 72, 54, 86, 46, 78,},
111 { 112, 16,104, 8,118, 22,110, 14,},
112}};
113
114
115static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
116 uint8_t val)
117{
118 int i;
119 uint8_t *ptr = plane + stride * y;
120 for (i = 0; i < height; i++) {
121 memset(ptr, val, width);
122 ptr += stride;
123 }
124}
125
126void ff_copyPlane(const uint8_t *src, int srcStride,
127 int srcSliceY, int srcSliceH, int width,
128 uint8_t *dst, int dstStride)
129{
130 if (!srcSliceH)
131 return;
132 av_assert0(srcSliceH > 0);
133
134 dst += dstStride * srcSliceY;
135 if (dstStride == srcStride && srcStride > 0) {
136 memcpy(dst, src, (srcSliceH - 1) * dstStride + width);
137 } else {
138 int i;
139 for (i = 0; i < srcSliceH; i++) {
140 memcpy(dst, src, width);
141 src += srcStride;
142 dst += dstStride;
143 }
144 }
145}
146
147static int planarToNv12Wrapper(SwsInternal *c, const uint8_t *const src[],
148 const int srcStride[], int srcSliceY,
149 int srcSliceH, uint8_t *const dstParam[],
150 const int dstStride[])
151{
152 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
153
154 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
155 dstParam[0], dstStride[0]);
156
157 if (c->opts.dst_format == AV_PIX_FMT_NV12)
158 interleaveBytes(src[1], src[2], dst, c->chrSrcW, (srcSliceH + 1) / 2,
159 srcStride[1], srcStride[2], dstStride[1]);
160 else
161 interleaveBytes(src[2], src[1], dst, c->chrSrcW, (srcSliceH + 1) / 2,
162 srcStride[2], srcStride[1], dstStride[1]);
163
164 return srcSliceH;
165}
166
167static int nv12ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[],
168 const int srcStride[], int srcSliceY,
169 int srcSliceH, uint8_t *const dstParam[],
170 const int dstStride[])
171{
172 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
173 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
174
175 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
176 dstParam[0], dstStride[0]);
177
178 if (c->opts.src_format == AV_PIX_FMT_NV12)
179 deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, (srcSliceH + 1) / 2,
180 srcStride[1], dstStride[1], dstStride[2]);
181 else
182 deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, (srcSliceH + 1) / 2,
183 srcStride[1], dstStride[2], dstStride[1]);
184
185 return srcSliceH;
186}
187
188static int planarToNv24Wrapper(SwsInternal *c, const uint8_t *const src[],
189 const int srcStride[], int srcSliceY,
190 int srcSliceH, uint8_t *const dstParam[],
191 const int dstStride[])
192{
193 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY;
194
195 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
196 dstParam[0], dstStride[0]);
197
198 if (c->opts.dst_format == AV_PIX_FMT_NV24)
199 interleaveBytes(src[1], src[2], dst, c->chrSrcW, srcSliceH,
200 srcStride[1], srcStride[2], dstStride[1]);
201 else
202 interleaveBytes(src[2], src[1], dst, c->chrSrcW, srcSliceH,
203 srcStride[2], srcStride[1], dstStride[1]);
204
205 return srcSliceH;
206}
207
208static int nv24ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[],
209 const int srcStride[], int srcSliceY,
210 int srcSliceH, uint8_t *const dstParam[],
211 const int dstStride[])
212{
213 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY;
214 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY;
215
216 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
217 dstParam[0], dstStride[0]);
218
219 if (c->opts.src_format == AV_PIX_FMT_NV24)
220 deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, srcSliceH,
221 srcStride[1], dstStride[1], dstStride[2]);
222 else
223 deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, srcSliceH,
224 srcStride[1], dstStride[2], dstStride[1]);
225
226 return srcSliceH;
227}
228
229static void nv24_to_yuv420p_chroma(uint8_t *dst1, int dstStride1,
230 uint8_t *dst2, int dstStride2,
231 const uint8_t *src, int srcStride,
232 int w, int h)
233{
234 const uint8_t *src1 = src;
235 const uint8_t *src2 = src + srcStride;
236 // average 4 pixels into 1 (interleaved U and V)
237 for (int y = 0; y < h; y += 2) {
238 if (y + 1 == h)
239 src2 = src1;
240 for (int x = 0; x < w; x++) {
241 dst1[x] = (src1[4 * x + 0] + src1[4 * x + 2] +
242 src2[4 * x + 0] + src2[4 * x + 2]) >> 2;
243 dst2[x] = (src1[4 * x + 1] + src1[4 * x + 3] +
244 src2[4 * x + 1] + src2[4 * x + 3]) >> 2;
245 }
246 src1 += srcStride * 2;
247 src2 += srcStride * 2;
248 dst1 += dstStride1;
249 dst2 += dstStride2;
250 }
251}
252
253static int nv24ToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
254 const int srcStride[], int srcSliceY, int srcSliceH,
255 uint8_t *const dstParam[], const int dstStride[])
256{
257 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
258 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
259
260 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
261 dstParam[0], dstStride[0]);
262
263 if (c->opts.src_format == AV_PIX_FMT_NV24)
264 nv24_to_yuv420p_chroma(dst1, dstStride[1], dst2, dstStride[2],
265 src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
266 else
267 nv24_to_yuv420p_chroma(dst2, dstStride[2], dst1, dstStride[1],
268 src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
269
270 return srcSliceH;
271}
272
273static int planarToP01xWrapper(SwsInternal *c, const uint8_t *const src8[],
274 const int srcStride[], int srcSliceY,
275 int srcSliceH, uint8_t *const dstParam8[],
276 const int dstStride[])
277{
278 const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
279 const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
280 const uint16_t **src = (const uint16_t**)src8;
281 uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
282 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
283 int x, y;
284
285 /* Calculate net shift required for values. */
286 const int shift[3] = {
287 dst_format->comp[0].depth + dst_format->comp[0].shift -
288 src_format->comp[0].depth - src_format->comp[0].shift,
289 dst_format->comp[1].depth + dst_format->comp[1].shift -
290 src_format->comp[1].depth - src_format->comp[1].shift,
291 dst_format->comp[2].depth + dst_format->comp[2].shift -
292 src_format->comp[2].depth - src_format->comp[2].shift,
293 };
294
295 av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
296 dstStride[0] % 2 || dstStride[1] % 2));
297
298 for (y = 0; y < srcSliceH; y++) {
299 uint16_t *tdstY = dstY;
300 const uint16_t *tsrc0 = src[0];
301 for (x = c->opts.src_w; x > 0; x--) {
302 *tdstY++ = *tsrc0++ << shift[0];
303 }
304 src[0] += srcStride[0] / 2;
305 dstY += dstStride[0] / 2;
306
307 if (!(y & 1)) {
308 uint16_t *tdstUV = dstUV;
309 const uint16_t *tsrc1 = src[1];
310 const uint16_t *tsrc2 = src[2];
311 for (x = c->opts.src_w / 2; x > 0; x--) {
312 *tdstUV++ = *tsrc1++ << shift[1];
313 *tdstUV++ = *tsrc2++ << shift[2];
314 }
315 src[1] += srcStride[1] / 2;
316 src[2] += srcStride[2] / 2;
317 dstUV += dstStride[1] / 2;
318 }
319 }
320
321 return srcSliceH;
322}
323
324#if AV_HAVE_BIGENDIAN
325#define output_pixel(p, v) do { \
326 uint16_t *pp = (p); \
327 AV_WL16(pp, (v)); \
328 } while(0)
329#else
330#define output_pixel(p, v) (*p) = (v)
331#endif
332
333static int planar8ToP01xleWrapper(SwsInternal *c, const uint8_t *const src[],
334 const int srcStride[], int srcSliceY,
335 int srcSliceH, uint8_t *const dstParam8[],
336 const int dstStride[])
337{
338 const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2];
339 uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
340 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
341 int x, y, t;
342
343 av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
344
345 for (y = 0; y < srcSliceH; y++) {
346 uint16_t *tdstY = dstY;
347 const uint8_t *tsrc0 = src0;
348 for (x = c->opts.src_w; x > 0; x--) {
349 t = *tsrc0++;
350 output_pixel(tdstY++, t << 8);
351 }
352 src0 += srcStride[0];
353 dstY += dstStride[0] / 2;
354
355 if (!(y & 1)) {
356 uint16_t *tdstUV = dstUV;
357 const uint8_t *tsrc1 = src1;
358 const uint8_t *tsrc2 = src2;
359 for (x = c->opts.src_w / 2; x > 0; x--) {
360 t = *tsrc1++;
361 output_pixel(tdstUV++, t << 8);
362 t = *tsrc2++;
363 output_pixel(tdstUV++, t << 8);
364 }
365 src1 += srcStride[1];
366 src2 += srcStride[2];
367 dstUV += dstStride[1] / 2;
368 }
369 }
370
371 return srcSliceH;
372}
373
374#undef output_pixel
375
376static int planarToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[],
377 const int srcStride[], int srcSliceY, int srcSliceH,
378 uint8_t *const dstParam[], const int dstStride[])
379{
380 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
381
382 yv12toyuy2(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
383 srcStride[1], dstStride[0]);
384
385 return srcSliceH;
386}
387
388static int planarToUyvyWrapper(SwsInternal *c, const uint8_t *const src[],
389 const int srcStride[], int srcSliceY, int srcSliceH,
390 uint8_t *const dstParam[], const int dstStride[])
391{
392 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
393
394 yv12touyvy(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
395 srcStride[1], dstStride[0]);
396
397 return srcSliceH;
398}
399
400static int yuv422pToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[],
401 const int srcStride[], int srcSliceY, int srcSliceH,
402 uint8_t *const dstParam[], const int dstStride[])
403{
404 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
405
406 yuv422ptoyuy2(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
407 srcStride[1], dstStride[0]);
408
409 return srcSliceH;
410}
411
412static int yuv422pToUyvyWrapper(SwsInternal *c, const uint8_t *const src[],
413 const int srcStride[], int srcSliceY, int srcSliceH,
414 uint8_t *const dstParam[], const int dstStride[])
415{
416 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
417
418 yuv422ptouyvy(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
419 srcStride[1], dstStride[0]);
420
421 return srcSliceH;
422}
423
424static int yuyvToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
425 const int srcStride[], int srcSliceY, int srcSliceH,
426 uint8_t *const dstParam[], const int dstStride[])
427{
428 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
429 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
430 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
431
432 yuyvtoyuv420(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
433 dstStride[1], srcStride[0]);
434
435 if (dstParam[3])
436 fillPlane(dstParam[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
437
438 return srcSliceH;
439}
440
441static int yuyvToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[],
442 const int srcStride[], int srcSliceY, int srcSliceH,
443 uint8_t *const dstParam[], const int dstStride[])
444{
445 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
446 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
447 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
448
449 yuyvtoyuv422(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
450 dstStride[1], srcStride[0]);
451
452 return srcSliceH;
453}
454
455static int uyvyToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
456 const int srcStride[], int srcSliceY, int srcSliceH,
457 uint8_t *const dstParam[], const int dstStride[])
458{
459 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
460 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
461 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
462
463 uyvytoyuv420(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
464 dstStride[1], srcStride[0]);
465
466 if (dstParam[3])
467 fillPlane(dstParam[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
468
469 return srcSliceH;
470}
471
472static int uyvyToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[],
473 const int srcStride[], int srcSliceY, int srcSliceH,
474 uint8_t *const dstParam[], const int dstStride[])
475{
476 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
477 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
478 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
479
480 uyvytoyuv422(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
481 dstStride[1], srcStride[0]);
482
483 return srcSliceH;
484}
485
486static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels,
487 const uint8_t *palette)
488{
489 int i;
490 for (i = 0; i < num_pixels; i++)
491 ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
492}
493
494static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels,
495 const uint8_t *palette)
496{
497 int i;
498
499 for (i = 0; i < num_pixels; i++)
500 ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
501}
502
503static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
504 const uint8_t *palette)
505{
506 int i;
507
508 for (i = 0; i < num_pixels; i++) {
509 //FIXME slow?
510 dst[0] = palette[src[i << 1] * 4 + 0];
511 dst[1] = palette[src[i << 1] * 4 + 1];
512 dst[2] = palette[src[i << 1] * 4 + 2];
513 dst += 3;
514 }
515}
516
517static void gray8aToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
518 uint8_t *dst2, uint8_t *dstA, int num_pixels,
519 const uint8_t *palette)
520{
521 for (int i = 0; i < num_pixels; i++) {
522 const uint8_t *rgb = &palette[src[i << 1] * 4];
523 dst0[i] = rgb[0];
524 dst1[i] = rgb[1];
525 dst2[i] = rgb[2];
526 if (dstA)
527 dstA[i] = src[(i << 1) + 1];
528 }
529}
530
531static void pal8ToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
532 uint8_t *dst2, uint8_t *dstA, int num_pixels,
533 const uint8_t *palette)
534{
535 for (int i = 0; i < num_pixels; i++) {
536 const uint8_t *rgba = &palette[src[i] * 4];
537 dst0[i] = rgba[0];
538 dst1[i] = rgba[1];
539 dst2[i] = rgba[2];
540 if (dstA)
541 dstA[i] = rgba[3];
542 }
543}
544
545static int bswap_16bpc(SwsInternal *c, const uint8_t *const src[],
546 const int srcStride[], int srcSliceY, int srcSliceH,
547 uint8_t *const dst[], const int dstStride[])
548{
549 int i, j, p;
550
551 for (p = 0; p < 4; p++) {
552 int srcstr = srcStride[p] / 2;
553 int dststr = dstStride[p] / 2;
554 uint16_t *dstPtr = (uint16_t *) dst[p];
555 const uint16_t *srcPtr = (const uint16_t *) src[p];
556 int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
557 if(!dstPtr || !srcPtr)
558 continue;
559 dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
560 for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
561 for (j = 0; j < min_stride; j++) {
562 dstPtr[j] = av_bswap16(srcPtr[j]);
563 }
564 srcPtr += srcstr;
565 dstPtr += dststr;
566 }
567 }
568
569 return srcSliceH;
570}
571
572static int bswap_32bpc(SwsInternal *c, const uint8_t *const src[],
573 const int srcStride[], int srcSliceY, int srcSliceH,
574 uint8_t *const dst[], const int dstStride[])
575{
576 int i, j, p;
577
578 for (p = 0; p < 4; p++) {
579 int srcstr = srcStride[p] / 4;
580 int dststr = dstStride[p] / 4;
581 uint32_t *dstPtr = (uint32_t *) dst[p];
582 const uint32_t *srcPtr = (const uint32_t *) src[p];
583 int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
584 if(!dstPtr || !srcPtr)
585 continue;
586 dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
587 for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
588 for (j = 0; j < min_stride; j++) {
589 dstPtr[j] = av_bswap32(srcPtr[j]);
590 }
591 srcPtr += srcstr;
592 dstPtr += dststr;
593 }
594 }
595
596 return srcSliceH;
597}
598
599
600static int palToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[],
601 int srcSliceY, int srcSliceH, uint8_t *const dst[],
602 const int dstStride[])
603{
604 const enum AVPixelFormat srcFormat = c->opts.src_format;
605 const enum AVPixelFormat dstFormat = c->opts.dst_format;
606 void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
607 const uint8_t *palette) = NULL;
608 int i;
609 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
610 const uint8_t *srcPtr = src[0];
611
612 if (srcFormat == AV_PIX_FMT_YA8) {
613 switch (dstFormat) {
614 case AV_PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
615 case AV_PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
616 case AV_PIX_FMT_BGR32_1: conv = gray8aToPacked32_1; break;
617 case AV_PIX_FMT_RGB32_1: conv = gray8aToPacked32_1; break;
618 case AV_PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
619 case AV_PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
620 }
621 } else if (usePal(srcFormat)) {
622 switch (dstFormat) {
629 }
630 }
631
632 if (!conv)
633 av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
634 av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
635 else {
636 for (i = 0; i < srcSliceH; i++) {
637 conv(srcPtr, dstPtr, c->opts.src_w, (uint8_t *) c->pal_rgb);
638 srcPtr += srcStride[0];
639 dstPtr += dstStride[0];
640 }
641 }
642
643 return srcSliceH;
644}
645
646static int palToGbrpWrapper(SwsInternal *c, const uint8_t *const src[],
647 const int srcStride[], int srcSliceY, int srcSliceH,
648 uint8_t *const dst[], const int dstStride[])
649{
650 const enum AVPixelFormat srcFormat = c->opts.src_format;
651 const enum AVPixelFormat dstFormat = c->opts.dst_format;
652 void (*conv)(const uint8_t *src, uint8_t *dstG, uint8_t *dstB, uint8_t *dstR,
653 uint8_t *dstA, int num_pixels, const uint8_t *palette) = NULL;
654
655 const int num_planes = isALPHA(dstFormat) ? 4 : 3;
656 const uint8_t *srcPtr = src[0];
657 uint8_t *dstPtr[4] = {0};
658 for (int i = 0; i < num_planes; i++)
659 dstPtr[i] = dst[i] + dstStride[i] * srcSliceY;
660
661 if (srcFormat == AV_PIX_FMT_YA8) {
662 switch (dstFormat) {
663 case AV_PIX_FMT_GBRP: conv = gray8aToPlanar8; break;
664 case AV_PIX_FMT_GBRAP: conv = gray8aToPlanar8; break;
665 }
666 } else if (usePal(srcFormat)) {
667 switch (dstFormat) {
668 case AV_PIX_FMT_GBRP: conv = pal8ToPlanar8; break;
669 case AV_PIX_FMT_GBRAP: conv = pal8ToPlanar8; break;
670 }
671 }
672
673 av_assert1(conv);
674 for (int y = 0; y < srcSliceH; y++) {
675 conv(srcPtr, dstPtr[0], dstPtr[1], dstPtr[2], dstPtr[3], c->opts.src_w,
676 (uint8_t *) c->pal_rgb);
677 srcPtr += srcStride[0];
678 for (int i = 0; i < num_planes; i++)
679 dstPtr[i] += dstStride[i];
680 }
681
682 return srcSliceH;
683}
684
685static void packed16togbra16(const uint8_t *src, int srcStride,
686 uint16_t *dst[], const int dstStride[], int srcSliceH,
687 int src_alpha, int swap, int shift, int width)
688{
689 int x, h, i;
690 int dst_alpha = dst[3] != NULL;
691 for (h = 0; h < srcSliceH; h++) {
692 uint16_t *src_line = (uint16_t *)(src + srcStride * h);
693 switch (swap) {
694 case 3:
695 if (src_alpha && dst_alpha) {
696 for (x = 0; x < width; x++) {
697 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
698 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
699 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
700 dst[3][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
701 }
702 } else if (dst_alpha) {
703 for (x = 0; x < width; x++) {
704 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
705 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
706 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
707 dst[3][x] = av_bswap16(0xFFFF >> shift);
708 }
709 } else if (src_alpha) {
710 for (x = 0; x < width; x++) {
711 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
712 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
713 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
714 src_line++;
715 }
716 } else {
717 for (x = 0; x < width; x++) {
718 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
719 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
720 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
721 }
722 }
723 break;
724 case 2:
725 if (src_alpha && dst_alpha) {
726 for (x = 0; x < width; x++) {
727 dst[0][x] = av_bswap16(*src_line++ >> shift);
728 dst[1][x] = av_bswap16(*src_line++ >> shift);
729 dst[2][x] = av_bswap16(*src_line++ >> shift);
730 dst[3][x] = av_bswap16(*src_line++ >> shift);
731 }
732 } else if (dst_alpha) {
733 for (x = 0; x < width; x++) {
734 dst[0][x] = av_bswap16(*src_line++ >> shift);
735 dst[1][x] = av_bswap16(*src_line++ >> shift);
736 dst[2][x] = av_bswap16(*src_line++ >> shift);
737 dst[3][x] = av_bswap16(0xFFFF >> shift);
738 }
739 } else if (src_alpha) {
740 for (x = 0; x < width; x++) {
741 dst[0][x] = av_bswap16(*src_line++ >> shift);
742 dst[1][x] = av_bswap16(*src_line++ >> shift);
743 dst[2][x] = av_bswap16(*src_line++ >> shift);
744 src_line++;
745 }
746 } else {
747 for (x = 0; x < width; x++) {
748 dst[0][x] = av_bswap16(*src_line++ >> shift);
749 dst[1][x] = av_bswap16(*src_line++ >> shift);
750 dst[2][x] = av_bswap16(*src_line++ >> shift);
751 }
752 }
753 break;
754 case 1:
755 if (src_alpha && dst_alpha) {
756 for (x = 0; x < width; x++) {
757 dst[0][x] = av_bswap16(*src_line++) >> shift;
758 dst[1][x] = av_bswap16(*src_line++) >> shift;
759 dst[2][x] = av_bswap16(*src_line++) >> shift;
760 dst[3][x] = av_bswap16(*src_line++) >> shift;
761 }
762 } else if (dst_alpha) {
763 for (x = 0; x < width; x++) {
764 dst[0][x] = av_bswap16(*src_line++) >> shift;
765 dst[1][x] = av_bswap16(*src_line++) >> shift;
766 dst[2][x] = av_bswap16(*src_line++) >> shift;
767 dst[3][x] = 0xFFFF >> shift;
768 }
769 } else if (src_alpha) {
770 for (x = 0; x < width; x++) {
771 dst[0][x] = av_bswap16(*src_line++) >> shift;
772 dst[1][x] = av_bswap16(*src_line++) >> shift;
773 dst[2][x] = av_bswap16(*src_line++) >> shift;
774 src_line++;
775 }
776 } else {
777 for (x = 0; x < width; x++) {
778 dst[0][x] = av_bswap16(*src_line++) >> shift;
779 dst[1][x] = av_bswap16(*src_line++) >> shift;
780 dst[2][x] = av_bswap16(*src_line++) >> shift;
781 }
782 }
783 break;
784 default:
785 if (src_alpha && dst_alpha) {
786 for (x = 0; x < width; x++) {
787 dst[0][x] = *src_line++ >> shift;
788 dst[1][x] = *src_line++ >> shift;
789 dst[2][x] = *src_line++ >> shift;
790 dst[3][x] = *src_line++ >> shift;
791 }
792 } else if (dst_alpha) {
793 for (x = 0; x < width; x++) {
794 dst[0][x] = *src_line++ >> shift;
795 dst[1][x] = *src_line++ >> shift;
796 dst[2][x] = *src_line++ >> shift;
797 dst[3][x] = 0xFFFF >> shift;
798 }
799 } else if (src_alpha) {
800 for (x = 0; x < width; x++) {
801 dst[0][x] = *src_line++ >> shift;
802 dst[1][x] = *src_line++ >> shift;
803 dst[2][x] = *src_line++ >> shift;
804 src_line++;
805 }
806 } else {
807 for (x = 0; x < width; x++) {
808 dst[0][x] = *src_line++ >> shift;
809 dst[1][x] = *src_line++ >> shift;
810 dst[2][x] = *src_line++ >> shift;
811 }
812 }
813 }
814 for (i = 0; i < 4 && dst[i]; i++)
815 dst[i] += dstStride[i] >> 1;
816 }
817}
818
819static void packed30togbra10(const uint8_t *src, int srcStride,
820 uint16_t *dst[], const int dstStride[], int srcSliceH,
821 int swap, int bpc, int shift, int width)
822{
823 int x, h, i;
824 int dst_alpha = dst[3] != NULL;
825 int scale_high = bpc - 10, scale_low = 10 - scale_high;
826 uint16_t alpha_val = (1U << bpc) - 1;
827 for (h = 0; h < srcSliceH; h++) {
828 uint32_t *src_line = (uint32_t *)(src + srcStride * h);
829 unsigned component;
830
831 switch (swap) {
832 case 3:
833 case 2:
834 if (dst_alpha) {
835 for (x = 0; x < width; x++) {
836 unsigned p = AV_RL32(src_line);
837 component = (p >> 20) & 0x3FF;
838 dst[0][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
839 component = (p >> 10) & 0x3FF;
840 dst[1][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
841 component = p & 0x3FF;
842 dst[2][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
843 dst[3][x] = av_bswap16(alpha_val) << shift;
844 src_line++;
845 }
846 } else {
847 for (x = 0; x < width; x++) {
848 unsigned p = AV_RL32(src_line);
849 component = (p >> 20) & 0x3FF;
850 dst[0][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
851 component = (p >> 10) & 0x3FF;
852 dst[1][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
853 component = p & 0x3FF;
854 dst[2][x] = av_bswap16((component << scale_high | component >> scale_low) << shift);
855 src_line++;
856 }
857 }
858 break;
859 default:
860 if (dst_alpha) {
861 for (x = 0; x < width; x++) {
862 unsigned p = AV_RL32(src_line);
863 component = (p >> 20) & 0x3FF;
864 dst[0][x] = (component << scale_high | component >> scale_low) << shift;
865 component = (p >> 10) & 0x3FF;
866 dst[1][x] = (component << scale_high | component >> scale_low) << shift;
867 component = p & 0x3FF;
868 dst[2][x] = (component << scale_high | component >> scale_low) << shift;
869 dst[3][x] = alpha_val << shift;
870 src_line++;
871 }
872 } else {
873 for (x = 0; x < width; x++) {
874 unsigned p = AV_RL32(src_line);
875 component = (p >> 20) & 0x3FF;
876 dst[0][x] = (component << scale_high | component >> scale_low) << shift;
877 component = (p >> 10) & 0x3FF;
878 dst[1][x] = (component << scale_high | component >> scale_low) << shift;
879 component = p & 0x3FF;
880 dst[2][x] = (component << scale_high | component >> scale_low) << shift;
881 src_line++;
882 }
883 }
884 break;
885 }
886 for (i = 0; i < 4 && dst[i]; i++)
887 dst[i] += dstStride[i] >> 1;
888 }
889}
890
891static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
892 const int srcStride[], int srcSliceY, int srcSliceH,
893 uint8_t *const dst[], const int dstStride[])
894{
895 uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
896 uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
897 int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
898 int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
899 const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
900 const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
901 int bpc = dst_format->comp[0].depth;
902 int shift = dst_format->comp[0].shift;
903 int alpha = src_format->flags & AV_PIX_FMT_FLAG_ALPHA;
904 int swap = 0;
905 int i;
906
907 if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
908 !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
909 swap++;
910 if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
911 !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
912 swap += 2;
913
914 if ((dst_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
916 av_log(c, AV_LOG_ERROR, "unsupported conversion to planar RGB %s -> %s\n",
917 src_format->name, dst_format->name);
918 return srcSliceH;
919 }
920
921 for (i = 0; i < 4 && dst[i]; i++) {
922 dst2013[i] += stride2013[i] * srcSliceY / 2;
923 dst1023[i] += stride1023[i] * srcSliceY / 2;
924 }
925
926 switch (c->opts.src_format) {
931 packed16togbra16(src[0], srcStride[0],
932 dst2013, stride2013, srcSliceH, alpha, swap,
933 16 - bpc, c->opts.src_w);
934 break;
936 av_assert0(bpc >= 10);
937 packed30togbra10(src[0], srcStride[0],
938 dst2013, stride2013, srcSliceH, swap,
939 bpc, shift, c->opts.src_w);
940 break;
945 packed16togbra16(src[0], srcStride[0],
946 dst1023, stride1023, srcSliceH, alpha, swap,
947 16 - bpc, c->opts.src_w);
948 break;
950 av_assert0(bpc >= 10);
951 packed30togbra10(src[0], srcStride[0],
952 dst1023, stride1023, srcSliceH, swap,
953 bpc, shift, c->opts.src_w);
954 break;
955 default:
957 "unsupported conversion to planar RGB %s -> %s\n",
958 src_format->name, dst_format->name);
959 }
960
961 return srcSliceH;
962}
963
964static void gbr16ptopacked16(const uint16_t *src[], const int srcStride[],
965 uint8_t *dst, int dstStride, int srcSliceH,
966 int alpha, int swap, int bpp, int width)
967{
968 int x, h, i;
969 int src_alpha = src[3] != NULL;
970 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
971 for (h = 0; h < srcSliceH; h++) {
972 uint16_t *dest = (uint16_t *)(dst + dstStride * h);
973 uint16_t component;
974
975 switch(swap) {
976 case 3:
977 if (alpha && !src_alpha) {
978 for (x = 0; x < width; x++) {
979 component = av_bswap16(src[0][x]);
980 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
981 component = av_bswap16(src[1][x]);
982 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
983 component = av_bswap16(src[2][x]);
984 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
985 *dest++ = 0xffff;
986 }
987 } else if (alpha && src_alpha) {
988 for (x = 0; x < width; x++) {
989 component = av_bswap16(src[0][x]);
990 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
991 component = av_bswap16(src[1][x]);
992 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
993 component = av_bswap16(src[2][x]);
994 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
995 component = av_bswap16(src[3][x]);
996 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
997 }
998 } else {
999 for (x = 0; x < width; x++) {
1000 component = av_bswap16(src[0][x]);
1001 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1002 component = av_bswap16(src[1][x]);
1003 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1004 component = av_bswap16(src[2][x]);
1005 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1006 }
1007 }
1008 break;
1009 case 2:
1010 if (alpha && !src_alpha) {
1011 for (x = 0; x < width; x++) {
1012 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1013 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1014 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1015 *dest++ = 0xffff;
1016 }
1017 } else if (alpha && src_alpha) {
1018 for (x = 0; x < width; x++) {
1019 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1020 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1021 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1022 *dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
1023 }
1024 } else {
1025 for (x = 0; x < width; x++) {
1026 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1027 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1028 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1029 }
1030 }
1031 break;
1032 case 1:
1033 if (alpha && !src_alpha) {
1034 for (x = 0; x < width; x++) {
1035 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1036 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1037 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1038 *dest++ = 0xffff;
1039 }
1040 } else if (alpha && src_alpha) {
1041 for (x = 0; x < width; x++) {
1042 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1043 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1044 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1045 *dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
1046 }
1047 } else {
1048 for (x = 0; x < width; x++) {
1049 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1050 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1051 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1052 }
1053 }
1054 break;
1055 default:
1056 if (alpha && !src_alpha) {
1057 for (x = 0; x < width; x++) {
1058 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1059 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1060 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1061 *dest++ = 0xffff;
1062 }
1063 } else if (alpha && src_alpha) {
1064 for (x = 0; x < width; x++) {
1065 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1066 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1067 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1068 *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
1069 }
1070 } else {
1071 for (x = 0; x < width; x++) {
1072 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1073 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1074 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1075 }
1076 }
1077 }
1078 for (i = 0; i < 3 + src_alpha; i++)
1079 src[i] += srcStride[i] >> 1;
1080 }
1081}
1082
1083static void gbr16ptopacked30(const uint16_t *src[], const int srcStride[],
1084 uint8_t *dst, int dstStride, int srcSliceH,
1085 int swap, int shift, int width)
1086{
1087 int x, h, i;
1088 av_assert0(shift >= 0);
1089 for (h = 0; h < srcSliceH; h++) {
1090 uint8_t *dest = dst + dstStride * h;
1091
1092 switch(swap) {
1093 case 3:
1094 case 1:
1095 for (x = 0; x < width; x++) {
1096 unsigned C0 = av_bswap16(src[0][x]) >> shift;
1097 unsigned C1 = av_bswap16(src[1][x]) >> shift;
1098 unsigned C2 = av_bswap16(src[2][x]) >> shift;
1099 AV_WL32(dest + 4 * x, (3U << 30) + (C0 << 20) + (C1 << 10) + C2);
1100 }
1101 break;
1102 default:
1103 for (x = 0; x < width; x++) {
1104 unsigned C0 = src[0][x] >> shift;
1105 unsigned C1 = src[1][x] >> shift;
1106 unsigned C2 = src[2][x] >> shift;
1107 AV_WL32(dest + 4 * x, (3U << 30) + (C0 << 20) + (C1 << 10) + C2);
1108 }
1109 break;
1110 }
1111 for (i = 0; i < 3; i++)
1112 src[i] += srcStride[i] >> 1;
1113 }
1114}
1115
1116
1117static int planarRgb16ToRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
1118 const int srcStride[], int srcSliceY, int srcSliceH,
1119 uint8_t *const dst[], const int dstStride[])
1120{
1121 const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
1122 const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
1123 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1124 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1125 const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
1126 const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
1127 int bits_per_sample = src_format->comp[0].depth;
1128 int shift = src_format->comp[0].shift;
1129 int swap = 0;
1130 if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
1131 !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
1132 swap++;
1133 if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
1134 !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
1135 swap += 2;
1136
1137 if ((src_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
1139 bits_per_sample <= 8) {
1140 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1141 src_format->name, dst_format->name);
1142 return srcSliceH;
1143 }
1144 switch (c->opts.dst_format) {
1145 case AV_PIX_FMT_BGR48LE:
1146 case AV_PIX_FMT_BGR48BE:
1147 gbr16ptopacked16(src102, stride102,
1148 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1149 srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1150 break;
1151 case AV_PIX_FMT_RGB48LE:
1152 case AV_PIX_FMT_RGB48BE:
1153 gbr16ptopacked16(src201, stride201,
1154 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1155 srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1156 break;
1159 gbr16ptopacked16(src201, stride201,
1160 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1161 srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1162 break;
1165 gbr16ptopacked16(src102, stride102,
1166 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1167 srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1168 break;
1170 gbr16ptopacked30(src201, stride201,
1171 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1172 srcSliceH, swap, bits_per_sample + shift - 10, c->opts.src_w);
1173 break;
1175 gbr16ptopacked30(src102, stride102,
1176 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1177 srcSliceH, swap, bits_per_sample + shift - 10, c->opts.src_w);
1178 break;
1179 default:
1181 "unsupported planar RGB conversion %s -> %s\n",
1182 src_format->name, dst_format->name);
1183 }
1184
1185 return srcSliceH;
1186}
1187
1188static void gbr24ptopacked24(const uint8_t *src[], const int srcStride[],
1189 uint8_t *dst, int dstStride, int srcSliceH,
1190 int width)
1191{
1192 int x, h, i;
1193 for (h = 0; h < srcSliceH; h++) {
1194 uint8_t *dest = dst + dstStride * h;
1195 for (x = 0; x < width; x++) {
1196 *dest++ = src[0][x];
1197 *dest++ = src[1][x];
1198 *dest++ = src[2][x];
1199 }
1200
1201 for (i = 0; i < 3; i++)
1202 src[i] += srcStride[i];
1203 }
1204}
1205
1206static void gbr24ptopacked32(const uint8_t *src[], const int srcStride[],
1207 uint8_t *dst, int dstStride, int srcSliceH,
1208 int alpha_first, int width)
1209{
1210 int x, h, i;
1211 for (h = 0; h < srcSliceH; h++) {
1212 uint8_t *dest = dst + dstStride * h;
1213
1214 if (alpha_first) {
1215 for (x = 0; x < width; x++) {
1216 *dest++ = 0xff;
1217 *dest++ = src[0][x];
1218 *dest++ = src[1][x];
1219 *dest++ = src[2][x];
1220 }
1221 } else {
1222 for (x = 0; x < width; x++) {
1223 *dest++ = src[0][x];
1224 *dest++ = src[1][x];
1225 *dest++ = src[2][x];
1226 *dest++ = 0xff;
1227 }
1228 }
1229
1230 for (i = 0; i < 3; i++)
1231 src[i] += srcStride[i];
1232 }
1233}
1234
1235static void gbraptopacked32(const uint8_t *src[], const int srcStride[],
1236 uint8_t *dst, int dstStride, int srcSliceH,
1237 int alpha_first, int width)
1238{
1239 int x, h, i;
1240 for (h = 0; h < srcSliceH; h++) {
1241 uint8_t *dest = dst + dstStride * h;
1242
1243 if (alpha_first) {
1244 for (x = 0; x < width; x++) {
1245 *dest++ = src[3][x];
1246 *dest++ = src[0][x];
1247 *dest++ = src[1][x];
1248 *dest++ = src[2][x];
1249 }
1250 } else {
1251 for (x = 0; x < width; x++) {
1252 *dest++ = src[0][x];
1253 *dest++ = src[1][x];
1254 *dest++ = src[2][x];
1255 *dest++ = src[3][x];
1256 }
1257 }
1258
1259 for (i = 0; i < 4; i++)
1260 src[i] += srcStride[i];
1261 }
1262}
1263
1264static int planarRgbaToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1265 const int srcStride[], int srcSliceY, int srcSliceH,
1266 uint8_t *const dst[], const int dstStride[])
1267{
1268 int alpha_first = 0;
1269 const uint8_t *src102[] = { src[1], src[0], src[2], src[3] };
1270 const uint8_t *src201[] = { src[2], src[0], src[1], src[3] };
1271 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1272 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1273
1274 if (c->opts.src_format != AV_PIX_FMT_GBRAP) {
1275 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1276 av_get_pix_fmt_name(c->opts.src_format),
1277 av_get_pix_fmt_name(c->opts.dst_format));
1278 return srcSliceH;
1279 }
1280
1281 switch (c->opts.dst_format) {
1282 case AV_PIX_FMT_BGR24:
1283 gbr24ptopacked24(src102, stride102,
1284 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1285 srcSliceH, c->opts.src_w);
1286 break;
1287
1288 case AV_PIX_FMT_RGB24:
1289 gbr24ptopacked24(src201, stride201,
1290 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1291 srcSliceH, c->opts.src_w);
1292 break;
1293
1294 case AV_PIX_FMT_ARGB:
1295 alpha_first = 1;
1297 case AV_PIX_FMT_RGBA:
1298 gbraptopacked32(src201, stride201,
1299 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1300 srcSliceH, alpha_first, c->opts.src_w);
1301 break;
1302
1303 case AV_PIX_FMT_ABGR:
1304 alpha_first = 1;
1306 case AV_PIX_FMT_BGRA:
1307 gbraptopacked32(src102, stride102,
1308 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1309 srcSliceH, alpha_first, c->opts.src_w);
1310 break;
1311
1312 default:
1314 "unsupported planar RGB conversion %s -> %s\n",
1315 av_get_pix_fmt_name(c->opts.src_format),
1316 av_get_pix_fmt_name(c->opts.dst_format));
1317 }
1318
1319 return srcSliceH;
1320}
1321
1322static int planarRgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1323 const int srcStride[], int srcSliceY, int srcSliceH,
1324 uint8_t *const dst[], const int dstStride[])
1325{
1326 int alpha_first = 0;
1327 const uint8_t *src102[] = { src[1], src[0], src[2] };
1328 const uint8_t *src201[] = { src[2], src[0], src[1] };
1329 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
1330 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
1331
1332 if (c->opts.src_format != AV_PIX_FMT_GBRP) {
1333 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1334 av_get_pix_fmt_name(c->opts.src_format),
1335 av_get_pix_fmt_name(c->opts.dst_format));
1336 return srcSliceH;
1337 }
1338
1339 switch (c->opts.dst_format) {
1340 case AV_PIX_FMT_BGR24:
1341 gbr24ptopacked24(src102, stride102,
1342 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1343 srcSliceH, c->opts.src_w);
1344 break;
1345
1346 case AV_PIX_FMT_RGB24:
1347 gbr24ptopacked24(src201, stride201,
1348 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1349 srcSliceH, c->opts.src_w);
1350 break;
1351
1352 case AV_PIX_FMT_ARGB:
1353 alpha_first = 1;
1355 case AV_PIX_FMT_RGBA:
1356 gbr24ptopacked32(src201, stride201,
1357 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1358 srcSliceH, alpha_first, c->opts.src_w);
1359 break;
1360
1361 case AV_PIX_FMT_ABGR:
1362 alpha_first = 1;
1364 case AV_PIX_FMT_BGRA:
1365 gbr24ptopacked32(src102, stride102,
1366 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1367 srcSliceH, alpha_first, c->opts.src_w);
1368 break;
1369
1370 default:
1372 "unsupported planar RGB conversion %s -> %s\n",
1373 av_get_pix_fmt_name(c->opts.src_format),
1374 av_get_pix_fmt_name(c->opts.dst_format));
1375 }
1376
1377 return srcSliceH;
1378}
1379
1381 const uint8_t *const src[], const int srcStride[],
1382 int srcSliceY, int srcSliceH,
1383 uint8_t *const dst[], const int dstStride[])
1384{
1385 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
1386 dst[0], dstStride[0]);
1387 ff_copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->opts.src_w,
1388 dst[1], dstStride[1]);
1389 ff_copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->opts.src_w,
1390 dst[2], dstStride[2]);
1391 if (dst[3]) {
1392 if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
1393 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
1394 fillPlane16(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 1,
1395 desc_dst->comp[3].depth, isBE(c->opts.dst_format));
1396 } else {
1397 fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
1398 }
1399 }
1400
1401 return srcSliceH;
1402}
1403
1404static void packedtogbr24p(const uint8_t *src, int srcStride,
1405 uint8_t *const dst[], const int dstStride[], int srcSliceH,
1406 int alpha_first, int inc_size, int width)
1407{
1408 uint8_t *dest[3];
1409 int x, h;
1410
1411 dest[0] = dst[0];
1412 dest[1] = dst[1];
1413 dest[2] = dst[2];
1414
1415 if (alpha_first)
1416 src++;
1417
1418 for (h = 0; h < srcSliceH; h++) {
1419 for (x = 0; x < width; x++) {
1420 dest[0][x] = src[0];
1421 dest[1][x] = src[1];
1422 dest[2][x] = src[2];
1423
1424 src += inc_size;
1425 }
1426 src += srcStride - width * inc_size;
1427 dest[0] += dstStride[0];
1428 dest[1] += dstStride[1];
1429 dest[2] += dstStride[2];
1430 }
1431}
1432
1433static int rgbToPlanarRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1434 const int srcStride[], int srcSliceY, int srcSliceH,
1435 uint8_t *const dst[], const int dstStride[])
1436{
1437 int alpha_first = 0;
1438 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1439 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1440 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1441 dst[0] + srcSliceY * dstStride[0],
1442 dst[2] + srcSliceY * dstStride[2] };
1443 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1444 dst[0] + srcSliceY * dstStride[0],
1445 dst[1] + srcSliceY * dstStride[1] };
1446
1447 switch (c->opts.src_format) {
1448 case AV_PIX_FMT_RGB24:
1449 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1450 stride201, srcSliceH, alpha_first, 3, c->opts.src_w);
1451 break;
1452 case AV_PIX_FMT_BGR24:
1453 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1454 stride102, srcSliceH, alpha_first, 3, c->opts.src_w);
1455 break;
1456 case AV_PIX_FMT_ARGB:
1457 alpha_first = 1;
1459 case AV_PIX_FMT_RGBA:
1460 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1461 stride201, srcSliceH, alpha_first, 4, c->opts.src_w);
1462 break;
1463 case AV_PIX_FMT_ABGR:
1464 alpha_first = 1;
1466 case AV_PIX_FMT_BGRA:
1467 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1468 stride102, srcSliceH, alpha_first, 4, c->opts.src_w);
1469 break;
1470 default:
1472 "unsupported planar RGB conversion %s -> %s\n",
1473 av_get_pix_fmt_name(c->opts.src_format),
1474 av_get_pix_fmt_name(c->opts.dst_format));
1475 }
1476
1477 return srcSliceH;
1478}
1479
1480static void packed24togbrap(const uint8_t *src, int srcStride,
1481 uint8_t *const dst[], const int dstStride[],
1482 int srcSliceH, int width)
1483{
1484 uint8_t *dest[4];
1485 int x, h;
1486
1487 dest[0] = dst[0];
1488 dest[1] = dst[1];
1489 dest[2] = dst[2];
1490 dest[3] = dst[3];
1491
1492 for (h = 0; h < srcSliceH; h++) {
1493 for (x = 0; x < width; x++) {
1494 dest[0][x] = src[x * 3 + 0];
1495 dest[1][x] = src[x * 3 + 1];
1496 dest[2][x] = src[x * 3 + 2];
1497 dest[3][x] = 0xff;
1498 }
1499 src += srcStride;
1500 dest[0] += dstStride[0];
1501 dest[1] += dstStride[1];
1502 dest[2] += dstStride[2];
1503 dest[3] += dstStride[3];
1504 }
1505}
1506
1507static void packed32togbrap(const uint8_t *src, int srcStride,
1508 uint8_t *const dst[], const int dstStride[],
1509 int srcSliceH, int alpha_first, int width)
1510{
1511 uint8_t *dest[4];
1512 int x, h;
1513
1514 dest[0] = dst[0];
1515 dest[1] = dst[1];
1516 dest[2] = dst[2];
1517 dest[3] = dst[3];
1518
1519 for (h = 0; h < srcSliceH; h++) {
1520 if (alpha_first) {
1521 for (x = 0; x < width; x++) {
1522 dest[0][x] = src[x * 4 + 1];
1523 dest[1][x] = src[x * 4 + 2];
1524 dest[2][x] = src[x * 4 + 3];
1525 dest[3][x] = src[x * 4 + 0];
1526 }
1527 } else {
1528 for (x = 0; x < width; x++) {
1529 dest[0][x] = src[x * 4 + 0];
1530 dest[1][x] = src[x * 4 + 1];
1531 dest[2][x] = src[x * 4 + 2];
1532 dest[3][x] = src[x * 4 + 3];
1533 }
1534 }
1535 src += srcStride;
1536 dest[0] += dstStride[0];
1537 dest[1] += dstStride[1];
1538 dest[2] += dstStride[2];
1539 dest[3] += dstStride[3];
1540 }
1541}
1542
1543static int rgbToPlanarRgbaWrapper(SwsInternal *c, const uint8_t *const src[],
1544 const int srcStride[], int srcSliceY, int srcSliceH,
1545 uint8_t *const dst[], const int dstStride[])
1546{
1547 int alpha_first = 0;
1548 int stride102[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
1549 int stride201[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
1550 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1551 dst[0] + srcSliceY * dstStride[0],
1552 dst[2] + srcSliceY * dstStride[2],
1553 dst[3] + srcSliceY * dstStride[3] };
1554 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1555 dst[0] + srcSliceY * dstStride[0],
1556 dst[1] + srcSliceY * dstStride[1],
1557 dst[3] + srcSliceY * dstStride[3] };
1558
1559 switch (c->opts.src_format) {
1560 case AV_PIX_FMT_RGB24:
1561 packed24togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1562 stride201, srcSliceH, c->opts.src_w);
1563 break;
1564 case AV_PIX_FMT_BGR24:
1565 packed24togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1566 stride102, srcSliceH, c->opts.src_w);
1567 break;
1568 case AV_PIX_FMT_ARGB:
1569 alpha_first = 1;
1571 case AV_PIX_FMT_RGBA:
1572 packed32togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1573 stride201, srcSliceH, alpha_first, c->opts.src_w);
1574 break;
1575 case AV_PIX_FMT_ABGR:
1576 alpha_first = 1;
1578 case AV_PIX_FMT_BGRA:
1579 packed32togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1580 stride102, srcSliceH, alpha_first, c->opts.src_w);
1581 break;
1582 default:
1584 "unsupported planar RGB conversion %s -> %s\n",
1585 av_get_pix_fmt_name(c->opts.src_format),
1586 av_get_pix_fmt_name(c->opts.dst_format));
1587 }
1588
1589 return srcSliceH;
1590}
1591
1592#define BAYER_GBRG
1593#define BAYER_8
1594#define BAYER_RENAME(x) bayer_gbrg8_to_##x
1595#include "bayer_template.c"
1596
1597#define BAYER_GBRG
1598#define BAYER_16LE
1599#define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1600#include "bayer_template.c"
1601
1602#define BAYER_GBRG
1603#define BAYER_16BE
1604#define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1605#include "bayer_template.c"
1606
1607#define BAYER_GRBG
1608#define BAYER_8
1609#define BAYER_RENAME(x) bayer_grbg8_to_##x
1610#include "bayer_template.c"
1611
1612#define BAYER_GRBG
1613#define BAYER_16LE
1614#define BAYER_RENAME(x) bayer_grbg16le_to_##x
1615#include "bayer_template.c"
1616
1617#define BAYER_GRBG
1618#define BAYER_16BE
1619#define BAYER_RENAME(x) bayer_grbg16be_to_##x
1620#include "bayer_template.c"
1621
1622#define BAYER_BGGR
1623#define BAYER_8
1624#define BAYER_RENAME(x) bayer_bggr8_to_##x
1625#include "bayer_template.c"
1626
1627#define BAYER_BGGR
1628#define BAYER_16LE
1629#define BAYER_RENAME(x) bayer_bggr16le_to_##x
1630#include "bayer_template.c"
1631
1632#define BAYER_BGGR
1633#define BAYER_16BE
1634#define BAYER_RENAME(x) bayer_bggr16be_to_##x
1635#include "bayer_template.c"
1636
1637#define BAYER_RGGB
1638#define BAYER_8
1639#define BAYER_RENAME(x) bayer_rggb8_to_##x
1640#include "bayer_template.c"
1641
1642#define BAYER_RGGB
1643#define BAYER_16LE
1644#define BAYER_RENAME(x) bayer_rggb16le_to_##x
1645#include "bayer_template.c"
1646
1647#define BAYER_RGGB
1648#define BAYER_16BE
1649#define BAYER_RENAME(x) bayer_rggb16be_to_##x
1650#include "bayer_template.c"
1651
1652static int bayer_to_rgb24_wrapper(SwsInternal *c, const uint8_t *const src[],
1653 const int srcStride[], int srcSliceY, int srcSliceH,
1654 uint8_t *const dst[], const int dstStride[])
1655{
1656 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1657 const uint8_t *srcPtr= src[0];
1658 int i;
1659 void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1660 void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1661
1662 switch(c->opts.src_format) {
1663#define CASE(pixfmt, prefix) \
1664 case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1665 interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1666 break;
1679#undef CASE
1680 default: return 0;
1681 }
1682
1683 av_assert0(srcSliceH > 1);
1684
1685 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1686 srcPtr += 2 * srcStride[0];
1687 dstPtr += 2 * dstStride[0];
1688
1689 for (i = 2; i < srcSliceH - 2; i += 2) {
1690 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1691 srcPtr += 2 * srcStride[0];
1692 dstPtr += 2 * dstStride[0];
1693 }
1694
1695 if (i + 1 == srcSliceH) {
1696 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1697 } else if (i < srcSliceH)
1698 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1699 return srcSliceH;
1700}
1701
1702static int bayer_to_rgb48_wrapper(SwsInternal *c, const uint8_t *const src[],
1703 const int srcStride[], int srcSliceY, int srcSliceH,
1704 uint8_t *const dst[], const int dstStride[])
1705{
1706 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1707 const uint8_t *srcPtr= src[0];
1708 int i;
1709 void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1710 void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1711
1712 switch(c->opts.src_format) {
1713#define CASE(pixfmt, prefix) \
1714 case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
1715 interpolate = bayer_##prefix##_to_rgb48_interpolate; \
1716 break;
1729#undef CASE
1730 default: return 0;
1731 }
1732
1733 av_assert0(srcSliceH > 1);
1734
1735 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1736 srcPtr += 2 * srcStride[0];
1737 dstPtr += 2 * dstStride[0];
1738
1739 for (i = 2; i < srcSliceH - 2; i += 2) {
1740 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1741 srcPtr += 2 * srcStride[0];
1742 dstPtr += 2 * dstStride[0];
1743 }
1744
1745 if (i + 1 == srcSliceH) {
1746 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1747 } else if (i < srcSliceH)
1748 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1749 return srcSliceH;
1750}
1751
1752static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[],
1753 const int srcStride[], int srcSliceY, int srcSliceH,
1754 uint8_t *const dst[], const int dstStride[])
1755{
1756 const uint8_t *srcPtr= src[0];
1757 uint8_t *dstY= dst[0] + srcSliceY * dstStride[0];
1758 uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1759 uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1760 int i;
1761 void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, const int32_t *rgb2yuv);
1762 void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, const int32_t *rgb2yuv);
1763
1764 switch(c->opts.src_format) {
1765#define CASE(pixfmt, prefix) \
1766 case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1767 interpolate = bayer_##prefix##_to_yv12_interpolate; \
1768 break;
1781#undef CASE
1782 default: return 0;
1783 }
1784
1785 av_assert0(srcSliceH > 1);
1786
1787 copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1788 srcPtr += 2 * srcStride[0];
1789 dstY += 2 * dstStride[0];
1790 dstU += dstStride[1];
1791 dstV += dstStride[1];
1792
1793 for (i = 2; i < srcSliceH - 2; i += 2) {
1794 interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1795 srcPtr += 2 * srcStride[0];
1796 dstY += 2 * dstStride[0];
1797 dstU += dstStride[1];
1798 dstV += dstStride[1];
1799 }
1800
1801 if (i + 1 == srcSliceH) {
1802 copy(srcPtr, -srcStride[0], dstY, dstU, dstV, -dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1803 } else if (i < srcSliceH)
1804 copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1805 return srcSliceH;
1806}
1807
1808#define isRGBA32(x) ( \
1809 (x) == AV_PIX_FMT_ARGB \
1810 || (x) == AV_PIX_FMT_RGBA \
1811 || (x) == AV_PIX_FMT_BGRA \
1812 || (x) == AV_PIX_FMT_ABGR \
1813 )
1814
1815#define isRGBA64(x) ( \
1816 (x) == AV_PIX_FMT_RGBA64LE \
1817 || (x) == AV_PIX_FMT_RGBA64BE \
1818 || (x) == AV_PIX_FMT_BGRA64LE \
1819 || (x) == AV_PIX_FMT_BGRA64BE \
1820 )
1821
1822#define isRGB48(x) ( \
1823 (x) == AV_PIX_FMT_RGB48LE \
1824 || (x) == AV_PIX_FMT_RGB48BE \
1825 || (x) == AV_PIX_FMT_BGR48LE \
1826 || (x) == AV_PIX_FMT_BGR48BE \
1827 )
1828
1829#define isAYUV(x) ( \
1830 (x) == AV_PIX_FMT_AYUV \
1831 || (x) == AV_PIX_FMT_VUYA \
1832 || (x) == AV_PIX_FMT_VUYX \
1833 || (x) == AV_PIX_FMT_UYVA \
1834 )
1835
1836#define isX2RGB(x) ( \
1837 (x) == AV_PIX_FMT_X2RGB10LE \
1838 || (x) == AV_PIX_FMT_X2BGR10LE \
1839 )
1840
1841/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1842typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1844{
1845 const enum AVPixelFormat srcFormat = c->opts.src_format;
1846 const enum AVPixelFormat dstFormat = c->opts.dst_format;
1847 const int srcId = c->srcFormatBpp;
1848 const int dstId = c->dstFormatBpp;
1849 rgbConvFn conv = NULL;
1850
1851#define IS_NOT_NE(Bpp, desc) \
1852 (Bpp == 2 && (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1853
1854#define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1855
1856 if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
1857 if ( CONV_IS(ABGR, RGBA)
1858 || CONV_IS(ARGB, BGRA)
1859 || CONV_IS(BGRA, ARGB)
1860 || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
1861 else if (CONV_IS(ABGR, ARGB)
1862 || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
1863 else if (CONV_IS(ABGR, BGRA)
1864 || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
1865 else if (CONV_IS(BGRA, RGBA)
1866 || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
1867 else if (CONV_IS(BGRA, ABGR)
1868 || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
1869 } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
1870 if (CONV_IS(RGB48LE, BGR48LE)
1871 || CONV_IS(BGR48LE, RGB48LE)
1872 || CONV_IS(RGB48BE, BGR48BE)
1873 || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
1874 else if (CONV_IS(RGB48LE, BGR48BE)
1875 || CONV_IS(BGR48LE, RGB48BE)
1876 || CONV_IS(RGB48BE, BGR48LE)
1877 || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
1878 } else if (isRGB48(srcFormat) && isRGBA64(dstFormat)) {
1879 if (CONV_IS(RGB48LE, BGRA64LE)
1880 || CONV_IS(BGR48LE, RGBA64LE)
1881 || CONV_IS(RGB48BE, BGRA64BE)
1882 || CONV_IS(BGR48BE, RGBA64BE)) conv = rgb48tobgr64_nobswap;
1883 else if (CONV_IS(RGB48LE, BGRA64BE)
1884 || CONV_IS(BGR48LE, RGBA64BE)
1885 || CONV_IS(RGB48BE, BGRA64LE)
1886 || CONV_IS(BGR48BE, RGBA64LE)) conv = rgb48tobgr64_bswap;
1887 if (CONV_IS(RGB48LE, RGBA64LE)
1888 || CONV_IS(BGR48LE, BGRA64LE)
1889 || CONV_IS(RGB48BE, RGBA64BE)
1890 || CONV_IS(BGR48BE, BGRA64BE)) conv = rgb48to64_nobswap;
1891 else if (CONV_IS(RGB48LE, RGBA64BE)
1892 || CONV_IS(BGR48LE, BGRA64BE)
1893 || CONV_IS(RGB48BE, RGBA64LE)
1894 || CONV_IS(BGR48BE, BGRA64LE)) conv = rgb48to64_bswap;
1895 } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
1896 if (CONV_IS(RGBA64LE, BGR48LE)
1897 || CONV_IS(BGRA64LE, RGB48LE)
1898 || CONV_IS(RGBA64BE, BGR48BE)
1899 || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
1900 else if (CONV_IS(RGBA64LE, BGR48BE)
1901 || CONV_IS(BGRA64LE, RGB48BE)
1902 || CONV_IS(RGBA64BE, BGR48LE)
1903 || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
1904 else if (CONV_IS(RGBA64LE, RGB48LE)
1905 || CONV_IS(BGRA64LE, BGR48LE)
1906 || CONV_IS(RGBA64BE, RGB48BE)
1907 || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
1908 else if (CONV_IS(RGBA64LE, RGB48BE)
1909 || CONV_IS(BGRA64LE, BGR48BE)
1910 || CONV_IS(RGBA64BE, RGB48LE)
1911 || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
1912 } else if (isX2RGB(srcFormat) && isRGB48(dstFormat)) {
1913 if (CONV_IS(X2RGB10LE, RGB48LE)
1914 || CONV_IS(X2BGR10LE, BGR48LE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_bswap
1916 else if (CONV_IS(X2RGB10LE, RGB48BE)
1917 || CONV_IS(X2BGR10LE, BGR48BE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_nobswap
1919 else if (CONV_IS(X2RGB10LE, BGR48LE)
1920 || CONV_IS(X2BGR10LE, RGB48LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_bswap
1922 else if (CONV_IS(X2RGB10LE, BGR48BE)
1923 || CONV_IS(X2BGR10LE, RGB48BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_nobswap
1925 } else if (isX2RGB(srcFormat) && isRGBA64(dstFormat)) {
1926 if (CONV_IS(X2RGB10LE, RGBA64LE)
1927 || CONV_IS(X2BGR10LE, BGRA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_bswap
1929 else if (CONV_IS(X2RGB10LE, RGBA64BE)
1930 || CONV_IS(X2BGR10LE, BGRA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_nobswap
1932 else if (CONV_IS(X2RGB10LE, BGRA64LE)
1933 || CONV_IS(X2BGR10LE, RGBA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_bswap
1935 else if (CONV_IS(X2RGB10LE, BGRA64BE)
1936 || CONV_IS(X2BGR10LE, RGBA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_nobswap
1938 } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) {
1939 /* VUYX only for dst, to avoid copying undefined bytes */
1940 if ( CONV_IS(AYUV, VUYA)
1941 || CONV_IS(AYUV, VUYX)
1942 || CONV_IS(VUYA, AYUV)) conv = shuffle_bytes_3210;
1943 else if (CONV_IS(AYUV, UYVA)) conv = shuffle_bytes_2130;
1944 else if (CONV_IS(VUYA, UYVA)) conv = shuffle_bytes_1203;
1945 else if (CONV_IS(UYVA, AYUV)) conv = shuffle_bytes_3102;
1946 else if (CONV_IS(UYVA, VUYA)
1947 || CONV_IS(UYVA, VUYX)) conv = shuffle_bytes_2013;
1948 } else
1949 /* BGR -> BGR */
1950 if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
1951 (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
1952 switch (srcId | (dstId << 16)) {
1953 case 0x000F000C: conv = rgb12to15; break;
1954 case 0x000F0010: conv = rgb16to15; break;
1955 case 0x000F0018: conv = rgb24to15; break;
1956 case 0x000F0020: conv = rgb32to15; break;
1957 case 0x0010000F: conv = rgb15to16; break;
1958 case 0x00100018: conv = rgb24to16; break;
1959 case 0x00100020: conv = rgb32to16; break;
1960 case 0x0018000F: conv = rgb15to24; break;
1961 case 0x00180010: conv = rgb16to24; break;
1962 case 0x00180020: conv = rgb32to24; break;
1963 case 0x0020000F: conv = rgb15to32; break;
1964 case 0x00200010: conv = rgb16to32; break;
1965 case 0x00200018: conv = rgb24to32; break;
1966 }
1967 } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
1968 (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
1969 switch (srcId | (dstId << 16)) {
1970 case 0x000C000C: conv = rgb12tobgr12; break;
1971 case 0x000F000F: conv = rgb15tobgr15; break;
1972 case 0x000F0010: conv = rgb16tobgr15; break;
1973 case 0x000F0018: conv = rgb24tobgr15; break;
1974 case 0x000F0020: conv = rgb32tobgr15; break;
1975 case 0x0010000F: conv = rgb15tobgr16; break;
1976 case 0x00100010: conv = rgb16tobgr16; break;
1977 case 0x00100018: conv = rgb24tobgr16; break;
1978 case 0x00100020: conv = rgb32tobgr16; break;
1979 case 0x0018000F: conv = rgb15tobgr24; break;
1980 case 0x00180010: conv = rgb16tobgr24; break;
1981 case 0x00180018: conv = rgb24tobgr24; break;
1982 case 0x00180020: conv = rgb32tobgr24; break;
1983 case 0x0020000F: conv = rgb15tobgr32; break;
1984 case 0x00200010: conv = rgb16tobgr32; break;
1985 case 0x00200018: conv = rgb24tobgr32; break;
1986 }
1987 }
1988
1989 if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
1990 return NULL;
1991
1992 // Maintain symmetry between endianness
1993 if (c->opts.flags & SWS_BITEXACT)
1994 if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0)
1995 return NULL;
1996
1997 return conv;
1998}
1999
2000/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
2001static int rgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[],
2002 int srcSliceY, int srcSliceH, uint8_t *const dst[],
2003 const int dstStride[])
2004
2005{
2006 const enum AVPixelFormat srcFormat = c->opts.src_format;
2007 const enum AVPixelFormat dstFormat = c->opts.dst_format;
2008 const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2009 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2010 const int srcBpp = desc_src->comp[0].step;
2011 const int dstBpp = desc_dst->comp[0].step;
2012 rgbConvFn conv = findRgbConvFn(c);
2013
2014 if (!conv) {
2015 av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
2016 av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
2017 } else {
2018 const uint8_t *srcPtr = src[0];
2019 uint8_t *dstPtr = dst[0];
2020 int src_bswap = IS_NOT_NE(srcBpp, desc_src);
2021 int dst_bswap = IS_NOT_NE(dstBpp, desc_dst);
2022
2023 if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
2024 !isRGBA32(dstFormat))
2025 srcPtr += ALT32_CORR;
2026
2027 if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
2028 !isRGBA32(srcFormat)) {
2029 int i;
2030 av_assert0(ALT32_CORR == 1);
2031 for (i = 0; i < srcSliceH; i++)
2032 dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
2033 dstPtr += ALT32_CORR;
2034 }
2035
2036 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
2037 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
2038 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
2039 (srcSliceH - 1) * srcStride[0] + c->opts.src_w * srcBpp);
2040 else {
2041 int i, j;
2042 dstPtr += dstStride[0] * srcSliceY;
2043
2044 for (i = 0; i < srcSliceH; i++) {
2045 if(src_bswap) {
2046 for(j=0; j<c->opts.src_w; j++)
2047 ((uint16_t*)c->formatConvBuffer)[j] = av_bswap16(((uint16_t*)srcPtr)[j]);
2048 conv(c->formatConvBuffer, dstPtr, c->opts.src_w * srcBpp);
2049 }else
2050 conv(srcPtr, dstPtr, c->opts.src_w * srcBpp);
2051 if(dst_bswap)
2052 for(j=0; j<c->opts.src_w; j++)
2053 ((uint16_t*)dstPtr)[j] = av_bswap16(((uint16_t*)dstPtr)[j]);
2054 srcPtr += srcStride[0];
2055 dstPtr += dstStride[0];
2056 }
2057 }
2058 }
2059 return srcSliceH;
2060}
2061
2062static int bgr24ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[],
2063 const int srcStride[], int srcSliceY, int srcSliceH,
2064 uint8_t *const dst[], const int dstStride[])
2065{
2067 src[0],
2068 dst[0] + srcSliceY * dstStride[0],
2069 dst[1] + (srcSliceY >> 1) * dstStride[1],
2070 dst[2] + (srcSliceY >> 1) * dstStride[2],
2071 c->opts.src_w, srcSliceH,
2072 dstStride[0], dstStride[1], srcStride[0],
2073 c->input_rgb2yuv_table);
2074 if (dst[3])
2075 fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
2076 return srcSliceH;
2077}
2078
2079static int yvu9ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[],
2080 const int srcStride[], int srcSliceY, int srcSliceH,
2081 uint8_t *const dst[], const int dstStride[])
2082{
2083 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
2084 dst[0], dstStride[0]);
2085
2086 planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->chrSrcW,
2087 srcSliceH >> 2, srcStride[1], dstStride[1]);
2088 planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->chrSrcW,
2089 srcSliceH >> 2, srcStride[2], dstStride[2]);
2090 if (dst[3])
2091 fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
2092 return srcSliceH;
2093}
2094
2095static int uint_y_to_float_y_wrapper(SwsInternal *c, const uint8_t *const src[],
2096 const int srcStride[], int srcSliceY,
2097 int srcSliceH, uint8_t *const dst[], const int dstStride[])
2098{
2099 int y, x;
2100 ptrdiff_t dstStrideFloat = dstStride[0] >> 2;
2101 const uint8_t *srcPtr = src[0];
2102 float *dstPtr = (float *)(dst[0] + dstStride[0] * srcSliceY);
2103
2104 for (y = 0; y < srcSliceH; ++y){
2105 for (x = 0; x < c->opts.src_w; ++x){
2106 dstPtr[x] = c->uint2float_lut[srcPtr[x]];
2107 }
2108 srcPtr += srcStride[0];
2109 dstPtr += dstStrideFloat;
2110 }
2111
2112 return srcSliceH;
2113}
2114
2116 const uint8_t *const src[],
2117 const int srcStride[], int srcSliceY,
2118 int srcSliceH, uint8_t *const dst[],
2119 const int dstStride[])
2120{
2121 int y, x;
2122 ptrdiff_t srcStrideFloat = srcStride[0] >> 2;
2123 const float *srcPtr = (const float *)src[0];
2124 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
2125
2126 for (y = 0; y < srcSliceH; ++y){
2127 for (x = 0; x < c->opts.src_w; ++x){
2128 dstPtr[x] = av_clip_uint8(lrintf(255.0f * srcPtr[x]));
2129 }
2130 srcPtr += srcStrideFloat;
2131 dstPtr += dstStride[0];
2132 }
2133
2134 return srcSliceH;
2135}
2136
2137/* unscaled copy like stuff (assumes nearly identical formats) */
2138static int packedCopyWrapper(SwsInternal *c, const uint8_t *const src[],
2139 const int srcStride[], int srcSliceY, int srcSliceH,
2140 uint8_t *const dst[], const int dstStride[])
2141{
2142 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
2143 memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
2144 else {
2145 int i;
2146 const uint8_t *srcPtr = src[0];
2147 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
2148
2149 const int length = FFMIN(FFABS(dstStride[0]), FFABS(srcStride[0]));
2150 for (i = 0; i < srcSliceH; i++) {
2151 memcpy(dstPtr, srcPtr, length);
2152 srcPtr += srcStride[0];
2153 dstPtr += dstStride[0];
2154 }
2155 }
2156 return srcSliceH;
2157}
2158
2159#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
2160 unsigned shift= src_depth-dst_depth, tmp;\
2161 unsigned bias = 1 << (shift - 1);\
2162 if (c->opts.dither == SWS_DITHER_NONE) {\
2163 for (i = 0; i < height; i++) {\
2164 for (j = 0; j < length-7; j+=8) {\
2165 tmp = ((bswap(src[j+0]) >> src_shift) + bias)>>shift; dst[j+0] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2166 tmp = ((bswap(src[j+1]) >> src_shift) + bias)>>shift; dst[j+1] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2167 tmp = ((bswap(src[j+2]) >> src_shift) + bias)>>shift; dst[j+2] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2168 tmp = ((bswap(src[j+3]) >> src_shift) + bias)>>shift; dst[j+3] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2169 tmp = ((bswap(src[j+4]) >> src_shift) + bias)>>shift; dst[j+4] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2170 tmp = ((bswap(src[j+5]) >> src_shift) + bias)>>shift; dst[j+5] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2171 tmp = ((bswap(src[j+6]) >> src_shift) + bias)>>shift; dst[j+6] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2172 tmp = ((bswap(src[j+7]) >> src_shift) + bias)>>shift; dst[j+7] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2173 }\
2174 for (; j < length; j++) {\
2175 tmp = (bswap(src[j]) + bias)>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth) << dst_shift);\
2176 }\
2177 dst += dstStride;\
2178 src += srcStride;\
2179 }\
2180 } else if (shiftonly) {\
2181 for (i = 0; i < height; i++) {\
2182 const uint8_t *dither= dithers[shift-1][i&7];\
2183 for (j = 0; j < length-7; j+=8) {\
2184 tmp = ((bswap(src[j+0]) >> src_shift) + dither[0])>>shift; dst[j+0] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2185 tmp = ((bswap(src[j+1]) >> src_shift) + dither[1])>>shift; dst[j+1] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2186 tmp = ((bswap(src[j+2]) >> src_shift) + dither[2])>>shift; dst[j+2] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2187 tmp = ((bswap(src[j+3]) >> src_shift) + dither[3])>>shift; dst[j+3] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2188 tmp = ((bswap(src[j+4]) >> src_shift) + dither[4])>>shift; dst[j+4] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2189 tmp = ((bswap(src[j+5]) >> src_shift) + dither[5])>>shift; dst[j+5] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2190 tmp = ((bswap(src[j+6]) >> src_shift) + dither[6])>>shift; dst[j+6] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2191 tmp = ((bswap(src[j+7]) >> src_shift) + dither[7])>>shift; dst[j+7] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2192 }\
2193 for (; j < length; j++) {\
2194 tmp = (bswap(src[j]) + dither[j&7])>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth) << dst_shift);\
2195 }\
2196 dst += dstStride;\
2197 src += srcStride;\
2198 }\
2199 } else {\
2200 for (i = 0; i < height; i++) {\
2201 const uint8_t *dither= dithers[shift-1][i&7];\
2202 for (j = 0; j < length-7; j+=8) {\
2203 tmp = bswap(src[j+0]) >> src_shift; dst[j+0] = dbswap(((tmp - (tmp>>dst_depth) + dither[0])>>shift) << dst_shift);\
2204 tmp = bswap(src[j+1]) >> src_shift; dst[j+1] = dbswap(((tmp - (tmp>>dst_depth) + dither[1])>>shift) << dst_shift);\
2205 tmp = bswap(src[j+2]) >> src_shift; dst[j+2] = dbswap(((tmp - (tmp>>dst_depth) + dither[2])>>shift) << dst_shift);\
2206 tmp = bswap(src[j+3]) >> src_shift; dst[j+3] = dbswap(((tmp - (tmp>>dst_depth) + dither[3])>>shift) << dst_shift);\
2207 tmp = bswap(src[j+4]) >> src_shift; dst[j+4] = dbswap(((tmp - (tmp>>dst_depth) + dither[4])>>shift) << dst_shift);\
2208 tmp = bswap(src[j+5]) >> src_shift; dst[j+5] = dbswap(((tmp - (tmp>>dst_depth) + dither[5])>>shift) << dst_shift);\
2209 tmp = bswap(src[j+6]) >> src_shift; dst[j+6] = dbswap(((tmp - (tmp>>dst_depth) + dither[6])>>shift) << dst_shift);\
2210 tmp = bswap(src[j+7]) >> src_shift; dst[j+7] = dbswap(((tmp - (tmp>>dst_depth) + dither[7])>>shift) << dst_shift);\
2211 }\
2212 for (; j < length; j++) {\
2213 tmp = bswap(src[j]); dst[j] = dbswap((tmp - (tmp>>dst_depth) + dither[j&7])>>shift);\
2214 }\
2215 dst += dstStride;\
2216 src += srcStride;\
2217 }\
2218 }
2219
2220static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[],
2221 const int srcStride[], int srcSliceY, int srcSliceH,
2222 uint8_t *const dst[], const int dstStride[])
2223{
2224 const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2225 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2226 int plane, i, j;
2227 for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
2228 int length = (plane == 0 || plane == 3) ? c->opts.src_w : AV_CEIL_RSHIFT(c->opts.src_w, c->chrDstHSubSample);
2229 int y = (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
2230 int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
2231 const uint8_t *srcPtr = src[plane];
2232 uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
2233 int shiftonly = plane == 1 || plane == 2 || (!c->opts.src_range && plane == 0);
2234 if (plane == 1 && isSemiPlanarYUV(c->opts.dst_format))
2235 length *= 2;
2236
2237 // ignore palette for GRAY8
2238 if (plane == 1 && desc_dst->nb_components < 3) continue;
2239 if (!src[plane] || (plane == 1 && desc_src->nb_components < 3) || (plane == 3 && desc_src->nb_components <= 3)) {
2240 if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
2241 fillPlane16(dst[plane], dstStride[plane], length, height, y,
2242 plane == 3, desc_dst->comp[plane].depth,
2243 isBE(c->opts.dst_format));
2244 } else {
2245 fillPlane(dst[plane], dstStride[plane], length, height, y,
2246 (plane == 3) ? 255 : 128);
2247 }
2248 } else {
2249 if(isNBPS(c->opts.src_format) || isNBPS(c->opts.dst_format)
2250 || (is16BPS(c->opts.src_format) != is16BPS(c->opts.dst_format))
2251 ) {
2252 const int src_depth = desc_src->comp[plane].depth;
2253 const int dst_depth = desc_dst->comp[plane].depth;
2254 const int src_shift = desc_src->comp[plane].shift;
2255 const int dst_shift = desc_dst->comp[plane].shift;
2256 const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
2257 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
2258
2259 if (dst_depth == 8) {
2260 av_assert1(src_depth > 8);
2261 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2262 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
2263 } else {
2264 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
2265 }
2266 } else if (src_depth == 8) {
2267 for (i = 0; i < height; i++) {
2268 #define COPY816(w)\
2269 if (shiftonly) {\
2270 for (j = 0; j < length; j++)\
2271 w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) << dst_shift);\
2272 } else {\
2273 for (j = 0; j < length; j++)\
2274 w(&dstPtr2[j], ((srcPtr[j]<<(dst_depth-8)) |\
2275 (srcPtr[j]>>(2*8-dst_depth))) << dst_shift);\
2276 }
2277 if(isBE(c->opts.dst_format)){
2279 } else {
2281 }
2282 dstPtr2 += dstStride[plane]/2;
2283 srcPtr += srcStride[plane];
2284 }
2285 } else if (src_depth <= dst_depth) {
2286 unsigned shift = dst_depth - src_depth;
2287 for (i = 0; i < height; i++) {
2288 j = 0;
2289 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN &&
2290 isBE(c->opts.dst_format) == HAVE_BIGENDIAN &&
2291 shiftonly) {
2292#if HAVE_FAST_64BIT
2293 for (; j < length - 3; j += 4) {
2294 uint64_t v = AV_RN64A(srcPtr2 + j) >> src_shift;
2295 AV_WN64A(dstPtr2 + j, (v << shift) << dst_shift);
2296 }
2297#else
2298 for (; j < length - 1; j += 2) {
2299 uint32_t v = AV_RN32A(srcPtr2 + j) >> src_shift;
2300 AV_WN32A(dstPtr2 + j, (v << shift) << dst_shift);
2301 }
2302#endif
2303 }
2304#define COPY_UP(r,w) \
2305 if(shiftonly){\
2306 for (; j < length; j++){ \
2307 unsigned int v= r(&srcPtr2[j]) >> src_shift;\
2308 w(&dstPtr2[j], (v << shift) << dst_shift);\
2309 }\
2310 }else{\
2311 for (; j < length; j++){ \
2312 unsigned int v= r(&srcPtr2[j]) >> src_shift;\
2313 w(&dstPtr2[j], ((v << shift) | (v>>(2*src_depth-dst_depth))) << dst_shift);\
2314 }\
2315 }
2316 if(isBE(c->opts.src_format)){
2317 if(isBE(c->opts.dst_format)){
2319 } else {
2321 }
2322 } else {
2323 if(isBE(c->opts.dst_format)){
2325 } else {
2327 }
2328 }
2329 dstPtr2 += dstStride[plane]/2;
2330 srcPtr2 += srcStride[plane]/2;
2331 }
2332 } else { /* src_depth > dst_depth */
2333 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2334 if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2335 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
2336 } else {
2337 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
2338 }
2339 }else{
2340 if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2341 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
2342 } else {
2343 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
2344 }
2345 }
2346 }
2347 } else if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format) &&
2348 isBE(c->opts.src_format) != isBE(c->opts.dst_format)) {
2349
2350 for (i = 0; i < height; i++) {
2351 for (j = 0; j < length; j++)
2352 ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
2353 srcPtr += srcStride[plane];
2354 dstPtr += dstStride[plane];
2355 }
2356 } else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format) &&
2357 isBE(c->opts.src_format) != isBE(c->opts.dst_format)) { /* swap float plane */
2358 for (i = 0; i < height; i++) {
2359 for (j = 0; j < length; j++)
2360 ((uint32_t *) dstPtr)[j] = av_bswap32(((const uint32_t *) srcPtr)[j]);
2361 srcPtr += srcStride[plane];
2362 dstPtr += dstStride[plane];
2363 }
2364 } else if (dstStride[plane] == srcStride[plane] &&
2365 srcStride[plane] > 0 && srcStride[plane] == length) {
2366 memcpy(dst[plane] + dstStride[plane] * y, src[plane],
2367 height * dstStride[plane]);
2368 } else {
2369 if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format))
2370 length *= 2;
2371 else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format))
2372 length *= 4;
2373 else if (desc_src->comp[0].depth == 1)
2374 length >>= 3; // monowhite/black
2375 for (i = 0; i < height; i++) {
2376 memcpy(dstPtr, srcPtr, length);
2377 srcPtr += srcStride[plane];
2378 dstPtr += dstStride[plane];
2379 }
2380 }
2381 }
2382 }
2383 return srcSliceH;
2384}
2385
2386
2387#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
2388 ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
2389 (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
2390
2391
2393{
2394 const enum AVPixelFormat srcFormat = c->opts.src_format;
2395 const enum AVPixelFormat dstFormat = c->opts.dst_format;
2396 const int flags = c->opts.flags;
2397 const int dstH = c->opts.dst_h;
2398 const int dstW = c->opts.dst_w;
2399 int needsDither;
2400
2401 needsDither = isAnyRGB(dstFormat) &&
2402 c->dstFormatBpp < 24 &&
2403 (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
2404
2405 /* yv12_to_nv12 */
2406 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2407 (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
2408 c->convert_unscaled = planarToNv12Wrapper;
2409 }
2410 /* yv24_to_nv24 */
2411 if ((srcFormat == AV_PIX_FMT_YUV444P || srcFormat == AV_PIX_FMT_YUVA444P) &&
2412 (dstFormat == AV_PIX_FMT_NV24 || dstFormat == AV_PIX_FMT_NV42)) {
2413 c->convert_unscaled = planarToNv24Wrapper;
2414 }
2415 /* nv12_to_yv12 */
2416 if (dstFormat == AV_PIX_FMT_YUV420P &&
2417 (srcFormat == AV_PIX_FMT_NV12 || srcFormat == AV_PIX_FMT_NV21)) {
2418 c->convert_unscaled = nv12ToPlanarWrapper;
2419 }
2420 /* nv24_to_yv24 */
2421 if (dstFormat == AV_PIX_FMT_YUV444P &&
2422 (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42)) {
2423 c->convert_unscaled = nv24ToPlanarWrapper;
2424 }
2425 /* yuv2bgr */
2426 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
2427 srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
2428 !(flags & SWS_ACCURATE_RND) && (c->opts.dither == SWS_DITHER_BAYER || c->opts.dither == SWS_DITHER_AUTO) && !(dstH & 1)) {
2429 c->convert_unscaled = ff_yuv2rgb_get_func_ptr(c);
2430 c->dst_slice_align = 2;
2431 }
2432 /* yuv420p1x_to_p01x */
2433 if ((srcFormat == AV_PIX_FMT_YUV420P10 || srcFormat == AV_PIX_FMT_YUVA420P10 ||
2434 srcFormat == AV_PIX_FMT_YUV420P12 ||
2435 srcFormat == AV_PIX_FMT_YUV420P14 ||
2436 srcFormat == AV_PIX_FMT_YUV420P16 || srcFormat == AV_PIX_FMT_YUVA420P16) &&
2437 (dstFormat == AV_PIX_FMT_P010 || dstFormat == AV_PIX_FMT_P016)) {
2438 c->convert_unscaled = planarToP01xWrapper;
2439 }
2440 /* yuv420p_to_p01xle */
2441 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2442 (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P016LE)) {
2443 c->convert_unscaled = planar8ToP01xleWrapper;
2444 }
2445
2446 if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) &&
2447 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2448 !(flags & SWS_BITEXACT)) {
2449 c->convert_unscaled = yvu9ToYv12Wrapper;
2450 c->dst_slice_align = 4;
2451 }
2452
2453 /* bgr24toYV12 */
2454 if (srcFormat == AV_PIX_FMT_BGR24 &&
2455 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2456 !(flags & SWS_ACCURATE_RND) && !(dstW&1))
2457 c->convert_unscaled = bgr24ToYv12Wrapper;
2458
2459 /* AYUV/VUYA/UYVA -> AYUV/VUYA/UYVA */
2460 if (isAYUV(srcFormat) && isAYUV(dstFormat) && findRgbConvFn(c))
2461 c->convert_unscaled = rgbToRgbWrapper;
2462
2463 /* RGB/BGR -> RGB/BGR (no dither needed forms) */
2464 if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
2465 && (!needsDither || (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT))))
2466 c->convert_unscaled = rgbToRgbWrapper;
2467
2468 /* RGB to planar RGB */
2469 if ((srcFormat == AV_PIX_FMT_GBRP && dstFormat == AV_PIX_FMT_GBRAP) ||
2470 (srcFormat == AV_PIX_FMT_GBRP10 && dstFormat == AV_PIX_FMT_GBRAP10) ||
2471 (srcFormat == AV_PIX_FMT_GBRP12 && dstFormat == AV_PIX_FMT_GBRAP12) ||
2472 (srcFormat == AV_PIX_FMT_GBRP14 && dstFormat == AV_PIX_FMT_GBRAP14) ||
2473 (srcFormat == AV_PIX_FMT_GBRP16 && dstFormat == AV_PIX_FMT_GBRAP16) ||
2474 (srcFormat == AV_PIX_FMT_GBRAP && dstFormat == AV_PIX_FMT_GBRP) ||
2475 (srcFormat == AV_PIX_FMT_GBRAP10 && dstFormat == AV_PIX_FMT_GBRP10) ||
2476 (srcFormat == AV_PIX_FMT_GBRAP12 && dstFormat == AV_PIX_FMT_GBRP12) ||
2477 (srcFormat == AV_PIX_FMT_GBRAP14 && dstFormat == AV_PIX_FMT_GBRP14) ||
2478 (srcFormat == AV_PIX_FMT_GBRAP16 && dstFormat == AV_PIX_FMT_GBRP16))
2479 c->convert_unscaled = planarRgbToplanarRgbWrapper;
2480
2481#define isByteRGB(f) ( \
2482 f == AV_PIX_FMT_RGB32 || \
2483 f == AV_PIX_FMT_RGB32_1 || \
2484 f == AV_PIX_FMT_RGB24 || \
2485 f == AV_PIX_FMT_BGR32 || \
2486 f == AV_PIX_FMT_BGR32_1 || \
2487 f == AV_PIX_FMT_BGR24)
2488
2489 if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
2490 c->convert_unscaled = planarRgbToRgbWrapper;
2491
2492 if (srcFormat == AV_PIX_FMT_GBRAP && isByteRGB(dstFormat))
2493 c->convert_unscaled = planarRgbaToRgbWrapper;
2494
2495 if ((srcFormat == AV_PIX_FMT_RGB48LE || srcFormat == AV_PIX_FMT_RGB48BE ||
2496 srcFormat == AV_PIX_FMT_BGR48LE || srcFormat == AV_PIX_FMT_BGR48BE ||
2497 srcFormat == AV_PIX_FMT_RGBA64LE || srcFormat == AV_PIX_FMT_RGBA64BE ||
2498 srcFormat == AV_PIX_FMT_BGRA64LE || srcFormat == AV_PIX_FMT_BGRA64BE) &&
2499 (dstFormat == AV_PIX_FMT_GBRP9LE || dstFormat == AV_PIX_FMT_GBRP9BE ||
2500 dstFormat == AV_PIX_FMT_GBRP10LE || dstFormat == AV_PIX_FMT_GBRP10BE ||
2501 dstFormat == AV_PIX_FMT_GBRP12LE || dstFormat == AV_PIX_FMT_GBRP12BE ||
2502 dstFormat == AV_PIX_FMT_GBRP14LE || dstFormat == AV_PIX_FMT_GBRP14BE ||
2503 dstFormat == AV_PIX_FMT_GBRP16LE || dstFormat == AV_PIX_FMT_GBRP16BE ||
2504 dstFormat == AV_PIX_FMT_GBRAP10LE || dstFormat == AV_PIX_FMT_GBRAP10BE ||
2505 dstFormat == AV_PIX_FMT_GBRAP12LE || dstFormat == AV_PIX_FMT_GBRAP12BE ||
2506 dstFormat == AV_PIX_FMT_GBRAP14LE || dstFormat == AV_PIX_FMT_GBRAP14BE ||
2507 dstFormat == AV_PIX_FMT_GBRAP16LE || dstFormat == AV_PIX_FMT_GBRAP16BE ))
2508 c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2509
2510 if (av_pix_fmt_desc_get(dstFormat)->comp[0].depth >= 10 &&
2511 isPlanarRGB(dstFormat) && !isFloat(dstFormat) &&
2512 (srcFormat == AV_PIX_FMT_X2RGB10LE || srcFormat == AV_PIX_FMT_X2BGR10LE))
2513 c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2514
2515 if ((srcFormat == AV_PIX_FMT_GBRP9LE || srcFormat == AV_PIX_FMT_GBRP9BE ||
2516 srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
2517 srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
2518 srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
2519 srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
2520 srcFormat == AV_PIX_FMT_GBRAP10LE || srcFormat == AV_PIX_FMT_GBRAP10BE ||
2521 srcFormat == AV_PIX_FMT_GBRAP12LE || srcFormat == AV_PIX_FMT_GBRAP12BE ||
2522 srcFormat == AV_PIX_FMT_GBRAP14LE || srcFormat == AV_PIX_FMT_GBRAP14BE ||
2523 srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
2524 (dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE ||
2525 dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
2526 dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
2527 dstFormat == AV_PIX_FMT_BGRA64LE || dstFormat == AV_PIX_FMT_BGRA64BE))
2528 c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2529
2530 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth >= 10 &&
2531 isPlanarRGB(srcFormat) && !isFloat(srcFormat) &&
2532 (dstFormat == AV_PIX_FMT_X2RGB10LE || dstFormat == AV_PIX_FMT_X2BGR10LE))
2533 c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2534
2535 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2536 isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
2537 c->convert_unscaled = rgbToPlanarRgbWrapper;
2538
2539 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2540 isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRAP)
2541 c->convert_unscaled = rgbToPlanarRgbaWrapper;
2542
2543 if (isBayer(srcFormat)) {
2544 c->dst_slice_align = 2;
2545 if (dstFormat == AV_PIX_FMT_RGB24)
2546 c->convert_unscaled = bayer_to_rgb24_wrapper;
2547 else if (dstFormat == AV_PIX_FMT_RGB48)
2548 c->convert_unscaled = bayer_to_rgb48_wrapper;
2549 else if (dstFormat == AV_PIX_FMT_YUV420P)
2550 c->convert_unscaled = bayer_to_yv12_wrapper;
2551 else if (!isBayer(dstFormat)) {
2552 av_log(c, AV_LOG_ERROR, "unsupported bayer conversion\n");
2553 av_assert0(0);
2554 }
2555 }
2556
2557 /* bswap 16 bits per pixel/component packed formats */
2558 if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_BGGR16) ||
2559 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_RGGB16) ||
2560 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GBRG16) ||
2561 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GRBG16) ||
2562 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
2563 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
2564 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
2565 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
2566 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
2567 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY9) ||
2568 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY10) ||
2569 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY12) ||
2570 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY14) ||
2571 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
2572 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16) ||
2573 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_AYUV64) ||
2574 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP9) ||
2575 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10) ||
2576 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) ||
2577 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP14) ||
2578 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP16) ||
2579 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10MSB) ||
2580 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12MSB) ||
2581 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP10) ||
2582 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP12) ||
2583 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP14) ||
2584 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) ||
2585 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
2586 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
2587 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
2588 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565) ||
2589 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
2590 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV36) ||
2591 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV48) ||
2592 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XYZ12) ||
2593 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P9) ||
2594 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P10) ||
2595 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P12) ||
2596 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P14) ||
2597 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P16) ||
2598 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P9) ||
2599 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P10) ||
2600 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P12) ||
2601 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P14) ||
2602 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P16) ||
2603 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P10) ||
2604 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P12) ||
2605 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P9) ||
2606 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10) ||
2607 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12) ||
2608 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P14) ||
2609 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P16) ||
2610 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10MSB) ||
2611 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12MSB))
2612 c->convert_unscaled = bswap_16bpc;
2613
2614 /* bswap 32 bits per pixel/component formats */
2615 if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRPF32) ||
2616 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAPF32))
2617 c->convert_unscaled = bswap_32bpc;
2618
2619 if (usePal(srcFormat)) {
2620 switch (dstFormat) {
2621 case AV_PIX_FMT_GBRP:
2622 case AV_PIX_FMT_GBRAP:
2623 c->convert_unscaled = palToGbrpWrapper;
2624 break;
2625 default:
2626 if (isByteRGB(dstFormat))
2627 c->convert_unscaled = palToRgbWrapper;
2628 break;
2629 }
2630 }
2631
2632 if (srcFormat == AV_PIX_FMT_YUV422P) {
2633 if (dstFormat == AV_PIX_FMT_YUYV422)
2634 c->convert_unscaled = yuv422pToYuy2Wrapper;
2635 else if (dstFormat == AV_PIX_FMT_UYVY422)
2636 c->convert_unscaled = yuv422pToUyvyWrapper;
2637 }
2638
2639 /* uint Y to float Y */
2640 if (srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32){
2641 c->convert_unscaled = uint_y_to_float_y_wrapper;
2642 }
2643
2644 /* float Y to uint Y */
2645 if (srcFormat == AV_PIX_FMT_GRAYF32 && dstFormat == AV_PIX_FMT_GRAY8){
2646 c->convert_unscaled = float_y_to_uint_y_wrapper;
2647 }
2648
2649 /* LQ converters if -sws 0 or -sws 4*/
2650 if (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
2651 /* yv12_to_yuy2 */
2652 if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
2653 if (dstFormat == AV_PIX_FMT_YUYV422)
2654 c->convert_unscaled = planarToYuy2Wrapper;
2655 else if (dstFormat == AV_PIX_FMT_UYVY422)
2656 c->convert_unscaled = planarToUyvyWrapper;
2657 }
2658 }
2659 if (srcFormat == AV_PIX_FMT_YUYV422 &&
2660 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2661 c->convert_unscaled = yuyvToYuv420Wrapper;
2662 if (srcFormat == AV_PIX_FMT_UYVY422 &&
2663 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2664 c->convert_unscaled = uyvyToYuv420Wrapper;
2665 if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
2666 c->convert_unscaled = yuyvToYuv422Wrapper;
2667 if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
2668 c->convert_unscaled = uyvyToYuv422Wrapper;
2669 if (dstFormat == AV_PIX_FMT_YUV420P &&
2670 (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42))
2671 c->convert_unscaled = nv24ToYuv420Wrapper;
2672
2673#define isPlanarGray(x) (isGray(x) && !isALPHA(x))
2674
2675 /* simple copy */
2676 if ( srcFormat == dstFormat ||
2677 (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
2678 (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
2679 (isFloat(srcFormat) == isFloat(dstFormat) && isFloat16(srcFormat) == isFloat16(dstFormat)) && ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
2680 (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
2681 (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
2682 (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
2683 c->chrDstHSubSample == c->chrSrcHSubSample &&
2684 c->chrDstVSubSample == c->chrSrcVSubSample &&
2685 isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) &&
2686 isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat))))
2687 {
2688 if (isPacked(c->opts.src_format)) {
2689 c->convert_unscaled = packedCopyWrapper;
2690 } else { /* Planar YUV or gray */
2691 c->convert_unscaled = planarCopyWrapper;
2692 if (c->opts.dither != SWS_DITHER_NONE)
2693 c->dst_slice_align = 8 << c->chrDstVSubSample;
2694 }
2695 }
2696
2698
2699#if ARCH_PPC
2701#elif ARCH_ARM
2703#elif ARCH_AARCH64
2705#endif
2706}
2707
2708/* Convert the palette to the same packed 32-bit format as the palette */
2709void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst,
2710 int num_pixels, const uint8_t *palette)
2711{
2712 int i;
2713
2714 for (i = 0; i < num_pixels; i++)
2715 ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
2716}
2717
2718/* Palette format: ABCD -> dst format: ABC */
2719void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst,
2720 int num_pixels, const uint8_t *palette)
2721{
2722 int i;
2723
2724 for (i = 0; i < num_pixels; i++) {
2725 //FIXME slow?
2726 dst[0] = palette[src[i] * 4 + 0];
2727 dst[1] = palette[src[i] * 4 + 1];
2728 dst[2] = palette[src[i] * 4 + 2];
2729 dst += 3;
2730 }
2731}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
void ff_get_unscaled_swscale_aarch64(SwsInternal *c)
static double val(void *priv, double ch)
Definition aeval.c:77
void ff_get_unscaled_swscale_arm(SwsInternal *c)
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Convenience header that includes libavutil's core.
byte swapping routines
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static void fn rgb2yuv(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t s, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define av_clip_uint8
Definition common.h:106
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define NULL
Definition coverity.c:32
#define RGBA(r, g, b, a)
Definition dvbsubdec.c:42
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition eamad.c:79
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
@ SWS_DITHER_AUTO
Definition swscale.h:79
@ SWS_DITHER_BAYER
Definition swscale.h:80
@ SWS_DITHER_NONE
Definition swscale.h:78
@ SWS_BITEXACT
Definition swscale.h:178
@ SWS_FAST_BILINEAR
Scaler selection options.
Definition swscale.h:197
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition swscale.h:177
@ SWS_POINT
nearest neighbor
Definition swscale.h:201
const pixel * src2
static const int16_t alpha[]
Definition ilbcdata.h:55
#define AV_WL32(p, v)
#define AV_RL32(p)
#define AV_WN32A(p, v)
#define AV_RN32A(p)
#define AV_RL16(p)
#define AV_WB16(p, v)
#define AV_WL16(p, v)
#define AV_WN64A(p, v)
#define AV_RB16(p)
#define AV_RN64A(p)
static int shift(int a, int b)
Definition bonk.c:261
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define lrintf(x)
Definition libm_mips.h:72
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define C1
#define C2
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition pixdesc.c:3380
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition pixdesc.h:147
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition pixdesc.h:136
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition pixdesc.h:132
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition pixdesc.h:116
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:569
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:556
#define AV_PIX_FMT_GBRPF32
Definition pixfmt.h:584
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:551
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:571
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:563
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:543
#define AV_PIX_FMT_BGR444
Definition pixfmt.h:539
#define AV_PIX_FMT_BGR555
Definition pixfmt.h:538
#define AV_PIX_FMT_BGR48
Definition pixfmt.h:536
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:601
#define AV_PIX_FMT_YA16
Definition pixfmt.h:530
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:549
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:596
#define AV_PIX_FMT_BAYER_GRBG16
Definition pixfmt.h:580
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:550
#define AV_PIX_FMT_XYZ12
Definition pixfmt.h:605
#define AV_PIX_FMT_GBRAP14
Definition pixfmt.h:570
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
#define AV_PIX_FMT_P016
Definition pixfmt.h:610
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:564
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV444P12MSB
Definition pixfmt.h:561
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:526
#define AV_PIX_FMT_BAYER_BGGR16
Definition pixfmt.h:577
#define AV_PIX_FMT_RGBA64
Definition pixfmt.h:535
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:565
#define AV_PIX_FMT_BGR32
Definition pixfmt.h:519
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:542
#define AV_PIX_FMT_RGB48
Definition pixfmt.h:531
#define AV_PIX_FMT_BAYER_RGGB16
Definition pixfmt.h:578
#define AV_PIX_FMT_GRAYF32
Definition pixfmt.h:588
#define AV_PIX_FMT_XV48
Definition pixfmt.h:617
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:553
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
Definition pixfmt.h:287
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_P010LE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
Definition pixfmt.h:307
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
Definition pixfmt.h:169
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition pixfmt.h:372
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition pixfmt.h:97
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
Definition pixfmt.h:168
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_BAYER_GRBG16LE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
Definition pixfmt.h:295
@ AV_PIX_FMT_P016LE
like NV12, with 16bpp per component, little-endian
Definition pixfmt.h:323
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
Definition pixfmt.h:279
@ AV_PIX_FMT_GBRAP12BE
planar GBR 4:4:4:4 48bpp, big-endian
Definition pixfmt.h:310
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_X2BGR10LE
packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
Definition pixfmt.h:386
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_BGR48BE
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:145
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition pixfmt.h:88
@ AV_PIX_FMT_RGB48BE
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:109
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_RGBA64BE
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:202
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:371
@ AV_PIX_FMT_GBRAP14BE
planar GBR 4:4:4:4 56bpp, big-endian
Definition pixfmt.h:432
@ AV_PIX_FMT_RGBA64LE
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:203
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
Definition pixfmt.h:213
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
Definition pixfmt.h:291
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
Definition pixfmt.h:288
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
Definition pixfmt.h:280
@ AV_PIX_FMT_BGRA64BE
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:204
@ AV_PIX_FMT_BAYER_BGGR16BE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian
Definition pixfmt.h:290
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition pixfmt.h:171
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
Definition pixfmt.h:311
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
Definition pixfmt.h:167
@ AV_PIX_FMT_RGB48LE
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:110
@ AV_PIX_FMT_BAYER_RGGB16BE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian
Definition pixfmt.h:292
@ AV_PIX_FMT_X2RGB10LE
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined
Definition pixfmt.h:384
@ AV_PIX_FMT_GBRAP14LE
planar GBR 4:4:4:4 56bpp, little-endian
Definition pixfmt.h:433
@ AV_PIX_FMT_BGR48LE
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:146
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
Definition pixfmt.h:282
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
Definition pixfmt.h:170
@ AV_PIX_FMT_GBRAP10BE
planar GBR 4:4:4:4 40bpp, big-endian
Definition pixfmt.h:313
@ AV_PIX_FMT_BAYER_GRBG16BE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian
Definition pixfmt.h:296
@ AV_PIX_FMT_BGRA64LE
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:205
@ AV_PIX_FMT_GBRAP10LE
planar GBR 4:4:4:4 40bpp, little-endian
Definition pixfmt.h:314
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition pixfmt.h:74
@ AV_PIX_FMT_BAYER_GBRG16LE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian
Definition pixfmt.h:293
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
Definition pixfmt.h:214
@ AV_PIX_FMT_BAYER_BGGR16LE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian
Definition pixfmt.h:289
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition pixfmt.h:140
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
Definition pixfmt.h:281
@ AV_PIX_FMT_BAYER_GBRG16BE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian
Definition pixfmt.h:294
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
Definition pixfmt.h:286
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
Definition pixfmt.h:172
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
Definition pixfmt.h:285
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:554
#define AV_PIX_FMT_RGB32_1
Definition pixfmt.h:518
#define AV_PIX_FMT_BGR32_1
Definition pixfmt.h:520
#define AV_PIX_FMT_BGR565
Definition pixfmt.h:537
#define AV_PIX_FMT_BAYER_GBRG16
Definition pixfmt.h:579
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GBRP12MSB
Definition pixfmt.h:575
#define AV_PIX_FMT_RGB565
Definition pixfmt.h:532
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:557
#define AV_PIX_FMT_BGRA64
Definition pixfmt.h:540
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:547
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:568
#define AV_PIX_FMT_RGB444
Definition pixfmt.h:534
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_XV36
Definition pixfmt.h:616
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:566
#define AV_PIX_FMT_GBRP10MSB
Definition pixfmt.h:574
#define AV_PIX_FMT_GBRAPF32
Definition pixfmt.h:585
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10MSB
Definition pixfmt.h:560
#define AV_PIX_FMT_AYUV64
Definition pixfmt.h:607
#define AV_PIX_FMT_RGB32
Definition pixfmt.h:517
#define AV_PIX_FMT_RGB555
Definition pixfmt.h:533
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548
void(* yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
Definition rgb2rgb.c:77
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:47
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:38
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:46
void(* shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:60
void(* ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, const int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
Definition rgb2rgb.c:81
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:311
void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:141
void(* shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:59
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:48
void(* uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition rgb2rgb.c:94
void(* yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
Definition rgb2rgb.c:65
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:244
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:40
void(* shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:61
void(* yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
Definition rgb2rgb.c:73
void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:276
void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:300
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:254
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:58
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:234
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:57
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:42
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:37
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:55
void(* shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:62
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:49
void(* yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
Definition rgb2rgb.c:69
void(* yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition rgb2rgb.c:100
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:36
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:179
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
Definition rgb2rgb.c:88
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:56
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:159
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:35
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:41
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:50
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:51
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)
Definition rgb2rgb.c:86
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
Definition rgb2rgb.c:91
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:52
void(* yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition rgb2rgb.c:103
void(* uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition rgb2rgb.c:97
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:45
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:43
void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:220
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:39
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:201
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:290
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
Definition rgb2rgb.c:54
void rgb48to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void x2rgb10to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
#define av_bswap32
Definition bswap.h:47
#define av_bswap16
Definition bswap.h:28
#define C0
int shift
Number of least significant bits that must be shifted away to get the value.
Definition pixdesc.h:52
int step
Number of elements between 2 horizontally consecutive pixels.
Definition pixdesc.h:40
int depth
Number of bits in the component.
Definition pixdesc.h:57
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
const char * name
Definition pixdesc.h:70
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition pixdesc.h:105
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
Definition pixdesc.h:94
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition pixdesc.h:71
Definition rpzaenc.c:60
#define stride
av_cold void ff_sws_init_xyzdsp(SwsInternal *c)
Definition swscale.c:863
external API header
static av_always_inline int isBGRinInt(enum AVPixelFormat pix_fmt)
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
static void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian)
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
static av_always_inline int isSwappedChroma(enum AVPixelFormat pix_fmt)
static av_always_inline int isFloat(enum AVPixelFormat pix_fmt)
#define ALT32_CORR
SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c)
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
void ff_copyPlane(const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
static av_always_inline int isRGBinInt(enum AVPixelFormat pix_fmt)
static av_always_inline int isFloat16(enum AVPixelFormat pix_fmt)
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
static void packed32togbrap(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int alpha_first, int width)
static void packedtogbr24p(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int alpha_first, int inc_size, int width)
static int float_y_to_uint_y_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static rgbConvFn findRgbConvFn(SwsInternal *c)
#define isRGBA64(x)
static void gray8aToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, uint8_t *dst2, uint8_t *dstA, int num_pixels, const uint8_t *palette)
static const uint8_t dithers[8][8][8]
static int palToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
#define CONV_IS(src, dst)
static void fillPlane(uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
static int nv24ToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
#define COPY_UP(r, w)
static void packed30togbra10(const uint8_t *src, int srcStride, uint16_t *dst[], const int dstStride[], int srcSliceH, int swap, int bpc, int shift, int width)
static int planar8ToP01xleWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam8[], const int dstStride[])
#define isByteRGB(f)
static int planarRgb16ToRgb16Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
#define isRGB48(x)
static int palToGbrpWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int yuv422pToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
#define isAYUV(x)
#define output_pixel(p, v)
static int uyvyToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int planarRgbaToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void gbr24ptopacked24(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
static int yuv422pToUyvyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static int uyvyToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int packedCopyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
#define isX2RGB(x)
static int rgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void pal8ToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, uint8_t *dst2, uint8_t *dstA, int num_pixels, const uint8_t *palette)
static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int uint_y_to_float_y_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
void ff_get_unscaled_swscale(SwsInternal *c)
Set c->convert_unscaled to an unscaled converter if one exists for the specific source and destinatio...
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
static int bgr24ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int planarRgbToplanarRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int planarToP01xWrapper(SwsInternal *c, const uint8_t *const src8[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam8[], const int dstStride[])
static int planarRgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void packed24togbrap(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int width)
static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int nv24ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
#define CASE(pixfmt, prefix)
#define isPlanarGray(x)
static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
void(* rgbConvFn)(const uint8_t *, uint8_t *, int)
static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static int yuyvToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int rgbToPlanarRgbaWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void gbr16ptopacked16(const uint16_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha, int swap, int bpp, int width)
static int nv12ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
#define isRGBA32(x)
static void gbraptopacked32(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
static int planarToUyvyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static void nv24_to_yuv420p_chroma(uint8_t *dst1, int dstStride1, uint8_t *dst2, int dstStride2, const uint8_t *src, int srcStride, int w, int h)
static int planarToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int planarToNv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int bswap_16bpc(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int rgbToPlanarRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static int yuyvToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int bswap_32bpc(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void gbr24ptopacked32(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
static int yvu9ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
#define COPY816(w)
static void packed16togbra16(const uint8_t *src, int srcStride, uint16_t *dst[], const int dstStride[], int srcSliceH, int src_alpha, int swap, int shift, int width)
#define IS_NOT_NE(Bpp, desc)
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
static int planarToNv24Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
static int bayer_to_rgb24_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static void gbr16ptopacked30(const uint16_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int swap, int shift, int width)
static int bayer_to_rgb48_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
#define av_log(a,...)
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static void interpolate(float *out, float v1, float v2, int size)
Definition twinvq.c:85
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
static void copy(const float *p1, float *p2, const int length)
static double c[64]
av_cold void ff_get_unscaled_swscale_ppc(SwsInternal *c)