FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/swscale_unscaled.c
Date: 2026-05-04 15:43:50
Exec Total Coverage
Lines: 993 1572 63.2%
Functions: 37 58 63.8%
Branches: 1445 2248 64.3%

Line Branch Exec Source
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"
26 #include "libavutil/attributes.h"
27 #include "swscale.h"
28 #include "swscale_internal.h"
29 #include "rgb2rgb.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/mathematics.h"
33 #include "libavutil/mem_internal.h"
34 #include "libavutil/bswap.h"
35 #include "libavutil/pixdesc.h"
36 #include "libavutil/avassert.h"
37 #include "libavutil/avconfig.h"
38
39 DECLARE_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
115 2450 static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
116 uint8_t val)
117 {
118 int i;
119 2450 uint8_t *ptr = plane + stride * y;
120
2/2
✓ Branch 0 taken 216000 times.
✓ Branch 1 taken 2450 times.
218450 for (i = 0; i < height; i++) {
121 216000 memset(ptr, val, width);
122 216000 ptr += stride;
123 }
124 2450 }
125
126 3214 void ff_copyPlane(const uint8_t *src, int srcStride,
127 int srcSliceY, int srcSliceH, int width,
128 uint8_t *dst, int dstStride)
129 {
130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3214 times.
3214 if (!srcSliceH)
131 return;
132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3214 times.
3214 av_assert0(srcSliceH > 0);
133
134 3214 dst += dstStride * srcSliceY;
135
3/4
✓ Branch 0 taken 2113 times.
✓ Branch 1 taken 1101 times.
✓ Branch 2 taken 2113 times.
✗ Branch 3 not taken.
3214 if (dstStride == srcStride && srcStride > 0) {
136 2113 memcpy(dst, src, (srcSliceH - 1) * dstStride + width);
137 } else {
138 int i;
139
2/2
✓ Branch 0 taken 48348 times.
✓ Branch 1 taken 1101 times.
49449 for (i = 0; i < srcSliceH; i++) {
140 48348 memcpy(dst, src, width);
141 48348 src += srcStride;
142 48348 dst += dstStride;
143 }
144 }
145 }
146
147 984 static 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 984 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
153
154 984 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
155 dstParam[0], dstStride[0]);
156
157
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 482 times.
984 if (c->opts.dst_format == AV_PIX_FMT_NV12)
158 502 interleaveBytes(src[1], src[2], dst, c->chrSrcW, (srcSliceH + 1) / 2,
159 502 srcStride[1], srcStride[2], dstStride[1]);
160 else
161 482 interleaveBytes(src[2], src[1], dst, c->chrSrcW, (srcSliceH + 1) / 2,
162 482 srcStride[2], srcStride[1], dstStride[1]);
163
164 984 return srcSliceH;
165 }
166
167 900 static 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 900 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
173 900 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
174
175 900 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
176 dstParam[0], dstStride[0]);
177
178
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 450 times.
900 if (c->opts.src_format == AV_PIX_FMT_NV12)
179 450 deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, (srcSliceH + 1) / 2,
180 450 srcStride[1], dstStride[1], dstStride[2]);
181 else
182 450 deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, (srcSliceH + 1) / 2,
183 450 srcStride[1], dstStride[2], dstStride[1]);
184
185 900 return srcSliceH;
186 }
187
188 474 static 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 474 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY;
194
195 474 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
196 dstParam[0], dstStride[0]);
197
198
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 3 times.
474 if (c->opts.dst_format == AV_PIX_FMT_NV24)
199 471 interleaveBytes(src[1], src[2], dst, c->chrSrcW, srcSliceH,
200 471 srcStride[1], srcStride[2], dstStride[1]);
201 else
202 3 interleaveBytes(src[2], src[1], dst, c->chrSrcW, srcSliceH,
203 3 srcStride[2], srcStride[1], dstStride[1]);
204
205 474 return srcSliceH;
206 }
207
208 471 static 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 471 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY;
214 471 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY;
215
216 471 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
217 dstParam[0], dstStride[0]);
218
219
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 1 times.
471 if (c->opts.src_format == AV_PIX_FMT_NV24)
220 470 deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, srcSliceH,
221 470 srcStride[1], dstStride[1], dstStride[2]);
222 else
223 1 deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, srcSliceH,
224 1 srcStride[1], dstStride[2], dstStride[1]);
225
226 471 return srcSliceH;
227 }
228
229 250 static 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 250 const uint8_t *src1 = src;
235 250 const uint8_t *src2 = src + srcStride;
236 // average 4 pixels into 1 (interleaved U and V)
237
2/2
✓ Branch 0 taken 3776 times.
✓ Branch 1 taken 250 times.
4026 for (int y = 0; y < h; y += 2) {
238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3776 times.
3776 if (y + 1 == h)
239 src2 = src1;
240
2/2
✓ Branch 0 taken 671488 times.
✓ Branch 1 taken 3776 times.
675264 for (int x = 0; x < w; x++) {
241 671488 dst1[x] = (src1[4 * x + 0] + src1[4 * x + 2] +
242 671488 src2[4 * x + 0] + src2[4 * x + 2]) >> 2;
243 671488 dst2[x] = (src1[4 * x + 1] + src1[4 * x + 3] +
244 671488 src2[4 * x + 1] + src2[4 * x + 3]) >> 2;
245 }
246 3776 src1 += srcStride * 2;
247 3776 src2 += srcStride * 2;
248 3776 dst1 += dstStride1;
249 3776 dst2 += dstStride2;
250 }
251 250 }
252
253 250 static 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 250 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
258 250 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
259
260 250 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
261 dstParam[0], dstStride[0]);
262
263
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 8 times.
250 if (c->opts.src_format == AV_PIX_FMT_NV24)
264 242 nv24_to_yuv420p_chroma(dst1, dstStride[1], dst2, dstStride[2],
265 242 src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
266 else
267 8 nv24_to_yuv420p_chroma(dst2, dstStride[2], dst1, dstStride[1],
268 8 src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
269
270 250 return srcSliceH;
271 }
272
273 static 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
333 64 static 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 64 const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2];
339 64 uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
340 64 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
341 int x, y, t;
342
343
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
344
345
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 64 times.
18496 for (y = 0; y < srcSliceH; y++) {
346 18432 uint16_t *tdstY = dstY;
347 18432 const uint8_t *tsrc0 = src0;
348
2/2
✓ Branch 0 taken 6488064 times.
✓ Branch 1 taken 18432 times.
6506496 for (x = c->opts.src_w; x > 0; x--) {
349 6488064 t = *tsrc0++;
350 6488064 output_pixel(tdstY++, t << 8);
351 }
352 18432 src0 += srcStride[0];
353 18432 dstY += dstStride[0] / 2;
354
355
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 9216 times.
18432 if (!(y & 1)) {
356 9216 uint16_t *tdstUV = dstUV;
357 9216 const uint8_t *tsrc1 = src1;
358 9216 const uint8_t *tsrc2 = src2;
359
2/2
✓ Branch 0 taken 1622016 times.
✓ Branch 1 taken 9216 times.
1631232 for (x = c->opts.src_w / 2; x > 0; x--) {
360 1622016 t = *tsrc1++;
361 1622016 output_pixel(tdstUV++, t << 8);
362 1622016 t = *tsrc2++;
363 1622016 output_pixel(tdstUV++, t << 8);
364 }
365 9216 src1 += srcStride[1];
366 9216 src2 += srcStride[2];
367 9216 dstUV += dstStride[1] / 2;
368 }
369 }
370
371 64 return srcSliceH;
372 }
373
374 #undef output_pixel
375
376 static 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
388 static 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
400 static 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
412 static 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
424 static 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
441 static 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
455 static 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
472 static 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
486 static 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
494 static 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
503 static 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
517 static 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
531 7488 static 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
2/2
✓ Branch 0 taken 2635776 times.
✓ Branch 1 taken 7488 times.
2643264 for (int i = 0; i < num_pixels; i++) {
536 2635776 const uint8_t *rgba = &palette[src[i] * 4];
537 2635776 dst0[i] = rgba[0];
538 2635776 dst1[i] = rgba[1];
539 2635776 dst2[i] = rgba[2];
540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2635776 times.
2635776 if (dstA)
541 dstA[i] = rgba[3];
542 }
543 7488 }
544
545 1475 static 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
2/2
✓ Branch 0 taken 5900 times.
✓ Branch 1 taken 1475 times.
7375 for (p = 0; p < 4; p++) {
552 5900 int srcstr = srcStride[p] / 2;
553 5900 int dststr = dstStride[p] / 2;
554 5900 uint16_t *dstPtr = (uint16_t *) dst[p];
555 5900 const uint16_t *srcPtr = (const uint16_t *) src[p];
556 5900 int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
557
3/4
✓ Branch 0 taken 4413 times.
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4413 times.
5900 if(!dstPtr || !srcPtr)
558 1487 continue;
559 4413 dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
560
2/2
✓ Branch 0 taken 190400 times.
✓ Branch 1 taken 4413 times.
194813 for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
561
2/2
✓ Branch 0 taken 69419008 times.
✓ Branch 1 taken 190400 times.
69609408 for (j = 0; j < min_stride; j++) {
562 69419008 dstPtr[j] = av_bswap16(srcPtr[j]);
563 }
564 190400 srcPtr += srcstr;
565 190400 dstPtr += dststr;
566 }
567 }
568
569 1475 return srcSliceH;
570 }
571
572 13 static 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
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 13 times.
65 for (p = 0; p < 4; p++) {
579 52 int srcstr = srcStride[p] / 4;
580 52 int dststr = dstStride[p] / 4;
581 52 uint32_t *dstPtr = (uint32_t *) dst[p];
582 52 const uint32_t *srcPtr = (const uint32_t *) src[p];
583 52 int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
584
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
52 if(!dstPtr || !srcPtr)
585 13 continue;
586 39 dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
587
2/2
✓ Branch 0 taken 11232 times.
✓ Branch 1 taken 39 times.
11271 for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
588
2/2
✓ Branch 0 taken 3953664 times.
✓ Branch 1 taken 11232 times.
3964896 for (j = 0; j < min_stride; j++) {
589 3953664 dstPtr[j] = av_bswap32(srcPtr[j]);
590 }
591 11232 srcPtr += srcstr;
592 11232 dstPtr += dststr;
593 }
594 }
595
596 13 return srcSliceH;
597 }
598
599
600 32597 static 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 32597 const enum AVPixelFormat srcFormat = c->opts.src_format;
605 32597 const enum AVPixelFormat dstFormat = c->opts.dst_format;
606 32597 void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
607 const uint8_t *palette) = NULL;
608 int i;
609 32597 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
610 32597 const uint8_t *srcPtr = src[0];
611
612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32597 times.
32597 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
1/2
✓ Branch 1 taken 32597 times.
✗ Branch 2 not taken.
32597 } else if (usePal(srcFormat)) {
622
3/7
✓ Branch 0 taken 2556 times.
✓ Branch 1 taken 1952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 28089 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
32597 switch (dstFormat) {
623 2556 case AV_PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
624 1952 case AV_PIX_FMT_BGR32 : conv = sws_convertPalette8ToPacked32; break;
625 case AV_PIX_FMT_BGR32_1: conv = sws_convertPalette8ToPacked32; break;
626 case AV_PIX_FMT_RGB32_1: conv = sws_convertPalette8ToPacked32; break;
627 28089 case AV_PIX_FMT_RGB24 : conv = sws_convertPalette8ToPacked24; break;
628 case AV_PIX_FMT_BGR24 : conv = sws_convertPalette8ToPacked24; break;
629 }
630 }
631
632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32597 times.
32597 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
2/2
✓ Branch 0 taken 814886 times.
✓ Branch 1 taken 32597 times.
847483 for (i = 0; i < srcSliceH; i++) {
637 814886 conv(srcPtr, dstPtr, c->opts.src_w, (uint8_t *) c->pal_rgb);
638 814886 srcPtr += srcStride[0];
639 814886 dstPtr += dstStride[0];
640 }
641 }
642
643 32597 return srcSliceH;
644 }
645
646 234 static 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 234 const enum AVPixelFormat srcFormat = c->opts.src_format;
651 234 const enum AVPixelFormat dstFormat = c->opts.dst_format;
652 234 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
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
234 const int num_planes = isALPHA(dstFormat) ? 4 : 3;
656 234 const uint8_t *srcPtr = src[0];
657 234 uint8_t *dstPtr[4] = {0};
658
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 234 times.
936 for (int i = 0; i < num_planes; i++)
659 702 dstPtr[i] = dst[i] + dstStride[i] * srcSliceY;
660
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
234 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
1/2
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
234 } else if (usePal(srcFormat)) {
667
1/3
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
234 switch (dstFormat) {
668 234 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
2/2
✓ Branch 0 taken 7488 times.
✓ Branch 1 taken 234 times.
7722 for (int y = 0; y < srcSliceH; y++) {
675 7488 conv(srcPtr, dstPtr[0], dstPtr[1], dstPtr[2], dstPtr[3], c->opts.src_w,
676 7488 (uint8_t *) c->pal_rgb);
677 7488 srcPtr += srcStride[0];
678
2/2
✓ Branch 0 taken 22464 times.
✓ Branch 1 taken 7488 times.
29952 for (int i = 0; i < num_planes; i++)
679 22464 dstPtr[i] += dstStride[i];
680 }
681
682 234 return srcSliceH;
683 }
684
685 2612 static 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 2612 int dst_alpha = dst[3] != NULL;
691
2/2
✓ Branch 0 taken 86080 times.
✓ Branch 1 taken 2612 times.
88692 for (h = 0; h < srcSliceH; h++) {
692 86080 uint16_t *src_line = (uint16_t *)(src + srcStride * h);
693
4/4
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 23328 times.
✓ Branch 2 taken 864 times.
✓ Branch 3 taken 60768 times.
86080 switch (swap) {
694 1120 case 3:
695
3/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 992 times.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
1120 if (src_alpha && dst_alpha) {
696
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 128 times.
16512 for (x = 0; x < width; x++) {
697 16384 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
698 16384 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
699 16384 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
700 16384 dst[3][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
701 }
702
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 608 times.
992 } else if (dst_alpha) {
703
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 384 times.
37248 for (x = 0; x < width; x++) {
704 36864 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
705 36864 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
706 36864 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
707 36864 dst[3][x] = av_bswap16(0xFFFF >> shift);
708 }
709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608 times.
608 } 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
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 608 times.
63072 for (x = 0; x < width; x++) {
718 62464 dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
719 62464 dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
720 62464 dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
721 }
722 }
723 1120 break;
724 23328 case 2:
725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23328 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
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 22944 times.
23328 } else if (dst_alpha) {
733
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 384 times.
37248 for (x = 0; x < width; x++) {
734 36864 dst[0][x] = av_bswap16(*src_line++ >> shift);
735 36864 dst[1][x] = av_bswap16(*src_line++ >> shift);
736 36864 dst[2][x] = av_bswap16(*src_line++ >> shift);
737 36864 dst[3][x] = av_bswap16(0xFFFF >> shift);
738 }
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22944 times.
22944 } 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
2/2
✓ Branch 0 taken 7953408 times.
✓ Branch 1 taken 22944 times.
7976352 for (x = 0; x < width; x++) {
748 7953408 dst[0][x] = av_bswap16(*src_line++ >> shift);
749 7953408 dst[1][x] = av_bswap16(*src_line++ >> shift);
750 7953408 dst[2][x] = av_bswap16(*src_line++ >> shift);
751 }
752 }
753 23328 break;
754 864 case 1:
755
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
864 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
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 480 times.
864 } else if (dst_alpha) {
763
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 384 times.
37248 for (x = 0; x < width; x++) {
764 36864 dst[0][x] = av_bswap16(*src_line++) >> shift;
765 36864 dst[1][x] = av_bswap16(*src_line++) >> shift;
766 36864 dst[2][x] = av_bswap16(*src_line++) >> shift;
767 36864 dst[3][x] = 0xFFFF >> shift;
768 }
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 } 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
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 480 times.
46560 for (x = 0; x < width; x++) {
778 46080 dst[0][x] = av_bswap16(*src_line++) >> shift;
779 46080 dst[1][x] = av_bswap16(*src_line++) >> shift;
780 46080 dst[2][x] = av_bswap16(*src_line++) >> shift;
781 }
782 }
783 864 break;
784 60768 default:
785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60768 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
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 60384 times.
60768 } else if (dst_alpha) {
793
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 384 times.
37248 for (x = 0; x < width; x++) {
794 36864 dst[0][x] = *src_line++ >> shift;
795 36864 dst[1][x] = *src_line++ >> shift;
796 36864 dst[2][x] = *src_line++ >> shift;
797 36864 dst[3][x] = 0xFFFF >> shift;
798 }
799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60384 times.
60384 } 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
2/2
✓ Branch 0 taken 21132288 times.
✓ Branch 1 taken 60384 times.
21192672 for (x = 0; x < width; x++) {
808 21132288 dst[0][x] = *src_line++ >> shift;
809 21132288 dst[1][x] = *src_line++ >> shift;
810 21132288 dst[2][x] = *src_line++ >> shift;
811 }
812 }
813 }
814
4/4
✓ Branch 0 taken 344320 times.
✓ Branch 1 taken 1664 times.
✓ Branch 2 taken 259904 times.
✓ Branch 3 taken 84416 times.
345984 for (i = 0; i < 4 && dst[i]; i++)
815 259904 dst[i] += dstStride[i] >> 1;
816 }
817 2612 }
818
819 936 static void packed30togbra10(const uint8_t *src, int srcStride,
820 uint16_t *dst[], const int dstStride[], int srcSliceH,
821 int swap, int bpc, int width)
822 {
823 int x, h, i;
824 936 int dst_alpha = dst[3] != NULL;
825 936 int scale_high = bpc - 10, scale_low = 10 - scale_high;
826 936 uint16_t alpha_val = (1U << bpc) - 1;
827
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 936 times.
30888 for (h = 0; h < srcSliceH; h++) {
828 29952 uint32_t *src_line = (uint32_t *)(src + srcStride * h);
829 unsigned component;
830
831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29952 times.
29952 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);
839 component = (p >> 10) & 0x3FF;
840 dst[1][x] = av_bswap16(component << scale_high | component >> scale_low);
841 component = p & 0x3FF;
842 dst[2][x] = av_bswap16(component << scale_high | component >> scale_low);
843 dst[3][x] = av_bswap16(alpha_val);
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);
851 component = (p >> 10) & 0x3FF;
852 dst[1][x] = av_bswap16(component << scale_high | component >> scale_low);
853 component = p & 0x3FF;
854 dst[2][x] = av_bswap16(component << scale_high | component >> scale_low);
855 src_line++;
856 }
857 }
858 break;
859 29952 default:
860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29952 times.
29952 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;
865 component = (p >> 10) & 0x3FF;
866 dst[1][x] = component << scale_high | component >> scale_low;
867 component = p & 0x3FF;
868 dst[2][x] = component << scale_high | component >> scale_low;
869 dst[3][x] = alpha_val;
870 src_line++;
871 }
872 } else {
873
2/2
✓ Branch 0 taken 10543104 times.
✓ Branch 1 taken 29952 times.
10573056 for (x = 0; x < width; x++) {
874 10543104 unsigned p = AV_RL32(src_line);
875 10543104 component = (p >> 20) & 0x3FF;
876 10543104 dst[0][x] = component << scale_high | component >> scale_low;
877 10543104 component = (p >> 10) & 0x3FF;
878 10543104 dst[1][x] = component << scale_high | component >> scale_low;
879 10543104 component = p & 0x3FF;
880 10543104 dst[2][x] = component << scale_high | component >> scale_low;
881 10543104 src_line++;
882 }
883 }
884 29952 break;
885 }
886
3/4
✓ Branch 0 taken 119808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89856 times.
✓ Branch 3 taken 29952 times.
119808 for (i = 0; i < 4 && dst[i]; i++)
887 89856 dst[i] += dstStride[i] >> 1;
888 }
889 936 }
890
891 3548 static 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 3548 uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
896 3548 uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
897 3548 int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
898 3548 int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
899 3548 const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
900 3548 const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
901 3548 int bpc = dst_format->comp[0].depth;
902 3548 int alpha = src_format->flags & AV_PIX_FMT_FLAG_ALPHA;
903 3548 int swap = 0;
904 int i;
905
906 3548 if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
907
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3528 times.
3548 !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
908 20 swap++;
909 3548 if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
910
2/2
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 2826 times.
3548 !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
911 722 swap += 2;
912
913
1/2
✓ Branch 0 taken 3548 times.
✗ Branch 1 not taken.
3548 if ((dst_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3548 times.
3548 (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB) || bpc < 9) {
915 av_log(c, AV_LOG_ERROR, "unsupported conversion to planar RGB %s -> %s\n",
916 src_format->name, dst_format->name);
917 return srcSliceH;
918 }
919
920
4/4
✓ Branch 0 taken 14192 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 10661 times.
✓ Branch 3 taken 3531 times.
14209 for (i = 0; i < 4 && dst[i]; i++) {
921 10661 dst2013[i] += stride2013[i] * srcSliceY / 2;
922 10661 dst1023[i] += stride1023[i] * srcSliceY / 2;
923 }
924
925
3/5
✓ Branch 0 taken 2612 times.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
3548 switch (c->opts.src_format) {
926 2612 case AV_PIX_FMT_RGB48LE:
927 case AV_PIX_FMT_RGB48BE:
928 case AV_PIX_FMT_RGBA64LE:
929 case AV_PIX_FMT_RGBA64BE:
930 2612 packed16togbra16(src[0], srcStride[0],
931 dst2013, stride2013, srcSliceH, alpha, swap,
932 16 - bpc, c->opts.src_w);
933 2612 break;
934 468 case AV_PIX_FMT_X2RGB10LE:
935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 av_assert0(bpc >= 10);
936 468 packed30togbra10(src[0], srcStride[0],
937 dst2013, stride2013, srcSliceH, swap,
938 bpc, c->opts.src_w);
939 468 break;
940 case AV_PIX_FMT_BGR48LE:
941 case AV_PIX_FMT_BGR48BE:
942 case AV_PIX_FMT_BGRA64LE:
943 case AV_PIX_FMT_BGRA64BE:
944 packed16togbra16(src[0], srcStride[0],
945 dst1023, stride1023, srcSliceH, alpha, swap,
946 16 - bpc, c->opts.src_w);
947 break;
948 468 case AV_PIX_FMT_X2BGR10LE:
949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 av_assert0(bpc >= 10);
950 468 packed30togbra10(src[0], srcStride[0],
951 dst1023, stride1023, srcSliceH, swap,
952 bpc, c->opts.src_w);
953 468 break;
954 default:
955 av_log(c, AV_LOG_ERROR,
956 "unsupported conversion to planar RGB %s -> %s\n",
957 src_format->name, dst_format->name);
958 }
959
960 3548 return srcSliceH;
961 }
962
963 2650 static void gbr16ptopacked16(const uint16_t *src[], const int srcStride[],
964 uint8_t *dst, int dstStride, int srcSliceH,
965 int alpha, int swap, int bpp, int width)
966 {
967 int x, h, i;
968 2650 int src_alpha = src[3] != NULL;
969 2650 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
970
2/2
✓ Branch 0 taken 91008 times.
✓ Branch 1 taken 2650 times.
93658 for (h = 0; h < srcSliceH; h++) {
971 91008 uint16_t *dest = (uint16_t *)(dst + dstStride * h);
972 uint16_t component;
973
974
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 864 times.
✓ Branch 2 taken 23328 times.
✓ Branch 3 taken 65952 times.
91008 switch(swap) {
975 864 case 3:
976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
864 if (alpha && !src_alpha) {
977 for (x = 0; x < width; x++) {
978 component = av_bswap16(src[0][x]);
979 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
980 component = av_bswap16(src[1][x]);
981 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
982 component = av_bswap16(src[2][x]);
983 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
984 *dest++ = 0xffff;
985 }
986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
864 } else if (alpha && src_alpha) {
987 for (x = 0; x < width; x++) {
988 component = av_bswap16(src[0][x]);
989 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
990 component = av_bswap16(src[1][x]);
991 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
992 component = av_bswap16(src[2][x]);
993 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
994 component = av_bswap16(src[3][x]);
995 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
996 }
997 } else {
998
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 864 times.
83808 for (x = 0; x < width; x++) {
999 82944 component = av_bswap16(src[0][x]);
1000 82944 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1001 82944 component = av_bswap16(src[1][x]);
1002 82944 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1003 82944 component = av_bswap16(src[2][x]);
1004 82944 *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1005 }
1006 }
1007 864 break;
1008 864 case 2:
1009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
864 if (alpha && !src_alpha) {
1010 for (x = 0; x < width; x++) {
1011 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1012 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1013 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1014 *dest++ = 0xffff;
1015 }
1016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
864 } else if (alpha && src_alpha) {
1017 for (x = 0; x < width; x++) {
1018 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1019 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1020 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1021 *dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
1022 }
1023 } else {
1024
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 864 times.
83808 for (x = 0; x < width; x++) {
1025 82944 *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1026 82944 *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1027 82944 *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1028 }
1029 }
1030 864 break;
1031 23328 case 1:
1032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23328 if (alpha && !src_alpha) {
1033 for (x = 0; x < width; x++) {
1034 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1035 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1036 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1037 *dest++ = 0xffff;
1038 }
1039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23328 } else if (alpha && src_alpha) {
1040 for (x = 0; x < width; x++) {
1041 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1042 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1043 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1044 *dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
1045 }
1046 } else {
1047
2/2
✓ Branch 0 taken 7990272 times.
✓ Branch 1 taken 23328 times.
8013600 for (x = 0; x < width; x++) {
1048 7990272 *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1049 7990272 *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1050 7990272 *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1051 }
1052 }
1053 23328 break;
1054 65952 default:
1055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 65952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
65952 if (alpha && !src_alpha) {
1056 for (x = 0; x < width; x++) {
1057 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1058 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1059 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1060 *dest++ = 0xffff;
1061 }
1062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 65952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
65952 } else if (alpha && src_alpha) {
1063 for (x = 0; x < width; x++) {
1064 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1065 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1066 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1067 *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
1068 }
1069 } else {
1070
2/2
✓ Branch 0 taken 23408640 times.
✓ Branch 1 taken 65952 times.
23474592 for (x = 0; x < width; x++) {
1071 23408640 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1072 23408640 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1073 23408640 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1074 }
1075 }
1076 }
1077
2/2
✓ Branch 0 taken 274560 times.
✓ Branch 1 taken 91008 times.
365568 for (i = 0; i < 3 + src_alpha; i++)
1078 274560 src[i] += srcStride[i] >> 1;
1079 }
1080 2650 }
1081
1082 936 static void gbr16ptopacked30(const uint16_t *src[], const int srcStride[],
1083 uint8_t *dst, int dstStride, int srcSliceH,
1084 int swap, int bpp, int width)
1085 {
1086 int x, h, i;
1087 936 int shift = bpp - 10;
1088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 936 times.
936 av_assert0(bpp >= 0);
1089
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 936 times.
30888 for (h = 0; h < srcSliceH; h++) {
1090 29952 uint8_t *dest = dst + dstStride * h;
1091
1092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29952 times.
29952 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 29952 default:
1103
2/2
✓ Branch 0 taken 10543104 times.
✓ Branch 1 taken 29952 times.
10573056 for (x = 0; x < width; x++) {
1104 10543104 unsigned C0 = src[0][x] >> shift;
1105 10543104 unsigned C1 = src[1][x] >> shift;
1106 10543104 unsigned C2 = src[2][x] >> shift;
1107 10543104 AV_WL32(dest + 4 * x, (3U << 30) + (C0 << 20) + (C1 << 10) + C2);
1108 }
1109 29952 break;
1110 }
1111
2/2
✓ Branch 0 taken 89856 times.
✓ Branch 1 taken 29952 times.
119808 for (i = 0; i < 3; i++)
1112 89856 src[i] += srcStride[i] >> 1;
1113 }
1114 936 }
1115
1116
1117 3586 static 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 3586 const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
1122 3586 const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
1123 3586 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1124 3586 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1125 3586 const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
1126 3586 const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
1127 3586 int bits_per_sample = src_format->comp[0].depth;
1128 3586 int swap = 0;
1129 3586 if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
1130
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 2866 times.
3586 !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
1131 720 swap++;
1132 3586 if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
1133
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 3568 times.
3586 !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
1134 18 swap += 2;
1135
1136
1/2
✓ Branch 0 taken 3586 times.
✗ Branch 1 not taken.
3586 if ((src_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
1137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB) ||
1138 bits_per_sample <= 8) {
1139 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1140 src_format->name, dst_format->name);
1141 return srcSliceH;
1142 }
1143
3/7
✗ Branch 0 not taken.
✓ Branch 1 taken 2650 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 468 times.
✓ Branch 5 taken 468 times.
✗ Branch 6 not taken.
3586 switch (c->opts.dst_format) {
1144 case AV_PIX_FMT_BGR48LE:
1145 case AV_PIX_FMT_BGR48BE:
1146 gbr16ptopacked16(src102, stride102,
1147 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1148 srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1149 break;
1150 2650 case AV_PIX_FMT_RGB48LE:
1151 case AV_PIX_FMT_RGB48BE:
1152 2650 gbr16ptopacked16(src201, stride201,
1153 2650 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1154 srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1155 2650 break;
1156 case AV_PIX_FMT_RGBA64LE:
1157 case AV_PIX_FMT_RGBA64BE:
1158 gbr16ptopacked16(src201, stride201,
1159 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1160 srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1161 break;
1162 case AV_PIX_FMT_BGRA64LE:
1163 case AV_PIX_FMT_BGRA64BE:
1164 gbr16ptopacked16(src102, stride102,
1165 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1166 srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1167 break;
1168 468 case AV_PIX_FMT_X2RGB10LE:
1169 468 gbr16ptopacked30(src201, stride201,
1170 468 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1171 srcSliceH, swap, bits_per_sample, c->opts.src_w);
1172 468 break;
1173 468 case AV_PIX_FMT_X2BGR10LE:
1174 468 gbr16ptopacked30(src102, stride102,
1175 468 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1176 srcSliceH, swap, bits_per_sample, c->opts.src_w);
1177 468 break;
1178 default:
1179 av_log(c, AV_LOG_ERROR,
1180 "unsupported planar RGB conversion %s -> %s\n",
1181 src_format->name, dst_format->name);
1182 }
1183
1184 3586 return srcSliceH;
1185 }
1186
1187 495 static void gbr24ptopacked24(const uint8_t *src[], const int srcStride[],
1188 uint8_t *dst, int dstStride, int srcSliceH,
1189 int width)
1190 {
1191 int x, h, i;
1192
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 495 times.
15855 for (h = 0; h < srcSliceH; h++) {
1193 15360 uint8_t *dest = dst + dstStride * h;
1194
2/2
✓ Branch 0 taken 5320704 times.
✓ Branch 1 taken 15360 times.
5336064 for (x = 0; x < width; x++) {
1195 5320704 *dest++ = src[0][x];
1196 5320704 *dest++ = src[1][x];
1197 5320704 *dest++ = src[2][x];
1198 }
1199
1200
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 15360 times.
61440 for (i = 0; i < 3; i++)
1201 46080 src[i] += srcStride[i];
1202 }
1203 495 }
1204
1205 234 static void gbr24ptopacked32(const uint8_t *src[], const int srcStride[],
1206 uint8_t *dst, int dstStride, int srcSliceH,
1207 int alpha_first, int width)
1208 {
1209 int x, h, i;
1210
2/2
✓ Branch 0 taken 7488 times.
✓ Branch 1 taken 234 times.
7722 for (h = 0; h < srcSliceH; h++) {
1211 7488 uint8_t *dest = dst + dstStride * h;
1212
1213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7488 times.
7488 if (alpha_first) {
1214 for (x = 0; x < width; x++) {
1215 *dest++ = 0xff;
1216 *dest++ = src[0][x];
1217 *dest++ = src[1][x];
1218 *dest++ = src[2][x];
1219 }
1220 } else {
1221
2/2
✓ Branch 0 taken 2635776 times.
✓ Branch 1 taken 7488 times.
2643264 for (x = 0; x < width; x++) {
1222 2635776 *dest++ = src[0][x];
1223 2635776 *dest++ = src[1][x];
1224 2635776 *dest++ = src[2][x];
1225 2635776 *dest++ = 0xff;
1226 }
1227 }
1228
1229
2/2
✓ Branch 0 taken 22464 times.
✓ Branch 1 taken 7488 times.
29952 for (i = 0; i < 3; i++)
1230 22464 src[i] += srcStride[i];
1231 }
1232 234 }
1233
1234 315 static void gbraptopacked32(const uint8_t *src[], const int srcStride[],
1235 uint8_t *dst, int dstStride, int srcSliceH,
1236 int alpha_first, int width)
1237 {
1238 int x, h, i;
1239
2/2
✓ Branch 0 taken 14400 times.
✓ Branch 1 taken 315 times.
14715 for (h = 0; h < srcSliceH; h++) {
1240 14400 uint8_t *dest = dst + dstStride * h;
1241
1242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14400 times.
14400 if (alpha_first) {
1243 for (x = 0; x < width; x++) {
1244 *dest++ = src[3][x];
1245 *dest++ = src[0][x];
1246 *dest++ = src[1][x];
1247 *dest++ = src[2][x];
1248 }
1249 } else {
1250
2/2
✓ Branch 0 taken 9408000 times.
✓ Branch 1 taken 14400 times.
9422400 for (x = 0; x < width; x++) {
1251 9408000 *dest++ = src[0][x];
1252 9408000 *dest++ = src[1][x];
1253 9408000 *dest++ = src[2][x];
1254 9408000 *dest++ = src[3][x];
1255 }
1256 }
1257
1258
2/2
✓ Branch 0 taken 57600 times.
✓ Branch 1 taken 14400 times.
72000 for (i = 0; i < 4; i++)
1259 57600 src[i] += srcStride[i];
1260 }
1261 315 }
1262
1263 324 static int planarRgbaToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1264 const int srcStride[], int srcSliceY, int srcSliceH,
1265 uint8_t *const dst[], const int dstStride[])
1266 {
1267 324 int alpha_first = 0;
1268 324 const uint8_t *src102[] = { src[1], src[0], src[2], src[3] };
1269 324 const uint8_t *src201[] = { src[2], src[0], src[1], src[3] };
1270 324 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1271 324 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1272
1273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 if (c->opts.src_format != AV_PIX_FMT_GBRAP) {
1274 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1275 av_get_pix_fmt_name(c->opts.src_format),
1276 av_get_pix_fmt_name(c->opts.dst_format));
1277 return srcSliceH;
1278 }
1279
1280
3/7
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 225 times.
✗ Branch 6 not taken.
324 switch (c->opts.dst_format) {
1281 case AV_PIX_FMT_BGR24:
1282 gbr24ptopacked24(src102, stride102,
1283 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1284 srcSliceH, c->opts.src_w);
1285 break;
1286
1287 9 case AV_PIX_FMT_RGB24:
1288 9 gbr24ptopacked24(src201, stride201,
1289 9 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1290 srcSliceH, c->opts.src_w);
1291 9 break;
1292
1293 case AV_PIX_FMT_ARGB:
1294 alpha_first = 1;
1295 av_fallthrough;
1296 90 case AV_PIX_FMT_RGBA:
1297 90 gbraptopacked32(src201, stride201,
1298 90 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1299 srcSliceH, alpha_first, c->opts.src_w);
1300 90 break;
1301
1302 case AV_PIX_FMT_ABGR:
1303 alpha_first = 1;
1304 av_fallthrough;
1305 225 case AV_PIX_FMT_BGRA:
1306 225 gbraptopacked32(src102, stride102,
1307 225 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1308 srcSliceH, alpha_first, c->opts.src_w);
1309 225 break;
1310
1311 default:
1312 av_log(c, AV_LOG_ERROR,
1313 "unsupported planar RGB conversion %s -> %s\n",
1314 av_get_pix_fmt_name(c->opts.src_format),
1315 av_get_pix_fmt_name(c->opts.dst_format));
1316 }
1317
1318 324 return srcSliceH;
1319 }
1320
1321 720 static int planarRgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1322 const int srcStride[], int srcSliceY, int srcSliceH,
1323 uint8_t *const dst[], const int dstStride[])
1324 {
1325 720 int alpha_first = 0;
1326 720 const uint8_t *src102[] = { src[1], src[0], src[2] };
1327 720 const uint8_t *src201[] = { src[2], src[0], src[1] };
1328 720 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
1329 720 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
1330
1331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if (c->opts.src_format != AV_PIX_FMT_GBRP) {
1332 av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1333 av_get_pix_fmt_name(c->opts.src_format),
1334 av_get_pix_fmt_name(c->opts.dst_format));
1335 return srcSliceH;
1336 }
1337
1338
3/7
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 252 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234 times.
✗ Branch 6 not taken.
720 switch (c->opts.dst_format) {
1339 234 case AV_PIX_FMT_BGR24:
1340 234 gbr24ptopacked24(src102, stride102,
1341 234 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1342 srcSliceH, c->opts.src_w);
1343 234 break;
1344
1345 252 case AV_PIX_FMT_RGB24:
1346 252 gbr24ptopacked24(src201, stride201,
1347 252 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1348 srcSliceH, c->opts.src_w);
1349 252 break;
1350
1351 case AV_PIX_FMT_ARGB:
1352 alpha_first = 1;
1353 av_fallthrough;
1354 case AV_PIX_FMT_RGBA:
1355 gbr24ptopacked32(src201, stride201,
1356 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1357 srcSliceH, alpha_first, c->opts.src_w);
1358 break;
1359
1360 case AV_PIX_FMT_ABGR:
1361 alpha_first = 1;
1362 av_fallthrough;
1363 234 case AV_PIX_FMT_BGRA:
1364 234 gbr24ptopacked32(src102, stride102,
1365 234 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1366 srcSliceH, alpha_first, c->opts.src_w);
1367 234 break;
1368
1369 default:
1370 av_log(c, AV_LOG_ERROR,
1371 "unsupported planar RGB conversion %s -> %s\n",
1372 av_get_pix_fmt_name(c->opts.src_format),
1373 av_get_pix_fmt_name(c->opts.dst_format));
1374 }
1375
1376 720 return srcSliceH;
1377 }
1378
1379 45 static int planarRgbToplanarRgbWrapper(SwsInternal *c,
1380 const uint8_t *const src[], const int srcStride[],
1381 int srcSliceY, int srcSliceH,
1382 uint8_t *const dst[], const int dstStride[])
1383 {
1384 45 ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
1385 dst[0], dstStride[0]);
1386 45 ff_copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->opts.src_w,
1387 45 dst[1], dstStride[1]);
1388 45 ff_copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->opts.src_w,
1389 45 dst[2], dstStride[2]);
1390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dst[3]) {
1391 if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
1392 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
1393 fillPlane16(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 1,
1394 desc_dst->comp[3].depth, isBE(c->opts.dst_format));
1395 } else {
1396 fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
1397 }
1398 }
1399
1400 45 return srcSliceH;
1401 }
1402
1403 991 static void packedtogbr24p(const uint8_t *src, int srcStride,
1404 uint8_t *const dst[], const int dstStride[], int srcSliceH,
1405 int alpha_first, int inc_size, int width)
1406 {
1407 uint8_t *dest[3];
1408 int x, h;
1409
1410 991 dest[0] = dst[0];
1411 991 dest[1] = dst[1];
1412 991 dest[2] = dst[2];
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 991 times.
991 if (alpha_first)
1415 src++;
1416
1417
2/2
✓ Branch 0 taken 28848 times.
✓ Branch 1 taken 991 times.
29839 for (h = 0; h < srcSliceH; h++) {
1418
2/2
✓ Branch 0 taken 9756480 times.
✓ Branch 1 taken 28848 times.
9785328 for (x = 0; x < width; x++) {
1419 9756480 dest[0][x] = src[0];
1420 9756480 dest[1][x] = src[1];
1421 9756480 dest[2][x] = src[2];
1422
1423 9756480 src += inc_size;
1424 }
1425 28848 src += srcStride - width * inc_size;
1426 28848 dest[0] += dstStride[0];
1427 28848 dest[1] += dstStride[1];
1428 28848 dest[2] += dstStride[2];
1429 }
1430 991 }
1431
1432 991 static int rgbToPlanarRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1433 const int srcStride[], int srcSliceY, int srcSliceH,
1434 uint8_t *const dst[], const int dstStride[])
1435 {
1436 991 int alpha_first = 0;
1437 991 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1438 991 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1439 991 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1440 991 dst[0] + srcSliceY * dstStride[0],
1441 991 dst[2] + srcSliceY * dstStride[2] };
1442 991 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1443 991 dst[0] + srcSliceY * dstStride[0],
1444 991 dst[1] + srcSliceY * dstStride[1] };
1445
1446
3/7
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234 times.
✗ Branch 6 not taken.
991 switch (c->opts.src_format) {
1447 523 case AV_PIX_FMT_RGB24:
1448 523 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1449 stride201, srcSliceH, alpha_first, 3, c->opts.src_w);
1450 523 break;
1451 234 case AV_PIX_FMT_BGR24:
1452 234 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1453 stride102, srcSliceH, alpha_first, 3, c->opts.src_w);
1454 234 break;
1455 case AV_PIX_FMT_ARGB:
1456 alpha_first = 1;
1457 av_fallthrough;
1458 case AV_PIX_FMT_RGBA:
1459 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1460 stride201, srcSliceH, alpha_first, 4, c->opts.src_w);
1461 break;
1462 case AV_PIX_FMT_ABGR:
1463 alpha_first = 1;
1464 av_fallthrough;
1465 234 case AV_PIX_FMT_BGRA:
1466 234 packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1467 stride102, srcSliceH, alpha_first, 4, c->opts.src_w);
1468 234 break;
1469 default:
1470 av_log(c, AV_LOG_ERROR,
1471 "unsupported planar RGB conversion %s -> %s\n",
1472 av_get_pix_fmt_name(c->opts.src_format),
1473 av_get_pix_fmt_name(c->opts.dst_format));
1474 }
1475
1476 991 return srcSliceH;
1477 }
1478
1479 static void packed24togbrap(const uint8_t *src, int srcStride,
1480 uint8_t *const dst[], const int dstStride[],
1481 int srcSliceH, int width)
1482 {
1483 uint8_t *dest[4];
1484 int x, h;
1485
1486 dest[0] = dst[0];
1487 dest[1] = dst[1];
1488 dest[2] = dst[2];
1489 dest[3] = dst[3];
1490
1491 for (h = 0; h < srcSliceH; h++) {
1492 for (x = 0; x < width; x++) {
1493 dest[0][x] = src[x * 3 + 0];
1494 dest[1][x] = src[x * 3 + 1];
1495 dest[2][x] = src[x * 3 + 2];
1496 dest[3][x] = 0xff;
1497 }
1498 src += srcStride;
1499 dest[0] += dstStride[0];
1500 dest[1] += dstStride[1];
1501 dest[2] += dstStride[2];
1502 dest[3] += dstStride[3];
1503 }
1504 }
1505
1506 207 static void packed32togbrap(const uint8_t *src, int srcStride,
1507 uint8_t *const dst[], const int dstStride[],
1508 int srcSliceH, int alpha_first, int width)
1509 {
1510 uint8_t *dest[4];
1511 int x, h;
1512
1513 207 dest[0] = dst[0];
1514 207 dest[1] = dst[1];
1515 207 dest[2] = dst[2];
1516 207 dest[3] = dst[3];
1517
1518
2/2
✓ Branch 0 taken 3604 times.
✓ Branch 1 taken 207 times.
3811 for (h = 0; h < srcSliceH; h++) {
1519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3604 times.
3604 if (alpha_first) {
1520 for (x = 0; x < width; x++) {
1521 dest[0][x] = src[x * 4 + 1];
1522 dest[1][x] = src[x * 4 + 2];
1523 dest[2][x] = src[x * 4 + 3];
1524 dest[3][x] = src[x * 4 + 0];
1525 }
1526 } else {
1527
2/2
✓ Branch 0 taken 912032 times.
✓ Branch 1 taken 3604 times.
915636 for (x = 0; x < width; x++) {
1528 912032 dest[0][x] = src[x * 4 + 0];
1529 912032 dest[1][x] = src[x * 4 + 1];
1530 912032 dest[2][x] = src[x * 4 + 2];
1531 912032 dest[3][x] = src[x * 4 + 3];
1532 }
1533 }
1534 3604 src += srcStride;
1535 3604 dest[0] += dstStride[0];
1536 3604 dest[1] += dstStride[1];
1537 3604 dest[2] += dstStride[2];
1538 3604 dest[3] += dstStride[3];
1539 }
1540 207 }
1541
1542 207 static int rgbToPlanarRgbaWrapper(SwsInternal *c, const uint8_t *const src[],
1543 const int srcStride[], int srcSliceY, int srcSliceH,
1544 uint8_t *const dst[], const int dstStride[])
1545 {
1546 207 int alpha_first = 0;
1547 207 int stride102[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
1548 207 int stride201[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
1549 207 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1550 207 dst[0] + srcSliceY * dstStride[0],
1551 207 dst[2] + srcSliceY * dstStride[2],
1552 207 dst[3] + srcSliceY * dstStride[3] };
1553 207 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1554 207 dst[0] + srcSliceY * dstStride[0],
1555 207 dst[1] + srcSliceY * dstStride[1],
1556 207 dst[3] + srcSliceY * dstStride[3] };
1557
1558
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 162 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
207 switch (c->opts.src_format) {
1559 case AV_PIX_FMT_RGB24:
1560 packed24togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1561 stride201, srcSliceH, c->opts.src_w);
1562 break;
1563 case AV_PIX_FMT_BGR24:
1564 packed24togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1565 stride102, srcSliceH, c->opts.src_w);
1566 break;
1567 case AV_PIX_FMT_ARGB:
1568 alpha_first = 1;
1569 av_fallthrough;
1570 162 case AV_PIX_FMT_RGBA:
1571 162 packed32togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1572 stride201, srcSliceH, alpha_first, c->opts.src_w);
1573 162 break;
1574 case AV_PIX_FMT_ABGR:
1575 alpha_first = 1;
1576 av_fallthrough;
1577 45 case AV_PIX_FMT_BGRA:
1578 45 packed32togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1579 stride102, srcSliceH, alpha_first, c->opts.src_w);
1580 45 break;
1581 default:
1582 av_log(c, AV_LOG_ERROR,
1583 "unsupported planar RGB conversion %s -> %s\n",
1584 av_get_pix_fmt_name(c->opts.src_format),
1585 av_get_pix_fmt_name(c->opts.dst_format));
1586 }
1587
1588 207 return srcSliceH;
1589 }
1590
1591 #define BAYER_GBRG
1592 #define BAYER_8
1593 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1594 #include "bayer_template.c"
1595
1596 #define BAYER_GBRG
1597 #define BAYER_16LE
1598 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1599 #include "bayer_template.c"
1600
1601 #define BAYER_GBRG
1602 #define BAYER_16BE
1603 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1604 #include "bayer_template.c"
1605
1606 #define BAYER_GRBG
1607 #define BAYER_8
1608 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1609 #include "bayer_template.c"
1610
1611 #define BAYER_GRBG
1612 #define BAYER_16LE
1613 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1614 #include "bayer_template.c"
1615
1616 #define BAYER_GRBG
1617 #define BAYER_16BE
1618 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1619 #include "bayer_template.c"
1620
1621 #define BAYER_BGGR
1622 #define BAYER_8
1623 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1624 #include "bayer_template.c"
1625
1626 #define BAYER_BGGR
1627 #define BAYER_16LE
1628 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1629 #include "bayer_template.c"
1630
1631 #define BAYER_BGGR
1632 #define BAYER_16BE
1633 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1634 #include "bayer_template.c"
1635
1636 #define BAYER_RGGB
1637 #define BAYER_8
1638 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1639 #include "bayer_template.c"
1640
1641 #define BAYER_RGGB
1642 #define BAYER_16LE
1643 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1644 #include "bayer_template.c"
1645
1646 #define BAYER_RGGB
1647 #define BAYER_16BE
1648 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1649 #include "bayer_template.c"
1650
1651 static int bayer_to_rgb24_wrapper(SwsInternal *c, const uint8_t *const src[],
1652 const int srcStride[], int srcSliceY, int srcSliceH,
1653 uint8_t *const dst[], const int dstStride[])
1654 {
1655 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1656 const uint8_t *srcPtr= src[0];
1657 int i;
1658 void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1659 void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1660
1661 switch(c->opts.src_format) {
1662 #define CASE(pixfmt, prefix) \
1663 case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1664 interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1665 break;
1666 CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
1667 CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1668 CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1669 CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
1670 CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1671 CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1672 CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
1673 CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1674 CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1675 CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
1676 CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1677 CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1678 #undef CASE
1679 default: return 0;
1680 }
1681
1682 av_assert0(srcSliceH > 1);
1683
1684 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1685 srcPtr += 2 * srcStride[0];
1686 dstPtr += 2 * dstStride[0];
1687
1688 for (i = 2; i < srcSliceH - 2; i += 2) {
1689 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1690 srcPtr += 2 * srcStride[0];
1691 dstPtr += 2 * dstStride[0];
1692 }
1693
1694 if (i + 1 == srcSliceH) {
1695 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1696 } else if (i < srcSliceH)
1697 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1698 return srcSliceH;
1699 }
1700
1701 static int bayer_to_rgb48_wrapper(SwsInternal *c, const uint8_t *const src[],
1702 const int srcStride[], int srcSliceY, int srcSliceH,
1703 uint8_t *const dst[], const int dstStride[])
1704 {
1705 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1706 const uint8_t *srcPtr= src[0];
1707 int i;
1708 void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1709 void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1710
1711 switch(c->opts.src_format) {
1712 #define CASE(pixfmt, prefix) \
1713 case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
1714 interpolate = bayer_##prefix##_to_rgb48_interpolate; \
1715 break;
1716 CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
1717 CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1718 CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1719 CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
1720 CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1721 CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1722 CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
1723 CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1724 CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1725 CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
1726 CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1727 CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1728 #undef CASE
1729 default: return 0;
1730 }
1731
1732 av_assert0(srcSliceH > 1);
1733
1734 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1735 srcPtr += 2 * srcStride[0];
1736 dstPtr += 2 * dstStride[0];
1737
1738 for (i = 2; i < srcSliceH - 2; i += 2) {
1739 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1740 srcPtr += 2 * srcStride[0];
1741 dstPtr += 2 * dstStride[0];
1742 }
1743
1744 if (i + 1 == srcSliceH) {
1745 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1746 } else if (i < srcSliceH)
1747 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1748 return srcSliceH;
1749 }
1750
1751 static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[],
1752 const int srcStride[], int srcSliceY, int srcSliceH,
1753 uint8_t *const dst[], const int dstStride[])
1754 {
1755 const uint8_t *srcPtr= src[0];
1756 uint8_t *dstY= dst[0] + srcSliceY * dstStride[0];
1757 uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1758 uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1759 int i;
1760 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);
1761 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);
1762
1763 switch(c->opts.src_format) {
1764 #define CASE(pixfmt, prefix) \
1765 case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1766 interpolate = bayer_##prefix##_to_yv12_interpolate; \
1767 break;
1768 CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
1769 CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1770 CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1771 CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
1772 CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1773 CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1774 CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
1775 CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1776 CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1777 CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
1778 CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1779 CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1780 #undef CASE
1781 default: return 0;
1782 }
1783
1784 av_assert0(srcSliceH > 1);
1785
1786 copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1787 srcPtr += 2 * srcStride[0];
1788 dstY += 2 * dstStride[0];
1789 dstU += dstStride[1];
1790 dstV += dstStride[1];
1791
1792 for (i = 2; i < srcSliceH - 2; i += 2) {
1793 interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1794 srcPtr += 2 * srcStride[0];
1795 dstY += 2 * dstStride[0];
1796 dstU += dstStride[1];
1797 dstV += dstStride[1];
1798 }
1799
1800 if (i + 1 == srcSliceH) {
1801 copy(srcPtr, -srcStride[0], dstY, dstU, dstV, -dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1802 } else if (i < srcSliceH)
1803 copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1804 return srcSliceH;
1805 }
1806
1807 #define isRGBA32(x) ( \
1808 (x) == AV_PIX_FMT_ARGB \
1809 || (x) == AV_PIX_FMT_RGBA \
1810 || (x) == AV_PIX_FMT_BGRA \
1811 || (x) == AV_PIX_FMT_ABGR \
1812 )
1813
1814 #define isRGBA64(x) ( \
1815 (x) == AV_PIX_FMT_RGBA64LE \
1816 || (x) == AV_PIX_FMT_RGBA64BE \
1817 || (x) == AV_PIX_FMT_BGRA64LE \
1818 || (x) == AV_PIX_FMT_BGRA64BE \
1819 )
1820
1821 #define isRGB48(x) ( \
1822 (x) == AV_PIX_FMT_RGB48LE \
1823 || (x) == AV_PIX_FMT_RGB48BE \
1824 || (x) == AV_PIX_FMT_BGR48LE \
1825 || (x) == AV_PIX_FMT_BGR48BE \
1826 )
1827
1828 #define isAYUV(x) ( \
1829 (x) == AV_PIX_FMT_AYUV \
1830 || (x) == AV_PIX_FMT_VUYA \
1831 || (x) == AV_PIX_FMT_VUYX \
1832 || (x) == AV_PIX_FMT_UYVA \
1833 )
1834
1835 #define isX2RGB(x) ( \
1836 (x) == AV_PIX_FMT_X2RGB10LE \
1837 || (x) == AV_PIX_FMT_X2BGR10LE \
1838 )
1839
1840 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1841 typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1842 21787 static rgbConvFn findRgbConvFn(SwsInternal *c)
1843 {
1844 21787 const enum AVPixelFormat srcFormat = c->opts.src_format;
1845 21787 const enum AVPixelFormat dstFormat = c->opts.dst_format;
1846 21787 const int srcId = c->srcFormatBpp;
1847 21787 const int dstId = c->dstFormatBpp;
1848 21787 rgbConvFn conv = NULL;
1849
1850 #define IS_NOT_NE(bpp, desc) \
1851 (((bpp + 7) >> 3) == 2 && \
1852 (!(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
13/16
✓ Branch 0 taken 21518 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 21183 times.
✓ Branch 3 taken 335 times.
✓ Branch 4 taken 16551 times.
✓ Branch 5 taken 4632 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 16545 times.
✓ Branch 8 taken 5242 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5242 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4748 times.
✓ Branch 13 taken 494 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 4748 times.
21787 if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
1857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
494 if ( CONV_IS(ABGR, RGBA)
1858
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
494 || CONV_IS(ARGB, BGRA)
1859
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 220 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
250 || CONV_IS(BGRA, ARGB)
1860
3/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
494 || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
1861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250 else if (CONV_IS(ABGR, ARGB)
1862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250 || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
1863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250 else if (CONV_IS(ABGR, BGRA)
1864
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250 || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
1865
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 220 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
250 else if (CONV_IS(BGRA, RGBA)
1866
3/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 220 times.
✗ Branch 3 not taken.
250 || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
1867
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 else if (CONV_IS(BGRA, ABGR)
1868
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
1869
16/16
✓ Branch 0 taken 20956 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 20870 times.
✓ Branch 3 taken 86 times.
✓ Branch 4 taken 20865 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 20861 times.
✓ Branch 8 taken 403 times.
✓ Branch 9 taken 29 times.
✓ Branch 10 taken 393 times.
✓ Branch 11 taken 10 times.
✓ Branch 12 taken 389 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 385 times.
21293 } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
1870
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 2 times.
47 if (CONV_IS(RGB48LE, BGR48LE)
1871
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
45 || CONV_IS(BGR48LE, RGB48LE)
1872
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 2 times.
43 || CONV_IS(RGB48BE, BGR48BE)
1873
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
47 || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
1874
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 2 times.
39 else if (CONV_IS(RGB48LE, BGR48BE)
1875
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
37 || CONV_IS(BGR48LE, RGB48BE)
1876
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2 times.
35 || CONV_IS(RGB48BE, BGR48LE)
1877
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
39 || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
1878
15/16
✓ Branch 0 taken 20939 times.
✓ Branch 1 taken 307 times.
✓ Branch 2 taken 20862 times.
✓ Branch 3 taken 77 times.
✓ Branch 4 taken 20861 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20861 times.
✓ Branch 8 taken 381 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 377 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 373 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 369 times.
21246 } else if (isRGB48(srcFormat) && isRGBA64(dstFormat)) {
1879
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2 times.
16 if (CONV_IS(RGB48LE, BGRA64LE)
1880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 || CONV_IS(BGR48LE, RGBA64LE)
1881
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2 times.
14 || CONV_IS(RGB48BE, BGRA64BE)
1882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 || CONV_IS(BGR48BE, RGBA64BE)) conv = rgb48tobgr64_nobswap;
1883
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
12 else if (CONV_IS(RGB48LE, BGRA64BE)
1884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 || CONV_IS(BGR48LE, RGBA64BE)
1885
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
10 || CONV_IS(RGB48BE, BGRA64LE)
1886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 || CONV_IS(BGR48BE, RGBA64LE)) conv = rgb48tobgr64_bswap;
1887
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2 times.
16 if (CONV_IS(RGB48LE, RGBA64LE)
1888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 || CONV_IS(BGR48LE, BGRA64LE)
1889
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2 times.
14 || CONV_IS(RGB48BE, RGBA64BE)
1890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 || CONV_IS(BGR48BE, BGRA64BE)) conv = rgb48to64_nobswap;
1891
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
12 else if (CONV_IS(RGB48LE, RGBA64BE)
1892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 || CONV_IS(BGR48LE, BGRA64BE)
1893
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
10 || CONV_IS(RGB48BE, RGBA64LE)
1894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 || CONV_IS(BGR48BE, BGRA64LE)) conv = rgb48to64_bswap;
1895
14/16
✓ Branch 0 taken 21225 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 21210 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 21205 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 21201 times.
✓ Branch 8 taken 21 times.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 13 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 13 times.
21230 } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
1896
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
16 if (CONV_IS(RGBA64LE, BGR48LE)
1897
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
16 || CONV_IS(BGRA64LE, RGB48LE)
1898
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
14 || CONV_IS(RGBA64BE, BGR48BE)
1899
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
16 || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
1900
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
12 else if (CONV_IS(RGBA64LE, BGR48BE)
1901
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
12 || CONV_IS(BGRA64LE, RGB48BE)
1902
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
10 || CONV_IS(RGBA64BE, BGR48LE)
1903
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
12 || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
1904
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
8 else if (CONV_IS(RGBA64LE, RGB48LE)
1905
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 || CONV_IS(BGRA64LE, BGR48LE)
1906
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
6 || CONV_IS(RGBA64BE, RGB48BE)
1907
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
1908
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
4 else if (CONV_IS(RGBA64LE, RGB48BE)
1909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 || CONV_IS(BGRA64LE, BGR48BE)
1910
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 || CONV_IS(RGBA64BE, RGB48LE)
1911
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
1912
10/12
✓ Branch 0 taken 20926 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 20638 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 80 times.
21214 } else if (isX2RGB(srcFormat) && isRGB48(dstFormat)) {
1913
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 248 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 246 times.
496 if (CONV_IS(X2RGB10LE, RGB48LE)
1914
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
496 || CONV_IS(X2BGR10LE, BGR48LE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_bswap
1915 : x2rgb10to48_nobswap;
1916
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
250 else if (CONV_IS(X2RGB10LE, RGB48BE)
1917
2/4
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
250 || CONV_IS(X2BGR10LE, BGR48BE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_nobswap
1918 : x2rgb10to48_bswap;
1919
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 else if (CONV_IS(X2RGB10LE, BGR48LE)
1920
3/4
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 2 times.
248 || CONV_IS(X2BGR10LE, RGB48LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_bswap
1921 : x2rgb10tobgr48_nobswap;
1922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 else if (CONV_IS(X2RGB10LE, BGR48BE)
1923
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 || CONV_IS(X2BGR10LE, RGB48BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_nobswap
1924 : x2rgb10tobgr48_bswap;
1925
8/12
✓ Branch 0 taken 20678 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 20638 times.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 80 times.
20718 } else if (isX2RGB(srcFormat) && isRGBA64(dstFormat)) {
1926 if (CONV_IS(X2RGB10LE, RGBA64LE)
1927 || CONV_IS(X2BGR10LE, BGRA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_bswap
1928 : x2rgb10to64_nobswap;
1929 else if (CONV_IS(X2RGB10LE, RGBA64BE)
1930 || CONV_IS(X2BGR10LE, BGRA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_nobswap
1931 : x2rgb10to64_bswap;
1932 else if (CONV_IS(X2RGB10LE, BGRA64LE)
1933 || CONV_IS(X2BGR10LE, RGBA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_bswap
1934 : x2rgb10tobgr64_nobswap;
1935 else if (CONV_IS(X2RGB10LE, BGRA64BE)
1936 || CONV_IS(X2BGR10LE, RGBA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_nobswap
1937 : x2rgb10tobgr64_bswap;
1938
4/16
✓ Branch 0 taken 20718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20718 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20718 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20718 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
20718 } 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
5/6
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 18234 times.
✓ Branch 4 taken 2484 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16864 times.
✓ Branch 7 taken 3854 times.
41436 if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
1951
2/2
✓ Branch 2 taken 15858 times.
✓ Branch 3 taken 1006 times.
37582 (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
1952
7/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8903 times.
✓ Branch 8 taken 1984 times.
✓ Branch 9 taken 4506 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 162 times.
✓ Branch 13 taken 283 times.
15858 switch (srcId | (dstId << 16)) {
1953 case 0x000F000C: conv = rgb12to15; break;
1954 case 0x000F0010: conv = rgb16to15; break;
1955 10 case 0x000F0018: conv = rgb24to15; break;
1956 case 0x000F0020: conv = rgb32to15; break;
1957 case 0x0010000F: conv = rgb15to16; break;
1958 10 case 0x00100018: conv = rgb24to16; break;
1959 case 0x00100020: conv = rgb32to16; break;
1960 8903 case 0x0018000F: conv = rgb15to24; break;
1961 1984 case 0x00180010: conv = rgb16to24; break;
1962 4506 case 0x00180020: conv = rgb32to24; break;
1963 case 0x0020000F: conv = rgb15to32; break;
1964 case 0x00200010: conv = rgb16to32; break;
1965 162 case 0x00200018: conv = rgb24to32; break;
1966 }
1967
6/6
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2420 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 2253 times.
✓ Branch 6 taken 1006 times.
✓ Branch 7 taken 1601 times.
7467 } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
1968
2/2
✓ Branch 2 taken 436 times.
✓ Branch 3 taken 570 times.
3613 (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
1969
5/17
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1595 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 828 times.
✓ Branch 12 taken 72 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 119 times.
✓ Branch 16 taken 75 times.
2689 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 1595 case 0x0018000F: conv = rgb15tobgr24; break;
1980 case 0x00180010: conv = rgb16tobgr24; break;
1981 828 case 0x00180018: conv = rgb24tobgr24; break;
1982 72 case 0x00180020: conv = rgb32tobgr24; break;
1983 case 0x0020000F: conv = rgb15tobgr32; break;
1984 case 0x00200010: conv = rgb16tobgr32; break;
1985 119 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
2/2
✓ Branch 0 taken 3436 times.
✓ Branch 1 taken 18351 times.
21787 if (c->opts.flags & SWS_BITEXACT)
1994
7/12
✓ Branch 0 taken 3386 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3386 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 50 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 50 times.
✗ Branch 11 not taken.
3436 if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0)
1995 50 return NULL;
1996
1997 21737 return conv;
1998 }
1999
2000 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
2001 18576 static 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 18576 const enum AVPixelFormat srcFormat = c->opts.src_format;
2007 18576 const enum AVPixelFormat dstFormat = c->opts.dst_format;
2008 18576 const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2009 18576 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2010 18576 const int srcBpp = desc_src->comp[0].step;
2011 18576 const int dstBpp = desc_dst->comp[0].step;
2012 18576 rgbConvFn conv = findRgbConvFn(c);
2013
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18576 times.
18576 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 18576 const uint8_t *srcPtr = src[0];
2019 18576 uint8_t *dstPtr = dst[0];
2020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18576 int src_bswap = IS_NOT_NE(srcBpp, desc_src);
2021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18576 int dst_bswap = IS_NOT_NE(dstBpp, desc_dst);
2022
2023
4/6
✓ Branch 0 taken 18576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 18333 times.
✓ Branch 4 taken 243 times.
✗ Branch 5 not taken.
18576 if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
2024
4/6
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
243 !isRGBA32(dstFormat))
2025 9 srcPtr += ALT32_CORR;
2026
2027
4/6
✓ Branch 0 taken 18576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 18567 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
18576 if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
2028
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 !isRGBA32(srcFormat)) {
2029 int i;
2030 av_assert0(ALT32_CORR == 1);
2031
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 9 times.
265 for (i = 0; i < srcSliceH; i++)
2032 256 dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
2033 9 dstPtr += ALT32_CORR;
2034 }
2035
2036
3/4
✓ Branch 0 taken 13747 times.
✓ Branch 1 taken 4829 times.
✓ Branch 2 taken 13747 times.
✗ Branch 3 not taken.
18576 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
2037
3/6
✓ Branch 0 taken 13747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13747 times.
✗ Branch 5 not taken.
13747 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
2038 13747 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
2039 13747 (srcSliceH - 1) * srcStride[0] + c->opts.src_w * srcBpp);
2040 else {
2041 int i, j;
2042 4829 dstPtr += dstStride[0] * srcSliceY;
2043
2044
2/2
✓ Branch 0 taken 183137 times.
✓ Branch 1 taken 4829 times.
187966 for (i = 0; i < srcSliceH; i++) {
2045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183137 times.
183137 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 183137 conv(srcPtr, dstPtr, c->opts.src_w * srcBpp);
2051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183137 times.
183137 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 183137 srcPtr += srcStride[0];
2055 183137 dstPtr += dstStride[0];
2056 }
2057 }
2058 }
2059 18576 return srcSliceH;
2060 }
2061
2062 static 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 {
2066 ff_rgb24toyv12(
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
2079 static 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
2095 static 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
2115 static int float_y_to_uint_y_wrapper(SwsInternal *c,
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) */
2138 499 static 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
2/4
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 499 times.
✗ Branch 3 not taken.
499 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
2143 499 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 499 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
2220 31210 static 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 31210 const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2225 31210 const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2226 int plane, i, j;
2227
4/4
✓ Branch 0 taken 114868 times.
✓ Branch 1 taken 3756 times.
✓ Branch 2 taken 87414 times.
✓ Branch 3 taken 27454 times.
118624 for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
2228
4/4
✓ Branch 0 taken 56204 times.
✓ Branch 1 taken 31210 times.
✓ Branch 2 taken 3756 times.
✓ Branch 3 taken 52448 times.
87414 int length = (plane == 0 || plane == 3) ? c->opts.src_w : AV_CEIL_RSHIFT(c->opts.src_w, c->chrDstHSubSample);
2229
4/4
✓ Branch 0 taken 56204 times.
✓ Branch 1 taken 31210 times.
✓ Branch 2 taken 52448 times.
✓ Branch 3 taken 3756 times.
87414 int y = (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
2230
4/4
✓ Branch 0 taken 56204 times.
✓ Branch 1 taken 31210 times.
✓ Branch 2 taken 52448 times.
✓ Branch 3 taken 3756 times.
87414 int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
2231 87414 const uint8_t *srcPtr = src[plane];
2232 87414 uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
2233
8/8
✓ Branch 0 taken 56255 times.
✓ Branch 1 taken 31159 times.
✓ Branch 2 taken 34966 times.
✓ Branch 3 taken 21289 times.
✓ Branch 4 taken 34888 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 31132 times.
✓ Branch 7 taken 3756 times.
87414 int shiftonly = plane == 1 || plane == 2 || (!c->opts.src_range && plane == 0);
2234
4/4
✓ Branch 0 taken 31159 times.
✓ Branch 1 taken 56255 times.
✓ Branch 3 taken 9870 times.
✓ Branch 4 taken 21289 times.
87414 if (plane == 1 && isSemiPlanarYUV(c->opts.dst_format))
2235 9870 length *= 2;
2236
2237 // ignore palette for GRAY8
2238
3/4
✓ Branch 0 taken 31159 times.
✓ Branch 1 taken 56255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31159 times.
87414 if (plane == 1 && desc_dst->nb_components < 3) continue;
2239
8/10
✓ Branch 0 taken 84706 times.
✓ Branch 1 taken 2708 times.
✓ Branch 2 taken 31159 times.
✓ Branch 3 taken 53547 times.
✓ Branch 4 taken 31159 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 83658 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1048 times.
87414 if (!src[plane] || (plane == 1 && desc_src->nb_components < 3) || (plane == 3 && desc_src->nb_components <= 3)) {
2240
4/4
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 70 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 2450 times.
5416 if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
2241 516 fillPlane16(dst[plane], dstStride[plane], length, height, y,
2242 258 plane == 3, desc_dst->comp[plane].depth,
2243 258 isBE(c->opts.dst_format));
2244 } else {
2245
1/2
✓ Branch 0 taken 2450 times.
✗ Branch 1 not taken.
2450 fillPlane(dst[plane], dstStride[plane], length, height, y,
2246 (plane == 3) ? 255 : 128);
2247 }
2248 } else {
2249
4/4
✓ Branch 1 taken 33631 times.
✓ Branch 2 taken 51075 times.
✓ Branch 4 taken 14584 times.
✓ Branch 5 taken 19047 times.
84706 if(isNBPS(c->opts.src_format) || isNBPS(c->opts.dst_format)
2250
2/2
✓ Branch 2 taken 7779 times.
✓ Branch 3 taken 6805 times.
14584 || (is16BPS(c->opts.src_format) != is16BPS(c->opts.dst_format))
2251 77901 ) {
2252 77901 const int src_depth = desc_src->comp[plane].depth;
2253 77901 const int dst_depth = desc_dst->comp[plane].depth;
2254 77901 const int src_shift = desc_src->comp[plane].shift;
2255 77901 const int dst_shift = desc_dst->comp[plane].shift;
2256 77901 const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
2257 77901 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
2258
2259
2/2
✓ Branch 0 taken 22760 times.
✓ Branch 1 taken 55141 times.
77901 if (dst_depth == 8) {
2260 av_assert1(src_depth > 8);
2261
2/2
✓ Branch 1 taken 13030 times.
✓ Branch 2 taken 9730 times.
22760 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2262
20/22
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 10690 times.
✓ Branch 2 taken 3953664 times.
✓ Branch 3 taken 74880 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74880 times.
✓ Branch 6 taken 74880 times.
✓ Branch 7 taken 2340 times.
✓ Branch 8 taken 10170 times.
✓ Branch 9 taken 520 times.
✓ Branch 10 taken 19267416 times.
✓ Branch 11 taken 701544 times.
✓ Branch 12 taken 5100 times.
✓ Branch 13 taken 701544 times.
✓ Branch 14 taken 701544 times.
✓ Branch 15 taken 10170 times.
✓ Branch 16 taken 599040 times.
✓ Branch 17 taken 49920 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 49920 times.
✓ Branch 20 taken 49920 times.
✓ Branch 21 taken 520 times.
24664594 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
2263 } else {
2264
13/22
✗ Branch 0 not taken.
✓ Branch 1 taken 9730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 9210 times.
✓ Branch 9 taken 520 times.
✓ Branch 10 taken 12859776 times.
✓ Branch 11 taken 569664 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 569664 times.
✓ Branch 14 taken 569664 times.
✓ Branch 15 taken 9210 times.
✓ Branch 16 taken 599040 times.
✓ Branch 17 taken 49920 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 49920 times.
✓ Branch 20 taken 49920 times.
✓ Branch 21 taken 520 times.
14088130 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
2265 }
2266
2/2
✓ Branch 0 taken 17966 times.
✓ Branch 1 taken 37175 times.
55141 } else if (src_depth == 8) {
2267
2/2
✓ Branch 0 taken 972592 times.
✓ Branch 1 taken 17966 times.
990558 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
2/2
✓ Branch 1 taken 308832 times.
✓ Branch 2 taken 663760 times.
972592 if(isBE(c->opts.dst_format)){
2278
6/6
✓ Branch 0 taken 308448 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 102574080 times.
✓ Branch 3 taken 308448 times.
✓ Branch 4 taken 36864 times.
✓ Branch 5 taken 384 times.
102919776 COPY816(AV_WB16)
2279 } else {
2280
6/6
✓ Branch 0 taken 663376 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 238919340 times.
✓ Branch 3 taken 663376 times.
✓ Branch 4 taken 36864 times.
✓ Branch 5 taken 384 times.
239619964 COPY816(AV_WL16)
2281 }
2282 972592 dstPtr2 += dstStride[plane]/2;
2283 972592 srcPtr += srcStride[plane];
2284 }
2285
2/2
✓ Branch 0 taken 24983 times.
✓ Branch 1 taken 12192 times.
37175 } else if (src_depth <= dst_depth) {
2286 24983 unsigned shift = dst_depth - src_depth;
2287
2/2
✓ Branch 0 taken 800560 times.
✓ Branch 1 taken 24983 times.
825543 for (i = 0; i < height; i++) {
2288 800560 j = 0;
2289
4/4
✓ Branch 1 taken 619312 times.
✓ Branch 2 taken 181248 times.
✓ Branch 3 taken 361600 times.
✓ Branch 4 taken 257712 times.
1419872 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN &&
2290
1/2
✓ Branch 1 taken 361600 times.
✗ Branch 2 not taken.
980912 isBE(c->opts.dst_format) == HAVE_BIGENDIAN &&
2291 shiftonly) {
2292 #if HAVE_FAST_64BIT
2293
2/2
✓ Branch 0 taken 35638272 times.
✓ Branch 1 taken 361600 times.
35999872 for (; j < length - 3; j += 4) {
2294 35638272 uint64_t v = AV_RN64A(srcPtr2 + j) >> src_shift;
2295 35638272 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
2/2
✓ Branch 1 taken 181248 times.
✓ Branch 2 taken 619312 times.
800560 if(isBE(c->opts.src_format)){
2317
2/2
✓ Branch 1 taken 576 times.
✓ Branch 2 taken 180672 times.
181248 if(isBE(c->opts.dst_format)){
2318
3/6
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✓ Branch 3 taken 576 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
83520 COPY_UP(AV_RB16, AV_WB16)
2319 } else {
2320
3/6
✓ Branch 0 taken 180672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71304192 times.
✓ Branch 3 taken 180672 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
71484864 COPY_UP(AV_RB16, AV_WL16)
2321 }
2322 } else {
2323
2/2
✓ Branch 1 taken 257712 times.
✓ Branch 2 taken 361600 times.
619312 if(isBE(c->opts.dst_format)){
2324
3/6
✓ Branch 0 taken 257712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104776704 times.
✓ Branch 3 taken 257712 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
105034416 COPY_UP(AV_RL16, AV_WB16)
2325 } else {
2326
2/6
✓ Branch 0 taken 361600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 361600 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
361600 COPY_UP(AV_RL16, AV_WL16)
2327 }
2328 }
2329 800560 dstPtr2 += dstStride[plane]/2;
2330 800560 srcPtr2 += srcStride[plane]/2;
2331 }
2332 } else { /* src_depth > dst_depth */
2333
2/2
✓ Branch 1 taken 7968 times.
✓ Branch 2 taken 4224 times.
12192 if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2334
2/2
✓ Branch 1 taken 6090 times.
✓ Branch 2 taken 1878 times.
7968 if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2335
13/22
✓ Branch 0 taken 1872 times.
✓ Branch 1 taken 4218 times.
✓ Branch 2 taken 2965248 times.
✓ Branch 3 taken 59904 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59904 times.
✓ Branch 6 taken 59904 times.
✓ Branch 7 taken 1872 times.
✓ Branch 8 taken 4218 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6929280 times.
✓ Branch 11 taken 135360 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 135360 times.
✓ Branch 14 taken 135360 times.
✓ Branch 15 taken 4218 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
10095882 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
2336 } else {
2337
13/22
✓ Branch 0 taken 1872 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2965248 times.
✓ Branch 3 taken 59904 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59904 times.
✓ Branch 6 taken 59904 times.
✓ Branch 7 taken 1872 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10368 times.
✓ Branch 11 taken 576 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 576 times.
✓ Branch 14 taken 576 times.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
3037974 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
2338 }
2339 }else{
2340
2/2
✓ Branch 1 taken 4218 times.
✓ Branch 2 taken 6 times.
4224 if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2341
7/22
✗ Branch 0 not taken.
✓ Branch 1 taken 4218 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4218 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6929280 times.
✓ Branch 11 taken 135360 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 135360 times.
✓ Branch 14 taken 135360 times.
✓ Branch 15 taken 4218 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
7068858 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
2342 } else {
2343
7/22
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10368 times.
✓ Branch 11 taken 576 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 576 times.
✓ Branch 14 taken 576 times.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
10950 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
2344 }
2345 }
2346 }
2347
5/6
✓ Branch 1 taken 3606 times.
✓ Branch 2 taken 3199 times.
✓ Branch 4 taken 3606 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2436 times.
✓ Branch 7 taken 1170 times.
12847 } else if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format) &&
2348 3606 isBE(c->opts.src_format) != isBE(c->opts.dst_format)) {
2349
2350
2/2
✓ Branch 0 taken 91176 times.
✓ Branch 1 taken 2436 times.
93612 for (i = 0; i < height; i++) {
2351
2/2
✓ Branch 0 taken 40513536 times.
✓ Branch 1 taken 91176 times.
40604712 for (j = 0; j < length; j++)
2352 40513536 ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
2353 91176 srcPtr += srcStride[plane];
2354 91176 dstPtr += dstStride[plane];
2355 }
2356
4/6
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 4356 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
4395 } else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format) &&
2357 13 isBE(c->opts.src_format) != isBE(c->opts.dst_format)) { /* swap float plane */
2358
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (i = 0; i < height; i++) {
2359
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for (j = 0; j < length; j++)
2360 1317888 ((uint32_t *) dstPtr)[j] = av_bswap32(((const uint32_t *) srcPtr)[j]);
2361 3744 srcPtr += srcStride[plane];
2362 3744 dstPtr += dstStride[plane];
2363 }
2364
2/2
✓ Branch 0 taken 2721 times.
✓ Branch 1 taken 1635 times.
4356 } else if (dstStride[plane] == srcStride[plane] &&
2365
3/4
✓ Branch 0 taken 2721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1551 times.
✓ Branch 3 taken 1170 times.
2721 srcStride[plane] > 0 && srcStride[plane] == length) {
2366 1551 memcpy(dst[plane] + dstStride[plane] * y, src[plane],
2367 1551 height * dstStride[plane]);
2368 } else {
2369
3/4
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 1635 times.
✓ Branch 4 taken 1170 times.
✗ Branch 5 not taken.
2805 if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format))
2370 1170 length *= 2;
2371
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1635 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1635 else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format))
2372 length *= 4;
2373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1635 times.
1635 else if (desc_src->comp[0].depth == 1)
2374 length >>= 3; // monowhite/black
2375
2/2
✓ Branch 0 taken 98880 times.
✓ Branch 1 taken 2805 times.
101685 for (i = 0; i < height; i++) {
2376 98880 memcpy(dstPtr, srcPtr, length);
2377 98880 srcPtr += srcStride[plane];
2378 98880 dstPtr += dstStride[plane];
2379 }
2380 }
2381 }
2382 }
2383 31210 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
2392 47021 void ff_get_unscaled_swscale(SwsInternal *c)
2393 {
2394 47021 const enum AVPixelFormat srcFormat = c->opts.src_format;
2395 47021 const enum AVPixelFormat dstFormat = c->opts.dst_format;
2396 47021 const int flags = c->opts.flags;
2397 47021 const int dstH = c->opts.dst_h;
2398 47021 const int dstW = c->opts.dst_w;
2399 int needsDither;
2400
2401 47021 needsDither = isAnyRGB(dstFormat) &&
2402
4/4
✓ Branch 0 taken 14591 times.
✓ Branch 1 taken 32430 times.
✓ Branch 2 taken 2343 times.
✓ Branch 3 taken 12248 times.
49364 c->dstFormatBpp < 24 &&
2403
3/4
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 1328 times.
✓ Branch 3 taken 1015 times.
✗ Branch 4 not taken.
2343 (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
2404
2405 /* yv12_to_nv12 */
2406
6/6
✓ Branch 0 taken 41106 times.
✓ Branch 1 taken 5915 times.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 40490 times.
✓ Branch 4 taken 6470 times.
✓ Branch 5 taken 61 times.
47021 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2407
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6448 times.
6470 (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
2408 83 c->convert_unscaled = planarToNv12Wrapper;
2409 }
2410 /* yv24_to_nv24 */
2411
6/6
✓ Branch 0 taken 45806 times.
✓ Branch 1 taken 1215 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 45682 times.
✓ Branch 4 taken 1316 times.
✓ Branch 5 taken 23 times.
47021 if ((srcFormat == AV_PIX_FMT_YUV444P || srcFormat == AV_PIX_FMT_YUVA444P) &&
2412
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1313 times.
1316 (dstFormat == AV_PIX_FMT_NV24 || dstFormat == AV_PIX_FMT_NV42)) {
2413 26 c->convert_unscaled = planarToNv24Wrapper;
2414 }
2415 /* nv12_to_yv12 */
2416
4/4
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 46284 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 10 times.
47021 if (dstFormat == AV_PIX_FMT_YUV420P &&
2417
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 717 times.
727 (srcFormat == AV_PIX_FMT_NV12 || srcFormat == AV_PIX_FMT_NV21)) {
2418 20 c->convert_unscaled = nv12ToPlanarWrapper;
2419 }
2420 /* nv24_to_yv24 */
2421
4/4
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 45962 times.
✓ Branch 2 taken 1037 times.
✓ Branch 3 taken 22 times.
47021 if (dstFormat == AV_PIX_FMT_YUV444P &&
2422
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1036 times.
1037 (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42)) {
2423 23 c->convert_unscaled = nv24ToPlanarWrapper;
2424 }
2425 /* yuv2bgr */
2426
6/6
✓ Branch 0 taken 41106 times.
✓ Branch 1 taken 5915 times.
✓ Branch 2 taken 40305 times.
✓ Branch 3 taken 801 times.
✓ Branch 4 taken 616 times.
✓ Branch 5 taken 39689 times.
47021 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
2427
2/2
✓ Branch 1 taken 4751 times.
✓ Branch 2 taken 2581 times.
7332 srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
2428
5/8
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 2903 times.
✓ Branch 2 taken 1848 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1848 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1848 times.
✗ Branch 7 not taken.
4751 !(flags & SWS_ACCURATE_RND) && (c->opts.dither == SWS_DITHER_BAYER || c->opts.dither == SWS_DITHER_AUTO) && !(dstH & 1)) {
2429 1848 c->convert_unscaled = ff_yuv2rgb_get_func_ptr(c);
2430 1848 c->dst_slice_align = 2;
2431 }
2432 /* yuv420p1x_to_p01x */
2433
5/6
✓ Branch 0 taken 46871 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 46871 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46754 times.
✓ Branch 5 taken 117 times.
47021 if ((srcFormat == AV_PIX_FMT_YUV420P10 || srcFormat == AV_PIX_FMT_YUVA420P10 ||
2434
1/2
✓ Branch 0 taken 46754 times.
✗ Branch 1 not taken.
46754 srcFormat == AV_PIX_FMT_YUV420P12 ||
2435
2/2
✓ Branch 0 taken 46614 times.
✓ Branch 1 taken 140 times.
46754 srcFormat == AV_PIX_FMT_YUV420P14 ||
2436
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46614 times.
✓ Branch 2 taken 407 times.
✗ Branch 3 not taken.
47021 srcFormat == AV_PIX_FMT_YUV420P16 || srcFormat == AV_PIX_FMT_YUVA420P16) &&
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 (dstFormat == AV_PIX_FMT_P010 || dstFormat == AV_PIX_FMT_P016)) {
2438 c->convert_unscaled = planarToP01xWrapper;
2439 }
2440 /* yuv420p_to_p01xle */
2441
6/6
✓ Branch 0 taken 41106 times.
✓ Branch 1 taken 5915 times.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 40490 times.
✓ Branch 4 taken 6519 times.
✓ Branch 5 taken 12 times.
47021 if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2442
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6507 times.
6519 (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P016LE)) {
2443 24 c->convert_unscaled = planar8ToP01xleWrapper;
2444 }
2445
2446
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46906 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 111 times.
✓ Branch 5 taken 3 times.
47021 if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) &&
2447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 !(flags & SWS_BITEXACT)) {
2449 c->convert_unscaled = yvu9ToYv12Wrapper;
2450 c->dst_slice_align = 4;
2451 }
2452
2453 /* bgr24toYV12 */
2454
4/4
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 46720 times.
✓ Branch 2 taken 281 times.
✓ Branch 3 taken 20 times.
47021 if (srcFormat == AV_PIX_FMT_BGR24 &&
2455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281 times.
281 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 !(flags & SWS_ACCURATE_RND) && !(dstW&1))
2457 c->convert_unscaled = bgr24ToYv12Wrapper;
2458
2459 /* AYUV/VUYA/UYVA -> AYUV/VUYA/UYVA */
2460
12/18
✓ Branch 0 taken 46881 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 46741 times.
✓ Branch 3 taken 140 times.
✓ Branch 4 taken 46490 times.
✓ Branch 5 taken 251 times.
✓ Branch 6 taken 144 times.
✓ Branch 7 taken 46346 times.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 675 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 675 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 675 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
47021 if (isAYUV(srcFormat) && isAYUV(dstFormat) && findRgbConvFn(c))
2461 c->convert_unscaled = rgbToRgbWrapper;
2462
2463 /* RGB/BGR -> RGB/BGR (no dither needed forms) */
2464
6/6
✓ Branch 1 taken 17498 times.
✓ Branch 2 taken 29523 times.
✓ Branch 4 taken 3211 times.
✓ Branch 5 taken 14287 times.
✓ Branch 7 taken 611 times.
✓ Branch 8 taken 2600 times.
47021 if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
2465
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
611 && (!needsDither || (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT))))
2466 591 c->convert_unscaled = rgbToRgbWrapper;
2467
2468 /* RGB to planar RGB */
2469
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 46019 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1086 times.
✓ Branch 5 taken 45935 times.
47021 if ((srcFormat == AV_PIX_FMT_GBRP && dstFormat == AV_PIX_FMT_GBRAP) ||
2470
3/4
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1071 times.
✓ Branch 3 taken 45950 times.
47021 (srcFormat == AV_PIX_FMT_GBRP10 && dstFormat == AV_PIX_FMT_GBRAP10) ||
2471
3/4
✓ Branch 0 taken 1071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46880 times.
47021 (srcFormat == AV_PIX_FMT_GBRP12 && dstFormat == AV_PIX_FMT_GBRAP12) ||
2472
3/4
✓ Branch 0 taken 141 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447 times.
✓ Branch 3 taken 46574 times.
47021 (srcFormat == AV_PIX_FMT_GBRP14 && dstFormat == AV_PIX_FMT_GBRAP14) ||
2473
3/4
✓ Branch 0 taken 447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 46820 times.
47021 (srcFormat == AV_PIX_FMT_GBRP16 && dstFormat == AV_PIX_FMT_GBRAP16) ||
2474
4/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46870 times.
47021 (srcFormat == AV_PIX_FMT_GBRAP && dstFormat == AV_PIX_FMT_GBRP) ||
2475
3/4
✓ Branch 0 taken 141 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46870 times.
47011 (srcFormat == AV_PIX_FMT_GBRAP10 && dstFormat == AV_PIX_FMT_GBRP10) ||
2476
3/4
✓ Branch 0 taken 141 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46871 times.
47011 (srcFormat == AV_PIX_FMT_GBRAP12 && dstFormat == AV_PIX_FMT_GBRP12) ||
2477
3/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 46868 times.
47011 (srcFormat == AV_PIX_FMT_GBRAP14 && dstFormat == AV_PIX_FMT_GBRP14) ||
2478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 (srcFormat == AV_PIX_FMT_GBRAP16 && dstFormat == AV_PIX_FMT_GBRP16))
2479 10 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
12/16
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 46019 times.
✓ Branch 3 taken 1002 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 992 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 992 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 962 times.
✓ Branch 10 taken 30 times.
✓ Branch 11 taken 962 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 962 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 10 times.
✓ Branch 16 taken 952 times.
47021 if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
2490 50 c->convert_unscaled = planarRgbToRgbWrapper;
2491
2492
11/14
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 46820 times.
✓ Branch 2 taken 191 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 191 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 181 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 171 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 171 times.
47021 if (srcFormat == AV_PIX_FMT_GBRAP && isByteRGB(dstFormat))
2493 30 c->convert_unscaled = planarRgbaToRgbWrapper;
2494
2495
6/6
✓ Branch 0 taken 45560 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 45165 times.
✓ Branch 3 taken 395 times.
✓ Branch 4 taken 45024 times.
✓ Branch 5 taken 141 times.
47021 if ((srcFormat == AV_PIX_FMT_RGB48LE || srcFormat == AV_PIX_FMT_RGB48BE ||
2496
4/4
✓ Branch 0 taken 44884 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 44743 times.
✓ Branch 3 taken 141 times.
45024 srcFormat == AV_PIX_FMT_BGR48LE || srcFormat == AV_PIX_FMT_BGR48BE ||
2497
4/4
✓ Branch 0 taken 44592 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 44451 times.
✓ Branch 3 taken 141 times.
44743 srcFormat == AV_PIX_FMT_RGBA64LE || srcFormat == AV_PIX_FMT_RGBA64BE ||
2498
4/4
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 44311 times.
✓ Branch 2 taken 2708 times.
✓ Branch 3 taken 2 times.
47021 srcFormat == AV_PIX_FMT_BGRA64LE || srcFormat == AV_PIX_FMT_BGRA64BE) &&
2499
4/4
✓ Branch 0 taken 2706 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2674 times.
✓ Branch 3 taken 32 times.
2708 (dstFormat == AV_PIX_FMT_GBRP9LE || dstFormat == AV_PIX_FMT_GBRP9BE ||
2500
4/4
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2630 times.
✓ Branch 3 taken 32 times.
2674 dstFormat == AV_PIX_FMT_GBRP10LE || dstFormat == AV_PIX_FMT_GBRP10BE ||
2501
4/4
✓ Branch 0 taken 2618 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2616 times.
✓ Branch 3 taken 2 times.
2630 dstFormat == AV_PIX_FMT_GBRP12LE || dstFormat == AV_PIX_FMT_GBRP12BE ||
2502
4/4
✓ Branch 0 taken 2614 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2592 times.
✓ Branch 3 taken 22 times.
2616 dstFormat == AV_PIX_FMT_GBRP14LE || dstFormat == AV_PIX_FMT_GBRP14BE ||
2503
4/4
✓ Branch 0 taken 2579 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2577 times.
✓ Branch 3 taken 2 times.
2592 dstFormat == AV_PIX_FMT_GBRP16LE || dstFormat == AV_PIX_FMT_GBRP16BE ||
2504
4/4
✓ Branch 0 taken 2575 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2573 times.
✓ Branch 3 taken 2 times.
2577 dstFormat == AV_PIX_FMT_GBRAP10LE || dstFormat == AV_PIX_FMT_GBRAP10BE ||
2505
4/4
✓ Branch 0 taken 2571 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2569 times.
✓ Branch 3 taken 2 times.
2573 dstFormat == AV_PIX_FMT_GBRAP12LE || dstFormat == AV_PIX_FMT_GBRAP12BE ||
2506
4/4
✓ Branch 0 taken 2567 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2565 times.
✓ Branch 3 taken 2 times.
2569 dstFormat == AV_PIX_FMT_GBRAP14LE || dstFormat == AV_PIX_FMT_GBRAP14BE ||
2507
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2562 times.
2565 dstFormat == AV_PIX_FMT_GBRAP16LE || dstFormat == AV_PIX_FMT_GBRAP16BE ))
2508 148 c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2509
2510
4/4
✓ Branch 1 taken 18633 times.
✓ Branch 2 taken 28388 times.
✓ Branch 3 taken 3814 times.
✓ Branch 4 taken 14819 times.
65654 if (av_pix_fmt_desc_get(dstFormat)->comp[0].depth >= 10 &&
2511
4/4
✓ Branch 2 taken 3284 times.
✓ Branch 3 taken 530 times.
✓ Branch 4 taken 3264 times.
✓ Branch 5 taken 20 times.
22447 isPlanarRGB(dstFormat) && !isFloat(dstFormat) &&
2512
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3244 times.
3264 (srcFormat == AV_PIX_FMT_X2RGB10LE || srcFormat == AV_PIX_FMT_X2BGR10LE))
2513 40 c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2514
2515
6/6
✓ Branch 0 taken 46880 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 46740 times.
✓ Branch 3 taken 140 times.
✓ Branch 4 taken 46293 times.
✓ Branch 5 taken 447 times.
47021 if ((srcFormat == AV_PIX_FMT_GBRP9LE || srcFormat == AV_PIX_FMT_GBRP9BE ||
2516
4/4
✓ Branch 0 taken 45993 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 44907 times.
✓ Branch 3 taken 1086 times.
46293 srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
2517
4/4
✓ Branch 0 taken 44657 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 43586 times.
✓ Branch 3 taken 1071 times.
44907 srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
2518
4/4
✓ Branch 0 taken 43336 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 43195 times.
✓ Branch 3 taken 141 times.
43586 srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
2519
4/4
✓ Branch 0 taken 43055 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 42914 times.
✓ Branch 3 taken 141 times.
43195 srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
2520
4/4
✓ Branch 0 taken 42774 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 42633 times.
✓ Branch 3 taken 141 times.
42914 srcFormat == AV_PIX_FMT_GBRAP10LE || srcFormat == AV_PIX_FMT_GBRAP10BE ||
2521
4/4
✓ Branch 0 taken 42493 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 42353 times.
✓ Branch 3 taken 140 times.
42633 srcFormat == AV_PIX_FMT_GBRAP12LE || srcFormat == AV_PIX_FMT_GBRAP12BE ||
2522
4/4
✓ Branch 0 taken 42213 times.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 42070 times.
✓ Branch 3 taken 143 times.
42353 srcFormat == AV_PIX_FMT_GBRAP14LE || srcFormat == AV_PIX_FMT_GBRAP14BE ||
2523
4/4
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 41930 times.
✓ Branch 2 taken 4952 times.
✓ Branch 3 taken 139 times.
47021 srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
2524
3/4
✓ Branch 0 taken 4934 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 4934 times.
✗ Branch 3 not taken.
4952 (dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE ||
2525
2/4
✓ Branch 0 taken 4934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4934 times.
✗ Branch 3 not taken.
4934 dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
2526
2/4
✓ Branch 0 taken 4934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4934 times.
✗ Branch 3 not taken.
4934 dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
2527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4934 times.
4934 dstFormat == AV_PIX_FMT_BGRA64LE || dstFormat == AV_PIX_FMT_BGRA64BE))
2528 157 c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2529
2530
4/4
✓ Branch 1 taken 25468 times.
✓ Branch 2 taken 21553 times.
✓ Branch 3 taken 6351 times.
✓ Branch 4 taken 19117 times.
72489 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth >= 10 &&
2531
4/4
✓ Branch 2 taken 5372 times.
✓ Branch 3 taken 979 times.
✓ Branch 4 taken 5352 times.
✓ Branch 5 taken 20 times.
31819 isPlanarRGB(srcFormat) && !isFloat(srcFormat) &&
2532
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5332 times.
5352 (dstFormat == AV_PIX_FMT_X2RGB10LE || dstFormat == AV_PIX_FMT_X2BGR10LE))
2533 40 c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2534
2535
4/4
✓ Branch 1 taken 17544 times.
✓ Branch 2 taken 29477 times.
✓ Branch 3 taken 3320 times.
✓ Branch 4 taken 14224 times.
64565 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2536
2/2
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 3209 times.
20864 isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
2537 111 c->convert_unscaled = rgbToPlanarRgbWrapper;
2538
2539
4/4
✓ Branch 1 taken 17544 times.
✓ Branch 2 taken 29477 times.
✓ Branch 3 taken 3320 times.
✓ Branch 4 taken 14224 times.
64565 if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2540
2/2
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 3220 times.
20864 isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRAP)
2541 100 c->convert_unscaled = rgbToPlanarRgbaWrapper;
2542
2543
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 47021 times.
47021 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
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 47021 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47021 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 47021 times.
47021 if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_BGGR16) ||
2559
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47021 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47021 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_RGGB16) ||
2560
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47021 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47021 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GBRG16) ||
2561
3/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47021 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46881 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GRBG16) ||
2562
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46881 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46881 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
2563
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46880 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46881 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
2564
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 46861 times.
✓ Branch 4 taken 160 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46881 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
2565
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46881 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46881 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
2566
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46880 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 47019 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
2567
6/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 47019 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52 times.
✓ Branch 7 taken 46969 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY9) ||
2568
6/8
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 46969 times.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52 times.
✓ Branch 7 taken 46969 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY10) ||
2569
6/8
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 46969 times.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 47019 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY12) ||
2570
6/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 47019 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 46929 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY14) ||
2571
7/8
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 46957 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 47007 times.
47021 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
2572
6/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 47017 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46879 times.
47019 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16) ||
2573
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46879 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46879 times.
47019 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_AYUV64) ||
2574
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46878 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46769 times.
47019 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP9) ||
2575
8/8
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 45923 times.
✓ Branch 4 taken 1076 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46749 times.
47019 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10) ||
2576
8/8
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1071 times.
✓ Branch 3 taken 45918 times.
✓ Branch 4 taken 1061 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46839 times.
46999 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) ||
2577
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46838 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✓ Branch 7 taken 46679 times.
46979 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP14) ||
2578
8/8
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 447 times.
✓ Branch 3 taken 46522 times.
✓ Branch 4 taken 435 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46979 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP16) ||
2579
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46816 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10MSB) ||
2580
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46816 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12MSB) ||
2581
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46816 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP10) ||
2582
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46816 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP12) ||
2583
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46817 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46817 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP14) ||
2584
7/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 46814 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46815 times.
46957 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) ||
2585
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46815 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 395 times.
✓ Branch 7 taken 46560 times.
46955 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
2586
8/8
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1461 times.
✓ Branch 3 taken 45491 times.
✓ Branch 4 taken 1457 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46808 times.
46955 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
2587
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 46582 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46808 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
2588
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 46663 times.
✓ Branch 4 taken 285 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 151 times.
✓ Branch 7 taken 46797 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565) ||
2589
6/8
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46807 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46698 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
2590
6/8
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 46698 times.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 280 times.
✓ Branch 7 taken 46668 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV36) ||
2591
5/8
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 46668 times.
✓ Branch 4 taken 280 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46948 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV48) ||
2592
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46948 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46948 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XYZ12) ||
2593
5/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 46928 times.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46838 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P9) ||
2594
6/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 46798 times.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46838 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P10) ||
2595
5/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 46831 times.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46948 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P12) ||
2596
3/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46948 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46808 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P14) ||
2597
5/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46808 times.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46948 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P16) ||
2598
5/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 46938 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46838 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P9) ||
2599
6/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 46787 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46838 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P10) ||
2600
5/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 46835 times.
✓ Branch 4 taken 113 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 46948 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P12) ||
2601
3/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46948 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46808 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P14) ||
2602
7/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 46798 times.
✓ Branch 4 taken 140 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46828 times.
46948 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P16) ||
2603
6/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 46828 times.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 46828 times.
46938 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P10) ||
2604
6/8
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 46828 times.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46798 times.
46938 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P12) ||
2605
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46797 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46688 times.
46938 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P9) ||
2606
8/8
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1090 times.
✓ Branch 3 taken 45838 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46668 times.
46938 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10) ||
2607
8/8
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1092 times.
✓ Branch 3 taken 45816 times.
✓ Branch 4 taken 1082 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 46758 times.
46918 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12) ||
2608
6/8
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 46757 times.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 280 times.
✓ Branch 7 taken 46618 times.
46898 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P14) ||
2609
8/8
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 459 times.
✓ Branch 3 taken 46429 times.
✓ Branch 4 taken 449 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46628 times.
46898 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P16) ||
2610
6/8
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 46627 times.
✓ Branch 4 taken 251 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 46628 times.
46878 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10MSB) ||
2611
4/6
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 46627 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 251 times.
46878 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12MSB))
2612 143 c->convert_unscaled = bswap_16bpc;
2613
2614 /* bswap 32 bits per pixel/component formats */
2615
9/10
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 46881 times.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175 times.
✓ Branch 5 taken 46846 times.
✓ Branch 6 taken 174 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 46880 times.
47021 if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRPF32) ||
2616
4/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 46880 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
47020 IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAPF32))
2617 1 c->convert_unscaled = bswap_32bpc;
2618
2619
2/2
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 45573 times.
47021 if (usePal(srcFormat)) {
2620
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1438 times.
1448 switch (dstFormat) {
2621 10 case AV_PIX_FMT_GBRP:
2622 case AV_PIX_FMT_GBRAP:
2623 10 c->convert_unscaled = palToGbrpWrapper;
2624 10 break;
2625 1438 default:
2626
9/12
✓ Branch 0 taken 1398 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 1398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 656 times.
✓ Branch 5 taken 742 times.
✓ Branch 6 taken 607 times.
✓ Branch 7 taken 49 times.
✓ Branch 8 taken 607 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 607 times.
1438 if (isByteRGB(dstFormat))
2627 831 c->convert_unscaled = palToRgbWrapper;
2628 1438 break;
2629 }
2630 }
2631
2632
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 46220 times.
47021 if (srcFormat == AV_PIX_FMT_YUV422P) {
2633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if (dstFormat == AV_PIX_FMT_YUYV422)
2634 c->convert_unscaled = yuv422pToYuy2Wrapper;
2635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 else if (dstFormat == AV_PIX_FMT_UYVY422)
2636 c->convert_unscaled = yuv422pToUyvyWrapper;
2637 }
2638
2639 /* uint Y to float Y */
2640
3/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 46949 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
47021 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
3/4
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 46880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 141 times.
47021 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
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 46917 times.
47021 if (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
2651 /* yv12_to_yuy2 */
2652
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
104 if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
2653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if (dstFormat == AV_PIX_FMT_YUYV422)
2654 c->convert_unscaled = planarToYuy2Wrapper;
2655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 else if (dstFormat == AV_PIX_FMT_UYVY422)
2656 c->convert_unscaled = planarToUyvyWrapper;
2657 }
2658 }
2659
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 46910 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
47021 if (srcFormat == AV_PIX_FMT_YUYV422 &&
2660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2661 c->convert_unscaled = yuyvToYuv420Wrapper;
2662
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 46910 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
47021 if (srcFormat == AV_PIX_FMT_UYVY422 &&
2663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2664 c->convert_unscaled = uyvyToYuv420Wrapper;
2665
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 46910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
47021 if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
2666 c->convert_unscaled = yuyvToYuv422Wrapper;
2667
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 46910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
47021 if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
2668 c->convert_unscaled = uyvyToYuv422Wrapper;
2669
4/4
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 46284 times.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 66 times.
47021 if (dstFormat == AV_PIX_FMT_YUV420P &&
2670
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 615 times.
671 (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42))
2671 122 c->convert_unscaled = nv24ToYuv420Wrapper;
2672
2673 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
2674
2675 /* simple copy */
2676
4/4
✓ Branch 0 taken 46695 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 46079 times.
47021 if ( srcFormat == dstFormat ||
2677
3/4
✓ Branch 0 taken 616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5724 times.
✓ Branch 3 taken 40971 times.
46695 (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
2678
4/4
✓ Branch 0 taken 5695 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 45604 times.
✓ Branch 3 taken 1062 times.
52390 (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
2679
7/14
✓ Branch 4 taken 45193 times.
✓ Branch 5 taken 411 times.
✓ Branch 7 taken 23991 times.
✓ Branch 8 taken 21202 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 23991 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 29204 times.
✓ Branch 19 taken 15989 times.
137463 (isFloat(srcFormat) == isFloat(dstFormat) && isFloat16(srcFormat) == isFloat16(dstFormat)) && ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
2680
3/10
✗ Branch 2 not taken.
✓ Branch 3 taken 29204 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 45190 times.
119590 (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
2681
9/16
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 23991 times.
✓ Branch 17 taken 21199 times.
90386 (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
2682
2/2
✓ Branch 2 taken 13501 times.
✓ Branch 3 taken 10490 times.
69181 (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
2683
2/2
✓ Branch 0 taken 8604 times.
✓ Branch 1 taken 4897 times.
13501 c->chrDstHSubSample == c->chrSrcHSubSample &&
2684
4/4
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 1180 times.
✓ Branch 2 taken 4659 times.
✓ Branch 3 taken 2765 times.
16028 c->chrDstVSubSample == c->chrSrcVSubSample &&
2685
2/2
✓ Branch 2 taken 4645 times.
✓ Branch 3 taken 14 times.
12083 isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) &&
2686 4659 isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat))))
2687 {
2688
2/2
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4949 times.
5003 if (isPacked(c->opts.src_format)) {
2689 54 c->convert_unscaled = packedCopyWrapper;
2690 } else { /* Planar YUV or gray */
2691 4949 c->convert_unscaled = planarCopyWrapper;
2692
2/2
✓ Branch 0 taken 4449 times.
✓ Branch 1 taken 500 times.
4949 if (c->opts.dither != SWS_DITHER_NONE)
2693 4449 c->dst_slice_align = 8 << c->chrDstVSubSample;
2694 }
2695 }
2696
2697 47021 ff_sws_init_xyzdsp(c);
2698
2699 #if ARCH_PPC
2700 ff_get_unscaled_swscale_ppc(c);
2701 #elif ARCH_ARM
2702 ff_get_unscaled_swscale_arm(c);
2703 #elif ARCH_AARCH64
2704 ff_get_unscaled_swscale_aarch64(c);
2705 #endif
2706 47021 }
2707
2708 /* Convert the palette to the same packed 32-bit format as the palette */
2709 97576 void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst,
2710 int num_pixels, const uint8_t *palette)
2711 {
2712 int i;
2713
2714
2/2
✓ Branch 0 taken 30214048 times.
✓ Branch 1 taken 97576 times.
30311624 for (i = 0; i < num_pixels; i++)
2715 30214048 ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
2716 97576 }
2717
2718 /* Palette format: ABCD -> dst format: ABC */
2719 717310 void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst,
2720 int num_pixels, const uint8_t *palette)
2721 {
2722 int i;
2723
2724
2/2
✓ Branch 0 taken 273951884 times.
✓ Branch 1 taken 717310 times.
274669194 for (i = 0; i < num_pixels; i++) {
2725 //FIXME slow?
2726 273951884 dst[0] = palette[src[i] * 4 + 0];
2727 273951884 dst[1] = palette[src[i] * 4 + 1];
2728 273951884 dst[2] = palette[src[i] * 4 + 2];
2729 273951884 dst += 3;
2730 }
2731 717310 }
2732