FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/output.c
Date: 2025-04-25 22:50:00
Exec Total Coverage
Lines: 1519 1979 76.8%
Functions: 208 301 69.1%
Branches: 1100 1633 67.4%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2001-2012 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <math.h>
22 #include <stddef.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #include "libavutil/attributes.h"
27 #include "libavutil/avutil.h"
28 #include "libavutil/avassert.h"
29 #include "libavutil/bswap.h"
30 #include "libavutil/intfloat.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/mathematics.h"
33 #include "libavutil/mem_internal.h"
34 #include "libavutil/pixdesc.h"
35 #include "config.h"
36 #include "rgb2rgb.h"
37 #include "swscale.h"
38 #include "swscale_internal.h"
39
40 DECLARE_ALIGNED(8, const uint8_t, ff_dither_2x2_4)[][8] = {
41 { 1, 3, 1, 3, 1, 3, 1, 3, },
42 { 2, 0, 2, 0, 2, 0, 2, 0, },
43 { 1, 3, 1, 3, 1, 3, 1, 3, },
44 };
45
46 DECLARE_ALIGNED(8, const uint8_t, ff_dither_2x2_8)[][8] = {
47 { 6, 2, 6, 2, 6, 2, 6, 2, },
48 { 0, 4, 0, 4, 0, 4, 0, 4, },
49 { 6, 2, 6, 2, 6, 2, 6, 2, },
50 };
51
52 DECLARE_ALIGNED(8, const uint8_t, ff_dither_4x4_16)[][8] = {
53 { 8, 4, 11, 7, 8, 4, 11, 7, },
54 { 2, 14, 1, 13, 2, 14, 1, 13, },
55 { 10, 6, 9, 5, 10, 6, 9, 5, },
56 { 0, 12, 3, 15, 0, 12, 3, 15, },
57 { 8, 4, 11, 7, 8, 4, 11, 7, },
58 };
59
60 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_32)[][8] = {
61 { 17, 9, 23, 15, 16, 8, 22, 14, },
62 { 5, 29, 3, 27, 4, 28, 2, 26, },
63 { 21, 13, 19, 11, 20, 12, 18, 10, },
64 { 0, 24, 6, 30, 1, 25, 7, 31, },
65 { 16, 8, 22, 14, 17, 9, 23, 15, },
66 { 4, 28, 2, 26, 5, 29, 3, 27, },
67 { 20, 12, 18, 10, 21, 13, 19, 11, },
68 { 1, 25, 7, 31, 0, 24, 6, 30, },
69 { 17, 9, 23, 15, 16, 8, 22, 14, },
70 };
71
72 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_73)[][8] = {
73 { 0, 55, 14, 68, 3, 58, 17, 72, },
74 { 37, 18, 50, 32, 40, 22, 54, 35, },
75 { 9, 64, 5, 59, 13, 67, 8, 63, },
76 { 46, 27, 41, 23, 49, 31, 44, 26, },
77 { 2, 57, 16, 71, 1, 56, 15, 70, },
78 { 39, 21, 52, 34, 38, 19, 51, 33, },
79 { 11, 66, 7, 62, 10, 65, 6, 60, },
80 { 48, 30, 43, 25, 47, 29, 42, 24, },
81 { 0, 55, 14, 68, 3, 58, 17, 72, },
82 };
83
84 #if 1
85 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_220)[][8] = {
86 {117, 62, 158, 103, 113, 58, 155, 100, },
87 { 34, 199, 21, 186, 31, 196, 17, 182, },
88 {144, 89, 131, 76, 141, 86, 127, 72, },
89 { 0, 165, 41, 206, 10, 175, 52, 217, },
90 {110, 55, 151, 96, 120, 65, 162, 107, },
91 { 28, 193, 14, 179, 38, 203, 24, 189, },
92 {138, 83, 124, 69, 148, 93, 134, 79, },
93 { 7, 172, 48, 213, 3, 168, 45, 210, },
94 {117, 62, 158, 103, 113, 58, 155, 100, },
95 };
96 #elif 1
97 // tries to correct a gamma of 1.5
98 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_220)[][8] = {
99 { 0, 143, 18, 200, 2, 156, 25, 215, },
100 { 78, 28, 125, 64, 89, 36, 138, 74, },
101 { 10, 180, 3, 161, 16, 195, 8, 175, },
102 {109, 51, 93, 38, 121, 60, 105, 47, },
103 { 1, 152, 23, 210, 0, 147, 20, 205, },
104 { 85, 33, 134, 71, 81, 30, 130, 67, },
105 { 14, 190, 6, 171, 12, 185, 5, 166, },
106 {117, 57, 101, 44, 113, 54, 97, 41, },
107 { 0, 143, 18, 200, 2, 156, 25, 215, },
108 };
109 #elif 1
110 // tries to correct a gamma of 2.0
111 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_220)[][8] = {
112 { 0, 124, 8, 193, 0, 140, 12, 213, },
113 { 55, 14, 104, 42, 66, 19, 119, 52, },
114 { 3, 168, 1, 145, 6, 187, 3, 162, },
115 { 86, 31, 70, 21, 99, 39, 82, 28, },
116 { 0, 134, 11, 206, 0, 129, 9, 200, },
117 { 62, 17, 114, 48, 58, 16, 109, 45, },
118 { 5, 181, 2, 157, 4, 175, 1, 151, },
119 { 95, 36, 78, 26, 90, 34, 74, 24, },
120 { 0, 124, 8, 193, 0, 140, 12, 213, },
121 };
122 #else
123 // tries to correct a gamma of 2.5
124 DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_220)[][8] = {
125 { 0, 107, 3, 187, 0, 125, 6, 212, },
126 { 39, 7, 86, 28, 49, 11, 102, 36, },
127 { 1, 158, 0, 131, 3, 180, 1, 151, },
128 { 68, 19, 52, 12, 81, 25, 64, 17, },
129 { 0, 119, 5, 203, 0, 113, 4, 195, },
130 { 45, 9, 96, 33, 42, 8, 91, 30, },
131 { 2, 172, 1, 144, 2, 165, 0, 137, },
132 { 77, 23, 60, 15, 72, 21, 56, 14, },
133 { 0, 107, 3, 187, 0, 125, 6, 212, },
134 };
135 #endif
136
137 #define IS_BE_LE 0
138 #define IS_BE_BE 1
139 /* ENDIAN_IDENTIFIER needs to be "BE" or "LE". */
140 #define IS_BE(ENDIAN_IDENTIFIER) IS_BE_ ## ENDIAN_IDENTIFIER
141
142 #define output_pixel(pos, val, bias, signedness) \
143 if (big_endian) { \
144 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
145 } else { \
146 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
147 }
148
149 static av_always_inline void
150 2412046 yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
151 int big_endian, int output_bits)
152 {
153 int i;
154 2412046 int shift = 3;
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2412046 times.
2412046 av_assert0(output_bits == 16);
156
157
2/2
✓ Branch 0 taken 777755080 times.
✓ Branch 1 taken 2412046 times.
780167126 for (i = 0; i < dstW; i++) {
158 777755080 int val = src[i] + (1 << (shift - 1));
159
2/2
✓ Branch 0 taken 329890464 times.
✓ Branch 1 taken 447864616 times.
777755080 output_pixel(&dest[i], val, 0, uint);
160 }
161 2412046 }
162
163 static av_always_inline void
164 479112 yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
165 const int32_t **src, uint16_t *dest, int dstW,
166 int big_endian, int output_bits)
167 {
168 int i;
169 479112 int shift = 15;
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479112 times.
479112 av_assert0(output_bits == 16);
171
172
2/2
✓ Branch 0 taken 122885152 times.
✓ Branch 1 taken 479112 times.
123364264 for (i = 0; i < dstW; i++) {
173 122885152 int val = 1 << (shift - 1);
174 int j;
175
176 /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
177 * filters (or anything with negative coeffs, the range can be slightly
178 * wider in both directions. To account for this overflow, we subtract
179 * a constant so it always fits in the signed range (assuming a
180 * reasonable filterSize), and re-add that at the end. */
181 122885152 val -= 0x40000000;
182
2/2
✓ Branch 0 taken 635000960 times.
✓ Branch 1 taken 122885152 times.
757886112 for (j = 0; j < filterSize; j++)
183 635000960 val += src[j][i] * (unsigned)filter[j];
184
185
2/2
✓ Branch 0 taken 30103168 times.
✓ Branch 1 taken 92781984 times.
122885152 output_pixel(&dest[i], val, 0x8000, int);
186 }
187 479112 }
188
189 static av_always_inline void
190 587876 yuv2nv12cX_16_c_template(int big_endian, const uint8_t *chrDither,
191 const int16_t *chrFilter, int chrFilterSize,
192 const int16_t **chrUSrc, const int16_t **chrVSrc,
193 uint8_t *dest8, int chrDstW, int output_bits)
194 {
195 587876 uint16_t *dest = (uint16_t*)dest8;
196 587876 const int32_t **uSrc = (const int32_t **)chrUSrc;
197 587876 const int32_t **vSrc = (const int32_t **)chrVSrc;
198 587876 int shift = 15;
199 int i, j;
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 587876 times.
587876 av_assert0(output_bits == 16);
201
202
2/2
✓ Branch 0 taken 152970352 times.
✓ Branch 1 taken 587876 times.
153558228 for (i = 0; i < chrDstW; i++) {
203 152970352 int u = 1 << (shift - 1);
204 152970352 int v = 1 << (shift - 1);
205
206 /* See yuv2planeX_16_c_template for details. */
207 152970352 u -= 0x40000000;
208 152970352 v -= 0x40000000;
209
2/2
✓ Branch 0 taken 323697216 times.
✓ Branch 1 taken 152970352 times.
476667568 for (j = 0; j < chrFilterSize; j++) {
210 323697216 u += uSrc[j][i] * (unsigned)chrFilter[j];
211 323697216 v += vSrc[j][i] * (unsigned)chrFilter[j];
212 }
213
214
2/2
✓ Branch 0 taken 52927928 times.
✓ Branch 1 taken 100042424 times.
152970352 output_pixel(&dest[2*i] , u, 0x8000, int);
215
2/2
✓ Branch 0 taken 52927928 times.
✓ Branch 1 taken 100042424 times.
152970352 output_pixel(&dest[2*i+1], v, 0x8000, int);
216 }
217 587876 }
218
219 static av_always_inline void
220 24496 yuv2plane1_float_c_template(const int32_t *src, float *dest, int dstW)
221 {
222 static const int big_endian = HAVE_BIGENDIAN;
223 static const int shift = 3;
224 static const float float_mult = 1.0f / 65535.0f;
225 int i, val;
226 uint16_t val_uint;
227
228
2/2
✓ Branch 0 taken 8617152 times.
✓ Branch 1 taken 24496 times.
8641648 for (i = 0; i < dstW; ++i){
229 8617152 val = src[i] + (1 << (shift - 1));
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8617152 times.
8617152 output_pixel(&val_uint, val, 0, uint);
231 8617152 dest[i] = float_mult * (float)val_uint;
232 }
233 24496 }
234
235 static av_always_inline void
236 9504 yuv2plane1_float_bswap_c_template(const int32_t *src, uint32_t *dest, int dstW)
237 {
238 static const int big_endian = HAVE_BIGENDIAN;
239 static const int shift = 3;
240 static const float float_mult = 1.0f / 65535.0f;
241 int i, val;
242 uint16_t val_uint;
243
244
2/2
✓ Branch 0 taken 3345408 times.
✓ Branch 1 taken 9504 times.
3354912 for (i = 0; i < dstW; ++i){
245 3345408 val = src[i] + (1 << (shift - 1));
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3345408 times.
3345408 output_pixel(&val_uint, val, 0, uint);
247 3345408 dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint));
248 }
249 9504 }
250
251 static av_always_inline void
252 100 yuv2planeX_float_c_template(const int16_t *filter, int filterSize, const int32_t **src,
253 float *dest, int dstW)
254 {
255 static const int big_endian = HAVE_BIGENDIAN;
256 static const int shift = 15;
257 static const float float_mult = 1.0f / 65535.0f;
258 int i, j, val;
259 uint16_t val_uint;
260
261
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 100 times.
20100 for (i = 0; i < dstW; ++i){
262 20000 val = (1 << (shift - 1)) - 0x40000000;
263
2/2
✓ Branch 0 taken 240000 times.
✓ Branch 1 taken 20000 times.
260000 for (j = 0; j < filterSize; ++j){
264 240000 val += src[j][i] * (unsigned)filter[j];
265 }
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20000 times.
20000 output_pixel(&val_uint, val, 0x8000, int);
267 20000 dest[i] = float_mult * (float)val_uint;
268 }
269 100 }
270
271 static av_always_inline void
272 100 yuv2planeX_float_bswap_c_template(const int16_t *filter, int filterSize, const int32_t **src,
273 uint32_t *dest, int dstW)
274 {
275 static const int big_endian = HAVE_BIGENDIAN;
276 static const int shift = 15;
277 static const float float_mult = 1.0f / 65535.0f;
278 int i, j, val;
279 uint16_t val_uint;
280
281
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 100 times.
20100 for (i = 0; i < dstW; ++i){
282 20000 val = (1 << (shift - 1)) - 0x40000000;
283
2/2
✓ Branch 0 taken 240000 times.
✓ Branch 1 taken 20000 times.
260000 for (j = 0; j < filterSize; ++j){
284 240000 val += src[j][i] * (unsigned)filter[j];
285 }
286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20000 times.
20000 output_pixel(&val_uint, val, 0x8000, int);
287 20000 dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint));
288 }
289 100 }
290
291 #define yuv2plane1_float(template, dest_type, BE_LE) \
292 static void yuv2plane1_float ## BE_LE ## _c(const int16_t *src, uint8_t *dest, int dstW, \
293 const uint8_t *dither, int offset) \
294 { \
295 template((const int32_t *)src, (dest_type *)dest, dstW); \
296 }
297
298 #define yuv2planeX_float(template, dest_type, BE_LE) \
299 static void yuv2planeX_float ## BE_LE ## _c(const int16_t *filter, int filterSize, \
300 const int16_t **src, uint8_t *dest, int dstW, \
301 const uint8_t *dither, int offset) \
302 { \
303 template(filter, filterSize, (const int32_t **)src, (dest_type *)dest, dstW); \
304 }
305
306 #if HAVE_BIGENDIAN
307 yuv2plane1_float(yuv2plane1_float_c_template, float, BE)
308 yuv2plane1_float(yuv2plane1_float_bswap_c_template, uint32_t, LE)
309 yuv2planeX_float(yuv2planeX_float_c_template, float, BE)
310 yuv2planeX_float(yuv2planeX_float_bswap_c_template, uint32_t, LE)
311 #else
312 24496 yuv2plane1_float(yuv2plane1_float_c_template, float, LE)
313 9504 yuv2plane1_float(yuv2plane1_float_bswap_c_template, uint32_t, BE)
314 100 yuv2planeX_float(yuv2planeX_float_c_template, float, LE)
315 100 yuv2planeX_float(yuv2planeX_float_bswap_c_template, uint32_t, BE)
316 #endif
317
318 #undef output_pixel
319
320 #define output_pixel(pos, val) \
321 if (big_endian) { \
322 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
323 } else { \
324 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
325 }
326
327 static av_always_inline void
328 6977244 yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
329 int big_endian, int output_bits)
330 {
331 int i;
332 6977244 int shift = 15 - output_bits;
333
334
2/2
✓ Branch 0 taken 2277490088 times.
✓ Branch 1 taken 6977244 times.
2284467332 for (i = 0; i < dstW; i++) {
335 2277490088 int val = src[i] + (1 << (shift - 1));
336
2/2
✓ Branch 0 taken 461362176 times.
✓ Branch 1 taken 1816127912 times.
2277490088 output_pixel(&dest[i], val);
337 }
338 6977244 }
339
340 static av_always_inline void
341 2932400 yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
342 const int16_t **src, uint16_t *dest, int dstW,
343 int big_endian, int output_bits)
344 {
345 int i;
346 2932400 int shift = 11 + 16 - output_bits;
347
348
2/2
✓ Branch 0 taken 910600584 times.
✓ Branch 1 taken 2932400 times.
913532984 for (i = 0; i < dstW; i++) {
349 910600584 int val = 1 << (shift - 1);
350 int j;
351
352
2/2
✓ Branch 0 taken 4376083488 times.
✓ Branch 1 taken 910600584 times.
5286684072 for (j = 0; j < filterSize; j++)
353 4376083488 val += src[j][i] * filter[j];
354
355
2/2
✓ Branch 0 taken 132177792 times.
✓ Branch 1 taken 778422792 times.
910600584 output_pixel(&dest[i], val);
356 }
357 2932400 }
358
359 #undef output_pixel
360
361 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
362 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
363 uint8_t *dest, int dstW, \
364 const uint8_t *dither, int offset)\
365 { \
366 yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
367 (uint16_t *) dest, dstW, is_be, bits); \
368 }\
369 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
370 const int16_t **src, uint8_t *dest, int dstW, \
371 const uint8_t *dither, int offset)\
372 { \
373 yuv2planeX_## template_size ## _c_template(filter, \
374 filterSize, (const typeX_t **) src, \
375 (uint16_t *) dest, dstW, is_be, bits); \
376 }
377
378 157216 yuv2NBPS( 9, BE, 1, 10, int16_t)
379 172204 yuv2NBPS( 9, LE, 0, 10, int16_t)
380 1856816 yuv2NBPS(10, BE, 1, 10, int16_t)
381 9864860 yuv2NBPS(10, LE, 0, 10, int16_t)
382 1856216 yuv2NBPS(12, BE, 1, 10, int16_t)
383 5735000 yuv2NBPS(12, LE, 0, 10, int16_t)
384 84168 yuv2NBPS(14, BE, 1, 10, int16_t)
385 92808 yuv2NBPS(14, LE, 0, 10, int16_t)
386 2363104 yuv2NBPS(16, BE, 1, 16, int32_t)
387 3419212 yuv2NBPS(16, LE, 0, 16, int32_t)
388
389
390 360250 static void yuv2nv12cX_16LE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
391 const int16_t *chrFilter, int chrFilterSize,
392 const int16_t **chrUSrc, const int16_t **chrVSrc,
393 uint8_t *dest8, int chrDstW)
394 {
395 360250 yuv2nv12cX_16_c_template(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW, 16);
396 360250 }
397
398 227626 static void yuv2nv12cX_16BE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
399 const int16_t *chrFilter, int chrFilterSize,
400 const int16_t **chrUSrc, const int16_t **chrVSrc,
401 uint8_t *dest8, int chrDstW)
402 {
403 227626 yuv2nv12cX_16_c_template(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW, 16);
404 227626 }
405
406 11354146 static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
407 const int16_t **src, uint8_t *dest, int dstW,
408 const uint8_t *dither, int offset)
409 {
410 int i;
411
2/2
✓ Branch 0 taken 6712418178 times.
✓ Branch 1 taken 11354146 times.
6723772324 for (i=0; i<dstW; i++) {
412 6712418178 int val = dither[(i + offset) & 7] << 12;
413 int j;
414
2/2
✓ Branch 0 taken 21974227237 times.
✓ Branch 1 taken 6712418178 times.
28686645415 for (j=0; j<filterSize; j++)
415 21974227237 val += src[j][i] * filter[j];
416
417 6712418178 dest[i]= av_clip_uint8(val>>19);
418 }
419 11354146 }
420
421 11066887 static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
422 const uint8_t *dither, int offset)
423 {
424 int i;
425
2/2
✓ Branch 0 taken 4124826173 times.
✓ Branch 1 taken 11066887 times.
4135893060 for (i=0; i<dstW; i++) {
426 4124826173 int val = (src[i] + dither[(i + offset) & 7]) >> 7;
427 4124826173 dest[i]= av_clip_uint8(val);
428 }
429 11066887 }
430
431 817002 static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
432 const int16_t *chrFilter, int chrFilterSize,
433 const int16_t **chrUSrc, const int16_t **chrVSrc,
434 uint8_t *dest, int chrDstW)
435 {
436 int i;
437
438
2/2
✓ Branch 1 taken 810804 times.
✓ Branch 2 taken 6198 times.
817002 if (!isSwappedChroma(dstFormat))
439
2/2
✓ Branch 0 taken 262468248 times.
✓ Branch 1 taken 810804 times.
263279052 for (i=0; i<chrDstW; i++) {
440 262468248 int u = chrDither[i & 7] << 12;
441 262468248 int v = chrDither[(i + 3) & 7] << 12;
442 int j;
443
2/2
✓ Branch 0 taken 498033088 times.
✓ Branch 1 taken 262468248 times.
760501336 for (j=0; j<chrFilterSize; j++) {
444 498033088 u += chrUSrc[j][i] * chrFilter[j];
445 498033088 v += chrVSrc[j][i] * chrFilter[j];
446 }
447
448 262468248 dest[2*i]= av_clip_uint8(u>>19);
449 262468248 dest[2*i+1]= av_clip_uint8(v>>19);
450 }
451 else
452
2/2
✓ Branch 0 taken 2153896 times.
✓ Branch 1 taken 6198 times.
2160094 for (i=0; i<chrDstW; i++) {
453 2153896 int u = chrDither[i & 7] << 12;
454 2153896 int v = chrDither[(i + 3) & 7] << 12;
455 int j;
456
2/2
✓ Branch 0 taken 8815584 times.
✓ Branch 1 taken 2153896 times.
10969480 for (j=0; j<chrFilterSize; j++) {
457 8815584 u += chrUSrc[j][i] * chrFilter[j];
458 8815584 v += chrVSrc[j][i] * chrFilter[j];
459 }
460
461 2153896 dest[2*i]= av_clip_uint8(v>>19);
462 2153896 dest[2*i+1]= av_clip_uint8(u>>19);
463 }
464 817002 }
465
466
467 #define output_pixel(pos, val) \
468 if (big_endian) { \
469 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
470 } else { \
471 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
472 }
473
474 2230560 static void yuv2p01xl1_c(const int16_t *src,
475 uint16_t *dest, int dstW,
476 int big_endian, int output_bits, int output_shift)
477 {
478 int i;
479 2230560 int shift = 15 - output_bits;
480
481
2/2
✓ Branch 0 taken 785157120 times.
✓ Branch 1 taken 2230560 times.
787387680 for (i = 0; i < dstW; i++) {
482 785157120 int val = src[i] + (1 << (shift - 1));
483
2/2
✓ Branch 0 taken 171832320 times.
✓ Branch 1 taken 613324800 times.
785157120 output_pixel(&dest[i], val);
484 }
485 2230560 }
486
487 1400 static void yuv2p01xlX_c(const int16_t *filter, int filterSize,
488 const int16_t **src, uint16_t *dest, int dstW,
489 int big_endian, int output_bits, int output_shift)
490 {
491 int i, j;
492 1400 int shift = 11 + 16 - output_bits;
493
494
2/2
✓ Branch 0 taken 280000 times.
✓ Branch 1 taken 1400 times.
281400 for (i = 0; i < dstW; i++) {
495 280000 int val = 1 << (shift - 1);
496
497
2/2
✓ Branch 0 taken 3360000 times.
✓ Branch 1 taken 280000 times.
3640000 for (j = 0; j < filterSize; j++)
498 3360000 val += src[j][i] * filter[j];
499
500
2/2
✓ Branch 0 taken 140000 times.
✓ Branch 1 taken 140000 times.
280000 output_pixel(&dest[i], val);
501 }
502 1400 }
503
504 2058672 static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
505 const int16_t *chrFilter, int chrFilterSize,
506 const int16_t **chrUSrc, const int16_t **chrVSrc,
507 uint8_t *dest8, int chrDstW, int output_bits, int output_shift)
508 {
509 2058672 uint16_t *dest = (uint16_t*)dest8;
510 int i, j;
511 2058672 int shift = 11 + 16 - output_bits;
512
513
2/2
✓ Branch 0 taken 630009088 times.
✓ Branch 1 taken 2058672 times.
632067760 for (i = 0; i < chrDstW; i++) {
514 630009088 int u = 1 << (shift - 1);
515 630009088 int v = 1 << (shift - 1);
516
517
2/2
✓ Branch 0 taken 1225376256 times.
✓ Branch 1 taken 630009088 times.
1855385344 for (j = 0; j < chrFilterSize; j++) {
518 1225376256 u += chrUSrc[j][i] * chrFilter[j];
519 1225376256 v += chrVSrc[j][i] * chrFilter[j];
520 }
521
522
2/2
✓ Branch 0 taken 93650048 times.
✓ Branch 1 taken 536359040 times.
630009088 output_pixel(&dest[2*i] , u);
523
2/2
✓ Branch 0 taken 93650048 times.
✓ Branch 1 taken 536359040 times.
630009088 output_pixel(&dest[2*i+1], v);
524 }
525 2058672 }
526
527 #undef output_pixel
528
529 #define yuv2p01x_wrapper(fmt, bits, shift) \
530 static void yuv2 ## fmt ## l1_LE_c(const int16_t *src, \
531 uint8_t *dest, int dstW, \
532 const uint8_t *dither, int offset) \
533 { \
534 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits, shift); \
535 } \
536 \
537 static void yuv2 ## fmt ## l1_BE_c(const int16_t *src, \
538 uint8_t *dest, int dstW, \
539 const uint8_t *dither, int offset) \
540 { \
541 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits, shift); \
542 } \
543 \
544 static void yuv2 ## fmt ## lX_LE_c(const int16_t *filter, \
545 int filterSize, const int16_t **src, \
546 uint8_t *dest, int dstW, \
547 const uint8_t *dither, int offset) \
548 { \
549 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, \
550 bits, shift); \
551 } \
552 \
553 static void yuv2 ## fmt ## lX_BE_c(const int16_t *filter, \
554 int filterSize, const int16_t **src, \
555 uint8_t *dest, int dstW, \
556 const uint8_t *dither, int offset) \
557 { \
558 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, \
559 bits, shift); \
560 } \
561 \
562 static void yuv2 ## fmt ## cX_LE_c(enum AVPixelFormat dstFormat, \
563 const uint8_t *chrDither, \
564 const int16_t *chrFilter, \
565 int chrFilterSize, \
566 const int16_t **chrUSrc, \
567 const int16_t **chrVSrc, \
568 uint8_t *dest8, int chrDstW) \
569 { \
570 yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
571 dest8, chrDstW, bits, shift); \
572 } \
573 \
574 static void yuv2 ## fmt ## cX_BE_c(enum AVPixelFormat dstFormat, \
575 const uint8_t *chrDither, \
576 const int16_t *chrFilter, \
577 int chrFilterSize, \
578 const int16_t **chrUSrc, \
579 const int16_t **chrVSrc, \
580 uint8_t *dest8, int chrDstW) \
581 { \
582 yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
583 dest8, chrDstW, bits, shift); \
584 }
585
586 4259128 yuv2p01x_wrapper(p010, 10, 6)
587 4276408 yuv2p01x_wrapper(p012, 12, 4)
588 45728 yuv2p01x_wrapper(nv20, 10, 0)
589
590 #define accumulate_bit(acc, val) \
591 acc <<= 1; \
592 acc |= (val) >= 234
593 #define output_pixel(pos, acc) \
594 if (target == AV_PIX_FMT_MONOBLACK) { \
595 pos = acc; \
596 } else { \
597 pos = ~acc; \
598 }
599
600 static av_always_inline void
601 85420 yuv2mono_X_c_template(SwsInternal *c, const int16_t *lumFilter,
602 const int16_t **lumSrc, int lumFilterSize,
603 const int16_t *chrFilter, const int16_t **chrUSrc,
604 const int16_t **chrVSrc, int chrFilterSize,
605 const int16_t **alpSrc, uint8_t *dest, int dstW,
606 int y, enum AVPixelFormat target)
607 {
608 85420 const uint8_t * const d128 = ff_dither_8x8_220[y&7];
609 int i;
610 85420 unsigned acc = 0;
611 85420 int err = 0;
612
613
2/2
✓ Branch 0 taken 14748420 times.
✓ Branch 1 taken 85420 times.
14833840 for (i = 0; i < dstW; i += 2) {
614 int j;
615 14748420 int Y1 = 1 << 18;
616 14748420 int Y2 = 1 << 18;
617
618
2/2
✓ Branch 0 taken 14968420 times.
✓ Branch 1 taken 14748420 times.
29716840 for (j = 0; j < lumFilterSize; j++) {
619 14968420 Y1 += lumSrc[j][i] * lumFilter[j];
620 14968420 Y2 += lumSrc[j][i+1] * lumFilter[j];
621 }
622 14748420 Y1 >>= 19;
623 14748420 Y2 >>= 19;
624
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 14748044 times.
14748420 if ((Y1 | Y2) & 0x100) {
625 376 Y1 = av_clip_uint8(Y1);
626 376 Y2 = av_clip_uint8(Y2);
627 }
628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14748420 times.
14748420 if (c->opts.dither == SWS_DITHER_ED) {
629 Y1 += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
630 c->dither_error[0][i] = err;
631 acc = 2*acc + (Y1 >= 128);
632 Y1 -= 220*(acc&1);
633
634 err = Y2 + ((7*Y1 + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4);
635 c->dither_error[0][i+1] = Y1;
636 acc = 2*acc + (err >= 128);
637 err -= 220*(acc&1);
638 } else {
639 14748420 accumulate_bit(acc, Y1 + d128[(i + 0) & 7]);
640 14748420 accumulate_bit(acc, Y2 + d128[(i + 1) & 7]);
641 }
642
2/2
✓ Branch 0 taken 3686680 times.
✓ Branch 1 taken 11061740 times.
14748420 if ((i & 7) == 6) {
643
2/2
✓ Branch 0 taken 560068 times.
✓ Branch 1 taken 3126612 times.
3686680 output_pixel(*dest++, acc);
644 }
645 }
646 85420 c->dither_error[0][i] = err;
647
648
2/2
✓ Branch 0 taken 1700 times.
✓ Branch 1 taken 83720 times.
85420 if (i & 6) {
649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1700 times.
1700 output_pixel(*dest, acc);
650 }
651 85420 }
652
653 static av_always_inline void
654 yuv2mono_2_c_template(SwsInternal *c, const int16_t *buf[2],
655 const int16_t *ubuf[2], const int16_t *vbuf[2],
656 const int16_t *abuf[2], uint8_t *dest, int dstW,
657 int yalpha, int uvalpha, int y,
658 enum AVPixelFormat target)
659 {
660 const int16_t *buf0 = buf[0], *buf1 = buf[1];
661 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
662 int yalpha1 = 4096 - yalpha;
663 int i;
664 av_assert2(yalpha <= 4096U);
665
666 if (c->opts.dither == SWS_DITHER_ED) {
667 int err = 0;
668 unsigned acc = 0;
669 for (i = 0; i < dstW; i +=2) {
670 int Y;
671
672 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
673 Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
674 c->dither_error[0][i] = err;
675 acc = 2*acc + (Y >= 128);
676 Y -= 220*(acc&1);
677
678 err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
679 err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
680 c->dither_error[0][i+1] = Y;
681 acc = 2*acc + (err >= 128);
682 err -= 220*(acc&1);
683
684 if ((i & 7) == 6)
685 output_pixel(*dest++, acc);
686 }
687 c->dither_error[0][i] = err;
688 } else {
689 for (i = 0; i < dstW; i += 8) {
690 int Y;
691 unsigned acc = 0;
692
693 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
694 accumulate_bit(acc, Y + d128[0]);
695 Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
696 accumulate_bit(acc, Y + d128[1]);
697 Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
698 accumulate_bit(acc, Y + d128[2]);
699 Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
700 accumulate_bit(acc, Y + d128[3]);
701 Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
702 accumulate_bit(acc, Y + d128[4]);
703 Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
704 accumulate_bit(acc, Y + d128[5]);
705 Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
706 accumulate_bit(acc, Y + d128[6]);
707 Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
708 accumulate_bit(acc, Y + d128[7]);
709
710 output_pixel(*dest++, acc);
711 }
712 }
713 }
714
715 static av_always_inline void
716 174336 yuv2mono_1_c_template(SwsInternal *c, const int16_t *buf0,
717 const int16_t *ubuf[2], const int16_t *vbuf[2],
718 const int16_t *abuf0, uint8_t *dest, int dstW,
719 int uvalpha, int y, enum AVPixelFormat target)
720 {
721 174336 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
722 int i;
723
724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174336 times.
174336 if (c->opts.dither == SWS_DITHER_ED) {
725 int err = 0;
726 unsigned acc = 0;
727 for (i = 0; i < dstW; i +=2) {
728 int Y;
729
730 Y = ((buf0[i + 0] + 64) >> 7);
731 Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
732 c->dither_error[0][i] = err;
733 acc = 2*acc + (Y >= 128);
734 Y -= 220*(acc&1);
735
736 err = ((buf0[i + 1] + 64) >> 7);
737 err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
738 c->dither_error[0][i+1] = Y;
739 acc = 2*acc + (err >= 128);
740 err -= 220*(acc&1);
741
742 if ((i & 7) == 6)
743 output_pixel(*dest++, acc);
744 }
745 c->dither_error[0][i] = err;
746 } else {
747
2/2
✓ Branch 0 taken 7305984 times.
✓ Branch 1 taken 174336 times.
7480320 for (i = 0; i < dstW; i += 8) {
748 7305984 unsigned acc = 0;
749 7305984 accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
750 7305984 accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
751 7305984 accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
752 7305984 accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
753 7305984 accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
754 7305984 accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
755 7305984 accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
756 7305984 accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
757
758
2/2
✓ Branch 0 taken 3624192 times.
✓ Branch 1 taken 3681792 times.
7305984 output_pixel(*dest++, acc);
759 }
760 }
761 174336 }
762
763 #undef output_pixel
764 #undef accumulate_bit
765
766 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
767 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
768 const int16_t **lumSrc, int lumFilterSize, \
769 const int16_t *chrFilter, const int16_t **chrUSrc, \
770 const int16_t **chrVSrc, int chrFilterSize, \
771 const int16_t **alpSrc, uint8_t *dest, int dstW, \
772 int y) \
773 { \
774 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
775 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
776 alpSrc, dest, dstW, y, fmt); \
777 } \
778 \
779 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *buf[2], \
780 const int16_t *ubuf[2], const int16_t *vbuf[2], \
781 const int16_t *abuf[2], uint8_t *dest, int dstW, \
782 int yalpha, int uvalpha, int y) \
783 { \
784 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
785 dest, dstW, yalpha, uvalpha, y, fmt); \
786 } \
787 \
788 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *buf0, \
789 const int16_t *ubuf[2], const int16_t *vbuf[2], \
790 const int16_t *abuf0, uint8_t *dest, int dstW, \
791 int uvalpha, int y) \
792 { \
793 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
794 abuf0, dest, dstW, uvalpha, \
795 y, fmt); \
796 }
797
798 329232 YUV2PACKEDWRAPPER(yuv2mono,, white, AV_PIX_FMT_MONOWHITE)
799 190280 YUV2PACKEDWRAPPER(yuv2mono,, black, AV_PIX_FMT_MONOBLACK)
800
801 #define output_pixels(pos, Y1, U, Y2, V) \
802 if (target == AV_PIX_FMT_YUYV422) { \
803 dest[pos + 0] = Y1; \
804 dest[pos + 1] = U; \
805 dest[pos + 2] = Y2; \
806 dest[pos + 3] = V; \
807 } else if (target == AV_PIX_FMT_YVYU422) { \
808 dest[pos + 0] = Y1; \
809 dest[pos + 1] = V; \
810 dest[pos + 2] = Y2; \
811 dest[pos + 3] = U; \
812 } else { /* AV_PIX_FMT_UYVY422 */ \
813 dest[pos + 0] = U; \
814 dest[pos + 1] = Y1; \
815 dest[pos + 2] = V; \
816 dest[pos + 3] = Y2; \
817 }
818
819 static av_always_inline void
820 24204 yuv2422_X_c_template(SwsInternal *c, const int16_t *lumFilter,
821 const int16_t **lumSrc, int lumFilterSize,
822 const int16_t *chrFilter, const int16_t **chrUSrc,
823 const int16_t **chrVSrc, int chrFilterSize,
824 const int16_t **alpSrc, uint8_t *dest, int dstW,
825 int y, enum AVPixelFormat target)
826 {
827 int i;
828
829
2/2
✓ Branch 0 taken 4237104 times.
✓ Branch 1 taken 24204 times.
4261308 for (i = 0; i < ((dstW + 1) >> 1); i++) {
830 int j;
831 4237104 int Y1 = 1 << 18;
832 4237104 int Y2 = 1 << 18;
833 4237104 int U = 1 << 18;
834 4237104 int V = 1 << 18;
835
836
2/2
✓ Branch 0 taken 4567104 times.
✓ Branch 1 taken 4237104 times.
8804208 for (j = 0; j < lumFilterSize; j++) {
837 4567104 Y1 += lumSrc[j][i * 2] * lumFilter[j];
838 4567104 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
839 }
840
2/2
✓ Branch 0 taken 17188416 times.
✓ Branch 1 taken 4237104 times.
21425520 for (j = 0; j < chrFilterSize; j++) {
841 17188416 U += chrUSrc[j][i] * chrFilter[j];
842 17188416 V += chrVSrc[j][i] * chrFilter[j];
843 }
844 4237104 Y1 >>= 19;
845 4237104 Y2 >>= 19;
846 4237104 U >>= 19;
847 4237104 V >>= 19;
848
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4237081 times.
4237104 if ((Y1 | Y2 | U | V) & 0x100) {
849 23 Y1 = av_clip_uint8(Y1);
850 23 Y2 = av_clip_uint8(Y2);
851 23 U = av_clip_uint8(U);
852 23 V = av_clip_uint8(V);
853 }
854
4/4
✓ Branch 0 taken 2290960 times.
✓ Branch 1 taken 1946144 times.
✓ Branch 2 taken 973072 times.
✓ Branch 3 taken 973072 times.
4237104 output_pixels(4*i, Y1, U, Y2, V);
855 }
856 24204 }
857
858 static av_always_inline void
859 yuv2422_2_c_template(SwsInternal *c, const int16_t *buf[2],
860 const int16_t *ubuf[2], const int16_t *vbuf[2],
861 const int16_t *abuf[2], uint8_t *dest, int dstW,
862 int yalpha, int uvalpha, int y,
863 enum AVPixelFormat target)
864 {
865 const int16_t *buf0 = buf[0], *buf1 = buf[1],
866 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
867 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
868 int yalpha1 = 4096 - yalpha;
869 int uvalpha1 = 4096 - uvalpha;
870 int i;
871 av_assert2(yalpha <= 4096U);
872 av_assert2(uvalpha <= 4096U);
873
874 for (i = 0; i < ((dstW + 1) >> 1); i++) {
875 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
876 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
877 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
878 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
879
880 if ((Y1 | Y2 | U | V) & 0x100) {
881 Y1 = av_clip_uint8(Y1);
882 Y2 = av_clip_uint8(Y2);
883 U = av_clip_uint8(U);
884 V = av_clip_uint8(V);
885 }
886
887 output_pixels(i * 4, Y1, U, Y2, V);
888 }
889 }
890
891 static av_always_inline void
892 333504 yuv2422_1_c_template(SwsInternal *c, const int16_t *buf0,
893 const int16_t *ubuf[2], const int16_t *vbuf[2],
894 const int16_t *abuf0, uint8_t *dest, int dstW,
895 int uvalpha, int y, enum AVPixelFormat target)
896 {
897 333504 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
898 int i;
899
900
1/2
✓ Branch 0 taken 333504 times.
✗ Branch 1 not taken.
333504 if (uvalpha < 2048) {
901
2/2
✓ Branch 0 taken 74594304 times.
✓ Branch 1 taken 333504 times.
74927808 for (i = 0; i < ((dstW + 1) >> 1); i++) {
902 74594304 int Y1 = (buf0[i * 2 ]+64) >> 7;
903 74594304 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
904 74594304 int U = (ubuf0[i] +64) >> 7;
905 74594304 int V = (vbuf0[i] +64) >> 7;
906
907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74594304 times.
74594304 if ((Y1 | Y2 | U | V) & 0x100) {
908 Y1 = av_clip_uint8(Y1);
909 Y2 = av_clip_uint8(Y2);
910 U = av_clip_uint8(U);
911 V = av_clip_uint8(V);
912 }
913
914
4/4
✓ Branch 0 taken 14496768 times.
✓ Branch 1 taken 60097536 times.
✓ Branch 2 taken 14496768 times.
✓ Branch 3 taken 45600768 times.
74594304 output_pixels(i * 4, Y1, U, Y2, V);
915 }
916 } else {
917 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
918 for (i = 0; i < ((dstW + 1) >> 1); i++) {
919 int Y1 = (buf0[i * 2 ] + 64) >> 7;
920 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
921 int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
922 int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
923
924 if ((Y1 | Y2 | U | V) & 0x100) {
925 Y1 = av_clip_uint8(Y1);
926 Y2 = av_clip_uint8(Y2);
927 U = av_clip_uint8(U);
928 V = av_clip_uint8(V);
929 }
930
931 output_pixels(i * 4, Y1, U, Y2, V);
932 }
933 }
934 333504 }
935
936 #undef output_pixels
937
938 190856 YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
939 175880 YUV2PACKEDWRAPPER(yuv2, 422, yvyu422, AV_PIX_FMT_YVYU422)
940 348680 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)
941
942 #define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? R : B)
943 #define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? B : R)
944 #define output_pixel(pos, val) \
945 if (is_be) { \
946 AV_WB16(pos, val); \
947 } else { \
948 AV_WL16(pos, val); \
949 }
950
951 static av_always_inline void
952 12008 yuv2ya16_X_c_template(SwsInternal *c, const int16_t *lumFilter,
953 const int32_t **lumSrc, int lumFilterSize,
954 const int16_t *chrFilter, const int32_t **unused_chrUSrc,
955 const int32_t **unused_chrVSrc, int unused_chrFilterSize,
956 const int32_t **alpSrc, uint16_t *dest, int dstW,
957 int y, enum AVPixelFormat target,
958 int unused_hasAlpha, int unused_eightbytes, int is_be)
959 {
960 12008 int hasAlpha = !!alpSrc;
961 int i;
962
963
2/2
✓ Branch 0 taken 4196416 times.
✓ Branch 1 taken 12008 times.
4208424 for (i = 0; i < dstW; i++) {
964 int j;
965 4196416 int Y = -0x40000000;
966 4196416 int A = 0xffff;
967
968
2/2
✓ Branch 0 taken 4636416 times.
✓ Branch 1 taken 4196416 times.
8832832 for (j = 0; j < lumFilterSize; j++)
969 4636416 Y += lumSrc[j][i] * lumFilter[j];
970
971 4196416 Y >>= 15;
972 4196416 Y += (1<<3) + 0x8000;
973 4196416 Y = av_clip_uint16(Y);
974
975
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 4156416 times.
4196416 if (hasAlpha) {
976 40000 A = -0x40000000 + (1<<14);
977
2/2
✓ Branch 0 taken 480000 times.
✓ Branch 1 taken 40000 times.
520000 for (j = 0; j < lumFilterSize; j++)
978 480000 A += alpSrc[j][i] * lumFilter[j];
979
980 40000 A >>= 15;
981 40000 A += 0x8000;
982 40000 A = av_clip_uint16(A);
983 }
984
985
2/2
✓ Branch 0 taken 2047520 times.
✓ Branch 1 taken 2148896 times.
4196416 output_pixel(&dest[2 * i ], Y);
986
2/2
✓ Branch 0 taken 2047520 times.
✓ Branch 1 taken 2148896 times.
4196416 output_pixel(&dest[2 * i + 1], A);
987 }
988 12008 }
989
990 static av_always_inline void
991 yuv2ya16_2_c_template(SwsInternal *c, const int32_t *buf[2],
992 const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2],
993 const int32_t *abuf[2], uint16_t *dest, int dstW,
994 int yalpha, int unused_uvalpha, int y,
995 enum AVPixelFormat target, int unused_hasAlpha,
996 int unused_eightbytes, int is_be)
997 {
998 int hasAlpha = abuf && abuf[0] && abuf[1];
999 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1000 *abuf0 = hasAlpha ? abuf[0] : NULL,
1001 *abuf1 = hasAlpha ? abuf[1] : NULL;
1002 int yalpha1 = 4096 - yalpha;
1003 int i;
1004
1005 av_assert2(yalpha <= 4096U);
1006
1007 for (i = 0; i < dstW; i++) {
1008 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 15;
1009 int A;
1010
1011 Y = av_clip_uint16(Y);
1012
1013 if (hasAlpha) {
1014 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 15;
1015 A = av_clip_uint16(A);
1016 }
1017
1018 output_pixel(&dest[2 * i ], Y);
1019 output_pixel(&dest[2 * i + 1], hasAlpha ? A : 65535);
1020 }
1021 }
1022
1023 static av_always_inline void
1024 yuv2ya16_1_c_template(SwsInternal *c, const int32_t *buf0,
1025 const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2],
1026 const int32_t *abuf0, uint16_t *dest, int dstW,
1027 int unused_uvalpha, int y, enum AVPixelFormat target,
1028 int unused_hasAlpha, int unused_eightbytes, int is_be)
1029 {
1030 int hasAlpha = !!abuf0;
1031 int i;
1032
1033 for (i = 0; i < dstW; i++) {
1034 int Y = buf0[i] >> 3;/* 19 - 16 */
1035 int A;
1036
1037 Y = av_clip_uint16(Y);
1038
1039 if (hasAlpha) {
1040 A = abuf0[i] >> 3;
1041 if (A & 0x100)
1042 A = av_clip_uint16(A);
1043 }
1044
1045 output_pixel(&dest[2 * i ], Y);
1046 output_pixel(&dest[2 * i + 1], hasAlpha ? A : 65535);
1047 }
1048 }
1049
1050 static av_always_inline void
1051 260080 yuv2rgba64_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1052 const int32_t **lumSrc, int lumFilterSize,
1053 const int16_t *chrFilter, const int32_t **chrUSrc,
1054 const int32_t **chrVSrc, int chrFilterSize,
1055 const int32_t **alpSrc, uint16_t *dest, int dstW,
1056 int y, enum AVPixelFormat target, int hasAlpha, int eightbytes,
1057 int is_be)
1058 {
1059 int i;
1060 260080 int A1 = 0xffff<<14, A2 = 0xffff<<14;
1061
1062
2/2
✓ Branch 0 taken 45574640 times.
✓ Branch 1 taken 260080 times.
45834720 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1063 int j;
1064 45574640 unsigned Y1 = -0x40000000;
1065 45574640 unsigned Y2 = -0x40000000;
1066 45574640 int U = -(128 << 23); // 19
1067 45574640 int V = -(128 << 23);
1068 int R, G, B;
1069
1070
2/2
✓ Branch 0 taken 46090176 times.
✓ Branch 1 taken 45574640 times.
91664816 for (j = 0; j < lumFilterSize; j++) {
1071 46090176 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
1072 46090176 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1073 }
1074
2/2
✓ Branch 0 taken 182339520 times.
✓ Branch 1 taken 45574640 times.
227914160 for (j = 0; j < chrFilterSize; j++) {;
1075 182339520 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1076 182339520 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1077 }
1078
1079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45574640 times.
45574640 if (hasAlpha) {
1080 A1 = -0x40000000;
1081 A2 = -0x40000000;
1082 for (j = 0; j < lumFilterSize; j++) {
1083 A1 += alpSrc[j][i * 2] * (unsigned)lumFilter[j];
1084 A2 += alpSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1085 }
1086 A1 >>= 1;
1087 A1 += 0x20002000;
1088 A2 >>= 1;
1089 A2 += 0x20002000;
1090 }
1091
1092 // 8 bits: 12+15=27; 16 bits: 12+19=31
1093 45574640 Y1 = (int)Y1 >> 14; // 10
1094 45574640 Y1 += 0x10000;
1095 45574640 Y2 = (int)Y2 >> 14;
1096 45574640 Y2 += 0x10000;
1097 45574640 U >>= 14;
1098 45574640 V >>= 14;
1099
1100 // 8 bits: 27 -> 17 bits, 16 bits: 31 - 14 = 17 bits
1101 45574640 Y1 -= c->yuv2rgb_y_offset;
1102 45574640 Y2 -= c->yuv2rgb_y_offset;
1103 45574640 Y1 *= c->yuv2rgb_y_coeff;
1104 45574640 Y2 *= c->yuv2rgb_y_coeff;
1105 45574640 Y1 += (1 << 13) - (1 << 29); // 21
1106 45574640 Y2 += (1 << 13) - (1 << 29);
1107 // 8 bits: 17 + 13 bits = 30 bits, 16 bits: 17 + 13 bits = 30 bits
1108
1109 45574640 R = V * c->yuv2rgb_v2r_coeff;
1110 45574640 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1111 45574640 B = U * c->yuv2rgb_u2b_coeff;
1112
1113 // 8 bits: 30 - 22 = 8 bits, 16 bits: 30 bits - 14 = 16 bits
1114
14/18
✓ Branch 0 taken 6390784 times.
✓ Branch 1 taken 39183856 times.
✓ Branch 2 taken 6390784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3044352 times.
✓ Branch 5 taken 3346432 times.
✓ Branch 6 taken 3044352 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1014784 times.
✓ Branch 9 taken 2029568 times.
✓ Branch 10 taken 3956736 times.
✓ Branch 11 taken 35227120 times.
✓ Branch 12 taken 3956736 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2080256 times.
✓ Branch 15 taken 1876480 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2080256 times.
45574640 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1115
2/2
✓ Branch 0 taken 6390784 times.
✓ Branch 1 taken 39183856 times.
45574640 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1116
14/18
✓ Branch 0 taken 6390784 times.
✓ Branch 1 taken 39183856 times.
✓ Branch 2 taken 6390784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3044352 times.
✓ Branch 5 taken 3346432 times.
✓ Branch 6 taken 3044352 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1014784 times.
✓ Branch 9 taken 2029568 times.
✓ Branch 10 taken 3956736 times.
✓ Branch 11 taken 35227120 times.
✓ Branch 12 taken 3956736 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2080256 times.
✓ Branch 15 taken 1876480 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2080256 times.
45574640 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1117
2/2
✓ Branch 0 taken 4920832 times.
✓ Branch 1 taken 40653808 times.
45574640 if (eightbytes) {
1118
2/2
✓ Branch 0 taken 2029568 times.
✓ Branch 1 taken 2891264 times.
4920832 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1119
12/18
✓ Branch 0 taken 2029568 times.
✓ Branch 1 taken 2891264 times.
✓ Branch 2 taken 2029568 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2029568 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2029568 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1014784 times.
✓ Branch 9 taken 1014784 times.
✓ Branch 10 taken 2891264 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2891264 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1014784 times.
✓ Branch 15 taken 1876480 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1014784 times.
4920832 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1120
2/2
✓ Branch 0 taken 2029568 times.
✓ Branch 1 taken 2891264 times.
4920832 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1121
12/18
✓ Branch 0 taken 2029568 times.
✓ Branch 1 taken 2891264 times.
✓ Branch 2 taken 2029568 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2029568 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2029568 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1014784 times.
✓ Branch 9 taken 1014784 times.
✓ Branch 10 taken 2891264 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2891264 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1014784 times.
✓ Branch 15 taken 1876480 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1014784 times.
4920832 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1122
2/2
✓ Branch 0 taken 2029568 times.
✓ Branch 1 taken 2891264 times.
4920832 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1123 4920832 dest += 8;
1124 } else {
1125
12/18
✓ Branch 0 taken 4361216 times.
✓ Branch 1 taken 36292592 times.
✓ Branch 2 taken 4361216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1014784 times.
✓ Branch 5 taken 3346432 times.
✓ Branch 6 taken 1014784 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1014784 times.
✓ Branch 10 taken 1065472 times.
✓ Branch 11 taken 35227120 times.
✓ Branch 12 taken 1065472 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1065472 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1065472 times.
40653808 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1126
2/2
✓ Branch 0 taken 4361216 times.
✓ Branch 1 taken 36292592 times.
40653808 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1127
12/18
✓ Branch 0 taken 4361216 times.
✓ Branch 1 taken 36292592 times.
✓ Branch 2 taken 4361216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1014784 times.
✓ Branch 5 taken 3346432 times.
✓ Branch 6 taken 1014784 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1014784 times.
✓ Branch 10 taken 1065472 times.
✓ Branch 11 taken 35227120 times.
✓ Branch 12 taken 1065472 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1065472 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1065472 times.
40653808 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1128 40653808 dest += 6;
1129 }
1130 }
1131 260080 }
1132
1133 static av_always_inline void
1134 48 yuv2rgba64_2_c_template(SwsInternal *c, const int32_t *buf[2],
1135 const int32_t *ubuf[2], const int32_t *vbuf[2],
1136 const int32_t *abuf[2], uint16_t *dest, int dstW,
1137 int yalpha, int uvalpha, int y,
1138 enum AVPixelFormat target, int hasAlpha, int eightbytes,
1139 int is_be)
1140 {
1141 48 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1142 48 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1143 48 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 *abuf0 = hasAlpha ? abuf[0] : NULL,
1145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 *abuf1 = hasAlpha ? abuf[1] : NULL;
1146 48 int yalpha1 = 4096 - yalpha;
1147 48 int uvalpha1 = 4096 - uvalpha;
1148 int i;
1149 48 int A1 = 0xffff<<14, A2 = 0xffff<<14;
1150
1151 av_assert2(yalpha <= 4096U);
1152 av_assert2(uvalpha <= 4096U);
1153
1154
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 48 times.
12336 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1155 12288 unsigned Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
1156 12288 unsigned Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
1157 12288 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1158 12288 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1159 int R, G, B;
1160
1161 12288 Y1 -= c->yuv2rgb_y_offset;
1162 12288 Y2 -= c->yuv2rgb_y_offset;
1163 12288 Y1 *= c->yuv2rgb_y_coeff;
1164 12288 Y2 *= c->yuv2rgb_y_coeff;
1165 12288 Y1 += (1 << 13) - (1 << 29);
1166 12288 Y2 += (1 << 13) - (1 << 29);
1167
1168 12288 R = V * c->yuv2rgb_v2r_coeff;
1169 12288 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1170 12288 B = U * c->yuv2rgb_u2b_coeff;
1171
1172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if (hasAlpha) {
1173 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1;
1174 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1;
1175
1176 A1 += 1 << 13;
1177 A2 += 1 << 13;
1178 }
1179
1180
14/18
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 6144 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4608 times.
✓ Branch 5 taken 1536 times.
✓ Branch 6 taken 4608 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1536 times.
✓ Branch 9 taken 3072 times.
✓ Branch 10 taken 4608 times.
✓ Branch 11 taken 1536 times.
✓ Branch 12 taken 4608 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3072 times.
✓ Branch 15 taken 1536 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3072 times.
12288 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1181
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6144 times.
12288 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1182
14/18
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 6144 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4608 times.
✓ Branch 5 taken 1536 times.
✓ Branch 6 taken 4608 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1536 times.
✓ Branch 9 taken 3072 times.
✓ Branch 10 taken 4608 times.
✓ Branch 11 taken 1536 times.
✓ Branch 12 taken 4608 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3072 times.
✓ Branch 15 taken 1536 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3072 times.
12288 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1183
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6144 times.
12288 if (eightbytes) {
1184
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1185
12/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3072 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1536 times.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 3072 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3072 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✓ Branch 15 taken 1536 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
6144 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1186
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1187
12/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3072 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1536 times.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 3072 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3072 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✓ Branch 15 taken 1536 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
6144 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1188
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1189 6144 dest += 8;
1190 } else {
1191
12/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 1536 times.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 1536 times.
✓ Branch 11 taken 1536 times.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
6144 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1192
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1193
12/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 1536 times.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 1536 times.
✓ Branch 11 taken 1536 times.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
6144 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1194 6144 dest += 6;
1195 }
1196 }
1197 48 }
1198
1199 static av_always_inline void
1200 209684 yuv2rgba64_1_c_template(SwsInternal *c, const int32_t *buf0,
1201 const int32_t *ubuf[2], const int32_t *vbuf[2],
1202 const int32_t *abuf0, uint16_t *dest, int dstW,
1203 int uvalpha, int y, enum AVPixelFormat target,
1204 int hasAlpha, int eightbytes, int is_be)
1205 {
1206 209684 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1207 int i;
1208 209684 int A1 = 0xffff<<14, A2= 0xffff<<14;
1209
1210
2/2
✓ Branch 0 taken 209652 times.
✓ Branch 1 taken 32 times.
209684 if (uvalpha == 0) {
1211
2/2
✓ Branch 0 taken 36629732 times.
✓ Branch 1 taken 209652 times.
36839384 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1212 36629732 SUINT Y1 = (buf0[i * 2] ) >> 2;
1213 36629732 SUINT Y2 = (buf0[i * 2 + 1]) >> 2;
1214 36629732 int U = (ubuf0[i] - (128 << 11)) >> 2;
1215 36629732 int V = (vbuf0[i] - (128 << 11)) >> 2;
1216 int R, G, B;
1217
1218 36629732 Y1 -= c->yuv2rgb_y_offset;
1219 36629732 Y2 -= c->yuv2rgb_y_offset;
1220 36629732 Y1 *= c->yuv2rgb_y_coeff;
1221 36629732 Y2 *= c->yuv2rgb_y_coeff;
1222 36629732 Y1 += (1 << 13) - (1 << 29);
1223 36629732 Y2 += (1 << 13) - (1 << 29);
1224
1225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36629732 times.
36629732 if (hasAlpha) {
1226 A1 = abuf0[i * 2 ] * (1 << 11);
1227 A2 = abuf0[i * 2 + 1] * (1 << 11);
1228
1229 A1 += 1 << 13;
1230 A2 += 1 << 13;
1231 }
1232
1233 36629732 R = V * c->yuv2rgb_v2r_coeff;
1234 36629732 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1235 36629732 B = U * c->yuv2rgb_u2b_coeff;
1236
1237
14/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 36627684 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 1536 times.
✓ Branch 11 taken 36626148 times.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✓ Branch 15 taken 512 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
36629732 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1238
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 36627684 times.
36629732 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1239
14/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 36627684 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 1536 times.
✓ Branch 11 taken 36626148 times.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✓ Branch 15 taken 512 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
36629732 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1240
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 36627684 times.
36629732 if (eightbytes) {
1241
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 1024 times.
2048 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1242
12/18
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 512 times.
✓ Branch 10 taken 1024 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1024 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 512 times.
✓ Branch 15 taken 512 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 512 times.
2048 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1243
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 1024 times.
2048 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1244
12/18
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 512 times.
✓ Branch 10 taken 1024 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1024 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 512 times.
✓ Branch 15 taken 512 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 512 times.
2048 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1245
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 1024 times.
2048 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1246 2048 dest += 8;
1247 } else {
1248
12/18
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 36626660 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 512 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 512 times.
✓ Branch 10 taken 512 times.
✓ Branch 11 taken 36626148 times.
✓ Branch 12 taken 512 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 512 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 512 times.
36627684 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1249
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 36626660 times.
36627684 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1250
12/18
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 36626660 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 512 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 512 times.
✓ Branch 10 taken 512 times.
✓ Branch 11 taken 36626148 times.
✓ Branch 12 taken 512 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 512 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 512 times.
36627684 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1251 36627684 dest += 6;
1252 }
1253 }
1254 } else {
1255 32 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1256 32 int A1 = 0xffff<<14, A2 = 0xffff<<14;
1257 32 int uvalpha1 = 4096 - uvalpha;
1258 av_assert2(uvalpha <= 4096U);
1259
1260
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 32 times.
8224 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1261 8192 SUINT Y1 = (buf0[i * 2] ) >> 2;
1262 8192 SUINT Y2 = (buf0[i * 2 + 1]) >> 2;
1263 8192 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1264 8192 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1265 int R, G, B;
1266
1267 8192 Y1 -= c->yuv2rgb_y_offset;
1268 8192 Y2 -= c->yuv2rgb_y_offset;
1269 8192 Y1 *= c->yuv2rgb_y_coeff;
1270 8192 Y2 *= c->yuv2rgb_y_coeff;
1271 8192 Y1 += (1 << 13) - (1 << 29);
1272 8192 Y2 += (1 << 13) - (1 << 29);
1273
1274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if (hasAlpha) {
1275 A1 = abuf0[i * 2 ] * (1 << 11);
1276 A2 = abuf0[i * 2 + 1] * (1 << 11);
1277
1278 A1 += 1 << 13;
1279 A2 += 1 << 13;
1280 }
1281
1282 8192 R = V * c->yuv2rgb_v2r_coeff;
1283 8192 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1284 8192 B = U * c->yuv2rgb_u2b_coeff;
1285
1286
14/18
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 4096 times.
✓ Branch 2 taken 4096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
✓ Branch 5 taken 1024 times.
✓ Branch 6 taken 3072 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1024 times.
✓ Branch 9 taken 2048 times.
✓ Branch 10 taken 3072 times.
✓ Branch 11 taken 1024 times.
✓ Branch 12 taken 3072 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2048 times.
✓ Branch 15 taken 1024 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2048 times.
8192 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1287
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 4096 times.
8192 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1288
14/18
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 4096 times.
✓ Branch 2 taken 4096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
✓ Branch 5 taken 1024 times.
✓ Branch 6 taken 3072 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1024 times.
✓ Branch 9 taken 2048 times.
✓ Branch 10 taken 3072 times.
✓ Branch 11 taken 1024 times.
✓ Branch 12 taken 3072 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2048 times.
✓ Branch 15 taken 1024 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2048 times.
8192 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1289
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 4096 times.
8192 if (eightbytes) {
1290
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
4096 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1291
12/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1024 times.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 2048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✓ Branch 15 taken 1024 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
4096 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1292
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
4096 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1293
12/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1024 times.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 2048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✓ Branch 15 taken 1024 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
4096 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1294
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
4096 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1295 4096 dest += 8;
1296 } else {
1297
12/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1024 times.
✓ Branch 5 taken 1024 times.
✓ Branch 6 taken 1024 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 1024 times.
✓ Branch 11 taken 1024 times.
✓ Branch 12 taken 1024 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
4096 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1298
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
4096 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1299
12/18
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1024 times.
✓ Branch 5 taken 1024 times.
✓ Branch 6 taken 1024 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1024 times.
✓ Branch 10 taken 1024 times.
✓ Branch 11 taken 1024 times.
✓ Branch 12 taken 1024 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1024 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1024 times.
4096 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1300 4096 dest += 6;
1301 }
1302 }
1303 }
1304 209684 }
1305
1306 static av_always_inline void
1307 1000 yuv2rgba64_full_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1308 const int32_t **lumSrc, int lumFilterSize,
1309 const int16_t *chrFilter, const int32_t **chrUSrc,
1310 const int32_t **chrVSrc, int chrFilterSize,
1311 const int32_t **alpSrc, uint16_t *dest, int dstW,
1312 int y, enum AVPixelFormat target, int hasAlpha,
1313 int eightbytes, int is_be)
1314 {
1315 int i;
1316 1000 int A = 0xffff<<14;
1317
1318
2/2
✓ Branch 0 taken 200000 times.
✓ Branch 1 taken 1000 times.
201000 for (i = 0; i < dstW; i++) {
1319 int j;
1320 200000 int Y = -0x40000000;
1321 200000 int U = -(128 << 23); // 19
1322 200000 int V = -(128 << 23);
1323 int R, G, B;
1324
1325
2/2
✓ Branch 0 taken 2400000 times.
✓ Branch 1 taken 200000 times.
2600000 for (j = 0; j < lumFilterSize; j++) {
1326 2400000 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
1327 }
1328
2/2
✓ Branch 0 taken 2400000 times.
✓ Branch 1 taken 200000 times.
2600000 for (j = 0; j < chrFilterSize; j++) {;
1329 2400000 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1330 2400000 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1331 }
1332
1333
2/2
✓ Branch 0 taken 80000 times.
✓ Branch 1 taken 120000 times.
200000 if (hasAlpha) {
1334 80000 A = -0x40000000;
1335
2/2
✓ Branch 0 taken 960000 times.
✓ Branch 1 taken 80000 times.
1040000 for (j = 0; j < lumFilterSize; j++) {
1336 960000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
1337 }
1338 80000 A >>= 1;
1339 80000 A += 0x20002000;
1340 }
1341
1342 // 8bit: 12+15=27; 16-bit: 12+19=31
1343 200000 Y >>= 14; // 10
1344 200000 Y += 0x10000;
1345 200000 U >>= 14;
1346 200000 V >>= 14;
1347
1348 // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit
1349 200000 Y -= c->yuv2rgb_y_offset;
1350 200000 Y *= c->yuv2rgb_y_coeff;
1351 200000 Y += (1 << 13) - (1<<29); // 21
1352 // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit
1353
1354 200000 R = V * c->yuv2rgb_v2r_coeff;
1355 200000 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1356 200000 B = U * c->yuv2rgb_u2b_coeff;
1357
1358 // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
1359
14/18
✓ Branch 0 taken 100000 times.
✓ Branch 1 taken 100000 times.
✓ Branch 2 taken 100000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60000 times.
✓ Branch 5 taken 40000 times.
✓ Branch 6 taken 60000 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20000 times.
✓ Branch 9 taken 40000 times.
✓ Branch 10 taken 60000 times.
✓ Branch 11 taken 40000 times.
✓ Branch 12 taken 60000 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 40000 times.
✓ Branch 15 taken 20000 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 40000 times.
200000 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + (unsigned)Y)>>14) + (1<<15), 16));
1360
2/2
✓ Branch 0 taken 100000 times.
✓ Branch 1 taken 100000 times.
200000 output_pixel(&dest[1], av_clip_uintp2(((int)( G + (unsigned)Y)>>14) + (1<<15), 16));
1361
14/18
✓ Branch 0 taken 100000 times.
✓ Branch 1 taken 100000 times.
✓ Branch 2 taken 100000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60000 times.
✓ Branch 5 taken 40000 times.
✓ Branch 6 taken 60000 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20000 times.
✓ Branch 9 taken 40000 times.
✓ Branch 10 taken 60000 times.
✓ Branch 11 taken 40000 times.
✓ Branch 12 taken 60000 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 40000 times.
✓ Branch 15 taken 20000 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 40000 times.
200000 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + (unsigned)Y)>>14) + (1<<15), 16));
1362
2/2
✓ Branch 0 taken 80000 times.
✓ Branch 1 taken 120000 times.
200000 if (eightbytes) {
1363
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 40000 times.
80000 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1364 80000 dest += 4;
1365 } else {
1366 120000 dest += 3;
1367 }
1368 }
1369 1000 }
1370
1371 static av_always_inline void
1372 yuv2rgba64_full_2_c_template(SwsInternal *c, const int32_t *buf[2],
1373 const int32_t *ubuf[2], const int32_t *vbuf[2],
1374 const int32_t *abuf[2], uint16_t *dest, int dstW,
1375 int yalpha, int uvalpha, int y,
1376 enum AVPixelFormat target, int hasAlpha, int eightbytes,
1377 int is_be)
1378 {
1379 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1380 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1381 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1382 *abuf0 = hasAlpha ? abuf[0] : NULL,
1383 *abuf1 = hasAlpha ? abuf[1] : NULL;
1384 int yalpha1 = 4096 - yalpha;
1385 int uvalpha1 = 4096 - uvalpha;
1386 int i;
1387 int A = 0xffff<<14;
1388
1389 av_assert2(yalpha <= 4096U);
1390 av_assert2(uvalpha <= 4096U);
1391
1392 for (i = 0; i < dstW; i++) {
1393 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14;
1394 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1395 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1396 int R, G, B;
1397
1398 Y -= c->yuv2rgb_y_offset;
1399 Y *= c->yuv2rgb_y_coeff;
1400 Y += (1 << 13) - (1 << 29);
1401
1402 R = V * c->yuv2rgb_v2r_coeff;
1403 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1404 B = U * c->yuv2rgb_u2b_coeff;
1405
1406 if (hasAlpha) {
1407 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1;
1408
1409 A += 1 << 13;
1410 }
1411
1412 output_pixel(&dest[0], av_clip_uintp2(((R_B + Y) >> 14) + (1<<15), 16));
1413 output_pixel(&dest[1], av_clip_uintp2((( G + Y) >> 14) + (1<<15), 16));
1414 output_pixel(&dest[2], av_clip_uintp2(((B_R + Y) >> 14) + (1<<15), 16));
1415 if (eightbytes) {
1416 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1417 dest += 4;
1418 } else {
1419 dest += 3;
1420 }
1421 }
1422 }
1423
1424 static av_always_inline void
1425 404736 yuv2rgba64_full_1_c_template(SwsInternal *c, const int32_t *buf0,
1426 const int32_t *ubuf[2], const int32_t *vbuf[2],
1427 const int32_t *abuf0, uint16_t *dest, int dstW,
1428 int uvalpha, int y, enum AVPixelFormat target,
1429 int hasAlpha, int eightbytes, int is_be)
1430 {
1431 404736 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1432 int i;
1433 404736 int A = 0xffff<<14;
1434
1435
1/2
✓ Branch 0 taken 404736 times.
✗ Branch 1 not taken.
404736 if (uvalpha == 0) {
1436
2/2
✓ Branch 0 taken 142368768 times.
✓ Branch 1 taken 404736 times.
142773504 for (i = 0; i < dstW; i++) {
1437 142368768 SUINT Y = (buf0[i]) >> 2;
1438 142368768 int U = (ubuf0[i] - (128 << 11)) >> 2;
1439 142368768 int V = (vbuf0[i] - (128 << 11)) >> 2;
1440 int R, G, B;
1441
1442 142368768 Y -= c->yuv2rgb_y_offset;
1443 142368768 Y *= c->yuv2rgb_y_coeff;
1444 142368768 Y += (1 << 13) - (1 << 29);
1445
1446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142368768 times.
142368768 if (hasAlpha) {
1447 A = abuf0[i] * (1 << 11);
1448
1449 A += 1 << 13;
1450 }
1451
1452 142368768 R = V * c->yuv2rgb_v2r_coeff;
1453 142368768 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1454 142368768 B = U * c->yuv2rgb_u2b_coeff;
1455
1456
7/18
✗ Branch 0 not taken.
✓ Branch 1 taken 142368768 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 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 27648 times.
✓ Branch 11 taken 142341120 times.
✓ Branch 12 taken 27648 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18432 times.
✓ Branch 15 taken 9216 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 18432 times.
142368768 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142368768 times.
142368768 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y) >> 14) + (1<<15), 16));
1458
7/18
✗ Branch 0 not taken.
✓ Branch 1 taken 142368768 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 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 27648 times.
✓ Branch 11 taken 142341120 times.
✓ Branch 12 taken 27648 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18432 times.
✓ Branch 15 taken 9216 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 18432 times.
142368768 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
1459
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 142350336 times.
142368768 if (eightbytes) {
1460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1461 18432 dest += 4;
1462 } else {
1463 142350336 dest += 3;
1464 }
1465 }
1466 } else {
1467 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1468 int uvalpha1 = 4096 - uvalpha;
1469 int A = 0xffff<<14;
1470 av_assert2(uvalpha <= 4096U);
1471
1472 for (i = 0; i < dstW; i++) {
1473 SUINT Y = (buf0[i] ) >> 2;
1474 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1475 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1476 int R, G, B;
1477
1478 Y -= c->yuv2rgb_y_offset;
1479 Y *= c->yuv2rgb_y_coeff;
1480 Y += (1 << 13) - (1 << 29);
1481
1482 if (hasAlpha) {
1483 A = abuf0[i] * (1 << 11);
1484
1485 A += 1 << 13;
1486 }
1487
1488 R = V * c->yuv2rgb_v2r_coeff;
1489 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1490 B = U * c->yuv2rgb_u2b_coeff;
1491
1492 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
1493 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y) >> 14) + (1<<15), 16));
1494 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
1495 if (eightbytes) {
1496 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1497 dest += 4;
1498 } else {
1499 dest += 3;
1500 }
1501 }
1502 }
1503 404736 }
1504
1505 #undef output_pixel
1506 #undef r_b
1507 #undef b_r
1508
1509 #define YUV2PACKED16WRAPPER_EXT(name, base, ext, fmt, is_be, hasAlpha, eightbytes) \
1510 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
1511 const int16_t **_lumSrc, int lumFilterSize, \
1512 const int16_t *chrFilter, const int16_t **_chrUSrc, \
1513 const int16_t **_chrVSrc, int chrFilterSize, \
1514 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
1515 int y) \
1516 { \
1517 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
1518 **chrUSrc = (const int32_t **) _chrUSrc, \
1519 **chrVSrc = (const int32_t **) _chrVSrc, \
1520 **alpSrc = (const int32_t **) _alpSrc; \
1521 uint16_t *dest = (uint16_t *) _dest; \
1522 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1523 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1524 alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes, is_be); \
1525 } \
1526 \
1527 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *_buf[2], \
1528 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1529 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
1530 int yalpha, int uvalpha, int y) \
1531 { \
1532 const int32_t **buf = (const int32_t **) _buf, \
1533 **ubuf = (const int32_t **) _ubuf, \
1534 **vbuf = (const int32_t **) _vbuf, \
1535 **abuf = (const int32_t **) _abuf; \
1536 uint16_t *dest = (uint16_t *) _dest; \
1537 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1538 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1539 } \
1540 \
1541 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *_buf0, \
1542 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1543 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
1544 int uvalpha, int y) \
1545 { \
1546 const int32_t *buf0 = (const int32_t *) _buf0, \
1547 **ubuf = (const int32_t **) _ubuf, \
1548 **vbuf = (const int32_t **) _vbuf, \
1549 *abuf0 = (const int32_t *) _abuf0; \
1550 uint16_t *dest = (uint16_t *) _dest; \
1551 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1552 dstW, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1553 }
1554 #define YUV2PACKED16WRAPPER(name, base, ext, base_fmt, endianness, hasAlpha, eightbytes) \
1555 YUV2PACKED16WRAPPER_EXT(name, base, ext, base_fmt ## endianness, IS_BE(endianness), hasAlpha, eightbytes)
1556
1557 38048 YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48be, AV_PIX_FMT_RGB48, BE, 0, 0)
1558 821896 YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48le, AV_PIX_FMT_RGB48, LE, 0, 0)
1559 11552 YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48be, AV_PIX_FMT_BGR48, BE, 0, 0)
1560 12128 YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48le, AV_PIX_FMT_BGR48, LE, 0, 0)
1561 YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64, BE, 1, 1)
1562 YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64, LE, 1, 1)
1563 11552 YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64, BE, 0, 1)
1564 21344 YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64, LE, 0, 1)
1565 YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64, BE, 1, 1)
1566 YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64, LE, 1, 1)
1567 11552 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64, BE, 0, 1)
1568 11552 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64, LE, 0, 1)
1569 11720 YUV2PACKED16WRAPPER(yuv2, ya16, ya16be, AV_PIX_FMT_YA16, BE, 1, 0)
1570 12296 YUV2PACKED16WRAPPER(yuv2, ya16, ya16le, AV_PIX_FMT_YA16, LE, 1, 0)
1571
1572 400 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48be_full, AV_PIX_FMT_RGB48, BE, 0, 0)
1573 809296 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48le_full, AV_PIX_FMT_RGB48, LE, 0, 0)
1574 200 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48be_full, AV_PIX_FMT_BGR48, BE, 0, 0)
1575 392 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48le_full, AV_PIX_FMT_BGR48, LE, 0, 0)
1576 200 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64be_full, AV_PIX_FMT_RGBA64, BE, 1, 1)
1577 200 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64le_full, AV_PIX_FMT_RGBA64, LE, 1, 1)
1578 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64be_full, AV_PIX_FMT_RGBA64, BE, 0, 1)
1579 192 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64le_full, AV_PIX_FMT_RGBA64, LE, 0, 1)
1580 200 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64, BE, 1, 1)
1581 200 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64, LE, 1, 1)
1582 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64, BE, 0, 1)
1583 192 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64, LE, 0, 1)
1584
1585 /*
1586 * Write out 2 RGB pixels in the target pixel format. This function takes a
1587 * R/G/B LUT as generated by ff_yuv2rgb_c_init_tables(), which takes care of
1588 * things like endianness conversion and shifting. The caller takes care of
1589 * setting the correct offset in these tables from the chroma (U/V) values.
1590 * This function then uses the luminance (Y1/Y2) values to write out the
1591 * correct RGB values into the destination buffer.
1592 */
1593 static av_always_inline void
1594 284146532 yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
1595 unsigned A1, unsigned A2,
1596 const void *_r, const void *_g, const void *_b, int y,
1597 enum AVPixelFormat target, int hasAlpha)
1598 {
1599
4/6
✓ Branch 0 taken 284146532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 284146532 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279113892 times.
✓ Branch 5 taken 5032640 times.
284146532 if (target == AV_PIX_FMT_ARGB || target == AV_PIX_FMT_RGBA ||
1600
2/2
✓ Branch 0 taken 25409992 times.
✓ Branch 1 taken 253703900 times.
309556524 target == AV_PIX_FMT_ABGR || target == AV_PIX_FMT_BGRA) {
1601 30442632 uint32_t *dest = (uint32_t *) _dest;
1602 30442632 const uint32_t *r = (const uint32_t *) _r;
1603 30442632 const uint32_t *g = (const uint32_t *) _g;
1604 30442632 const uint32_t *b = (const uint32_t *) _b;
1605
1606 #if CONFIG_SMALL
1607 int sh = hasAlpha ? ((target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24) : 0;
1608
1609 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
1610 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
1611 #else
1612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30442632 times.
30442632 if (hasAlpha) {
1613 int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
1614
1615 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0);
1616 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
1617 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
1618 } else {
1619 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
1620 int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
1621
1622 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0xFF);
1623 #endif
1624 30442632 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
1625 30442632 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
1626 }
1627 #endif
1628
4/4
✓ Branch 0 taken 132054534 times.
✓ Branch 1 taken 121649366 times.
✓ Branch 2 taken 26307054 times.
✓ Branch 3 taken 105747480 times.
253703900 } else if (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) {
1629 147956420 uint8_t *dest = (uint8_t *) _dest;
1630 147956420 const uint8_t *r = (const uint8_t *) _r;
1631 147956420 const uint8_t *g = (const uint8_t *) _g;
1632 147956420 const uint8_t *b = (const uint8_t *) _b;
1633
1634 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
1635 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
1636
1637
2/2
✓ Branch 0 taken 121649366 times.
✓ Branch 1 taken 26307054 times.
147956420 dest[i * 6 + 0] = r_b[Y1];
1638 147956420 dest[i * 6 + 1] = g[Y1];
1639
2/2
✓ Branch 0 taken 121649366 times.
✓ Branch 1 taken 26307054 times.
147956420 dest[i * 6 + 2] = b_r[Y1];
1640
2/2
✓ Branch 0 taken 121649366 times.
✓ Branch 1 taken 26307054 times.
147956420 dest[i * 6 + 3] = r_b[Y2];
1641 147956420 dest[i * 6 + 4] = g[Y2];
1642
2/2
✓ Branch 0 taken 121649366 times.
✓ Branch 1 taken 26307054 times.
147956420 dest[i * 6 + 5] = b_r[Y2];
1643 #undef r_b
1644 #undef b_r
1645
5/6
✓ Branch 0 taken 78544116 times.
✓ Branch 1 taken 27203364 times.
✓ Branch 2 taken 78544116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28473352 times.
✓ Branch 5 taken 50070764 times.
105747480 } else if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565 ||
1646
3/4
✓ Branch 0 taken 28473352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24361928 times.
✓ Branch 3 taken 4111424 times.
28473352 target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555 ||
1647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24361928 times.
24361928 target == AV_PIX_FMT_RGB444 || target == AV_PIX_FMT_BGR444) {
1648 81385552 uint16_t *dest = (uint16_t *) _dest;
1649 81385552 const uint16_t *r = (const uint16_t *) _r;
1650 81385552 const uint16_t *g = (const uint16_t *) _g;
1651 81385552 const uint16_t *b = (const uint16_t *) _b;
1652 int dr1, dg1, db1, dr2, dg2, db2;
1653
1654
3/4
✓ Branch 0 taken 54182188 times.
✓ Branch 1 taken 27203364 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54182188 times.
81385552 if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565) {
1655 27203364 dr1 = ff_dither_2x2_8[ y & 1 ][0];
1656 27203364 dg1 = ff_dither_2x2_4[ y & 1 ][0];
1657 27203364 db1 = ff_dither_2x2_8[(y & 1) ^ 1][0];
1658 27203364 dr2 = ff_dither_2x2_8[ y & 1 ][1];
1659 27203364 dg2 = ff_dither_2x2_4[ y & 1 ][1];
1660 27203364 db2 = ff_dither_2x2_8[(y & 1) ^ 1][1];
1661
3/4
✓ Branch 0 taken 4111424 times.
✓ Branch 1 taken 50070764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4111424 times.
54182188 } else if (target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555) {
1662 50070764 dr1 = ff_dither_2x2_8[ y & 1 ][0];
1663 50070764 dg1 = ff_dither_2x2_8[ y & 1 ][1];
1664 50070764 db1 = ff_dither_2x2_8[(y & 1) ^ 1][0];
1665 50070764 dr2 = ff_dither_2x2_8[ y & 1 ][1];
1666 50070764 dg2 = ff_dither_2x2_8[ y & 1 ][0];
1667 50070764 db2 = ff_dither_2x2_8[(y & 1) ^ 1][1];
1668 } else {
1669 4111424 dr1 = ff_dither_4x4_16[ y & 3 ][0];
1670 4111424 dg1 = ff_dither_4x4_16[ y & 3 ][1];
1671 4111424 db1 = ff_dither_4x4_16[(y & 3) ^ 3][0];
1672 4111424 dr2 = ff_dither_4x4_16[ y & 3 ][1];
1673 4111424 dg2 = ff_dither_4x4_16[ y & 3 ][0];
1674 4111424 db2 = ff_dither_4x4_16[(y & 3) ^ 3][1];
1675 }
1676
1677 81385552 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1678 81385552 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1679
4/4
✓ Branch 0 taken 23348168 times.
✓ Branch 1 taken 1013760 times.
✓ Branch 2 taken 1013760 times.
✓ Branch 3 taken 22334408 times.
24361928 } else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) {
1680 2027520 uint32_t *dest = (uint32_t *) _dest;
1681 2027520 const uint32_t *r = (const uint32_t *) _r;
1682 2027520 const uint32_t *g = (const uint32_t *) _g;
1683 2027520 const uint32_t *b = (const uint32_t *) _b;
1684 2027520 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
1685 2027520 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
1686 } else /* 8/4 bits */ {
1687 22334408 uint8_t *dest = (uint8_t *) _dest;
1688 22334408 const uint8_t *r = (const uint8_t *) _r;
1689 22334408 const uint8_t *g = (const uint8_t *) _g;
1690 22334408 const uint8_t *b = (const uint8_t *) _b;
1691 int dr1, dg1, db1, dr2, dg2, db2;
1692
1693
3/4
✓ Branch 0 taken 2702848 times.
✓ Branch 1 taken 19631560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2702848 times.
22334408 if (target == AV_PIX_FMT_RGB8 || target == AV_PIX_FMT_BGR8) {
1694 19631560 const uint8_t * const d64 = ff_dither_8x8_73[y & 7];
1695 19631560 const uint8_t * const d32 = ff_dither_8x8_32[y & 7];
1696 19631560 dr1 = dg1 = d32[(i * 2 + 0) & 7];
1697 19631560 db1 = d64[(i * 2 + 0) & 7];
1698 19631560 dr2 = dg2 = d32[(i * 2 + 1) & 7];
1699 19631560 db2 = d64[(i * 2 + 1) & 7];
1700 } else {
1701 2702848 const uint8_t * const d64 = ff_dither_8x8_73 [y & 7];
1702 2702848 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
1703 2702848 dr1 = db1 = d128[(i * 2 + 0) & 7];
1704 2702848 dg1 = d64[(i * 2 + 0) & 7];
1705 2702848 dr2 = db2 = d128[(i * 2 + 1) & 7];
1706 2702848 dg2 = d64[(i * 2 + 1) & 7];
1707 }
1708
1709
3/4
✓ Branch 0 taken 22326216 times.
✓ Branch 1 taken 8192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22326216 times.
22334408 if (target == AV_PIX_FMT_RGB4 || target == AV_PIX_FMT_BGR4) {
1710 8192 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
1711 8192 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
1712 } else {
1713 22326216 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1714 22326216 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1715 }
1716 }
1717 284146532 }
1718
1719 static av_always_inline void
1720 1184472 yuv2rgb_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1721 const int16_t **lumSrc, int lumFilterSize,
1722 const int16_t *chrFilter, const int16_t **chrUSrc,
1723 const int16_t **chrVSrc, int chrFilterSize,
1724 const int16_t **alpSrc, uint8_t *dest, int dstW,
1725 int y, enum AVPixelFormat target, int hasAlpha)
1726 {
1727 int i;
1728
1729
2/2
✓ Branch 0 taken 203189432 times.
✓ Branch 1 taken 1184472 times.
204373904 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1730 int j, A1, A2;
1731 203189432 int Y1 = 1 << 18;
1732 203189432 int Y2 = 1 << 18;
1733 203189432 int U = 1 << 18;
1734 203189432 int V = 1 << 18;
1735 const void *r, *g, *b;
1736
1737
2/2
✓ Branch 0 taken 216298040 times.
✓ Branch 1 taken 203189432 times.
419487472 for (j = 0; j < lumFilterSize; j++) {
1738 216298040 Y1 += lumSrc[j][i * 2] * lumFilter[j];
1739 216298040 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
1740 }
1741
2/2
✓ Branch 0 taken 816317408 times.
✓ Branch 1 taken 203189432 times.
1019506840 for (j = 0; j < chrFilterSize; j++) {
1742 816317408 U += chrUSrc[j][i] * chrFilter[j];
1743 816317408 V += chrVSrc[j][i] * chrFilter[j];
1744 }
1745 203189432 Y1 >>= 19;
1746 203189432 Y2 >>= 19;
1747 203189432 U >>= 19;
1748 203189432 V >>= 19;
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203189432 times.
203189432 if (hasAlpha) {
1750 A1 = 1 << 18;
1751 A2 = 1 << 18;
1752 for (j = 0; j < lumFilterSize; j++) {
1753 A1 += alpSrc[j][i * 2 ] * lumFilter[j];
1754 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
1755 }
1756 A1 >>= 19;
1757 A2 >>= 19;
1758 if ((A1 | A2) & 0x100) {
1759 A1 = av_clip_uint8(A1);
1760 A2 = av_clip_uint8(A2);
1761 }
1762 }
1763
1764 203189432 r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
1765 203189432 g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
1766 203189432 b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1767
1768
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203189432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203189432 times.
203189432 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1769 r, g, b, y, target, hasAlpha);
1770 }
1771 1184472 }
1772
1773 static av_always_inline void
1774 144 yuv2rgb_2_c_template(SwsInternal *c, const int16_t *buf[2],
1775 const int16_t *ubuf[2], const int16_t *vbuf[2],
1776 const int16_t *abuf[2], uint8_t *dest, int dstW,
1777 int yalpha, int uvalpha, int y,
1778 enum AVPixelFormat target, int hasAlpha)
1779 {
1780 144 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1781 144 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1782 144 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 *abuf0 = hasAlpha ? abuf[0] : NULL,
1784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 *abuf1 = hasAlpha ? abuf[1] : NULL;
1785 144 int yalpha1 = 4096 - yalpha;
1786 144 int uvalpha1 = 4096 - uvalpha;
1787 int i;
1788 av_assert2(yalpha <= 4096U);
1789 av_assert2(uvalpha <= 4096U);
1790
1791
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 144 times.
37008 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1792 36864 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
1793 36864 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
1794 36864 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
1795 36864 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
1796 int A1, A2;
1797 36864 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1798 36864 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1799 36864 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1800
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36864 times.
36864 if (hasAlpha) {
1802 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
1803 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
1804 A1 = av_clip_uint8(A1);
1805 A2 = av_clip_uint8(A2);
1806 }
1807
1808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36864 times.
36864 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1809 r, g, b, y, target, hasAlpha);
1810 }
1811 144 }
1812
1813 static av_always_inline void
1814 464316 yuv2rgb_1_c_template(SwsInternal *c, const int16_t *buf0,
1815 const int16_t *ubuf[2], const int16_t *vbuf[2],
1816 const int16_t *abuf0, uint8_t *dest, int dstW,
1817 int uvalpha, int y, enum AVPixelFormat target,
1818 int hasAlpha)
1819 {
1820 464316 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1821 int i;
1822
1823
2/2
✓ Branch 0 taken 464220 times.
✓ Branch 1 taken 96 times.
464316 if (uvalpha == 0) {
1824
2/2
✓ Branch 0 taken 80895660 times.
✓ Branch 1 taken 464220 times.
81359880 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1825 80895660 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1826 80895660 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1827 80895660 int U = (ubuf0[i] + 64) >> 7;
1828 80895660 int V = (vbuf0[i] + 64) >> 7;
1829 int A1, A2;
1830 80895660 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1831 80895660 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1832 80895660 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1833
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80895660 times.
80895660 if (hasAlpha) {
1835 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
1836 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
1837 A1 = av_clip_uint8(A1);
1838 A2 = av_clip_uint8(A2);
1839 }
1840
1841
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80895660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80895660 times.
80895660 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1842 r, g, b, y, target, hasAlpha);
1843 }
1844 } else {
1845 96 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1846 96 int uvalpha1 = 4096 - uvalpha;
1847 av_assert2(uvalpha <= 4096U);
1848
1849
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1850 24576 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1851 24576 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1852 24576 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (128 << 11)) >> 19;
1853 24576 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (128 << 11)) >> 19;
1854 int A1, A2;
1855 24576 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1856 24576 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1857 24576 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1858
1859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if (hasAlpha) {
1860 A1 = (abuf0[i * 2 ] + 64) >> 7;
1861 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
1862 A1 = av_clip_uint8(A1);
1863 A2 = av_clip_uint8(A2);
1864 }
1865
1866
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24576 times.
24576 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1867 r, g, b, y, target, hasAlpha);
1868 }
1869 }
1870 464316 }
1871
1872 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1873 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
1874 const int16_t **lumSrc, int lumFilterSize, \
1875 const int16_t *chrFilter, const int16_t **chrUSrc, \
1876 const int16_t **chrVSrc, int chrFilterSize, \
1877 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1878 int y) \
1879 { \
1880 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1881 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1882 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1883 }
1884
1885 #define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1886 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1887 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *buf[2], \
1888 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1889 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1890 int yalpha, int uvalpha, int y) \
1891 { \
1892 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1893 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1894 }
1895
1896 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1897 YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1898 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *buf0, \
1899 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1900 const int16_t *abuf0, uint8_t *dest, int dstW, \
1901 int uvalpha, int y) \
1902 { \
1903 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1904 dstW, uvalpha, y, fmt, hasAlpha); \
1905 }
1906
1907 #if CONFIG_SMALL
1908 YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->needAlpha)
1909 YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->needAlpha)
1910 #else
1911 #if CONFIG_SWSCALE_ALPHA
1912 YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1)
1913 YUV2RGBWRAPPER(yuv2rgb,, a32, AV_PIX_FMT_RGB32, 1)
1914 #endif
1915 62560 YUV2RGBWRAPPER(yuv2rgb,, x32_1, AV_PIX_FMT_RGB32_1, 0)
1916 294864 YUV2RGBWRAPPER(yuv2rgb,, x32, AV_PIX_FMT_RGB32, 0)
1917 #endif
1918 1411412 YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
1919 308148 YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
1920 312488 YUV2RGBWRAPPER(yuv2rgb,, 16, AV_PIX_FMT_RGB565, 0)
1921 578488 YUV2RGBWRAPPER(yuv2rgb,, 15, AV_PIX_FMT_RGB555, 0)
1922 47008 YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0)
1923 229200 YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
1924 64 YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
1925 30592 YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
1926 11520 YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0)
1927 11520 YUV2RGBWRAPPER(yuv2, rgb, x2bgr10, AV_PIX_FMT_X2BGR10, 0)
1928
1929 348030372 static av_always_inline void yuv2rgb_write_full(SwsInternal *c,
1930 uint8_t *dest, int i, int Y, int A, int U, int V,
1931 int y, enum AVPixelFormat target, int hasAlpha, int err[4])
1932 {
1933 int R, G, B;
1934
4/4
✓ Branch 0 taken 331697578 times.
✓ Branch 1 taken 16332794 times.
✓ Branch 2 taken 10700797 times.
✓ Branch 3 taken 320996781 times.
348030372 int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8;
1935
1936 348030372 Y -= c->yuv2rgb_y_offset;
1937 348030372 Y *= c->yuv2rgb_y_coeff;
1938 348030372 Y += 1 << 21;
1939 348030372 R = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2r_coeff;
1940 348030372 G = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2g_coeff + U*(unsigned)c->yuv2rgb_u2g_coeff;
1941 348030372 B = (unsigned)Y + U*(unsigned)c->yuv2rgb_u2b_coeff;
1942
2/2
✓ Branch 0 taken 48117053 times.
✓ Branch 1 taken 299913319 times.
348030372 if ((R | G | B) & 0xC0000000) {
1943 48117053 R = av_clip_uintp2(R, 30);
1944 48117053 G = av_clip_uintp2(G, 30);
1945 48117053 B = av_clip_uintp2(B, 30);
1946 }
1947
1948
9/10
✓ Branch 0 taken 58432 times.
✓ Branch 1 taken 147636040 times.
✓ Branch 2 taken 58432 times.
✓ Branch 3 taken 58432 times.
✓ Branch 4 taken 54522884 times.
✓ Branch 5 taken 54845799 times.
✓ Branch 6 taken 23741984 times.
✓ Branch 7 taken 23741984 times.
✓ Branch 8 taken 43366385 times.
✗ Branch 9 not taken.
348030372 switch(target) {
1949 58432 case AV_PIX_FMT_ARGB:
1950
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 18432 times.
58432 dest[0] = hasAlpha ? A : 255;
1951 58432 dest[1] = R >> 22;
1952 58432 dest[2] = G >> 22;
1953 58432 dest[3] = B >> 22;
1954 58432 break;
1955 147636040 case AV_PIX_FMT_RGB24:
1956 147636040 dest[0] = R >> 22;
1957 147636040 dest[1] = G >> 22;
1958 147636040 dest[2] = B >> 22;
1959 147636040 break;
1960 58432 case AV_PIX_FMT_RGBA:
1961 58432 dest[0] = R >> 22;
1962 58432 dest[1] = G >> 22;
1963 58432 dest[2] = B >> 22;
1964
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 18432 times.
58432 dest[3] = hasAlpha ? A : 255;
1965 58432 break;
1966 58432 case AV_PIX_FMT_ABGR:
1967
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 18432 times.
58432 dest[0] = hasAlpha ? A : 255;
1968 58432 dest[1] = B >> 22;
1969 58432 dest[2] = G >> 22;
1970 58432 dest[3] = R >> 22;
1971 58432 break;
1972 54522884 case AV_PIX_FMT_BGR24:
1973 54522884 dest[0] = B >> 22;
1974 54522884 dest[1] = G >> 22;
1975 54522884 dest[2] = R >> 22;
1976 54522884 break;
1977 54845799 case AV_PIX_FMT_BGRA:
1978 54845799 dest[0] = B >> 22;
1979 54845799 dest[1] = G >> 22;
1980 54845799 dest[2] = R >> 22;
1981
2/2
✓ Branch 0 taken 3932007 times.
✓ Branch 1 taken 50913792 times.
54845799 dest[3] = hasAlpha ? A : 255;
1982 54845799 break;
1983 23741984 case AV_PIX_FMT_X2RGB10LE:
1984 23741984 R >>= 20;
1985 23741984 G >>= 20;
1986 23741984 B >>= 20;
1987 23741984 AV_WL32(dest, (3U << 30) + (R << 20) + (G << 10) + B);
1988 23741984 break;
1989 23741984 case AV_PIX_FMT_X2BGR10LE:
1990 23741984 R >>= 20;
1991 23741984 G >>= 20;
1992 23741984 B >>= 20;
1993 23741984 AV_WL32(dest, (3U << 30) + (B << 20) + (G << 10) + R);
1994 23741984 break;
1995 43366385 case AV_PIX_FMT_BGR4_BYTE:
1996 case AV_PIX_FMT_RGB4_BYTE:
1997 case AV_PIX_FMT_BGR8:
1998 case AV_PIX_FMT_RGB8:
1999 {
2000 int r,g,b;
2001
2002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43366385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43366385 switch (c->opts.dither) {
2003 case SWS_DITHER_NONE:
2004 if (isrgb8) {
2005 r = av_clip_uintp2(R >> 27, 3);
2006 g = av_clip_uintp2(G >> 27, 3);
2007 b = av_clip_uintp2(B >> 28, 2);
2008 } else {
2009 r = av_clip_uintp2(R >> 29, 1);
2010 g = av_clip_uintp2(G >> 28, 2);
2011 b = av_clip_uintp2(B >> 29, 1);
2012 }
2013 break;
2014 43366385 default:
2015 case SWS_DITHER_AUTO:
2016 case SWS_DITHER_ED:
2017 43366385 R >>= 22;
2018 43366385 G >>= 22;
2019 43366385 B >>= 22;
2020 43366385 R += (7*err[0] + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
2021 43366385 G += (7*err[1] + 1*c->dither_error[1][i] + 5*c->dither_error[1][i+1] + 3*c->dither_error[1][i+2])>>4;
2022 43366385 B += (7*err[2] + 1*c->dither_error[2][i] + 5*c->dither_error[2][i+1] + 3*c->dither_error[2][i+2])>>4;
2023 43366385 c->dither_error[0][i] = err[0];
2024 43366385 c->dither_error[1][i] = err[1];
2025 43366385 c->dither_error[2][i] = err[2];
2026
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 r = R >> (isrgb8 ? 5 : 7);
2027
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 g = G >> (isrgb8 ? 5 : 6);
2028
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 b = B >> (isrgb8 ? 6 : 7);
2029
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 r = av_clip(r, 0, isrgb8 ? 7 : 1);
2030
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 g = av_clip(g, 0, isrgb8 ? 7 : 3);
2031
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 b = av_clip(b, 0, isrgb8 ? 3 : 1);
2032
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 err[0] = R - r*(isrgb8 ? 36 : 255);
2033
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 err[1] = G - g*(isrgb8 ? 36 : 85);
2034
2/2
✓ Branch 0 taken 27033591 times.
✓ Branch 1 taken 16332794 times.
43366385 err[2] = B - b*(isrgb8 ? 85 : 255);
2035 43366385 break;
2036 case SWS_DITHER_A_DITHER:
2037 if (isrgb8) {
2038 /* see http://pippin.gimp.org/a_dither/ for details/origin */
2039 #define A_DITHER(u,v) (((((u)+((v)*236))*119)&0xff))
2040 r = (((R >> 19) + A_DITHER(i,y) -96)>>8);
2041 g = (((G >> 19) + A_DITHER(i + 17,y) - 96)>>8);
2042 b = (((B >> 20) + A_DITHER(i + 17*2,y) -96)>>8);
2043 r = av_clip_uintp2(r, 3);
2044 g = av_clip_uintp2(g, 3);
2045 b = av_clip_uintp2(b, 2);
2046 } else {
2047 r = (((R >> 21) + A_DITHER(i,y)-256)>>8);
2048 g = (((G >> 19) + A_DITHER(i + 17,y)-256)>>8);
2049 b = (((B >> 21) + A_DITHER(i + 17*2,y)-256)>>8);
2050 r = av_clip_uintp2(r, 1);
2051 g = av_clip_uintp2(g, 2);
2052 b = av_clip_uintp2(b, 1);
2053 }
2054 break;
2055 case SWS_DITHER_X_DITHER:
2056 if (isrgb8) {
2057 /* see http://pippin.gimp.org/a_dither/ for details/origin */
2058 #define X_DITHER(u,v) (((((u)^((v)*237))*181)&0x1ff)/2)
2059 r = (((R >> 19) + X_DITHER(i,y) - 96)>>8);
2060 g = (((G >> 19) + X_DITHER(i + 17,y) - 96)>>8);
2061 b = (((B >> 20) + X_DITHER(i + 17*2,y) - 96)>>8);
2062 r = av_clip_uintp2(r, 3);
2063 g = av_clip_uintp2(g, 3);
2064 b = av_clip_uintp2(b, 2);
2065 } else {
2066 r = (((R >> 21) + X_DITHER(i,y)-256)>>8);
2067 g = (((G >> 19) + X_DITHER(i + 17,y)-256)>>8);
2068 b = (((B >> 21) + X_DITHER(i + 17*2,y)-256)>>8);
2069 r = av_clip_uintp2(r, 1);
2070 g = av_clip_uintp2(g, 2);
2071 b = av_clip_uintp2(b, 1);
2072 }
2073
2074 break;
2075 }
2076
2077
2/2
✓ Branch 0 taken 8166397 times.
✓ Branch 1 taken 35199988 times.
43366385 if(target == AV_PIX_FMT_BGR4_BYTE) {
2078 8166397 dest[0] = r + 2*g + 8*b;
2079
2/2
✓ Branch 0 taken 8166397 times.
✓ Branch 1 taken 27033591 times.
35199988 } else if(target == AV_PIX_FMT_RGB4_BYTE) {
2080 8166397 dest[0] = b + 2*g + 8*r;
2081
2/2
✓ Branch 0 taken 16332794 times.
✓ Branch 1 taken 10700797 times.
27033591 } else if(target == AV_PIX_FMT_BGR8) {
2082 16332794 dest[0] = r + 8*g + 64*b;
2083
1/2
✓ Branch 0 taken 10700797 times.
✗ Branch 1 not taken.
10700797 } else if(target == AV_PIX_FMT_RGB8) {
2084 10700797 dest[0] = b + 4*g + 32*r;
2085 } else
2086 av_assert2(0);
2087 43366385 break;}
2088 }
2089 348030372 }
2090
2091 static av_always_inline void
2092 10535 yuv2rgb_full_X_c_template(SwsInternal *c, const int16_t *lumFilter,
2093 const int16_t **lumSrc, int lumFilterSize,
2094 const int16_t *chrFilter, const int16_t **chrUSrc,
2095 const int16_t **chrVSrc, int chrFilterSize,
2096 const int16_t **alpSrc, uint8_t *dest,
2097 int dstW, int y, enum AVPixelFormat target, int hasAlpha)
2098 {
2099 int i;
2100
4/4
✓ Branch 0 taken 8823 times.
✓ Branch 1 taken 1712 times.
✓ Branch 2 taken 722 times.
✓ Branch 3 taken 8101 times.
10535 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2101 10535 int err[4] = {0};
2102 10535 int A = 0; //init to silence warning
2103
2104
4/4
✓ Branch 0 taken 10435 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 10335 times.
✓ Branch 3 taken 100 times.
10535 if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2105
4/4
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 10035 times.
10335 || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2106 500 step = 1;
2107
2108
2/2
✓ Branch 0 taken 4865275 times.
✓ Branch 1 taken 10535 times.
4875810 for (i = 0; i < dstW; i++) {
2109 int j;
2110 4865275 int Y = 1<<9;
2111 4865275 int U = (1<<9)-(128 << 19);
2112 4865275 int V = (1<<9)-(128 << 19);
2113
2114
2/2
✓ Branch 0 taken 21139196 times.
✓ Branch 1 taken 4865275 times.
26004471 for (j = 0; j < lumFilterSize; j++) {
2115 21139196 Y += lumSrc[j][i] * lumFilter[j];
2116 }
2117
2/2
✓ Branch 0 taken 22598900 times.
✓ Branch 1 taken 4865275 times.
27464175 for (j = 0; j < chrFilterSize; j++) {
2118 22598900 U += chrUSrc[j][i] * chrFilter[j];
2119 22598900 V += chrVSrc[j][i] * chrFilter[j];
2120 }
2121 4865275 Y >>= 10;
2122 4865275 U >>= 10;
2123 4865275 V >>= 10;
2124
2/2
✓ Branch 0 taken 4052007 times.
✓ Branch 1 taken 813268 times.
4865275 if (hasAlpha) {
2125 4052007 A = 1 << 18;
2126
2/2
✓ Branch 0 taken 17488028 times.
✓ Branch 1 taken 4052007 times.
21540035 for (j = 0; j < lumFilterSize; j++) {
2127 17488028 A += alpSrc[j][i] * lumFilter[j];
2128 }
2129 4052007 A >>= 19;
2130
1/2
✓ Branch 0 taken 4052007 times.
✗ Branch 1 not taken.
4052007 if (A & 0x100)
2131 4052007 A = av_clip_uint8(A);
2132 }
2133 4865275 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2134 4865275 dest += step;
2135 }
2136 10535 c->dither_error[0][i] = err[0];
2137 10535 c->dither_error[1][i] = err[1];
2138 10535 c->dither_error[2][i] = err[2];
2139 10535 }
2140
2141 static av_always_inline void
2142 yuv2rgb_full_2_c_template(SwsInternal *c, const int16_t *buf[2],
2143 const int16_t *ubuf[2], const int16_t *vbuf[2],
2144 const int16_t *abuf[2], uint8_t *dest, int dstW,
2145 int yalpha, int uvalpha, int y,
2146 enum AVPixelFormat target, int hasAlpha)
2147 {
2148 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2149 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2150 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2151 *abuf0 = hasAlpha ? abuf[0] : NULL,
2152 *abuf1 = hasAlpha ? abuf[1] : NULL;
2153 int yalpha1 = 4096 - yalpha;
2154 int uvalpha1 = 4096 - uvalpha;
2155 int i;
2156 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2157 int err[4] = {0};
2158 int A = 0; // init to silcene warning
2159
2160 av_assert2(yalpha <= 4096U);
2161 av_assert2(uvalpha <= 4096U);
2162
2163 if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2164 || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2165 step = 1;
2166
2167 for (i = 0; i < dstW; i++) {
2168 int Y = ( buf0[i] * yalpha1 + buf1[i] * yalpha ) >> 10; //FIXME rounding
2169 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha-(128 << 19)) >> 10;
2170 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha-(128 << 19)) >> 10;
2171
2172 if (hasAlpha) {
2173 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha + (1<<18)) >> 19;
2174 if (A & 0x100)
2175 A = av_clip_uint8(A);
2176 }
2177
2178 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2179 dest += step;
2180 }
2181 c->dither_error[0][i] = err[0];
2182 c->dither_error[1][i] = err[1];
2183 c->dither_error[2][i] = err[2];
2184 }
2185
2186 static av_always_inline void
2187 1059981 yuv2rgb_full_1_c_template(SwsInternal *c, const int16_t *buf0,
2188 const int16_t *ubuf[2], const int16_t *vbuf[2],
2189 const int16_t *abuf0, uint8_t *dest, int dstW,
2190 int uvalpha, int y, enum AVPixelFormat target,
2191 int hasAlpha)
2192 {
2193 1059981 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
2194 int i;
2195
4/4
✓ Branch 0 taken 639305 times.
✓ Branch 1 taken 420676 times.
✓ Branch 2 taken 157288 times.
✓ Branch 3 taken 482017 times.
1059981 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2196 1059981 int err[4] = {0};
2197
2198
4/4
✓ Branch 0 taken 1022440 times.
✓ Branch 1 taken 37541 times.
✓ Branch 2 taken 984899 times.
✓ Branch 3 taken 37541 times.
1059981 if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2199
4/4
✓ Branch 0 taken 909817 times.
✓ Branch 1 taken 75082 times.
✓ Branch 2 taken 44741 times.
✓ Branch 3 taken 865076 times.
984899 || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2200 194905 step = 1;
2201
2202
1/2
✓ Branch 0 taken 1059981 times.
✗ Branch 1 not taken.
1059981 if (uvalpha == 0) {
2203 1059981 int A = 0; //init to silence warning
2204
2/2
✓ Branch 0 taken 343165097 times.
✓ Branch 1 taken 1059981 times.
344225078 for (i = 0; i < dstW; i++) {
2205 343165097 int Y = buf0[i] * 4;
2206 343165097 int U = (ubuf0[i] - (128<<7)) * 4;
2207 343165097 int V = (vbuf0[i] - (128<<7)) * 4;
2208
2209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 343165097 times.
343165097 if (hasAlpha) {
2210 A = (abuf0[i] + 64) >> 7;
2211 if (A & 0x100)
2212 A = av_clip_uint8(A);
2213 }
2214
2215 343165097 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2216 343165097 dest += step;
2217 }
2218 } else {
2219 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
2220 int A = 0; //init to silence warning
2221 int uvalpha1 = 4096 - uvalpha;
2222 av_assert2(uvalpha <= 4096U);
2223
2224 for (i = 0; i < dstW; i++) {
2225 int Y = buf0[i] * 4;
2226 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 19)) >> 10;
2227 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 19)) >> 10;
2228
2229 if (hasAlpha) {
2230 A = (abuf0[i] + 64) >> 7;
2231 if (A & 0x100)
2232 A = av_clip_uint8(A);
2233 }
2234
2235 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2236 dest += step;
2237 }
2238 }
2239
2240 1059981 c->dither_error[0][i] = err[0];
2241 1059981 c->dither_error[1][i] = err[1];
2242 1059981 c->dither_error[2][i] = err[2];
2243 1059981 }
2244
2245 #if CONFIG_SMALL
2246 YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2247 YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2248 YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2249 YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2250 #else
2251 #if CONFIG_SWSCALE_ALPHA
2252 13602 YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1)
2253 400 YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, 1)
2254 400 YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, 1)
2255 400 YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, 1)
2256 #endif
2257 303504 YUV2RGBWRAPPER(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
2258 384 YUV2RGBWRAPPER(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
2259 384 YUV2RGBWRAPPER(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
2260 384 YUV2RGBWRAPPER(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
2261 #endif
2262 316020 YUV2RGBWRAPPER(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
2263 844776 YUV2RGBWRAPPER(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
2264
2265 75282 YUV2RGBWRAPPER(yuv2, rgb_full, bgr4_byte_full, AV_PIX_FMT_BGR4_BYTE, 0)
2266 75282 YUV2RGBWRAPPER(yuv2, rgb_full, rgb4_byte_full, AV_PIX_FMT_RGB4_BYTE, 0)
2267 150564 YUV2RGBWRAPPER(yuv2, rgb_full, bgr8_full, AV_PIX_FMT_BGR8, 0)
2268 89682 YUV2RGBWRAPPER(yuv2, rgb_full, rgb8_full, AV_PIX_FMT_RGB8, 0)
2269
2270 134984 YUV2RGBWRAPPER(yuv2, rgb_full, x2rgb10_full, AV_PIX_FMT_X2RGB10LE, 0)
2271 134984 YUV2RGBWRAPPER(yuv2, rgb_full, x2bgr10_full, AV_PIX_FMT_X2BGR10LE, 0)
2272
2273 static void
2274 2514792 yuv2gbrp_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2275 const int16_t **lumSrc, int lumFilterSize,
2276 const int16_t *chrFilter, const int16_t **chrUSrc,
2277 const int16_t **chrVSrc, int chrFilterSize,
2278 const int16_t **alpSrc, uint8_t **dest,
2279 int dstW, int y)
2280 {
2281 2514792 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2282 int i;
2283
4/4
✓ Branch 0 taken 96106 times.
✓ Branch 1 taken 2418686 times.
✓ Branch 2 taken 1060 times.
✓ Branch 3 taken 95046 times.
2514792 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrc;
2284 2514792 uint16_t **dest16 = (uint16_t**)dest;
2285 2514792 int SH = 22 + 8 - desc->comp[0].depth;
2286 2514792 int A = 0; // init to silence warning
2287
2288
2/2
✓ Branch 0 taken 883703568 times.
✓ Branch 1 taken 2514792 times.
886218360 for (i = 0; i < dstW; i++) {
2289 int j;
2290 883703568 int Y = 1 << 9;
2291 883703568 int U = (1 << 9) - (128 << 19);
2292 883703568 int V = (1 << 9) - (128 << 19);
2293 int R, G, B;
2294
2295
2/2
✓ Branch 0 taken 888349168 times.
✓ Branch 1 taken 883703568 times.
1772052736 for (j = 0; j < lumFilterSize; j++)
2296 888349168 Y += lumSrc[j][i] * lumFilter[j];
2297
2298
2/2
✓ Branch 0 taken 1727785120 times.
✓ Branch 1 taken 883703568 times.
2611488688 for (j = 0; j < chrFilterSize; j++) {
2299 1727785120 U += chrUSrc[j][i] * chrFilter[j];
2300 1727785120 V += chrVSrc[j][i] * chrFilter[j];
2301 }
2302
2303 883703568 Y >>= 10;
2304 883703568 U >>= 10;
2305 883703568 V >>= 10;
2306
2307
2/2
✓ Branch 0 taken 204320 times.
✓ Branch 1 taken 883499248 times.
883703568 if (hasAlpha) {
2308 204320 A = 1 << 18;
2309
2310
2/2
✓ Branch 0 taken 2146320 times.
✓ Branch 1 taken 204320 times.
2350640 for (j = 0; j < lumFilterSize; j++)
2311 2146320 A += alpSrc[j][i] * lumFilter[j];
2312
2313
2/2
✓ Branch 0 taken 179935 times.
✓ Branch 1 taken 24385 times.
204320 if (A & 0xF8000000)
2314 179935 A = av_clip_uintp2(A, 27);
2315 }
2316
2317 883703568 Y -= c->yuv2rgb_y_offset;
2318 883703568 Y *= c->yuv2rgb_y_coeff;
2319 883703568 Y += 1 << (SH-1);
2320 883703568 R = Y + V * (unsigned)c->yuv2rgb_v2r_coeff;
2321 883703568 G = Y + V * (unsigned)c->yuv2rgb_v2g_coeff + U * (unsigned)c->yuv2rgb_u2g_coeff;
2322 883703568 B = Y + U * (unsigned)c->yuv2rgb_u2b_coeff;
2323
2324
2/2
✓ Branch 0 taken 274375920 times.
✓ Branch 1 taken 609327648 times.
883703568 if ((R | G | B) & 0xC0000000) {
2325 274375920 R = av_clip_uintp2(R, 30);
2326 274375920 G = av_clip_uintp2(G, 30);
2327 274375920 B = av_clip_uintp2(B, 30);
2328 }
2329
2330
2/2
✓ Branch 0 taken 606272720 times.
✓ Branch 1 taken 277430848 times.
883703568 if (SH != 22) {
2331 606272720 dest16[0][i] = G >> SH;
2332 606272720 dest16[1][i] = B >> SH;
2333 606272720 dest16[2][i] = R >> SH;
2334
2/2
✓ Branch 0 taken 171456 times.
✓ Branch 1 taken 606101264 times.
606272720 if (hasAlpha)
2335 171456 dest16[3][i] = A >> (SH - 3);
2336 } else {
2337 277430848 dest[0][i] = G >> 22;
2338 277430848 dest[1][i] = B >> 22;
2339 277430848 dest[2][i] = R >> 22;
2340
2/2
✓ Branch 0 taken 32864 times.
✓ Branch 1 taken 277397984 times.
277430848 if (hasAlpha)
2341 32864 dest[3][i] = A >> 19;
2342 }
2343 }
2344
4/4
✓ Branch 0 taken 1726476 times.
✓ Branch 1 taken 788316 times.
✓ Branch 3 taken 176236 times.
✓ Branch 4 taken 1550240 times.
2514792 if (SH != 22 && (!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2345
2/2
✓ Branch 0 taken 61853792 times.
✓ Branch 1 taken 176236 times.
62030028 for (i = 0; i < dstW; i++) {
2346 61853792 dest16[0][i] = av_bswap16(dest16[0][i]);
2347 61853792 dest16[1][i] = av_bswap16(dest16[1][i]);
2348 61853792 dest16[2][i] = av_bswap16(dest16[2][i]);
2349
2/2
✓ Branch 0 taken 85728 times.
✓ Branch 1 taken 61768064 times.
61853792 if (hasAlpha)
2350 85728 dest16[3][i] = av_bswap16(dest16[3][i]);
2351 }
2352 }
2353 2514792 }
2354
2355 static void
2356 332252 yuv2gbrp16_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2357 const int16_t **lumSrcx, int lumFilterSize,
2358 const int16_t *chrFilter, const int16_t **chrUSrcx,
2359 const int16_t **chrVSrcx, int chrFilterSize,
2360 const int16_t **alpSrcx, uint8_t **dest,
2361 int dstW, int y)
2362 {
2363 332252 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2364 int i;
2365
4/4
✓ Branch 0 taken 20110 times.
✓ Branch 1 taken 312142 times.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 19586 times.
332252 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrcx;
2366 332252 uint16_t **dest16 = (uint16_t**)dest;
2367 332252 const int32_t **lumSrc = (const int32_t**)lumSrcx;
2368 332252 const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
2369 332252 const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
2370 332252 const int32_t **alpSrc = (const int32_t**)alpSrcx;
2371
2372
2/2
✓ Branch 0 taken 116740160 times.
✓ Branch 1 taken 332252 times.
117072412 for (i = 0; i < dstW; i++) {
2373 int j;
2374 116740160 int Y = -0x40000000;
2375 116740160 int U = -(128 << 23);
2376 116740160 int V = -(128 << 23);
2377 int R, G, B, A;
2378
2379
2/2
✓ Branch 0 taken 117941760 times.
✓ Branch 1 taken 116740160 times.
234681920 for (j = 0; j < lumFilterSize; j++)
2380 117941760 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2381
2382
2/2
✓ Branch 0 taken 190932480 times.
✓ Branch 1 taken 116740160 times.
307672640 for (j = 0; j < chrFilterSize; j++) {
2383 190932480 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2384 190932480 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2385 }
2386
2387 116740160 Y >>= 14;
2388 116740160 Y += 0x10000;
2389 116740160 U >>= 14;
2390 116740160 V >>= 14;
2391
2392
2/2
✓ Branch 0 taken 78688 times.
✓ Branch 1 taken 116661472 times.
116740160 if (hasAlpha) {
2393 78688 A = -0x40000000;
2394
2395
2/2
✓ Branch 0 taken 679488 times.
✓ Branch 1 taken 78688 times.
758176 for (j = 0; j < lumFilterSize; j++)
2396 679488 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2397
2398 78688 A >>= 1;
2399 78688 A += 0x20002000;
2400 }
2401
2402 116740160 Y -= c->yuv2rgb_y_offset;
2403 116740160 Y *= c->yuv2rgb_y_coeff;
2404 116740160 Y += (1 << 13) - (1 << 29);
2405 116740160 R = V * c->yuv2rgb_v2r_coeff;
2406 116740160 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
2407 116740160 B = U * c->yuv2rgb_u2b_coeff;
2408
2409 116740160 dest16[2][i] = av_clip_uintp2(((Y + R) >> 14) + (1<<15), 16);
2410 116740160 dest16[0][i] = av_clip_uintp2(((Y + G) >> 14) + (1<<15), 16);
2411 116740160 dest16[1][i] = av_clip_uintp2(((Y + B) >> 14) + (1<<15), 16);
2412
2413
2/2
✓ Branch 0 taken 78688 times.
✓ Branch 1 taken 116661472 times.
116740160 if (hasAlpha)
2414 78688 dest16[3][i] = av_clip_uintp2(A, 30) >> 14;
2415 }
2416
2/2
✓ Branch 1 taken 109568 times.
✓ Branch 2 taken 222684 times.
332252 if ((!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2417
2/2
✓ Branch 0 taken 38411776 times.
✓ Branch 1 taken 109568 times.
38521344 for (i = 0; i < dstW; i++) {
2418 38411776 dest16[0][i] = av_bswap16(dest16[0][i]);
2419 38411776 dest16[1][i] = av_bswap16(dest16[1][i]);
2420 38411776 dest16[2][i] = av_bswap16(dest16[2][i]);
2421
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 38365952 times.
38411776 if (hasAlpha)
2422 45824 dest16[3][i] = av_bswap16(dest16[3][i]);
2423 }
2424 }
2425 332252 }
2426
2427 static void
2428 67579 yuv2gbrpf32_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2429 const int16_t **lumSrcx, int lumFilterSize,
2430 const int16_t *chrFilter, const int16_t **chrUSrcx,
2431 const int16_t **chrVSrcx, int chrFilterSize,
2432 const int16_t **alpSrcx, uint8_t **dest,
2433 int dstW, int y)
2434 {
2435 67579 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2436 int i;
2437
4/4
✓ Branch 0 taken 29881 times.
✓ Branch 1 taken 37698 times.
✓ Branch 2 taken 3385 times.
✓ Branch 3 taken 26496 times.
67579 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrcx;
2438 67579 uint32_t **dest32 = (uint32_t**)dest;
2439 67579 const int32_t **lumSrc = (const int32_t**)lumSrcx;
2440 67579 const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
2441 67579 const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
2442 67579 const int32_t **alpSrc = (const int32_t**)alpSrcx;
2443 static const float float_mult = 1.0f / 65535.0f;
2444
2445
2/2
✓ Branch 0 taken 24887478 times.
✓ Branch 1 taken 67579 times.
24955057 for (i = 0; i < dstW; i++) {
2446 int j;
2447 24887478 int Y = -0x40000000;
2448 24887478 int U = -(128 << 23);
2449 24887478 int V = -(128 << 23);
2450 int R, G, B, A;
2451
2452
2/2
✓ Branch 0 taken 26089078 times.
✓ Branch 1 taken 24887478 times.
50976556 for (j = 0; j < lumFilterSize; j++)
2453 26089078 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2454
2455
2/2
✓ Branch 0 taken 89955958 times.
✓ Branch 1 taken 24887478 times.
114843436 for (j = 0; j < chrFilterSize; j++) {
2456 89955958 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2457 89955958 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2458 }
2459
2460 24887478 Y >>= 14;
2461 24887478 Y += 0x10000;
2462 24887478 U >>= 14;
2463 24887478 V >>= 14;
2464
2465
2/2
✓ Branch 0 taken 1886539 times.
✓ Branch 1 taken 23000939 times.
24887478 if (hasAlpha) {
2466 1886539 A = -0x40000000;
2467
2468
2/2
✓ Branch 0 taken 2487339 times.
✓ Branch 1 taken 1886539 times.
4373878 for (j = 0; j < lumFilterSize; j++)
2469 2487339 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2470
2471 1886539 A >>= 1;
2472 1886539 A += 0x20002000;
2473 }
2474
2475 24887478 Y -= c->yuv2rgb_y_offset;
2476 24887478 Y *= c->yuv2rgb_y_coeff;
2477 24887478 Y += (1 << 13) - (1 << 29);
2478 24887478 R = V * c->yuv2rgb_v2r_coeff;
2479 24887478 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
2480 24887478 B = U * c->yuv2rgb_u2b_coeff;
2481
2482 24887478 R = av_clip_uintp2(((Y + R) >> 14) + (1<<15), 16);
2483 24887478 G = av_clip_uintp2(((Y + G) >> 14) + (1<<15), 16);
2484 24887478 B = av_clip_uintp2(((Y + B) >> 14) + (1<<15), 16);
2485
2486 24887478 dest32[0][i] = av_float2int(float_mult * (float)G);
2487 24887478 dest32[1][i] = av_float2int(float_mult * (float)B);
2488 24887478 dest32[2][i] = av_float2int(float_mult * (float)R);
2489
2/2
✓ Branch 0 taken 1886539 times.
✓ Branch 1 taken 23000939 times.
24887478 if (hasAlpha)
2490 1886539 dest32[3][i] = av_float2int(float_mult * (float)(av_clip_uintp2(A, 30) >> 14));
2491 }
2492
2/2
✓ Branch 1 taken 15608 times.
✓ Branch 2 taken 51971 times.
67579 if ((!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2493
2/2
✓ Branch 0 taken 5438656 times.
✓ Branch 1 taken 15608 times.
5454264 for (i = 0; i < dstW; i++) {
2494 5438656 dest32[0][i] = av_bswap32(dest32[0][i]);
2495 5438656 dest32[1][i] = av_bswap32(dest32[1][i]);
2496 5438656 dest32[2][i] = av_bswap32(dest32[2][i]);
2497
2/2
✓ Branch 0 taken 32864 times.
✓ Branch 1 taken 5405792 times.
5438656 if (hasAlpha)
2498 32864 dest32[3][i] = av_bswap32(dest32[3][i]);
2499 }
2500 }
2501 67579 }
2502
2503 static void
2504 yuv2ya8_1_c(SwsInternal *c, const int16_t *buf0,
2505 const int16_t *ubuf[2], const int16_t *vbuf[2],
2506 const int16_t *abuf0, uint8_t *dest, int dstW,
2507 int uvalpha, int y)
2508 {
2509 int hasAlpha = !!abuf0;
2510 int i;
2511
2512 for (i = 0; i < dstW; i++) {
2513 int Y = (buf0[i] + 64) >> 7;
2514 int A;
2515
2516 Y = av_clip_uint8(Y);
2517
2518 if (hasAlpha) {
2519 A = (abuf0[i] + 64) >> 7;
2520 if (A & 0x100)
2521 A = av_clip_uint8(A);
2522 }
2523
2524 dest[i * 2 ] = Y;
2525 dest[i * 2 + 1] = hasAlpha ? A : 255;
2526 }
2527 }
2528
2529 static void
2530 yuv2ya8_2_c(SwsInternal *c, const int16_t *buf[2],
2531 const int16_t *ubuf[2], const int16_t *vbuf[2],
2532 const int16_t *abuf[2], uint8_t *dest, int dstW,
2533 int yalpha, int uvalpha, int y)
2534 {
2535 int hasAlpha = abuf && abuf[0] && abuf[1];
2536 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2537 *abuf0 = hasAlpha ? abuf[0] : NULL,
2538 *abuf1 = hasAlpha ? abuf[1] : NULL;
2539 int yalpha1 = 4096 - yalpha;
2540 int i;
2541
2542 av_assert2(yalpha <= 4096U);
2543
2544 for (i = 0; i < dstW; i++) {
2545 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2546 int A;
2547
2548 Y = av_clip_uint8(Y);
2549
2550 if (hasAlpha) {
2551 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2552 A = av_clip_uint8(A);
2553 }
2554
2555 dest[i * 2 ] = Y;
2556 dest[i * 2 + 1] = hasAlpha ? A : 255;
2557 }
2558 }
2559
2560 static void
2561 6148 yuv2ya8_X_c(SwsInternal *c, const int16_t *lumFilter,
2562 const int16_t **lumSrc, int lumFilterSize,
2563 const int16_t *chrFilter, const int16_t **chrUSrc,
2564 const int16_t **chrVSrc, int chrFilterSize,
2565 const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
2566 {
2567 6148 int hasAlpha = !!alpSrc;
2568 int i;
2569
2570
2/2
✓ Branch 0 taken 2148896 times.
✓ Branch 1 taken 6148 times.
2155044 for (i = 0; i < dstW; i++) {
2571 int j;
2572 2148896 int Y = 1 << 18, A = 1 << 18;
2573
2574
2/2
✓ Branch 0 taken 2368896 times.
✓ Branch 1 taken 2148896 times.
4517792 for (j = 0; j < lumFilterSize; j++)
2575 2368896 Y += lumSrc[j][i] * lumFilter[j];
2576
2577 2148896 Y >>= 19;
2578
2/2
✓ Branch 0 taken 11918 times.
✓ Branch 1 taken 2136978 times.
2148896 if (Y & 0x100)
2579 11918 Y = av_clip_uint8(Y);
2580
2581
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 2128896 times.
2148896 if (hasAlpha) {
2582
2/2
✓ Branch 0 taken 240000 times.
✓ Branch 1 taken 20000 times.
260000 for (j = 0; j < lumFilterSize; j++)
2583 240000 A += alpSrc[j][i] * lumFilter[j];
2584
2585 20000 A >>= 19;
2586
2587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20000 times.
20000 if (A & 0x100)
2588 A = av_clip_uint8(A);
2589 }
2590
2591 2148896 dest[2 * i ] = Y;
2592
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 2128896 times.
2148896 dest[2 * i + 1] = hasAlpha ? A : 255;
2593 }
2594 6148 }
2595
2596 #define output_pixels(pos, val) \
2597 if (is_be) { \
2598 AV_WB16(pos, val); \
2599 } else { \
2600 AV_WL16(pos, val); \
2601 }
2602
2603 static av_always_inline void
2604 218128 yuv2ayuv64_X_c(SwsInternal *c, const int16_t *lumFilter,
2605 const int16_t **_lumSrc, int lumFilterSize,
2606 const int16_t *chrFilter, const int16_t **_chrUSrc,
2607 const int16_t **_chrVSrc, int chrFilterSize,
2608 const int16_t **_alpSrc, uint8_t *dest, int dstW, int y,
2609 int A_offset, int Y_offset, int U_offset, int V_offset, int is_be)
2610 {
2611 218128 const int32_t **lumSrc = (const int32_t **) _lumSrc,
2612 218128 **chrUSrc = (const int32_t **) _chrUSrc,
2613 218128 **chrVSrc = (const int32_t **) _chrVSrc,
2614 218128 **alpSrc = (const int32_t **) _alpSrc;
2615 218128 int hasAlpha = !!alpSrc;
2616 int i;
2617
2618
2/2
✓ Branch 0 taken 76720256 times.
✓ Branch 1 taken 218128 times.
76938384 for (i = 0; i < dstW; i++) {
2619 76720256 int Y = 1 << 14, U = 1 << 14;
2620 76720256 int V = 1 << 14, A = 1 << 14;
2621 int j;
2622
2623 76720256 Y -= 0x40000000;
2624 76720256 U -= 0x40000000;
2625 76720256 V -= 0x40000000;
2626 76720256 A -= 0x40000000;
2627
2628
2/2
✓ Branch 0 taken 77600256 times.
✓ Branch 1 taken 76720256 times.
154320512 for (j = 0; j < lumFilterSize; j++)
2629 77600256 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2630
2631
2/2
✓ Branch 0 taken 101930496 times.
✓ Branch 1 taken 76720256 times.
178650752 for (j = 0; j < chrFilterSize; j++)
2632 101930496 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2633
2634
2/2
✓ Branch 0 taken 101930496 times.
✓ Branch 1 taken 76720256 times.
178650752 for (j = 0; j < chrFilterSize; j++)
2635 101930496 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2636
2637
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 76680256 times.
76720256 if (hasAlpha)
2638
2/2
✓ Branch 0 taken 480000 times.
✓ Branch 1 taken 40000 times.
520000 for (j = 0; j < lumFilterSize; j++)
2639 480000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2640
2641 76720256 Y = 0x8000 + av_clip_int16(Y >> 15);
2642 76720256 U = 0x8000 + av_clip_int16(U >> 15);
2643 76720256 V = 0x8000 + av_clip_int16(V >> 15);
2644
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 76680256 times.
76720256 if (hasAlpha)
2645 40000 A = 0x8000 + av_clip_int16(A >> 15);
2646
2647
6/6
✓ Branch 0 taken 38360128 times.
✓ Branch 1 taken 38360128 times.
✓ Branch 2 taken 20000 times.
✓ Branch 3 taken 38340128 times.
✓ Branch 4 taken 20000 times.
✓ Branch 5 taken 38340128 times.
76720256 output_pixels(dest + 8 * i + A_offset, hasAlpha ? A : 65535);
2648
2/2
✓ Branch 0 taken 38360128 times.
✓ Branch 1 taken 38360128 times.
76720256 output_pixels(dest + 8 * i + Y_offset, Y);
2649
2/2
✓ Branch 0 taken 38360128 times.
✓ Branch 1 taken 38360128 times.
76720256 output_pixels(dest + 8 * i + U_offset, U);
2650
2/2
✓ Branch 0 taken 38360128 times.
✓ Branch 1 taken 38360128 times.
76720256 output_pixels(dest + 8 * i + V_offset, V);
2651 }
2652 218128 }
2653
2654 #define YUV2AYUV64(pixfmt, BE_LE, A, Y, U, V, is_be) \
2655 static void \
2656 yuv2 ## pixfmt ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
2657 const int16_t **lumSrc, int lumFilterSize, \
2658 const int16_t *chrFilter, const int16_t **chrUSrc, \
2659 const int16_t **chrVSrc, int chrFilterSize, \
2660 const int16_t **alpSrc, uint8_t *dest, int dstW, int y) \
2661 { \
2662 yuv2ayuv64_X_c(c, lumFilter, lumSrc, lumFilterSize, \
2663 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2664 alpSrc, dest, dstW, y, A, Y, U, V, is_be); \
2665 }
2666
2667 5860 YUV2AYUV64(ayuv64, le, 0, 2, 4, 6, 0)
2668 5860 YUV2AYUV64(ayuv64, be, 0, 2, 4, 6, 1)
2669
2670 103204 YUV2AYUV64(xv48, le, 6, 2, 0, 4, 0)
2671 103204 YUV2AYUV64(xv48, be, 6, 2, 0, 4, 1)
2672
2673 #undef output_pixels
2674
2675 static av_always_inline void
2676 221356 yuv2v30_X_c_template(SwsInternal *c, const int16_t *lumFilter,
2677 const int16_t **lumSrc, int lumFilterSize,
2678 const int16_t *chrFilter, const int16_t **chrUSrc,
2679 const int16_t **chrVSrc, int chrFilterSize,
2680 const int16_t **alpSrc, uint8_t *dest, int dstW, int y,
2681 int shift)
2682 {
2683 int i;
2684
2/2
✓ Branch 0 taken 77346312 times.
✓ Branch 1 taken 221356 times.
77567668 for (i = 0; i < dstW; i++) {
2685 77346312 int Y = 1 << 16, U = 1 << 16, V = 1 << 16, A = 0x3;
2686 int j;
2687
2688
2/2
✓ Branch 0 taken 77786312 times.
✓ Branch 1 taken 77346312 times.
155132624 for (j = 0; j < lumFilterSize; j++)
2689 77786312 Y += lumSrc[j][i] * lumFilter[j];
2690
2691
2/2
✓ Branch 0 taken 89951432 times.
✓ Branch 1 taken 77346312 times.
167297744 for (j = 0; j < chrFilterSize; j++) {
2692 89951432 U += chrUSrc[j][i] * chrFilter[j];
2693 89951432 V += chrVSrc[j][i] * chrFilter[j];
2694 }
2695
2696 77346312 Y = av_clip_uintp2(Y >> 17, 10);
2697 77346312 U = av_clip_uintp2(U >> 17, 10);
2698 77346312 V = av_clip_uintp2(V >> 17, 10);
2699
2700
2/2
✓ Branch 0 taken 46305256 times.
✓ Branch 1 taken 31041056 times.
77346312 AV_WL32(dest + 4 * i, U << (shift + 0) |
2701 Y << (shift + 10) |
2702 (unsigned)V << (shift + 20) |
2703 (unsigned)A << (shift ? 0 : 30 /* xv30le = 30, v30xle = 0 */));
2704 }
2705 221356 }
2706
2707 #define V30LE_WRAPPER(name, shift) \
2708 static void yuv2 ## name ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
2709 const int16_t **lumSrc, int lumFilterSize, \
2710 const int16_t *chrFilter, const int16_t **chrUSrc, \
2711 const int16_t **chrVSrc, int chrFilterSize, \
2712 const int16_t **alpSrc, uint8_t *dest, int dstW, \
2713 int y) \
2714 { \
2715 yuv2v30_X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
2716 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2717 alpSrc, dest, dstW, y, shift); \
2718 }
2719
2720 88228 V30LE_WRAPPER(xv30le, 0)
2721 133128 V30LE_WRAPPER(v30xle, 2)
2722
2723 #define output_pixels(pos, val, shift, bits, output_shift) \
2724 if (is_be) { \
2725 AV_WB16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \
2726 } else { \
2727 AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \
2728 }
2729
2730 static void
2731 176456 yuv2xv36_X_c(SwsInternal *c, const int16_t *lumFilter,
2732 const int16_t **lumSrc, int lumFilterSize,
2733 const int16_t *chrFilter, const int16_t **chrUSrc,
2734 const int16_t **chrVSrc, int chrFilterSize,
2735 const int16_t **alpSrc, uint8_t *dest, int dstW, int y, int is_be)
2736 {
2737 int i;
2738
2/2
✓ Branch 0 taken 62082112 times.
✓ Branch 1 taken 176456 times.
62258568 for (i = 0; i < dstW; i++) {
2739 62082112 int Y = 1 << 14, U = 1 << 14, V = 1 << 14, A = 65535;
2740 int j;
2741
2742
2/2
✓ Branch 0 taken 62522112 times.
✓ Branch 1 taken 62082112 times.
124604224 for (j = 0; j < lumFilterSize; j++)
2743 62522112 Y += lumSrc[j][i] * lumFilter[j];
2744
2745
2/2
✓ Branch 0 taken 74687232 times.
✓ Branch 1 taken 62082112 times.
136769344 for (j = 0; j < chrFilterSize; j++) {
2746 74687232 U += chrUSrc[j][i] * chrFilter[j];
2747 74687232 V += chrVSrc[j][i] * chrFilter[j];
2748 }
2749
2750
2/2
✓ Branch 0 taken 31041056 times.
✓ Branch 1 taken 31041056 times.
62082112 output_pixels(dest + 8 * i + 2, Y, 15, 12, 4)
2751
2/2
✓ Branch 0 taken 31041056 times.
✓ Branch 1 taken 31041056 times.
62082112 output_pixels(dest + 8 * i + 0, U, 15, 12, 4)
2752
2/2
✓ Branch 0 taken 31041056 times.
✓ Branch 1 taken 31041056 times.
62082112 output_pixels(dest + 8 * i + 4, V, 15, 12, 4)
2753
2/2
✓ Branch 0 taken 31041056 times.
✓ Branch 1 taken 31041056 times.
62082112 output_pixels(dest + 8 * i + 6, A, 0, 12, 4);
2754 }
2755 176456 }
2756
2757 #undef output_pixels
2758
2759 #define YUV2XV36(BE_LE, is_be) \
2760 static void \
2761 yuv2xv36 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
2762 const int16_t **lumSrc, int lumFilterSize, \
2763 const int16_t *chrFilter, const int16_t **chrUSrc, \
2764 const int16_t **chrVSrc, int chrFilterSize, \
2765 const int16_t **alpSrc, uint8_t *dest, int dstW, int y) \
2766 { \
2767 yuv2xv36_X_c(c, lumFilter, lumSrc, lumFilterSize, \
2768 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2769 alpSrc, dest, dstW, y, is_be); \
2770 }
2771
2772 88228 YUV2XV36(le, 0)
2773 88228 YUV2XV36(be, 1)
2774
2775 #define output_pixels(pos, A, Y, U, V) \
2776 if (target == AV_PIX_FMT_AYUV) { \
2777 dest[pos + 0] = A; \
2778 dest[pos + 1] = Y; \
2779 dest[pos + 2] = U; \
2780 dest[pos + 3] = V; \
2781 } else if (target == AV_PIX_FMT_UYVA) { \
2782 dest[pos + 0] = U; \
2783 dest[pos + 1] = Y; \
2784 dest[pos + 2] = V; \
2785 dest[pos + 3] = A; \
2786 } else { /* AV_PIX_FMT_VUYA || AV_PIX_FMT_VUYX */ \
2787 dest[pos + 0] = V; \
2788 dest[pos + 1] = U; \
2789 dest[pos + 2] = Y; \
2790 dest[pos + 3] = A; \
2791 }
2792
2793 static av_always_inline void
2794 127268 yuv2ayuv_1_c_template(SwsInternal *c, const int16_t *buf0,
2795 const int16_t *ubuf[2], const int16_t *vbuf[2],
2796 const int16_t *abuf0, uint8_t *dest, int dstW,
2797 int uvalpha, int y, enum AVPixelFormat target)
2798 {
2799 127268 int hasAlpha = !!abuf0;
2800 int i;
2801
2802
1/2
✓ Branch 0 taken 127268 times.
✗ Branch 1 not taken.
127268 if (uvalpha < 2048) {
2803
2/2
✓ Branch 0 taken 44257736 times.
✓ Branch 1 taken 127268 times.
44385004 for (i = 0; i < dstW; i++) {
2804 44257736 int Y = (buf0[i] + 64) >> 7;
2805 44257736 int U = (ubuf[0][i] + 64) >> 7;
2806 44257736 int V = (vbuf[0][i] + 64) >> 7;
2807 44257736 int A = 255;
2808
2809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (Y & 0x100)
2810 Y = av_clip_uint8(Y);
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (U & 0x100)
2812 U = av_clip_uint8(U);
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (V & 0x100)
2814 V = av_clip_uint8(V);
2815
2816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (hasAlpha) {
2817 A = (abuf0[i] + 64) >> 7;
2818 if (A & 0x100)
2819 A = av_clip_uint8(A);
2820 }
2821
2822
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
✓ Branch 2 taken 15264200 times.
✓ Branch 3 taken 28993536 times.
44257736 output_pixels(i * 4, A, Y, U, V)
2823 }
2824 } else {
2825 for (i = 0; i < dstW; i++) {
2826 int Y = (buf0[i] + 64) >> 7;
2827 int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8;
2828 int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8;
2829 int A = 255;
2830
2831 if (Y & 0x100)
2832 Y = av_clip_uint8(Y);
2833 if (U & 0x100)
2834 U = av_clip_uint8(U);
2835 if (V & 0x100)
2836 V = av_clip_uint8(V);
2837
2838 if (hasAlpha) {
2839 A = (abuf0[i] + 64) >> 7;
2840 if (A & 0x100)
2841 A = av_clip_uint8(A);
2842 }
2843
2844 output_pixels(i * 4, A, Y, U, V)
2845 }
2846 }
2847 127268 }
2848
2849 static av_always_inline void
2850 yuv2ayuv_2_c_template(SwsInternal *c, const int16_t *buf[2],
2851 const int16_t *ubuf[2], const int16_t *vbuf[2],
2852 const int16_t *abuf[2], uint8_t *dest, int dstW,
2853 int yalpha, int uvalpha, int y,
2854 enum AVPixelFormat target)
2855 {
2856 int hasAlpha = abuf && abuf[0] && abuf[1];
2857 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2858 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2859 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2860 *abuf0 = hasAlpha ? abuf[0] : NULL,
2861 *abuf1 = hasAlpha ? abuf[1] : NULL;
2862 int yalpha1 = 4096 - yalpha;
2863 int uvalpha1 = 4096 - uvalpha;
2864 int i;
2865
2866 av_assert2(yalpha <= 4096U);
2867 av_assert2(uvalpha <= 4096U);
2868
2869 for (i = 0; i < dstW; i++) {
2870 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2871 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
2872 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
2873 int A = 255;
2874
2875 if (Y & 0x100)
2876 Y = av_clip_uint8(Y);
2877 if (U & 0x100)
2878 U = av_clip_uint8(U);
2879 if (V & 0x100)
2880 V = av_clip_uint8(V);
2881
2882 if (hasAlpha) {
2883 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2884 A = av_clip_uint8(A);
2885 }
2886
2887 output_pixels(i * 4, A, Y, U, V)
2888 }
2889 }
2890
2891 static av_always_inline void
2892 25168 yuv2ayuv_X_c_template(SwsInternal *c, const int16_t *lumFilter,
2893 const int16_t **lumSrc, int lumFilterSize,
2894 const int16_t *chrFilter, const int16_t **chrUSrc,
2895 const int16_t **chrVSrc, int chrFilterSize,
2896 const int16_t **alpSrc, uint8_t *dest, int dstW,
2897 int y, enum AVPixelFormat target)
2898 {
2899 int i;
2900
2901
2/2
✓ Branch 0 taken 8798336 times.
✓ Branch 1 taken 25168 times.
8823504 for (i = 0; i < dstW; i++) {
2902 int j;
2903 8798336 int Y = 1 << 18, U = 1 << 18;
2904 8798336 int V = 1 << 18, A = 255;
2905
2906
2/2
✓ Branch 0 taken 9678336 times.
✓ Branch 1 taken 8798336 times.
18476672 for (j = 0; j < lumFilterSize; j++)
2907 9678336 Y += lumSrc[j][i] * lumFilter[j];
2908
2909
2/2
✓ Branch 0 taken 35833344 times.
✓ Branch 1 taken 8798336 times.
44631680 for (j = 0; j < chrFilterSize; j++)
2910 35833344 U += chrUSrc[j][i] * chrFilter[j];
2911
2912
2/2
✓ Branch 0 taken 35833344 times.
✓ Branch 1 taken 8798336 times.
44631680 for (j = 0; j < chrFilterSize; j++)
2913 35833344 V += chrVSrc[j][i] * chrFilter[j];
2914
2915 8798336 Y >>= 19;
2916 8798336 U >>= 19;
2917 8798336 V >>= 19;
2918
2919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8798336 times.
8798336 if (Y & 0x100)
2920 Y = av_clip_uint8(Y);
2921
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 8797972 times.
8798336 if (U & 0x100)
2922 364 U = av_clip_uint8(U);
2923
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8798328 times.
8798336 if (V & 0x100)
2924 8 V = av_clip_uint8(V);
2925
2926
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 8738336 times.
8798336 if (alpSrc) {
2927 60000 A = 1 << 18;
2928
2929
2/2
✓ Branch 0 taken 720000 times.
✓ Branch 1 taken 60000 times.
780000 for (j = 0; j < lumFilterSize; j++)
2930 720000 A += alpSrc[j][i] * lumFilter[j];
2931
2932 60000 A >>= 19;
2933
2934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60000 times.
60000 if (A & 0x100)
2935 A = av_clip_uint8(A);
2936 }
2937
2938
4/4
✓ Branch 0 taken 2148896 times.
✓ Branch 1 taken 6649440 times.
✓ Branch 2 taken 2148896 times.
✓ Branch 3 taken 4500544 times.
8798336 output_pixels(i * 4, A, Y, U, V)
2939 }
2940 25168 }
2941
2942 #undef output_pixels
2943
2944 #define AYUVPACKEDWRAPPER(name, fmt) \
2945 static void yuv2 ## name ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
2946 const int16_t **lumSrc, int lumFilterSize, \
2947 const int16_t *chrFilter, const int16_t **chrUSrc, \
2948 const int16_t **chrVSrc, int chrFilterSize, \
2949 const int16_t **alpSrc, uint8_t *dest, int dstW, \
2950 int y) \
2951 { \
2952 yuv2ayuv_X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
2953 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2954 alpSrc, dest, dstW, y, fmt); \
2955 } \
2956 \
2957 static void yuv2 ## name ## _2_c(SwsInternal *c, const int16_t *buf[2], \
2958 const int16_t *ubuf[2], const int16_t *vbuf[2], \
2959 const int16_t *abuf[2], uint8_t *dest, int dstW, \
2960 int yalpha, int uvalpha, int y) \
2961 { \
2962 yuv2ayuv_2_c_template(c, buf, ubuf, vbuf, abuf, \
2963 dest, dstW, yalpha, uvalpha, y, fmt); \
2964 } \
2965 \
2966 static void yuv2 ## name ## _1_c(SwsInternal *c, const int16_t *buf0, \
2967 const int16_t *ubuf[2], const int16_t *vbuf[2], \
2968 const int16_t *abuf0, uint8_t *dest, int dstW, \
2969 int uvalpha, int y) \
2970 { \
2971 yuv2ayuv_1_c_template(c, buf0, ubuf, vbuf, \
2972 abuf0, dest, dstW, uvalpha, \
2973 y, fmt); \
2974 }
2975
2976 190480 AYUVPACKEDWRAPPER(vuyX, AV_PIX_FMT_VUYX)
2977 12296 AYUVPACKEDWRAPPER(ayuv, AV_PIX_FMT_AYUV)
2978 102096 AYUVPACKEDWRAPPER(uyva, AV_PIX_FMT_UYVA)
2979
2980 #define output_pixel(pos, val, bits) \
2981 AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
2982
2983 #define yuv2y2xx_wrapper(bits) \
2984 static void \
2985 yuv2y2 ## bits ## le_X_c(SwsInternal *c, const int16_t *lumFilter, \
2986 const int16_t **lumSrc, int lumFilterSize, \
2987 const int16_t *chrFilter, \
2988 const int16_t **chrUSrc, \
2989 const int16_t **chrVSrc, int chrFilterSize, \
2990 const int16_t **alpSrc, \
2991 uint8_t *dest, int dstW, int y) \
2992 { \
2993 int i, j; \
2994 int shift = 11 + 16 - bits; \
2995 int output_shift = 16 - bits; \
2996 for (i = 0; i < ((dstW + 1) >> 1); i++) { \
2997 int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1); \
2998 int U = 1 << (shift - 1), V = 1 << (shift - 1); \
2999 \
3000 for (j = 0; j < lumFilterSize; j++) { \
3001 Y1 += lumSrc[j][i * 2] * lumFilter[j]; \
3002 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; \
3003 } \
3004 \
3005 for (j = 0; j < chrFilterSize; j++) { \
3006 U += chrUSrc[j][i] * chrFilter[j]; \
3007 V += chrVSrc[j][i] * chrFilter[j]; \
3008 } \
3009 \
3010 output_pixel(dest + 8 * i + 0, Y1, bits); \
3011 output_pixel(dest + 8 * i + 2, U, bits); \
3012 output_pixel(dest + 8 * i + 4, Y2, bits); \
3013 output_pixel(dest + 8 * i + 6, V, bits); \
3014 } \
3015 }
3016
3017
6/6
✓ Branch 0 taken 15478464 times.
✓ Branch 1 taken 15368464 times.
✓ Branch 2 taken 18063552 times.
✓ Branch 3 taken 15368464 times.
✓ Branch 4 taken 15368464 times.
✓ Branch 5 taken 87364 times.
48997844 yuv2y2xx_wrapper(10)
3018
6/6
✓ Branch 0 taken 15478464 times.
✓ Branch 1 taken 15368464 times.
✓ Branch 2 taken 18063552 times.
✓ Branch 3 taken 15368464 times.
✓ Branch 4 taken 15368464 times.
✓ Branch 5 taken 87364 times.
48997844 yuv2y2xx_wrapper(12)
3019
3020 static void
3021 102340 yuv2y216le_X_c(SwsInternal *c, const int16_t *lumFilter,
3022 const int16_t **_lumSrc, int lumFilterSize,
3023 const int16_t *chrFilter,
3024 const int16_t **_chrUSrc,
3025 const int16_t **_chrVSrc, int chrFilterSize,
3026 const int16_t **_alpSrc,
3027 uint8_t *dest, int dstW, int y)
3028 {
3029 102340 const int32_t **lumSrc = (const int32_t **)_lumSrc;
3030 102340 const int32_t **chrUSrc = (const int32_t **)_chrUSrc;
3031 102340 const int32_t **chrVSrc = (const int32_t **)_chrVSrc;
3032 102340 int shift = 15;
3033
3034
2/2
✓ Branch 0 taken 18004240 times.
✓ Branch 1 taken 102340 times.
18106580 for (int i = 0; i < ((dstW + 1) >> 1); i++) {
3035 18004240 int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1);
3036 18004240 int U = 1 << (shift - 1), V = 1 << (shift - 1);
3037
3038 /* See yuv2planeX_16_c_template for details. */
3039 18004240 Y1 -= 0x40000000;
3040 18004240 U -= 0x40000000;
3041 18004240 Y2 -= 0x40000000;
3042 18004240 V -= 0x40000000;
3043
3044
2/2
✓ Branch 0 taken 18114240 times.
✓ Branch 1 taken 18004240 times.
36118480 for (int j = 0; j < lumFilterSize; j++) {
3045 18114240 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
3046 18114240 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
3047 }
3048
3049
2/2
✓ Branch 0 taken 20699328 times.
✓ Branch 1 taken 18004240 times.
38703568 for (int j = 0; j < chrFilterSize; j++) {
3050 20699328 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
3051 20699328 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
3052 }
3053
3054 18004240 AV_WL16(dest + 8 * i + 0, 0x8000 + av_clip_int16(Y1 >> shift));
3055 18004240 AV_WL16(dest + 8 * i + 2, 0x8000 + av_clip_int16(U >> shift));
3056 18004240 AV_WL16(dest + 8 * i + 4, 0x8000 + av_clip_int16(Y2 >> shift));
3057 18004240 AV_WL16(dest + 8 * i + 6, 0x8000 + av_clip_int16(V >> shift));
3058 }
3059 102340 }
3060
3061 static void
3062 127268 yuv2vyu444_1_c(SwsInternal *c, const int16_t *buf0,
3063 const int16_t *ubuf[2], const int16_t *vbuf[2],
3064 const int16_t *abuf0, uint8_t *dest, int dstW,
3065 int uvalpha, int y)
3066 {
3067 int i;
3068
3069
1/2
✓ Branch 0 taken 127268 times.
✗ Branch 1 not taken.
127268 if (uvalpha < 2048) {
3070
2/2
✓ Branch 0 taken 44257736 times.
✓ Branch 1 taken 127268 times.
44385004 for (i = 0; i < dstW; i++) {
3071 44257736 int Y = (buf0[i] + 64) >> 7;
3072 44257736 int U = (ubuf[0][i] + 64) >> 7;
3073 44257736 int V = (vbuf[0][i] + 64) >> 7;
3074
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (Y & 0x100)
3076 Y = av_clip_uint8(Y);
3077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (U & 0x100)
3078 U = av_clip_uint8(U);
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44257736 times.
44257736 if (V & 0x100)
3080 V = av_clip_uint8(V);
3081
3082 44257736 dest[3 * i ] = V;
3083 44257736 dest[3 * i + 1] = Y;
3084 44257736 dest[3 * i + 2] = U;
3085 }
3086 } else {
3087 for (i = 0; i < dstW; i++) {
3088 int Y = (buf0[i] + 64) >> 7;
3089 int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8;
3090 int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8;
3091
3092 if (Y & 0x100)
3093 Y = av_clip_uint8(Y);
3094 if (U & 0x100)
3095 U = av_clip_uint8(U);
3096 if (V & 0x100)
3097 V = av_clip_uint8(V);
3098
3099 dest[3 * i ] = V;
3100 dest[3 * i + 1] = Y;
3101 dest[3 * i + 2] = U;
3102 }
3103 }
3104 127268 }
3105
3106 static void
3107 yuv2vyu444_2_c(SwsInternal *c, const int16_t *buf[2],
3108 const int16_t *ubuf[2], const int16_t *vbuf[2],
3109 const int16_t *abuf[2], uint8_t *dest, int dstW,
3110 int yalpha, int uvalpha, int y)
3111 {
3112 const int16_t *buf0 = buf[0], *buf1 = buf[1],
3113 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
3114 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
3115 int yalpha1 = 4096 - yalpha;
3116 int uvalpha1 = 4096 - uvalpha;
3117 int i;
3118
3119 av_assert2(yalpha <= 4096U);
3120 av_assert2(uvalpha <= 4096U);
3121
3122 for (i = 0; i < dstW; i++) {
3123 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
3124 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
3125 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
3126
3127 if (Y & 0x100)
3128 Y = av_clip_uint8(Y);
3129 if (U & 0x100)
3130 U = av_clip_uint8(U);
3131 if (V & 0x100)
3132 V = av_clip_uint8(V);
3133
3134 dest[3 * i ] = V;
3135 dest[3 * i + 1] = Y;
3136 dest[3 * i + 2] = U;
3137 }
3138 }
3139
3140 static void
3141 6724 yuv2vyu444_X_c(SwsInternal *c, const int16_t *lumFilter,
3142 const int16_t **lumSrc, int lumFilterSize,
3143 const int16_t *chrFilter, const int16_t **chrUSrc,
3144 const int16_t **chrVSrc, int chrFilterSize,
3145 const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
3146 {
3147 int i;
3148
3149
2/2
✓ Branch 0 taken 2351648 times.
✓ Branch 1 taken 6724 times.
2358372 for (i = 0; i < dstW; i++) {
3150 int j;
3151 2351648 int Y = 1 << 18, U = 1 << 18;
3152 2351648 int V = 1 << 18;
3153
3154
2/2
✓ Branch 0 taken 2571648 times.
✓ Branch 1 taken 2351648 times.
4923296 for (j = 0; j < lumFilterSize; j++)
3155 2571648 Y += lumSrc[j][i] * lumFilter[j];
3156
3157
2/2
✓ Branch 0 taken 9566592 times.
✓ Branch 1 taken 2351648 times.
11918240 for (j = 0; j < chrFilterSize; j++)
3158 9566592 U += chrUSrc[j][i] * chrFilter[j];
3159
3160
2/2
✓ Branch 0 taken 9566592 times.
✓ Branch 1 taken 2351648 times.
11918240 for (j = 0; j < chrFilterSize; j++)
3161 9566592 V += chrVSrc[j][i] * chrFilter[j];
3162
3163 2351648 Y >>= 19;
3164 2351648 U >>= 19;
3165 2351648 V >>= 19;
3166
3167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2351648 times.
2351648 if (Y & 0x100)
3168 Y = av_clip_uint8(Y);
3169
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2351551 times.
2351648 if (U & 0x100)
3170 97 U = av_clip_uint8(U);
3171
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2351646 times.
2351648 if (V & 0x100)
3172 2 V = av_clip_uint8(V);
3173
3174 2351648 dest[3 * i ] = V;
3175 2351648 dest[3 * i + 1] = Y;
3176 2351648 dest[3 * i + 2] = U;
3177 }
3178 6724 }
3179
3180 #undef output_pixel
3181
3182 214974 av_cold void ff_sws_init_output_funcs(SwsInternal *c,
3183 yuv2planar1_fn *yuv2plane1,
3184 yuv2planarX_fn *yuv2planeX,
3185 yuv2interleavedX_fn *yuv2nv12cX,
3186 yuv2packed1_fn *yuv2packed1,
3187 yuv2packed2_fn *yuv2packed2,
3188 yuv2packedX_fn *yuv2packedX,
3189 yuv2anyX_fn *yuv2anyX)
3190 {
3191 214974 enum AVPixelFormat dstFormat = c->opts.dst_format;
3192 214974 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
3193
3194
4/4
✓ Branch 1 taken 31458 times.
✓ Branch 2 taken 183516 times.
✓ Branch 4 taken 18458 times.
✓ Branch 5 taken 13000 times.
214974 if (isSemiPlanarYUV(dstFormat) && isDataInHighBits(dstFormat)) {
3195
2/2
✓ Branch 0 taken 9203 times.
✓ Branch 1 taken 9255 times.
18458 if (desc->comp[0].depth == 10) {
3196
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7184 times.
9203 *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c;
3197
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7184 times.
9203 *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c;
3198
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7184 times.
9203 *yuv2nv12cX = isBE(dstFormat) ? yuv2p010cX_BE_c : yuv2p010cX_LE_c;
3199
1/2
✓ Branch 0 taken 9255 times.
✗ Branch 1 not taken.
9255 } else if (desc->comp[0].depth == 12) {
3200
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7236 times.
9255 *yuv2plane1 = isBE(dstFormat) ? yuv2p012l1_BE_c : yuv2p012l1_LE_c;
3201
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7236 times.
9255 *yuv2planeX = isBE(dstFormat) ? yuv2p012lX_BE_c : yuv2p012lX_LE_c;
3202
2/2
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 7236 times.
9255 *yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c;
3203 } else
3204 av_assert0(0);
3205
4/4
✓ Branch 1 taken 13000 times.
✓ Branch 2 taken 183516 times.
✓ Branch 4 taken 107 times.
✓ Branch 5 taken 12893 times.
196516 } else if (isSemiPlanarYUV(dstFormat) && isNBPS(dstFormat)) {
3206
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if (desc->comp[0].depth == 10) {
3207
2/2
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 55 times.
107 *yuv2plane1 = isBE(dstFormat) ? yuv2nv20l1_BE_c : yuv2nv20l1_LE_c;
3208
2/2
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 55 times.
107 *yuv2planeX = isBE(dstFormat) ? yuv2nv20lX_BE_c : yuv2nv20lX_LE_c;
3209
2/2
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 55 times.
107 *yuv2nv12cX = isBE(dstFormat) ? yuv2nv20cX_BE_c : yuv2nv20cX_LE_c;
3210 } else
3211 av_assert0(0);
3212
2/2
✓ Branch 1 taken 32465 times.
✓ Branch 2 taken 163944 times.
196409 } else if (is16BPS(dstFormat)) {
3213
2/2
✓ Branch 1 taken 8799 times.
✓ Branch 2 taken 23666 times.
32465 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
3214
2/2
✓ Branch 1 taken 8799 times.
✓ Branch 2 taken 23666 times.
32465 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
3215
2/2
✓ Branch 1 taken 5731 times.
✓ Branch 2 taken 26734 times.
32465 if (isSemiPlanarYUV(dstFormat)) {
3216
2/2
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 3402 times.
5731 *yuv2nv12cX = isBE(dstFormat) ? yuv2nv12cX_16BE_c : yuv2nv12cX_16LE_c;
3217 }
3218
2/2
✓ Branch 1 taken 56470 times.
✓ Branch 2 taken 107474 times.
163944 } else if (isNBPS(dstFormat)) {
3219
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 55068 times.
56470 if (desc->comp[0].depth == 9) {
3220
2/2
✓ Branch 1 taken 654 times.
✓ Branch 2 taken 748 times.
1402 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
3221
2/2
✓ Branch 1 taken 654 times.
✓ Branch 2 taken 748 times.
1402 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
3222
2/2
✓ Branch 0 taken 30750 times.
✓ Branch 1 taken 24318 times.
55068 } else if (desc->comp[0].depth == 10) {
3223
2/2
✓ Branch 1 taken 4855 times.
✓ Branch 2 taken 25895 times.
30750 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
3224
2/2
✓ Branch 1 taken 4855 times.
✓ Branch 2 taken 25895 times.
30750 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
3225
2/2
✓ Branch 0 taken 23047 times.
✓ Branch 1 taken 1271 times.
24318 } else if (desc->comp[0].depth == 12) {
3226
2/2
✓ Branch 1 taken 5589 times.
✓ Branch 2 taken 17458 times.
23047 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
3227
2/2
✓ Branch 1 taken 5589 times.
✓ Branch 2 taken 17458 times.
23047 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
3228
1/2
✓ Branch 0 taken 1271 times.
✗ Branch 1 not taken.
1271 } else if (desc->comp[0].depth == 14) {
3229
2/2
✓ Branch 1 taken 593 times.
✓ Branch 2 taken 678 times.
1271 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
3230
2/2
✓ Branch 1 taken 593 times.
✓ Branch 2 taken 678 times.
1271 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
3231 } else
3232 av_assert0(0);
3233
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 107392 times.
107474 } else if (dstFormat == AV_PIX_FMT_GRAYF32BE) {
3234 82 *yuv2planeX = yuv2planeX_floatBE_c;
3235 82 *yuv2plane1 = yuv2plane1_floatBE_c;
3236
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 107180 times.
107392 } else if (dstFormat == AV_PIX_FMT_GRAYF32LE) {
3237 212 *yuv2planeX = yuv2planeX_floatLE_c;
3238 212 *yuv2plane1 = yuv2plane1_floatLE_c;
3239 } else {
3240 107180 *yuv2plane1 = yuv2plane1_8_c;
3241 107180 *yuv2planeX = yuv2planeX_8_c;
3242
2/2
✓ Branch 1 taken 7162 times.
✓ Branch 2 taken 100018 times.
107180 if (isSemiPlanarYUV(dstFormat))
3243 7162 *yuv2nv12cX = yuv2nv12cX_c;
3244 }
3245
3246
2/2
✓ Branch 0 taken 170263 times.
✓ Branch 1 taken 44711 times.
214974 if(c->opts.flags & SWS_FULL_CHR_H_INT) {
3247
23/24
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1640 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3692 times.
✓ Branch 9 taken 1378 times.
✓ Branch 10 taken 3357 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 350 times.
✓ Branch 15 taken 350 times.
✓ Branch 16 taken 700 times.
✓ Branch 17 taken 401 times.
✓ Branch 18 taken 561 times.
✓ Branch 19 taken 561 times.
✓ Branch 20 taken 25297 times.
✓ Branch 21 taken 4050 times.
✓ Branch 22 taken 2305 times.
✗ Branch 23 not taken.
44711 switch (dstFormat) {
3248 12 case AV_PIX_FMT_RGBA:
3249 #if CONFIG_SMALL
3250 *yuv2packedX = yuv2rgba32_full_X_c;
3251 *yuv2packed2 = yuv2rgba32_full_2_c;
3252 *yuv2packed1 = yuv2rgba32_full_1_c;
3253 #else
3254 #if CONFIG_SWSCALE_ALPHA
3255
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (c->needAlpha) {
3256 6 *yuv2packedX = yuv2rgba32_full_X_c;
3257 6 *yuv2packed2 = yuv2rgba32_full_2_c;
3258 6 *yuv2packed1 = yuv2rgba32_full_1_c;
3259 } else
3260 #endif /* CONFIG_SWSCALE_ALPHA */
3261 {
3262 6 *yuv2packedX = yuv2rgbx32_full_X_c;
3263 6 *yuv2packed2 = yuv2rgbx32_full_2_c;
3264 6 *yuv2packed1 = yuv2rgbx32_full_1_c;
3265 }
3266 #endif /* !CONFIG_SMALL */
3267 12 break;
3268 12 case AV_PIX_FMT_ARGB:
3269 #if CONFIG_SMALL
3270 *yuv2packedX = yuv2argb32_full_X_c;
3271 *yuv2packed2 = yuv2argb32_full_2_c;
3272 *yuv2packed1 = yuv2argb32_full_1_c;
3273 #else
3274 #if CONFIG_SWSCALE_ALPHA
3275
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (c->needAlpha) {
3276 6 *yuv2packedX = yuv2argb32_full_X_c;
3277 6 *yuv2packed2 = yuv2argb32_full_2_c;
3278 6 *yuv2packed1 = yuv2argb32_full_1_c;
3279 } else
3280 #endif /* CONFIG_SWSCALE_ALPHA */
3281 {
3282 6 *yuv2packedX = yuv2xrgb32_full_X_c;
3283 6 *yuv2packed2 = yuv2xrgb32_full_2_c;
3284 6 *yuv2packed1 = yuv2xrgb32_full_1_c;
3285 }
3286 #endif /* !CONFIG_SMALL */
3287 12 break;
3288 1640 case AV_PIX_FMT_BGRA:
3289 #if CONFIG_SMALL
3290 *yuv2packedX = yuv2bgra32_full_X_c;
3291 *yuv2packed2 = yuv2bgra32_full_2_c;
3292 *yuv2packed1 = yuv2bgra32_full_1_c;
3293 #else
3294 #if CONFIG_SWSCALE_ALPHA
3295
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1538 times.
1640 if (c->needAlpha) {
3296 102 *yuv2packedX = yuv2bgra32_full_X_c;
3297 102 *yuv2packed2 = yuv2bgra32_full_2_c;
3298 102 *yuv2packed1 = yuv2bgra32_full_1_c;
3299 } else
3300 #endif /* CONFIG_SWSCALE_ALPHA */
3301 {
3302 1538 *yuv2packedX = yuv2bgrx32_full_X_c;
3303 1538 *yuv2packed2 = yuv2bgrx32_full_2_c;
3304 1538 *yuv2packed1 = yuv2bgrx32_full_1_c;
3305 }
3306 #endif /* !CONFIG_SMALL */
3307 1640 break;
3308 12 case AV_PIX_FMT_ABGR:
3309 #if CONFIG_SMALL
3310 *yuv2packedX = yuv2abgr32_full_X_c;
3311 *yuv2packed2 = yuv2abgr32_full_2_c;
3312 *yuv2packed1 = yuv2abgr32_full_1_c;
3313 #else
3314 #if CONFIG_SWSCALE_ALPHA
3315
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (c->needAlpha) {
3316 6 *yuv2packedX = yuv2abgr32_full_X_c;
3317 6 *yuv2packed2 = yuv2abgr32_full_2_c;
3318 6 *yuv2packed1 = yuv2abgr32_full_1_c;
3319 } else
3320 #endif /* CONFIG_SWSCALE_ALPHA */
3321 {
3322 6 *yuv2packedX = yuv2xbgr32_full_X_c;
3323 6 *yuv2packed2 = yuv2xbgr32_full_2_c;
3324 6 *yuv2packed1 = yuv2xbgr32_full_1_c;
3325 }
3326 #endif /* !CONFIG_SMALL */
3327 12 break;
3328 6 case AV_PIX_FMT_RGBA64LE:
3329 #if CONFIG_SWSCALE_ALPHA
3330
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (c->needAlpha) {
3331 3 *yuv2packedX = yuv2rgba64le_full_X_c;
3332 3 *yuv2packed2 = yuv2rgba64le_full_2_c;
3333 3 *yuv2packed1 = yuv2rgba64le_full_1_c;
3334 } else
3335 #endif /* CONFIG_SWSCALE_ALPHA */
3336 {
3337 3 *yuv2packedX = yuv2rgbx64le_full_X_c;
3338 3 *yuv2packed2 = yuv2rgbx64le_full_2_c;
3339 3 *yuv2packed1 = yuv2rgbx64le_full_1_c;
3340 }
3341 6 break;
3342 3 case AV_PIX_FMT_RGBA64BE:
3343 #if CONFIG_SWSCALE_ALPHA
3344
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (c->needAlpha) {
3345 3 *yuv2packedX = yuv2rgba64be_full_X_c;
3346 3 *yuv2packed2 = yuv2rgba64be_full_2_c;
3347 3 *yuv2packed1 = yuv2rgba64be_full_1_c;
3348 } else
3349 #endif /* CONFIG_SWSCALE_ALPHA */
3350 {
3351 *yuv2packedX = yuv2rgbx64be_full_X_c;
3352 *yuv2packed2 = yuv2rgbx64be_full_2_c;
3353 *yuv2packed1 = yuv2rgbx64be_full_1_c;
3354 }
3355 3 break;
3356 6 case AV_PIX_FMT_BGRA64LE:
3357 #if CONFIG_SWSCALE_ALPHA
3358
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (c->needAlpha) {
3359 3 *yuv2packedX = yuv2bgra64le_full_X_c;
3360 3 *yuv2packed2 = yuv2bgra64le_full_2_c;
3361 3 *yuv2packed1 = yuv2bgra64le_full_1_c;
3362 } else
3363 #endif /* CONFIG_SWSCALE_ALPHA */
3364 {
3365 3 *yuv2packedX = yuv2bgrx64le_full_X_c;
3366 3 *yuv2packed2 = yuv2bgrx64le_full_2_c;
3367 3 *yuv2packed1 = yuv2bgrx64le_full_1_c;
3368 }
3369 6 break;
3370 3 case AV_PIX_FMT_BGRA64BE:
3371 #if CONFIG_SWSCALE_ALPHA
3372
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (c->needAlpha) {
3373 3 *yuv2packedX = yuv2bgra64be_full_X_c;
3374 3 *yuv2packed2 = yuv2bgra64be_full_2_c;
3375 3 *yuv2packed1 = yuv2bgra64be_full_1_c;
3376 } else
3377 #endif /* CONFIG_SWSCALE_ALPHA */
3378 {
3379 *yuv2packedX = yuv2bgrx64be_full_X_c;
3380 *yuv2packed2 = yuv2bgrx64be_full_2_c;
3381 *yuv2packed1 = yuv2bgrx64be_full_1_c;
3382 }
3383 3 break;
3384
3385 3692 case AV_PIX_FMT_RGB24:
3386 3692 *yuv2packedX = yuv2rgb24_full_X_c;
3387 3692 *yuv2packed2 = yuv2rgb24_full_2_c;
3388 3692 *yuv2packed1 = yuv2rgb24_full_1_c;
3389 3692 break;
3390 1378 case AV_PIX_FMT_BGR24:
3391 1378 *yuv2packedX = yuv2bgr24_full_X_c;
3392 1378 *yuv2packed2 = yuv2bgr24_full_2_c;
3393 1378 *yuv2packed1 = yuv2bgr24_full_1_c;
3394 1378 break;
3395 3357 case AV_PIX_FMT_RGB48LE:
3396 3357 *yuv2packedX = yuv2rgb48le_full_X_c;
3397 3357 *yuv2packed2 = yuv2rgb48le_full_2_c;
3398 3357 *yuv2packed1 = yuv2rgb48le_full_1_c;
3399 3357 break;
3400 6 case AV_PIX_FMT_BGR48LE:
3401 6 *yuv2packedX = yuv2bgr48le_full_X_c;
3402 6 *yuv2packed2 = yuv2bgr48le_full_2_c;
3403 6 *yuv2packed1 = yuv2bgr48le_full_1_c;
3404 6 break;
3405 6 case AV_PIX_FMT_RGB48BE:
3406 6 *yuv2packedX = yuv2rgb48be_full_X_c;
3407 6 *yuv2packed2 = yuv2rgb48be_full_2_c;
3408 6 *yuv2packed1 = yuv2rgb48be_full_1_c;
3409 6 break;
3410 3 case AV_PIX_FMT_BGR48BE:
3411 3 *yuv2packedX = yuv2bgr48be_full_X_c;
3412 3 *yuv2packed2 = yuv2bgr48be_full_2_c;
3413 3 *yuv2packed1 = yuv2bgr48be_full_1_c;
3414 3 break;
3415 350 case AV_PIX_FMT_BGR4_BYTE:
3416 350 *yuv2packedX = yuv2bgr4_byte_full_X_c;
3417 350 *yuv2packed2 = yuv2bgr4_byte_full_2_c;
3418 350 *yuv2packed1 = yuv2bgr4_byte_full_1_c;
3419 350 break;
3420 350 case AV_PIX_FMT_RGB4_BYTE:
3421 350 *yuv2packedX = yuv2rgb4_byte_full_X_c;
3422 350 *yuv2packed2 = yuv2rgb4_byte_full_2_c;
3423 350 *yuv2packed1 = yuv2rgb4_byte_full_1_c;
3424 350 break;
3425 700 case AV_PIX_FMT_BGR8:
3426 700 *yuv2packedX = yuv2bgr8_full_X_c;
3427 700 *yuv2packed2 = yuv2bgr8_full_2_c;
3428 700 *yuv2packed1 = yuv2bgr8_full_1_c;
3429 700 break;
3430 401 case AV_PIX_FMT_RGB8:
3431 401 *yuv2packedX = yuv2rgb8_full_X_c;
3432 401 *yuv2packed2 = yuv2rgb8_full_2_c;
3433 401 *yuv2packed1 = yuv2rgb8_full_1_c;
3434 401 break;
3435 561 case AV_PIX_FMT_X2RGB10LE:
3436 561 *yuv2packedX = yuv2x2rgb10_full_X_c;
3437 561 *yuv2packed2 = yuv2x2rgb10_full_2_c;
3438 561 *yuv2packed1 = yuv2x2rgb10_full_1_c;
3439 561 break;
3440 561 case AV_PIX_FMT_X2BGR10LE:
3441 561 *yuv2packedX = yuv2x2bgr10_full_X_c;
3442 561 *yuv2packed2 = yuv2x2bgr10_full_2_c;
3443 561 *yuv2packed1 = yuv2x2bgr10_full_1_c;
3444 561 break;
3445 25297 case AV_PIX_FMT_GBRP:
3446 case AV_PIX_FMT_GBRP9BE:
3447 case AV_PIX_FMT_GBRP9LE:
3448 case AV_PIX_FMT_GBRP10BE:
3449 case AV_PIX_FMT_GBRP10LE:
3450 case AV_PIX_FMT_GBRP12BE:
3451 case AV_PIX_FMT_GBRP12LE:
3452 case AV_PIX_FMT_GBRP14BE:
3453 case AV_PIX_FMT_GBRP14LE:
3454 case AV_PIX_FMT_GBRAP:
3455 case AV_PIX_FMT_GBRAP10BE:
3456 case AV_PIX_FMT_GBRAP10LE:
3457 case AV_PIX_FMT_GBRAP12BE:
3458 case AV_PIX_FMT_GBRAP12LE:
3459 case AV_PIX_FMT_GBRAP14BE:
3460 case AV_PIX_FMT_GBRAP14LE:
3461 25297 *yuv2anyX = yuv2gbrp_full_X_c;
3462 25297 break;
3463 4050 case AV_PIX_FMT_GBRP16BE:
3464 case AV_PIX_FMT_GBRP16LE:
3465 case AV_PIX_FMT_GBRAP16BE:
3466 case AV_PIX_FMT_GBRAP16LE:
3467 4050 *yuv2anyX = yuv2gbrp16_full_X_c;
3468 4050 break;
3469 2305 case AV_PIX_FMT_GBRPF32BE:
3470 case AV_PIX_FMT_GBRPF32LE:
3471 case AV_PIX_FMT_GBRAPF32BE:
3472 case AV_PIX_FMT_GBRAPF32LE:
3473 2305 *yuv2anyX = yuv2gbrpf32_full_X_c;
3474 2305 break;
3475 }
3476
3/4
✓ Branch 0 taken 31652 times.
✓ Branch 1 taken 13059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31652 times.
44711 if (!*yuv2packedX && !*yuv2anyX)
3477 goto YUV_PACKED;
3478 } else {
3479 170263 YUV_PACKED:
3480
21/21
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 3491 times.
✓ Branch 5 taken 197 times.
✓ Branch 6 taken 94 times.
✓ Branch 7 taken 91 times.
✓ Branch 8 taken 1364 times.
✓ Branch 9 taken 444 times.
✓ Branch 10 taken 6252 times.
✓ Branch 11 taken 1416 times.
✓ Branch 12 taken 1506 times.
✓ Branch 13 taken 2617 times.
✓ Branch 14 taken 376 times.
✓ Branch 15 taken 1091 times.
✓ Branch 16 taken 78 times.
✓ Branch 17 taken 209 times.
✓ Branch 18 taken 52 times.
✓ Branch 19 taken 52 times.
✓ Branch 20 taken 150523 times.
170263 switch (dstFormat) {
3481 137 case AV_PIX_FMT_RGBA64LE:
3482 #if CONFIG_SWSCALE_ALPHA
3483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if (c->needAlpha) {
3484 *yuv2packed1 = yuv2rgba64le_1_c;
3485 *yuv2packed2 = yuv2rgba64le_2_c;
3486 *yuv2packedX = yuv2rgba64le_X_c;
3487 } else
3488 #endif /* CONFIG_SWSCALE_ALPHA */
3489 {
3490 137 *yuv2packed1 = yuv2rgbx64le_1_c;
3491 137 *yuv2packed2 = yuv2rgbx64le_2_c;
3492 137 *yuv2packedX = yuv2rgbx64le_X_c;
3493 }
3494 137 break;
3495 91 case AV_PIX_FMT_RGBA64BE:
3496 #if CONFIG_SWSCALE_ALPHA
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if (c->needAlpha) {
3498 *yuv2packed1 = yuv2rgba64be_1_c;
3499 *yuv2packed2 = yuv2rgba64be_2_c;
3500 *yuv2packedX = yuv2rgba64be_X_c;
3501 } else
3502 #endif /* CONFIG_SWSCALE_ALPHA */
3503 {
3504 91 *yuv2packed1 = yuv2rgbx64be_1_c;
3505 91 *yuv2packed2 = yuv2rgbx64be_2_c;
3506 91 *yuv2packedX = yuv2rgbx64be_X_c;
3507 }
3508 91 break;
3509 91 case AV_PIX_FMT_BGRA64LE:
3510 #if CONFIG_SWSCALE_ALPHA
3511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if (c->needAlpha) {
3512 *yuv2packed1 = yuv2bgra64le_1_c;
3513 *yuv2packed2 = yuv2bgra64le_2_c;
3514 *yuv2packedX = yuv2bgra64le_X_c;
3515 } else
3516 #endif /* CONFIG_SWSCALE_ALPHA */
3517 {
3518 91 *yuv2packed1 = yuv2bgrx64le_1_c;
3519 91 *yuv2packed2 = yuv2bgrx64le_2_c;
3520 91 *yuv2packedX = yuv2bgrx64le_X_c;
3521 }
3522 91 break;
3523 91 case AV_PIX_FMT_BGRA64BE:
3524 #if CONFIG_SWSCALE_ALPHA
3525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if (c->needAlpha) {
3526 *yuv2packed1 = yuv2bgra64be_1_c;
3527 *yuv2packed2 = yuv2bgra64be_2_c;
3528 *yuv2packedX = yuv2bgra64be_X_c;
3529 } else
3530 #endif /* CONFIG_SWSCALE_ALPHA */
3531 {
3532 91 *yuv2packed1 = yuv2bgrx64be_1_c;
3533 91 *yuv2packed2 = yuv2bgrx64be_2_c;
3534 91 *yuv2packedX = yuv2bgrx64be_X_c;
3535 }
3536 91 break;
3537 3491 case AV_PIX_FMT_RGB48LE:
3538 3491 *yuv2packed1 = yuv2rgb48le_1_c;
3539 3491 *yuv2packed2 = yuv2rgb48le_2_c;
3540 3491 *yuv2packedX = yuv2rgb48le_X_c;
3541 3491 break;
3542 197 case AV_PIX_FMT_RGB48BE:
3543 197 *yuv2packed1 = yuv2rgb48be_1_c;
3544 197 *yuv2packed2 = yuv2rgb48be_2_c;
3545 197 *yuv2packedX = yuv2rgb48be_X_c;
3546 197 break;
3547 94 case AV_PIX_FMT_BGR48LE:
3548 94 *yuv2packed1 = yuv2bgr48le_1_c;
3549 94 *yuv2packed2 = yuv2bgr48le_2_c;
3550 94 *yuv2packedX = yuv2bgr48le_X_c;
3551 94 break;
3552 91 case AV_PIX_FMT_BGR48BE:
3553 91 *yuv2packed1 = yuv2bgr48be_1_c;
3554 91 *yuv2packed2 = yuv2bgr48be_2_c;
3555 91 *yuv2packedX = yuv2bgr48be_X_c;
3556 91 break;
3557 1364 case AV_PIX_FMT_RGB32:
3558 case AV_PIX_FMT_BGR32:
3559 #if CONFIG_SMALL
3560 *yuv2packed1 = yuv2rgb32_1_c;
3561 *yuv2packed2 = yuv2rgb32_2_c;
3562 *yuv2packedX = yuv2rgb32_X_c;
3563 #else
3564 #if CONFIG_SWSCALE_ALPHA
3565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1364 times.
1364 if (c->needAlpha) {
3566 *yuv2packed1 = yuv2rgba32_1_c;
3567 *yuv2packed2 = yuv2rgba32_2_c;
3568 *yuv2packedX = yuv2rgba32_X_c;
3569 } else
3570 #endif /* CONFIG_SWSCALE_ALPHA */
3571 {
3572 1364 *yuv2packed1 = yuv2rgbx32_1_c;
3573 1364 *yuv2packed2 = yuv2rgbx32_2_c;
3574 1364 *yuv2packedX = yuv2rgbx32_X_c;
3575 }
3576 #endif /* !CONFIG_SMALL */
3577 1364 break;
3578 444 case AV_PIX_FMT_RGB32_1:
3579 case AV_PIX_FMT_BGR32_1:
3580 #if CONFIG_SMALL
3581 *yuv2packed1 = yuv2rgb32_1_1_c;
3582 *yuv2packed2 = yuv2rgb32_1_2_c;
3583 *yuv2packedX = yuv2rgb32_1_X_c;
3584 #else
3585 #if CONFIG_SWSCALE_ALPHA
3586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444 times.
444 if (c->needAlpha) {
3587 *yuv2packed1 = yuv2rgba32_1_1_c;
3588 *yuv2packed2 = yuv2rgba32_1_2_c;
3589 *yuv2packedX = yuv2rgba32_1_X_c;
3590 } else
3591 #endif /* CONFIG_SWSCALE_ALPHA */
3592 {
3593 444 *yuv2packed1 = yuv2rgbx32_1_1_c;
3594 444 *yuv2packed2 = yuv2rgbx32_1_2_c;
3595 444 *yuv2packedX = yuv2rgbx32_1_X_c;
3596 }
3597 #endif /* !CONFIG_SMALL */
3598 444 break;
3599 6252 case AV_PIX_FMT_RGB24:
3600 6252 *yuv2packed1 = yuv2rgb24_1_c;
3601 6252 *yuv2packed2 = yuv2rgb24_2_c;
3602 6252 *yuv2packedX = yuv2rgb24_X_c;
3603 6252 break;
3604 1416 case AV_PIX_FMT_BGR24:
3605 1416 *yuv2packed1 = yuv2bgr24_1_c;
3606 1416 *yuv2packed2 = yuv2bgr24_2_c;
3607 1416 *yuv2packedX = yuv2bgr24_X_c;
3608 1416 break;
3609 1506 case AV_PIX_FMT_RGB565LE:
3610 case AV_PIX_FMT_RGB565BE:
3611 case AV_PIX_FMT_BGR565LE:
3612 case AV_PIX_FMT_BGR565BE:
3613 1506 *yuv2packed1 = yuv2rgb16_1_c;
3614 1506 *yuv2packed2 = yuv2rgb16_2_c;
3615 1506 *yuv2packedX = yuv2rgb16_X_c;
3616 1506 break;
3617 2617 case AV_PIX_FMT_RGB555LE:
3618 case AV_PIX_FMT_RGB555BE:
3619 case AV_PIX_FMT_BGR555LE:
3620 case AV_PIX_FMT_BGR555BE:
3621 2617 *yuv2packed1 = yuv2rgb15_1_c;
3622 2617 *yuv2packed2 = yuv2rgb15_2_c;
3623 2617 *yuv2packedX = yuv2rgb15_X_c;
3624 2617 break;
3625 376 case AV_PIX_FMT_RGB444LE:
3626 case AV_PIX_FMT_RGB444BE:
3627 case AV_PIX_FMT_BGR444LE:
3628 case AV_PIX_FMT_BGR444BE:
3629 376 *yuv2packed1 = yuv2rgb12_1_c;
3630 376 *yuv2packed2 = yuv2rgb12_2_c;
3631 376 *yuv2packedX = yuv2rgb12_X_c;
3632 376 break;
3633 1091 case AV_PIX_FMT_RGB8:
3634 case AV_PIX_FMT_BGR8:
3635 1091 *yuv2packed1 = yuv2rgb8_1_c;
3636 1091 *yuv2packed2 = yuv2rgb8_2_c;
3637 1091 *yuv2packedX = yuv2rgb8_X_c;
3638 1091 break;
3639 78 case AV_PIX_FMT_RGB4:
3640 case AV_PIX_FMT_BGR4:
3641 78 *yuv2packed1 = yuv2rgb4_1_c;
3642 78 *yuv2packed2 = yuv2rgb4_2_c;
3643 78 *yuv2packedX = yuv2rgb4_X_c;
3644 78 break;
3645 209 case AV_PIX_FMT_RGB4_BYTE:
3646 case AV_PIX_FMT_BGR4_BYTE:
3647 209 *yuv2packed1 = yuv2rgb4b_1_c;
3648 209 *yuv2packed2 = yuv2rgb4b_2_c;
3649 209 *yuv2packedX = yuv2rgb4b_X_c;
3650 209 break;
3651 52 case AV_PIX_FMT_X2RGB10LE:
3652 case AV_PIX_FMT_X2RGB10BE:
3653 52 *yuv2packed1 = yuv2x2rgb10_1_c;
3654 52 *yuv2packed2 = yuv2x2rgb10_2_c;
3655 52 *yuv2packedX = yuv2x2rgb10_X_c;
3656 52 break;
3657 52 case AV_PIX_FMT_X2BGR10LE:
3658 case AV_PIX_FMT_X2BGR10BE:
3659 52 *yuv2packed1 = yuv2x2bgr10_1_c;
3660 52 *yuv2packed2 = yuv2x2bgr10_2_c;
3661 52 *yuv2packedX = yuv2x2bgr10_X_c;
3662 52 break;
3663 }
3664 }
3665
24/24
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 784 times.
✓ Branch 2 taken 796 times.
✓ Branch 3 taken 733 times.
✓ Branch 4 taken 1036 times.
✓ Branch 5 taken 1149 times.
✓ Branch 6 taken 58 times.
✓ Branch 7 taken 58 times.
✓ Branch 8 taken 55 times.
✓ Branch 9 taken 1141 times.
✓ Branch 10 taken 55 times.
✓ Branch 11 taken 55 times.
✓ Branch 12 taken 58 times.
✓ Branch 13 taken 803 times.
✓ Branch 14 taken 462 times.
✓ Branch 15 taken 737 times.
✓ Branch 16 taken 737 times.
✓ Branch 17 taken 737 times.
✓ Branch 18 taken 861 times.
✓ Branch 19 taken 861 times.
✓ Branch 20 taken 728 times.
✓ Branch 21 taken 728 times.
✓ Branch 22 taken 852 times.
✓ Branch 23 taken 199792 times.
214974 switch (dstFormat) {
3666 1698 case AV_PIX_FMT_MONOWHITE:
3667 1698 *yuv2packed1 = yuv2monowhite_1_c;
3668 1698 *yuv2packed2 = yuv2monowhite_2_c;
3669 1698 *yuv2packedX = yuv2monowhite_X_c;
3670 1698 break;
3671 784 case AV_PIX_FMT_MONOBLACK:
3672 784 *yuv2packed1 = yuv2monoblack_1_c;
3673 784 *yuv2packed2 = yuv2monoblack_2_c;
3674 784 *yuv2packedX = yuv2monoblack_X_c;
3675 784 break;
3676 796 case AV_PIX_FMT_YUYV422:
3677 796 *yuv2packed1 = yuv2yuyv422_1_c;
3678 796 *yuv2packed2 = yuv2yuyv422_2_c;
3679 796 *yuv2packedX = yuv2yuyv422_X_c;
3680 796 break;
3681 733 case AV_PIX_FMT_YVYU422:
3682 733 *yuv2packed1 = yuv2yvyu422_1_c;
3683 733 *yuv2packed2 = yuv2yvyu422_2_c;
3684 733 *yuv2packedX = yuv2yvyu422_X_c;
3685 733 break;
3686 1036 case AV_PIX_FMT_UYVY422:
3687 1036 *yuv2packed1 = yuv2uyvy422_1_c;
3688 1036 *yuv2packed2 = yuv2uyvy422_2_c;
3689 1036 *yuv2packedX = yuv2uyvy422_X_c;
3690 1036 break;
3691 1149 case AV_PIX_FMT_VYU444:
3692 1149 *yuv2packed1 = yuv2vyu444_1_c;
3693 1149 *yuv2packed2 = yuv2vyu444_2_c;
3694 1149 *yuv2packedX = yuv2vyu444_X_c;
3695 1149 break;
3696 58 case AV_PIX_FMT_YA8:
3697 58 *yuv2packed1 = yuv2ya8_1_c;
3698 58 *yuv2packed2 = yuv2ya8_2_c;
3699 58 *yuv2packedX = yuv2ya8_X_c;
3700 58 break;
3701 58 case AV_PIX_FMT_YA16LE:
3702 58 *yuv2packed1 = yuv2ya16le_1_c;
3703 58 *yuv2packed2 = yuv2ya16le_2_c;
3704 58 *yuv2packedX = yuv2ya16le_X_c;
3705 58 break;
3706 55 case AV_PIX_FMT_YA16BE:
3707 55 *yuv2packed1 = yuv2ya16be_1_c;
3708 55 *yuv2packed2 = yuv2ya16be_2_c;
3709 55 *yuv2packedX = yuv2ya16be_X_c;
3710 55 break;
3711 1141 case AV_PIX_FMT_V30XLE:
3712 1141 *yuv2packedX = yuv2v30xle_X_c;
3713 1141 break;
3714 55 case AV_PIX_FMT_AYUV64LE:
3715 55 *yuv2packedX = yuv2ayuv64le_X_c;
3716 55 break;
3717 55 case AV_PIX_FMT_AYUV64BE:
3718 55 *yuv2packedX = yuv2ayuv64be_X_c;
3719 55 break;
3720 58 case AV_PIX_FMT_AYUV:
3721 58 *yuv2packed1 = yuv2ayuv_1_c;
3722 58 *yuv2packed2 = yuv2ayuv_2_c;
3723 58 *yuv2packedX = yuv2ayuv_X_c;
3724 58 break;
3725 803 case AV_PIX_FMT_VUYA:
3726 case AV_PIX_FMT_VUYX:
3727 803 *yuv2packed1 = yuv2vuyX_1_c;
3728 803 *yuv2packed2 = yuv2vuyX_2_c;
3729 803 *yuv2packedX = yuv2vuyX_X_c;
3730 803 break;
3731 462 case AV_PIX_FMT_UYVA:
3732 462 *yuv2packed1 = yuv2uyva_1_c;
3733 462 *yuv2packed2 = yuv2uyva_2_c;
3734 462 *yuv2packedX = yuv2uyva_X_c;
3735 462 break;
3736 737 case AV_PIX_FMT_XV30LE:
3737 737 *yuv2packedX = yuv2xv30le_X_c;
3738 737 break;
3739 737 case AV_PIX_FMT_XV36LE:
3740 737 *yuv2packedX = yuv2xv36le_X_c;
3741 737 break;
3742 737 case AV_PIX_FMT_XV36BE:
3743 737 *yuv2packedX = yuv2xv36be_X_c;
3744 737 break;
3745 861 case AV_PIX_FMT_XV48LE:
3746 861 *yuv2packedX = yuv2xv48le_X_c;
3747 861 break;
3748 861 case AV_PIX_FMT_XV48BE:
3749 861 *yuv2packedX = yuv2xv48be_X_c;
3750 861 break;
3751 728 case AV_PIX_FMT_Y210LE:
3752 728 *yuv2packedX = yuv2y210le_X_c;
3753 728 break;
3754 728 case AV_PIX_FMT_Y212LE:
3755 728 *yuv2packedX = yuv2y212le_X_c;
3756 728 break;
3757 852 case AV_PIX_FMT_Y216LE:
3758 852 *yuv2packedX = yuv2y216le_X_c;
3759 852 break;
3760 }
3761 214974 }
3762