FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/swscale_unscaled.c
Date: 2025-04-25 22:50:00
Exec Total Coverage
Lines: 890 1559 57.1%
Functions: 37 58 63.8%
Branches: 1130 2196 51.5%

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