FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/swscale_unscaled.c
Date: 2026-04-29 00:23:12
Exec Total Coverage
Lines: 992 1570 63.2%
Functions: 37 58 63.8%
Branches: 1443 2244 64.3%

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