FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/output.c
Date: 2026-11-01 12:52:33
Exec Total Coverage
Lines: 1657 2038 81.3%
Functions: 239 312 76.6%
Branches: 1205 1684 71.6%

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 2935342 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 2935342 int shift = 3;
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2935342 times.
2935342 av_assert0(output_bits == 16);
156
157
2/2
✓ Branch 0 taken 956093896 times.
✓ Branch 1 taken 2935342 times.
959029238 for (i = 0; i < dstW; i++) {
158 956093896 int val = src[i] + (1 << (shift - 1));
159
2/2
✓ Branch 0 taken 358386336 times.
✓ Branch 1 taken 597707560 times.
956093896 output_pixel(&dest[i], val, 0, uint);
160 }
161 2935342 }
162
163 static av_always_inline void
164 621952 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 621952 int shift = 15;
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621952 times.
621952 av_assert0(output_bits == 16);
171
172
2/2
✓ Branch 0 taken 164438304 times.
✓ Branch 1 taken 621952 times.
165060256 for (i = 0; i < dstW; i++) {
173 164438304 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 164438304 val -= 0x40000000;
182
2/2
✓ Branch 0 taken 818156672 times.
✓ Branch 1 taken 164438304 times.
982594976 for (j = 0; j < filterSize; j++)
183 818156672 val += src[j][i] * (unsigned)filter[j];
184
185
2/2
✓ Branch 0 taken 39525632 times.
✓ Branch 1 taken 124912672 times.
164438304 output_pixel(&dest[i], val, 0x8000, int);
186 }
187 621952 }
188
189 static av_always_inline void
190 641224 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 641224 uint16_t *dest = (uint16_t*)dest8;
196 641224 const int32_t **uSrc = (const int32_t **)chrUSrc;
197 641224 const int32_t **vSrc = (const int32_t **)chrVSrc;
198 641224 int shift = 15;
199 int i, j;
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 641224 times.
641224 av_assert0(output_bits == 16);
201
202
2/2
✓ Branch 0 taken 166244576 times.
✓ Branch 1 taken 641224 times.
166885800 for (i = 0; i < chrDstW; i++) {
203 166244576 int u = 1 << (shift - 1);
204 166244576 int v = 1 << (shift - 1);
205
206 /* See yuv2planeX_16_c_template for details. */
207 166244576 u -= 0x40000000;
208 166244576 v -= 0x40000000;
209
2/2
✓ Branch 0 taken 358067328 times.
✓ Branch 1 taken 166244576 times.
524311904 for (j = 0; j < chrFilterSize; j++) {
210 358067328 u += uSrc[j][i] * (unsigned)chrFilter[j];
211 358067328 v += vSrc[j][i] * (unsigned)chrFilter[j];
212 }
213
214
2/2
✓ Branch 0 taken 59628400 times.
✓ Branch 1 taken 106616176 times.
166244576 output_pixel(&dest[2*i] , u, 0x8000, int);
215
2/2
✓ Branch 0 taken 59628400 times.
✓ Branch 1 taken 106616176 times.
166244576 output_pixel(&dest[2*i+1], v, 0x8000, int);
216 }
217 641224 }
218
219 static av_always_inline void
220 29392 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 10340544 times.
✓ Branch 1 taken 29392 times.
10369936 for (i = 0; i < dstW; ++i){
229 10340544 val = src[i] + (1 << (shift - 1));
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10340544 times.
10340544 output_pixel(&val_uint, val, 0, uint);
231 10340544 dest[i] = float_mult * (float)val_uint;
232 }
233 29392 }
234
235 static av_always_inline void
236 13248 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 4663296 times.
✓ Branch 1 taken 13248 times.
4676544 for (i = 0; i < dstW; ++i){
245 4663296 val = src[i] + (1 << (shift - 1));
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4663296 times.
4663296 output_pixel(&val_uint, val, 0, uint);
247 4663296 dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint));
248 }
249 13248 }
250
251 static av_always_inline void
252 200 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 40000 times.
✓ Branch 1 taken 200 times.
40200 for (i = 0; i < dstW; ++i){
262 40000 val = (1 << (shift - 1)) - 0x40000000;
263
2/2
✓ Branch 0 taken 480000 times.
✓ Branch 1 taken 40000 times.
520000 for (j = 0; j < filterSize; ++j){
264 480000 val += src[j][i] * (unsigned)filter[j];
265 }
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40000 times.
40000 output_pixel(&val_uint, val, 0x8000, int);
267 40000 dest[i] = float_mult * (float)val_uint;
268 }
269 200 }
270
271 static av_always_inline void
272 200 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 40000 times.
✓ Branch 1 taken 200 times.
40200 for (i = 0; i < dstW; ++i){
282 40000 val = (1 << (shift - 1)) - 0x40000000;
283
2/2
✓ Branch 0 taken 480000 times.
✓ Branch 1 taken 40000 times.
520000 for (j = 0; j < filterSize; ++j){
284 480000 val += src[j][i] * (unsigned)filter[j];
285 }
286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40000 times.
40000 output_pixel(&val_uint, val, 0x8000, int);
287 40000 dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint));
288 }
289 200 }
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 29392 yuv2plane1_float(yuv2plane1_float_c_template, float, LE)
313 13248 yuv2plane1_float(yuv2plane1_float_bswap_c_template, uint32_t, BE)
314 200 yuv2planeX_float(yuv2planeX_float_c_template, float, LE)
315 200 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 7155884 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 7155884 int shift = 15 - output_bits;
333
334
2/2
✓ Branch 0 taken 2337991592 times.
✓ Branch 1 taken 7155884 times.
2345147476 for (i = 0; i < dstW; i++) {
335 2337991592 int val = src[i] + (1 << (shift - 1));
336
2/2
✓ Branch 0 taken 488871936 times.
✓ Branch 1 taken 1849119656 times.
2337991592 output_pixel(&dest[i], val);
337 }
338 7155884 }
339
340 static av_always_inline void
341 3183768 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 3183768 int shift = 11 + 16 - output_bits;
347
348
2/2
✓ Branch 0 taken 990480776 times.
✓ Branch 1 taken 3183768 times.
993664544 for (i = 0; i < dstW; i++) {
349 990480776 int val = 1 << (shift - 1);
350 int j;
351
352
2/2
✓ Branch 0 taken 4717519584 times.
✓ Branch 1 taken 990480776 times.
5708000360 for (j = 0; j < filterSize; j++)
353 4717519584 val += src[j][i] * filter[j];
354
355
2/2
✓ Branch 0 taken 160650496 times.
✓ Branch 1 taken 829830280 times.
990480776 output_pixel(&dest[i], val);
356 }
357 3183768 }
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 257504 yuv2NBPS( 9, BE, 1, 10, int16_t)
379 287772 yuv2NBPS( 9, LE, 0, 10, int16_t)
380 1970176 yuv2NBPS(10, BE, 1, 10, int16_t)
381 10007948 yuv2NBPS(10, LE, 0, 10, int16_t)
382 1968976 yuv2NBPS(12, BE, 1, 10, int16_t)
383 5892112 yuv2NBPS(12, LE, 0, 10, int16_t)
384 139056 yuv2NBPS(14, BE, 1, 10, int16_t)
385 155760 yuv2NBPS(14, LE, 0, 10, int16_t)
386 2618840 yuv2NBPS(16, BE, 1, 16, int32_t)
387 4495748 yuv2NBPS(16, LE, 0, 16, int32_t)
388
389 #define output_pixel(pos, val) \
390 if (big_endian) { \
391 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits) << (16 - output_bits)); \
392 } else { \
393 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits) << (16 - output_bits)); \
394 }
395
396 static av_always_inline void
397 757440 yuv2msbplane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
398 int big_endian, int output_bits)
399 {
400 int i;
401 757440 int shift = 15 - output_bits;
402
403
2/2
✓ Branch 0 taken 266471424 times.
✓ Branch 1 taken 757440 times.
267228864 for (i = 0; i < dstW; i++) {
404 266471424 int val = src[i] + (1 << (shift - 1));
405
2/2
✓ Branch 0 taken 133005312 times.
✓ Branch 1 taken 133466112 times.
266471424 output_pixel(&dest[i], val);
406 }
407 757440 }
408
409 static av_always_inline void
410 78432 yuv2msbplaneX_10_c_template(const int16_t *filter, int filterSize,
411 const int16_t **src, uint16_t *dest, int dstW,
412 int big_endian, int output_bits)
413 {
414 int i;
415 78432 int shift = 11 + 16 - output_bits;
416
417
2/2
✓ Branch 0 taken 27243264 times.
✓ Branch 1 taken 78432 times.
27321696 for (i = 0; i < dstW; i++) {
418 27243264 int val = 1 << (shift - 1);
419 int j;
420
421
2/2
✓ Branch 0 taken 112813056 times.
✓ Branch 1 taken 27243264 times.
140056320 for (j = 0; j < filterSize; j++)
422 112813056 val += src[j][i] * filter[j];
423
424
2/2
✓ Branch 0 taken 13216128 times.
✓ Branch 1 taken 14027136 times.
27243264 output_pixel(&dest[i], val);
425 }
426 78432 }
427
428 #define yuv2MSBNBPS(bits, BE_LE, is_be, template_size, typeX_t) \
429 static void yuv2msbplane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
430 uint8_t *dest, int dstW, \
431 const uint8_t *dither, int offset)\
432 { \
433 yuv2msbplane1_ ## template_size ## _c_template((const typeX_t *) src, \
434 (uint16_t *) dest, dstW, is_be, bits); \
435 }\
436 static void yuv2msbplaneX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
437 const int16_t **src, uint8_t *dest, int dstW, \
438 const uint8_t *dither, int offset)\
439 { \
440 yuv2msbplaneX_## template_size ## _c_template(filter, \
441 filterSize, (const typeX_t **) src, \
442 (uint16_t *) dest, dstW, is_be, bits); \
443 }
444
445 415920 yuv2MSBNBPS(10, BE, 1, 10, int16_t)
446 419952 yuv2MSBNBPS(10, LE, 0, 10, int16_t)
447 415920 yuv2MSBNBPS(12, BE, 1, 10, int16_t)
448 419952 yuv2MSBNBPS(12, LE, 0, 10, int16_t)
449
450 #undef output_pixel
451
452 386420 static void yuv2nv12cX_16LE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
453 const int16_t *chrFilter, int chrFilterSize,
454 const int16_t **chrUSrc, const int16_t **chrVSrc,
455 uint8_t *dest8, int chrDstW)
456 {
457 386420 yuv2nv12cX_16_c_template(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW, 16);
458 386420 }
459
460 254804 static void yuv2nv12cX_16BE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
461 const int16_t *chrFilter, int chrFilterSize,
462 const int16_t **chrUSrc, const int16_t **chrVSrc,
463 uint8_t *dest8, int chrDstW)
464 {
465 254804 yuv2nv12cX_16_c_template(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW, 16);
466 254804 }
467
468 12035776 static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
469 const int16_t **src, uint8_t *dest, int dstW,
470 const uint8_t *dither, int offset)
471 {
472 int i;
473
2/2
✓ Branch 0 taken 7083241220 times.
✓ Branch 1 taken 12035776 times.
7095276996 for (i=0; i<dstW; i++) {
474 7083241220 int val = dither[(i + offset) & 7] << 12;
475 int j;
476
2/2
✓ Branch 0 taken 23439319804 times.
✓ Branch 1 taken 7083241220 times.
30522561024 for (j=0; j<filterSize; j++) {
477 23439319804 val += (unsigned)(src[j][i] * filter[j]);
478
479 }
480
481 7083241220 dest[i]= av_clip_uint8(val>>19);
482 }
483 12035776 }
484
485 29387536 static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
486 const uint8_t *dither, int offset)
487 {
488 int i;
489
2/2
✓ Branch 0 taken 6424645689 times.
✓ Branch 1 taken 29387536 times.
6454033225 for (i=0; i<dstW; i++) {
490 6424645689 int val = (src[i] + dither[(i + offset) & 7]) >> 7;
491 6424645689 dest[i]= av_clip_uint8(val);
492 }
493 29387536 }
494
495 858370 static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
496 const int16_t *chrFilter, int chrFilterSize,
497 const int16_t **chrUSrc, const int16_t **chrVSrc,
498 uint8_t *dest, int chrDstW)
499 {
500 int i;
501
502
2/2
✓ Branch 1 taken 848278 times.
✓ Branch 2 taken 10092 times.
858370 if (!isSwappedChroma(dstFormat))
503
2/2
✓ Branch 0 taken 274980688 times.
✓ Branch 1 taken 848278 times.
275828966 for (i=0; i<chrDstW; i++) {
504 274980688 int u = chrDither[i & 7] << 12;
505 274980688 int v = chrDither[(i + 3) & 7] << 12;
506 int j;
507
2/2
✓ Branch 0 taken 516747872 times.
✓ Branch 1 taken 274980688 times.
791728560 for (j=0; j<chrFilterSize; j++) {
508 516747872 u += chrUSrc[j][i] * (unsigned)chrFilter[j];
509 516747872 v += chrVSrc[j][i] * (unsigned)chrFilter[j];
510 }
511
512 274980688 dest[2*i]= av_clip_uint8(u>>19);
513 274980688 dest[2*i+1]= av_clip_uint8(v>>19);
514 }
515 else
516
2/2
✓ Branch 0 taken 3496784 times.
✓ Branch 1 taken 10092 times.
3506876 for (i=0; i<chrDstW; i++) {
517 3496784 int u = chrDither[i & 7] << 12;
518 3496784 int v = chrDither[(i + 3) & 7] << 12;
519 int j;
520
2/2
✓ Branch 0 taken 14387136 times.
✓ Branch 1 taken 3496784 times.
17883920 for (j=0; j<chrFilterSize; j++) {
521 14387136 u += chrUSrc[j][i] * (unsigned)chrFilter[j];
522 14387136 v += chrVSrc[j][i] * (unsigned)chrFilter[j];
523 }
524
525 3496784 dest[2*i]= av_clip_uint8(v>>19);
526 3496784 dest[2*i+1]= av_clip_uint8(u>>19);
527 }
528 858370 }
529
530
531 #define output_pixel(pos, val) \
532 if (big_endian) { \
533 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
534 } else { \
535 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
536 }
537
538 2334528 static void yuv2p01xl1_c(const int16_t *src,
539 uint16_t *dest, int dstW,
540 int big_endian, int output_bits, int output_shift)
541 {
542 int i;
543 2334528 int shift = 15 - output_bits;
544
545
2/2
✓ Branch 0 taken 821753856 times.
✓ Branch 1 taken 2334528 times.
824088384 for (i = 0; i < dstW; i++) {
546 821753856 int val = src[i] + (1 << (shift - 1));
547
2/2
✓ Branch 0 taken 179841024 times.
✓ Branch 1 taken 641912832 times.
821753856 output_pixel(&dest[i], val);
548 }
549 2334528 }
550
551 2800 static void yuv2p01xlX_c(const int16_t *filter, int filterSize,
552 const int16_t **src, uint16_t *dest, int dstW,
553 int big_endian, int output_bits, int output_shift)
554 {
555 int i, j;
556 2800 int shift = 11 + 16 - output_bits;
557
558
2/2
✓ Branch 0 taken 560000 times.
✓ Branch 1 taken 2800 times.
562800 for (i = 0; i < dstW; i++) {
559 560000 int val = 1 << (shift - 1);
560
561
2/2
✓ Branch 0 taken 6720000 times.
✓ Branch 1 taken 560000 times.
7280000 for (j = 0; j < filterSize; j++)
562 6720000 val += src[j][i] * filter[j];
563
564
2/2
✓ Branch 0 taken 280000 times.
✓ Branch 1 taken 280000 times.
560000 output_pixel(&dest[i], val);
565 }
566 2800 }
567
568 2158944 static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
569 const int16_t *chrFilter, int chrFilterSize,
570 const int16_t **chrUSrc, const int16_t **chrVSrc,
571 uint8_t *dest8, int chrDstW, int output_bits, int output_shift)
572 {
573 2158944 uint16_t *dest = (uint16_t*)dest8;
574 int i, j;
575 2158944 int shift = 11 + 16 - output_bits;
576
577
2/2
✓ Branch 0 taken 660683264 times.
✓ Branch 1 taken 2158944 times.
662842208 for (i = 0; i < chrDstW; i++) {
578 660683264 int u = 1 << (shift - 1);
579 660683264 int v = 1 << (shift - 1);
580
581
2/2
✓ Branch 0 taken 1283509248 times.
✓ Branch 1 taken 660683264 times.
1944192512 for (j = 0; j < chrFilterSize; j++) {
582 1283509248 u += chrUSrc[j][i] * (unsigned)chrFilter[j];
583 1283509248 v += chrVSrc[j][i] * (unsigned)chrFilter[j];
584 }
585
586
2/2
✓ Branch 0 taken 98393344 times.
✓ Branch 1 taken 562289920 times.
660683264 output_pixel(&dest[2*i] , u);
587
2/2
✓ Branch 0 taken 98393344 times.
✓ Branch 1 taken 562289920 times.
660683264 output_pixel(&dest[2*i+1], v);
588 }
589 2158944 }
590
591 #undef output_pixel
592
593 #define yuv2p01x_wrapper(fmt, bits, shift) \
594 static void yuv2 ## fmt ## l1_LE_c(const int16_t *src, \
595 uint8_t *dest, int dstW, \
596 const uint8_t *dither, int offset) \
597 { \
598 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits, shift); \
599 } \
600 \
601 static void yuv2 ## fmt ## l1_BE_c(const int16_t *src, \
602 uint8_t *dest, int dstW, \
603 const uint8_t *dither, int offset) \
604 { \
605 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits, shift); \
606 } \
607 \
608 static void yuv2 ## fmt ## lX_LE_c(const int16_t *filter, \
609 int filterSize, const int16_t **src, \
610 uint8_t *dest, int dstW, \
611 const uint8_t *dither, int offset) \
612 { \
613 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, \
614 bits, shift); \
615 } \
616 \
617 static void yuv2 ## fmt ## lX_BE_c(const int16_t *filter, \
618 int filterSize, const int16_t **src, \
619 uint8_t *dest, int dstW, \
620 const uint8_t *dither, int offset) \
621 { \
622 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, \
623 bits, shift); \
624 } \
625 \
626 static void yuv2 ## fmt ## cX_LE_c(enum AVPixelFormat dstFormat, \
627 const uint8_t *chrDither, \
628 const int16_t *chrFilter, \
629 int chrFilterSize, \
630 const int16_t **chrUSrc, \
631 const int16_t **chrVSrc, \
632 uint8_t *dest8, int chrDstW) \
633 { \
634 yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
635 dest8, chrDstW, bits, shift); \
636 } \
637 \
638 static void yuv2 ## fmt ## cX_BE_c(enum AVPixelFormat dstFormat, \
639 const uint8_t *chrDither, \
640 const int16_t *chrFilter, \
641 int chrFilterSize, \
642 const int16_t **chrUSrc, \
643 const int16_t **chrVSrc, \
644 uint8_t *dest8, int chrDstW) \
645 { \
646 yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
647 dest8, chrDstW, bits, shift); \
648 }
649
650 4445936 yuv2p01x_wrapper(p010, 10, 6)
651 4473584 yuv2p01x_wrapper(p012, 12, 4)
652 73024 yuv2p01x_wrapper(nv20, 10, 0)
653
654 #define accumulate_bit(acc, val) \
655 acc <<= 1; \
656 acc |= (val) >= 234
657 #define output_pixel(pos, acc) \
658 if (target == AV_PIX_FMT_MONOBLACK) { \
659 pos = acc; \
660 } else { \
661 pos = ~acc; \
662 }
663
664 static av_always_inline void
665 93684 yuv2mono_X_c_template(SwsInternal *c, const int16_t *lumFilter,
666 const int16_t **lumSrc, int lumFilterSize,
667 const int16_t *chrFilter, const int16_t **chrUSrc,
668 const int16_t **chrVSrc, int chrFilterSize,
669 const int16_t **alpSrc, uint8_t *dest, int dstW,
670 int y, enum AVPixelFormat target)
671 {
672 93684 const uint8_t * const d128 = ff_dither_8x8_220[y&7];
673 int i;
674 93684 unsigned acc = 0;
675 93684 int err = 0;
676
677
2/2
✓ Branch 0 taken 16187684 times.
✓ Branch 1 taken 93684 times.
16281368 for (i = 0; i < dstW; i += 2) {
678 int j;
679 16187684 int Y1 = 1 << 18;
680 16187684 int Y2 = 1 << 18;
681
682
2/2
✓ Branch 0 taken 16627684 times.
✓ Branch 1 taken 16187684 times.
32815368 for (j = 0; j < lumFilterSize; j++) {
683 16627684 Y1 += lumSrc[j][i] * (unsigned)lumFilter[j];
684 16627684 Y2 += lumSrc[j][i+1] * (unsigned)lumFilter[j];
685 }
686 16187684 Y1 >>= 19;
687 16187684 Y2 >>= 19;
688
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 16186950 times.
16187684 if ((Y1 | Y2) & 0x100) {
689 734 Y1 = av_clip_uint8(Y1);
690 734 Y2 = av_clip_uint8(Y2);
691 }
692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16187684 times.
16187684 if (c->opts.dither == SWS_DITHER_ED) {
693 ✗ 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;
694 ✗ c->dither_error[0][i] = err;
695 ✗ acc = 2*acc + (Y1 >= 128);
696 ✗ Y1 -= 220*(acc&1);
697
698 ✗ 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);
699 ✗ c->dither_error[0][i+1] = Y1;
700 ✗ acc = 2*acc + (err >= 128);
701 ✗ err -= 220*(acc&1);
702 } else {
703 16187684 accumulate_bit(acc, Y1 + d128[(i + 0) & 7]);
704 16187684 accumulate_bit(acc, Y2 + d128[(i + 1) & 7]);
705 }
706
2/2
✓ Branch 0 taken 4046496 times.
✓ Branch 1 taken 12141188 times.
16187684 if ((i & 7) == 6) {
707
2/2
✓ Branch 0 taken 790664 times.
✓ Branch 1 taken 3255832 times.
4046496 output_pixel(*dest++, acc);
708 }
709 }
710 93684 c->dither_error[0][i] = err;
711
712
2/2
✓ Branch 0 taken 1700 times.
✓ Branch 1 taken 91984 times.
93684 if (i & 6) {
713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1700 times.
1700 output_pixel(*dest, acc);
714 }
715 93684 }
716
717 static av_always_inline void
718 64 yuv2mono_2_c_template(SwsInternal *c, const int16_t *buf[2],
719 const int16_t *ubuf[2], const int16_t *vbuf[2],
720 const int16_t *abuf[2], uint8_t *dest, int dstW,
721 int yalpha, int uvalpha, int y,
722 enum AVPixelFormat target)
723 {
724 64 const int16_t *buf0 = buf[0], *buf1 = buf[1];
725 64 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
726 64 int yalpha1 = 4096 - yalpha;
727 int i;
728 av_assert2(yalpha <= 4096U);
729
730
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if (c->opts.dither == SWS_DITHER_ED) {
731 64 int err = 0;
732 64 unsigned acc = 0;
733
2/2
✓ Branch 0 taken 3264 times.
✓ Branch 1 taken 64 times.
3328 for (i = 0; i < dstW; i +=2) {
734 int Y;
735
736 3264 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
737 3264 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;
738 3264 c->dither_error[0][i] = err;
739 3264 acc = 2*acc + (Y >= 128);
740 3264 Y -= 220*(acc&1);
741
742 3264 err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
743 3264 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;
744 3264 c->dither_error[0][i+1] = Y;
745 3264 acc = 2*acc + (err >= 128);
746 3264 err -= 220*(acc&1);
747
748
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 2496 times.
3264 if ((i & 7) == 6)
749
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 384 times.
768 output_pixel(*dest++, acc);
750 }
751 64 c->dither_error[0][i] = err;
752
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if (i & 6)
753
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 32 times.
64 output_pixel(*dest, acc << (8 - (i & 7)));
754 } else {
755 ✗ for (i = 0; i < dstW; i += 8) {
756 int Y;
757 ✗ unsigned acc = 0;
758
759 ✗ Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
760 ✗ accumulate_bit(acc, Y + d128[0]);
761 ✗ Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
762 ✗ accumulate_bit(acc, Y + d128[1]);
763 ✗ Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
764 ✗ accumulate_bit(acc, Y + d128[2]);
765 ✗ Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
766 ✗ accumulate_bit(acc, Y + d128[3]);
767 ✗ Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
768 ✗ accumulate_bit(acc, Y + d128[4]);
769 ✗ Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
770 ✗ accumulate_bit(acc, Y + d128[5]);
771 ✗ Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
772 ✗ accumulate_bit(acc, Y + d128[6]);
773 ✗ Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
774 ✗ accumulate_bit(acc, Y + d128[7]);
775
776 ✗ output_pixel(*dest++, acc);
777 }
778 }
779 64 }
780
781 static av_always_inline void
782 176672 yuv2mono_1_c_template(SwsInternal *c, const int16_t *buf0,
783 const int16_t *ubuf[2], const int16_t *vbuf[2],
784 const int16_t *abuf0, uint8_t *dest, int dstW,
785 int uvalpha, int y, enum AVPixelFormat target)
786 {
787 176672 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
788 int i;
789
790
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 176640 times.
176672 if (c->opts.dither == SWS_DITHER_ED) {
791 32 int err = 0;
792 32 unsigned acc = 0;
793
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 32 times.
1632 for (i = 0; i < dstW; i +=2) {
794 int Y;
795
796 1600 Y = ((buf0[i + 0] + 64) >> 7);
797 1600 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;
798 1600 c->dither_error[0][i] = err;
799 1600 acc = 2*acc + (Y >= 128);
800 1600 Y -= 220*(acc&1);
801
802 1600 err = ((buf0[i + 1] + 64) >> 7);
803 1600 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;
804 1600 c->dither_error[0][i+1] = Y;
805 1600 acc = 2*acc + (err >= 128);
806 1600 err -= 220*(acc&1);
807
808
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1216 times.
1600 if ((i & 7) == 6)
809
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
384 output_pixel(*dest++, acc);
810 }
811 32 c->dither_error[0][i] = err;
812
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if (i & 6)
813
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 output_pixel(*dest, acc << (8 - (i & 7)));
814 } else {
815
2/2
✓ Branch 0 taken 7333632 times.
✓ Branch 1 taken 176640 times.
7510272 for (i = 0; i < dstW; i += 8) {
816 7333632 unsigned acc = 0;
817 7333632 accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
818 7333632 accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
819 7333632 accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
820 7333632 accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
821 7333632 accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
822 7333632 accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
823 7333632 accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
824 7333632 accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
825
826
2/2
✓ Branch 0 taken 3638016 times.
✓ Branch 1 taken 3695616 times.
7333632 output_pixel(*dest++, acc);
827 }
828 }
829 176672 }
830
831 #undef output_pixel
832 #undef accumulate_bit
833
834 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
835 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
836 const int16_t **lumSrc, int lumFilterSize, \
837 const int16_t *chrFilter, const int16_t **chrUSrc, \
838 const int16_t **chrVSrc, int chrFilterSize, \
839 const int16_t **alpSrc, uint8_t *dest, int dstW, \
840 int y) \
841 { \
842 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
843 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
844 alpSrc, dest, dstW, y, fmt); \
845 } \
846 \
847 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *buf[2], \
848 const int16_t *ubuf[2], const int16_t *vbuf[2], \
849 const int16_t *abuf[2], uint8_t *dest, int dstW, \
850 int yalpha, int uvalpha, int y) \
851 { \
852 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
853 dest, dstW, yalpha, uvalpha, y, fmt); \
854 } \
855 \
856 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *buf0, \
857 const int16_t *ubuf[2], const int16_t *vbuf[2], \
858 const int16_t *abuf0, uint8_t *dest, int dstW, \
859 int uvalpha, int y) \
860 { \
861 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
862 abuf0, dest, dstW, uvalpha, \
863 y, fmt); \
864 }
865
866 337592 YUV2PACKEDWRAPPER(yuv2mono,, white, AV_PIX_FMT_MONOWHITE)
867 203248 YUV2PACKEDWRAPPER(yuv2mono,, black, AV_PIX_FMT_MONOBLACK)
868
869 #define output_pixels(pos, Y1, U, Y2, V) \
870 if (target == AV_PIX_FMT_YUYV422) { \
871 dest[pos + 0] = Y1; \
872 dest[pos + 1] = U; \
873 dest[pos + 2] = Y2; \
874 dest[pos + 3] = V; \
875 } else if (target == AV_PIX_FMT_YVYU422) { \
876 dest[pos + 0] = Y1; \
877 dest[pos + 1] = V; \
878 dest[pos + 2] = Y2; \
879 dest[pos + 3] = U; \
880 } else { /* AV_PIX_FMT_UYVY422 */ \
881 dest[pos + 0] = U; \
882 dest[pos + 1] = Y1; \
883 dest[pos + 2] = V; \
884 dest[pos + 3] = Y2; \
885 }
886
887 static av_always_inline void
888 32472 yuv2422_X_c_template(SwsInternal *c, const int16_t *lumFilter,
889 const int16_t **lumSrc, int lumFilterSize,
890 const int16_t *chrFilter, const int16_t **chrUSrc,
891 const int16_t **chrVSrc, int chrFilterSize,
892 const int16_t **alpSrc, uint8_t *dest, int dstW,
893 int y, enum AVPixelFormat target)
894 {
895 int i;
896
897
2/2
✓ Branch 0 taken 5641824 times.
✓ Branch 1 taken 32472 times.
5674296 for (i = 0; i < ((dstW + 1) >> 1); i++) {
898 int j;
899 5641824 int Y1 = 1 << 18;
900 5641824 int Y2 = 1 << 18;
901 5641824 int U = 1 << 18;
902 5641824 int V = 1 << 18;
903
904
2/2
✓ Branch 0 taken 6301824 times.
✓ Branch 1 taken 5641824 times.
11943648 for (j = 0; j < lumFilterSize; j++) {
905 6301824 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
906 6301824 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
907 }
908
2/2
✓ Branch 0 taken 23047296 times.
✓ Branch 1 taken 5641824 times.
28689120 for (j = 0; j < chrFilterSize; j++) {
909 23047296 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
910 23047296 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
911 }
912 5641824 Y1 >>= 19;
913 5641824 Y2 >>= 19;
914 5641824 U >>= 19;
915 5641824 V >>= 19;
916
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 5641774 times.
5641824 if ((Y1 | Y2 | U | V) & 0x100) {
917 50 Y1 = av_clip_uint8(Y1);
918 50 Y2 = av_clip_uint8(Y2);
919 50 U = av_clip_uint8(U);
920 50 V = av_clip_uint8(V);
921 }
922
4/4
✓ Branch 0 taken 2761248 times.
✓ Branch 1 taken 2880576 times.
✓ Branch 2 taken 1439264 times.
✓ Branch 3 taken 1441312 times.
5641824 output_pixels(4*i, Y1, U, Y2, V);
923 }
924 32472 }
925
926 static av_always_inline void
927 ✗ yuv2422_2_c_template(SwsInternal *c, const int16_t *buf[2],
928 const int16_t *ubuf[2], const int16_t *vbuf[2],
929 const int16_t *abuf[2], uint8_t *dest, int dstW,
930 int yalpha, int uvalpha, int y,
931 enum AVPixelFormat target)
932 {
933 ✗ const int16_t *buf0 = buf[0], *buf1 = buf[1],
934 ✗ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
935 ✗ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
936 ✗ int yalpha1 = 4096 - yalpha;
937 ✗ int uvalpha1 = 4096 - uvalpha;
938 int i;
939 av_assert2(yalpha <= 4096U);
940 av_assert2(uvalpha <= 4096U);
941
942 ✗ for (i = 0; i < ((dstW + 1) >> 1); i++) {
943 ✗ int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
944 ✗ int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
945 ✗ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
946 ✗ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
947
948 ✗ if ((Y1 | Y2 | U | V) & 0x100) {
949 ✗ Y1 = av_clip_uint8(Y1);
950 ✗ Y2 = av_clip_uint8(Y2);
951 ✗ U = av_clip_uint8(U);
952 ✗ V = av_clip_uint8(V);
953 }
954
955 ✗ output_pixels(i * 4, Y1, U, Y2, V);
956 }
957 ✗ }
958
959 static av_always_inline void
960 333504 yuv2422_1_c_template(SwsInternal *c, const int16_t *buf0,
961 const int16_t *ubuf[2], const int16_t *vbuf[2],
962 const int16_t *abuf0, uint8_t *dest, int dstW,
963 int uvalpha, int y, enum AVPixelFormat target)
964 {
965 333504 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
966 int i;
967
968
1/2
✓ Branch 0 taken 333504 times.
✗ Branch 1 not taken.
333504 if (uvalpha < 2048) {
969
2/2
✓ Branch 0 taken 74594304 times.
✓ Branch 1 taken 333504 times.
74927808 for (i = 0; i < ((dstW + 1) >> 1); i++) {
970 74594304 int Y1 = (buf0[i * 2 ]+64) >> 7;
971 74594304 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
972 74594304 int U = (ubuf0[i] +64) >> 7;
973 74594304 int V = (vbuf0[i] +64) >> 7;
974
975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74594304 times.
74594304 if ((Y1 | Y2 | U | V) & 0x100) {
976 ✗ Y1 = av_clip_uint8(Y1);
977 ✗ Y2 = av_clip_uint8(Y2);
978 ✗ U = av_clip_uint8(U);
979 ✗ V = av_clip_uint8(V);
980 }
981
982
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);
983 }
984 } else {
985 ✗ const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
986 ✗ for (i = 0; i < ((dstW + 1) >> 1); i++) {
987 ✗ int Y1 = (buf0[i * 2 ] + 64) >> 7;
988 ✗ int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
989 ✗ int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
990 ✗ int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
991
992 ✗ if ((Y1 | Y2 | U | V) & 0x100) {
993 ✗ Y1 = av_clip_uint8(Y1);
994 ✗ Y2 = av_clip_uint8(Y2);
995 ✗ U = av_clip_uint8(U);
996 ✗ V = av_clip_uint8(V);
997 }
998
999 ✗ output_pixels(i * 4, Y1, U, Y2, V);
1000 }
1001 }
1002 333504 }
1003
1004 #undef output_pixels
1005
1006 196496 YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
1007 181264 YUV2PACKEDWRAPPER(yuv2, 422, yvyu422, AV_PIX_FMT_YVYU422)
1008 354192 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)
1009
1010 #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)
1011 #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)
1012 #define output_pixel(pos, val) \
1013 if (is_be) { \
1014 AV_WB16(pos, val); \
1015 } else { \
1016 AV_WL16(pos, val); \
1017 }
1018
1019 static av_always_inline void
1020 19408 yuv2ya16_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1021 const int32_t **lumSrc, int lumFilterSize,
1022 const int16_t *chrFilter, const int32_t **unused_chrUSrc,
1023 const int32_t **unused_chrVSrc, int unused_chrFilterSize,
1024 const int32_t **alpSrc, uint16_t *dest, int dstW,
1025 int y, enum AVPixelFormat target,
1026 int unused_hasAlpha, int unused_eightbytes, int is_be)
1027 {
1028 19408 int hasAlpha = !!alpSrc;
1029 int i;
1030
1031
2/2
✓ Branch 0 taken 6770816 times.
✓ Branch 1 taken 19408 times.
6790224 for (i = 0; i < dstW; i++) {
1032 int j;
1033 6770816 int Y = -0x40000000;
1034 6770816 int A = 0xffff;
1035
1036
2/2
✓ Branch 0 taken 7650816 times.
✓ Branch 1 taken 6770816 times.
14421632 for (j = 0; j < lumFilterSize; j++)
1037 7650816 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
1038
1039 6770816 Y >>= 15;
1040 6770816 Y += (1<<3) + 0x8000;
1041 6770816 Y = av_clip_uint16(Y);
1042
1043
2/2
✓ Branch 0 taken 80000 times.
✓ Branch 1 taken 6690816 times.
6770816 if (hasAlpha) {
1044 80000 A = -0x40000000 + (1<<14);
1045
2/2
✓ Branch 0 taken 960000 times.
✓ Branch 1 taken 80000 times.
1040000 for (j = 0; j < lumFilterSize; j++)
1046 960000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
1047
1048 80000 A >>= 15;
1049 80000 A += 0x8000;
1050 80000 A = av_clip_uint16(A);
1051 }
1052
1053
2/2
✓ Branch 0 taken 3284032 times.
✓ Branch 1 taken 3486784 times.
6770816 output_pixel(&dest[2 * i ], Y);
1054
2/2
✓ Branch 0 taken 3284032 times.
✓ Branch 1 taken 3486784 times.
6770816 output_pixel(&dest[2 * i + 1], A);
1055 }
1056 19408 }
1057
1058 static av_always_inline void
1059 ✗ yuv2ya16_2_c_template(SwsInternal *c, const int32_t *buf[2],
1060 const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2],
1061 const int32_t *abuf[2], uint16_t *dest, int dstW,
1062 int yalpha_param, int unused_uvalpha, int y,
1063 enum AVPixelFormat target, int unused_hasAlpha,
1064 int unused_eightbytes, int is_be)
1065 {
1066 ✗ unsigned yalpha = yalpha_param;
1067 ✗ int hasAlpha = abuf && abuf[0] && abuf[1];
1068 ✗ const int32_t *buf0 = buf[0], *buf1 = buf[1],
1069 ✗ *abuf0 = hasAlpha ? abuf[0] : NULL,
1070 ✗ *abuf1 = hasAlpha ? abuf[1] : NULL;
1071 ✗ unsigned yalpha1 = 4096 - yalpha;
1072 int i;
1073
1074 av_assert2(yalpha <= 4096U);
1075
1076 ✗ for (i = 0; i < dstW; i++) {
1077 ✗ int Y = (int)(buf0[i] * yalpha1 + buf1[i] * yalpha) >> 15;
1078 int A;
1079
1080 ✗ Y = av_clip_uint16(Y);
1081
1082 ✗ if (hasAlpha) {
1083 ✗ A = (int)(abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 15;
1084 ✗ A = av_clip_uint16(A);
1085 }
1086
1087 ✗ output_pixel(&dest[2 * i ], Y);
1088 ✗ output_pixel(&dest[2 * i + 1], hasAlpha ? A : 65535);
1089 }
1090 ✗ }
1091
1092 static av_always_inline void
1093 2304 yuv2ya16_1_c_template(SwsInternal *c, const int32_t *buf0,
1094 const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2],
1095 const int32_t *abuf0, uint16_t *dest, int dstW,
1096 int unused_uvalpha, int y, enum AVPixelFormat target,
1097 int unused_hasAlpha, int unused_eightbytes, int is_be)
1098 {
1099 2304 int hasAlpha = !!abuf0;
1100 int i;
1101
1102
2/2
✓ Branch 0 taken 221184 times.
✓ Branch 1 taken 2304 times.
223488 for (i = 0; i < dstW; i++) {
1103 221184 int Y = buf0[i] >> 3;/* 19 - 16 */
1104 int A;
1105
1106 221184 Y = av_clip_uint16(Y);
1107
1108
1/2
✓ Branch 0 taken 221184 times.
✗ Branch 1 not taken.
221184 if (hasAlpha) {
1109 221184 A = abuf0[i] >> 3;
1110
2/2
✓ Branch 0 taken 113256 times.
✓ Branch 1 taken 107928 times.
221184 if (A & 0x100)
1111 113256 A = av_clip_uint16(A);
1112 }
1113
1114
2/2
✓ Branch 0 taken 110592 times.
✓ Branch 1 taken 110592 times.
221184 output_pixel(&dest[2 * i ], Y);
1115
4/6
✓ Branch 0 taken 110592 times.
✓ Branch 1 taken 110592 times.
✓ Branch 2 taken 110592 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110592 times.
✗ Branch 5 not taken.
221184 output_pixel(&dest[2 * i + 1], hasAlpha ? A : 65535);
1116 }
1117 2304 }
1118
1119 static av_always_inline void
1120 297536 yuv2rgba64_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1121 const int32_t **lumSrc, int lumFilterSize,
1122 const int16_t *chrFilter, const int32_t **chrUSrc,
1123 const int32_t **chrVSrc, int chrFilterSize,
1124 const int32_t **alpSrc, uint16_t *dest, int dstW,
1125 int y, enum AVPixelFormat target, int hasAlpha, int eightbytes,
1126 int is_be)
1127 {
1128 int i;
1129 297536 int A1 = 0xffff<<14, A2 = 0xffff<<14;
1130
1131
2/2
✓ Branch 0 taken 52168176 times.
✓ Branch 1 taken 297536 times.
52465712 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1132 int j;
1133 52168176 unsigned Y1 = -0x40000000;
1134 52168176 unsigned Y2 = -0x40000000;
1135 52168176 unsigned U = -(128 << 23); // 19
1136 52168176 unsigned V = -(128 << 23);
1137 int R, G, B;
1138
1139
2/2
✓ Branch 0 taken 52716480 times.
✓ Branch 1 taken 52168176 times.
104884656 for (j = 0; j < lumFilterSize; j++) {
1140 52716480 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
1141 52716480 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1142 }
1143
2/2
✓ Branch 0 taken 208734144 times.
✓ Branch 1 taken 52168176 times.
260902320 for (j = 0; j < chrFilterSize; j++) {;
1144 208734144 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1145 208734144 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1146 }
1147
1148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52168176 times.
52168176 if (hasAlpha) {
1149 ✗ A1 = -0x40000000;
1150 ✗ A2 = -0x40000000;
1151 ✗ for (j = 0; j < lumFilterSize; j++) {
1152 ✗ A1 += alpSrc[j][i * 2] * (unsigned)lumFilter[j];
1153 ✗ A2 += alpSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1154 }
1155 ✗ A1 >>= 1;
1156 ✗ A1 += 0x20002000;
1157 ✗ A2 >>= 1;
1158 ✗ A2 += 0x20002000;
1159 }
1160
1161 // 8 bits: 12+15=27; 16 bits: 12+19=31
1162 52168176 Y1 = (int)Y1 >> 14; // 10
1163 52168176 Y1 += 0x10000;
1164 52168176 Y2 = (int)Y2 >> 14;
1165 52168176 Y2 += 0x10000;
1166 52168176 U = (int)U >> 14;
1167 52168176 V = (int)V >> 14;
1168
1169 // 8 bits: 27 -> 17 bits, 16 bits: 31 - 14 = 17 bits
1170 52168176 Y1 -= c->yuv2rgb_y_offset;
1171 52168176 Y2 -= c->yuv2rgb_y_offset;
1172 52168176 Y1 *= c->yuv2rgb_y_coeff;
1173 52168176 Y2 *= c->yuv2rgb_y_coeff;
1174 52168176 Y1 += (1 << 13) - (1 << 29); // 21
1175 52168176 Y2 += (1 << 13) - (1 << 29);
1176 // 8 bits: 17 + 13 bits = 30 bits, 16 bits: 17 + 13 bits = 30 bits
1177
1178 52168176 R = V * c->yuv2rgb_v2r_coeff;
1179 52168176 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1180 52168176 B = U * c->yuv2rgb_u2b_coeff;
1181
1182 // 8 bits: 30 - 22 = 8 bits, 16 bits: 30 bits - 14 = 16 bits
1183
14/18
✓ Branch 0 taken 9535488 times.
✓ Branch 1 taken 42632688 times.
✓ Branch 2 taken 9535488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4870656 times.
✓ Branch 5 taken 4664832 times.
✓ Branch 6 taken 4870656 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1623552 times.
✓ Branch 9 taken 3247104 times.
✓ Branch 10 taken 5985792 times.
✓ Branch 11 taken 36646896 times.
✓ Branch 12 taken 5985792 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3348480 times.
✓ Branch 15 taken 2637312 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3348480 times.
52168176 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1184
2/2
✓ Branch 0 taken 9535488 times.
✓ Branch 1 taken 42632688 times.
52168176 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1185
14/18
✓ Branch 0 taken 9535488 times.
✓ Branch 1 taken 42632688 times.
✓ Branch 2 taken 9535488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4870656 times.
✓ Branch 5 taken 4664832 times.
✓ Branch 6 taken 4870656 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1623552 times.
✓ Branch 9 taken 3247104 times.
✓ Branch 10 taken 5985792 times.
✓ Branch 11 taken 36646896 times.
✓ Branch 12 taken 5985792 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3348480 times.
✓ Branch 15 taken 2637312 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3348480 times.
52168176 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1186
2/2
✓ Branch 0 taken 7507968 times.
✓ Branch 1 taken 44660208 times.
52168176 if (eightbytes) {
1187
2/2
✓ Branch 0 taken 3247104 times.
✓ Branch 1 taken 4260864 times.
7507968 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1188
12/18
✓ Branch 0 taken 3247104 times.
✓ Branch 1 taken 4260864 times.
✓ Branch 2 taken 3247104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3247104 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3247104 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1623552 times.
✓ Branch 9 taken 1623552 times.
✓ Branch 10 taken 4260864 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4260864 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1623552 times.
✓ Branch 15 taken 2637312 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1623552 times.
7507968 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1189
2/2
✓ Branch 0 taken 3247104 times.
✓ Branch 1 taken 4260864 times.
7507968 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1190
12/18
✓ Branch 0 taken 3247104 times.
✓ Branch 1 taken 4260864 times.
✓ Branch 2 taken 3247104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3247104 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3247104 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1623552 times.
✓ Branch 9 taken 1623552 times.
✓ Branch 10 taken 4260864 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4260864 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1623552 times.
✓ Branch 15 taken 2637312 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1623552 times.
7507968 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1191
2/2
✓ Branch 0 taken 3247104 times.
✓ Branch 1 taken 4260864 times.
7507968 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1192 7507968 dest += 8;
1193 } else {
1194
12/18
✓ Branch 0 taken 6288384 times.
✓ Branch 1 taken 38371824 times.
✓ Branch 2 taken 6288384 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1623552 times.
✓ Branch 5 taken 4664832 times.
✓ Branch 6 taken 1623552 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1623552 times.
✓ Branch 10 taken 1724928 times.
✓ Branch 11 taken 36646896 times.
✓ Branch 12 taken 1724928 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1724928 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1724928 times.
44660208 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1195
2/2
✓ Branch 0 taken 6288384 times.
✓ Branch 1 taken 38371824 times.
44660208 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1196
12/18
✓ Branch 0 taken 6288384 times.
✓ Branch 1 taken 38371824 times.
✓ Branch 2 taken 6288384 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1623552 times.
✓ Branch 5 taken 4664832 times.
✓ Branch 6 taken 1623552 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1623552 times.
✓ Branch 10 taken 1724928 times.
✓ Branch 11 taken 36646896 times.
✓ Branch 12 taken 1724928 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1724928 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1724928 times.
44660208 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1197 44660208 dest += 6;
1198 }
1199 }
1200 297536 }
1201
1202 static av_always_inline void
1203 72 yuv2rgba64_2_c_template(SwsInternal *c, const int32_t *buf[2],
1204 const int32_t *ubuf[2], const int32_t *vbuf[2],
1205 const int32_t *abuf[2], uint16_t *dest, int dstW,
1206 int yalpha_param, int uvalpha_param, int y,
1207 enum AVPixelFormat target, int hasAlpha, int eightbytes,
1208 int is_be)
1209 {
1210 72 unsigned yalpha = yalpha_param;
1211 72 unsigned uvalpha = uvalpha_param;
1212 72 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1213 72 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1214 72 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 *abuf0 = hasAlpha ? abuf[0] : NULL,
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 *abuf1 = hasAlpha ? abuf[1] : NULL;
1217 72 unsigned yalpha1 = 4096 - yalpha;
1218 72 unsigned uvalpha1 = 4096 - uvalpha;
1219 int i;
1220 72 int A1 = 0xffff<<14, A2 = 0xffff<<14;
1221
1222 av_assert2(yalpha <= 4096U);
1223 av_assert2(uvalpha <= 4096U);
1224
1225
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 72 times.
18504 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1226 18432 unsigned Y1 = (int)(buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
1227 18432 unsigned Y2 = (int)(buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
1228 18432 int U = (int)(ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1229 18432 int V = (int)(vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1230 int R, G, B;
1231
1232 18432 Y1 -= c->yuv2rgb_y_offset;
1233 18432 Y2 -= c->yuv2rgb_y_offset;
1234 18432 Y1 *= c->yuv2rgb_y_coeff;
1235 18432 Y2 *= c->yuv2rgb_y_coeff;
1236 18432 Y1 += (1 << 13) - (1 << 29);
1237 18432 Y2 += (1 << 13) - (1 << 29);
1238
1239 18432 R = (SUINT)V * c->yuv2rgb_v2r_coeff;
1240 18432 G = (SUINT)V * c->yuv2rgb_v2g_coeff + (SUINT)U * c->yuv2rgb_u2g_coeff;
1241 18432 B = (SUINT)U * c->yuv2rgb_u2b_coeff;
1242
1243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if (hasAlpha) {
1244 ✗ A1 = (int)(abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1;
1245 ✗ A2 = (int)(abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1;
1246
1247 ✗ A1 += 1 << 13;
1248 ✗ A2 += 1 << 13;
1249 }
1250
1251
14/18
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 9216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6912 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 6912 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2304 times.
✓ Branch 9 taken 4608 times.
✓ Branch 10 taken 6912 times.
✓ Branch 11 taken 2304 times.
✓ Branch 12 taken 6912 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4608 times.
✓ Branch 15 taken 2304 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4608 times.
18432 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1252
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 9216 times.
18432 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1253
14/18
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 9216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6912 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 6912 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2304 times.
✓ Branch 9 taken 4608 times.
✓ Branch 10 taken 6912 times.
✓ Branch 11 taken 2304 times.
✓ Branch 12 taken 6912 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4608 times.
✓ Branch 15 taken 2304 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4608 times.
18432 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1254
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 9216 times.
18432 if (eightbytes) {
1255
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
9216 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1256
12/18
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
✓ Branch 2 taken 4608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4608 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4608 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2304 times.
✓ Branch 9 taken 2304 times.
✓ Branch 10 taken 4608 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4608 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2304 times.
✓ Branch 15 taken 2304 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2304 times.
9216 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1257
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
9216 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1258
12/18
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
✓ Branch 2 taken 4608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4608 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4608 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2304 times.
✓ Branch 9 taken 2304 times.
✓ Branch 10 taken 4608 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4608 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2304 times.
✓ Branch 15 taken 2304 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2304 times.
9216 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1259
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
9216 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1260 9216 dest += 8;
1261 } else {
1262
12/18
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
✓ Branch 2 taken 4608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2304 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2304 times.
✓ Branch 10 taken 2304 times.
✓ Branch 11 taken 2304 times.
✓ Branch 12 taken 2304 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2304 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2304 times.
9216 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1263
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
9216 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1264
12/18
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 4608 times.
✓ Branch 2 taken 4608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2304 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2304 times.
✓ Branch 10 taken 2304 times.
✓ Branch 11 taken 2304 times.
✓ Branch 12 taken 2304 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2304 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2304 times.
9216 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1265 9216 dest += 6;
1266 }
1267 }
1268 72 }
1269
1270 static av_always_inline void
1271 209708 yuv2rgba64_1_c_template(SwsInternal *c, const int32_t *buf0,
1272 const int32_t *ubuf[2], const int32_t *vbuf[2],
1273 const int32_t *abuf0, uint16_t *dest, int dstW,
1274 int uvalpha, int y, enum AVPixelFormat target,
1275 int hasAlpha, int eightbytes, int is_be)
1276 {
1277 209708 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1278 int i;
1279 209708 SUINT A1 = 0xffff<<14, A2= 0xffff<<14;
1280
1281
2/2
✓ Branch 0 taken 209660 times.
✓ Branch 1 taken 48 times.
209708 if (uvalpha == 0) {
1282
2/2
✓ Branch 0 taken 36631780 times.
✓ Branch 1 taken 209660 times.
36841440 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1283 36631780 SUINT Y1 = (buf0[i * 2] ) >> 2;
1284 36631780 SUINT Y2 = (buf0[i * 2 + 1]) >> 2;
1285 36631780 SUINT U = (ubuf0[i] - (128 << 11)) >> 2;
1286 36631780 SUINT V = (vbuf0[i] - (128 << 11)) >> 2;
1287 int R, G, B;
1288
1289 36631780 Y1 -= c->yuv2rgb_y_offset;
1290 36631780 Y2 -= c->yuv2rgb_y_offset;
1291 36631780 Y1 *= c->yuv2rgb_y_coeff;
1292 36631780 Y2 *= c->yuv2rgb_y_coeff;
1293 36631780 Y1 += (1 << 13) - (1 << 29);
1294 36631780 Y2 += (1 << 13) - (1 << 29);
1295
1296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36631780 times.
36631780 if (hasAlpha) {
1297 ✗ A1 = abuf0[i * 2 ] * (SUINT)(1 << 11);
1298 ✗ A2 = abuf0[i * 2 + 1] * (SUINT)(1 << 11);
1299
1300 ✗ A1 += 1 << 13;
1301 ✗ A2 += 1 << 13;
1302 }
1303
1304 36631780 R = V * c->yuv2rgb_v2r_coeff;
1305 36631780 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1306 36631780 B = U * c->yuv2rgb_u2b_coeff;
1307
1308
14/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 36628708 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 768 times.
✓ Branch 6 taken 2304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 768 times.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 2304 times.
✓ Branch 11 taken 36626404 times.
✓ Branch 12 taken 2304 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✓ Branch 15 taken 768 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
36631780 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y1) >> 14) + (1<<15), 16));
1309
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 36628708 times.
36631780 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y1) >> 14) + (1<<15), 16));
1310
14/18
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 36628708 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 768 times.
✓ Branch 6 taken 2304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 768 times.
✓ Branch 9 taken 1536 times.
✓ Branch 10 taken 2304 times.
✓ Branch 11 taken 36626404 times.
✓ Branch 12 taken 2304 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1536 times.
✓ Branch 15 taken 768 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
36631780 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y1) >> 14) + (1<<15), 16));
1311
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 36628708 times.
36631780 if (eightbytes) {
1312
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1536 times.
3072 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1313
12/18
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 768 times.
✓ Branch 9 taken 768 times.
✓ Branch 10 taken 1536 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 768 times.
✓ Branch 15 taken 768 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 768 times.
3072 output_pixel(&dest[4], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1314
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1536 times.
3072 output_pixel(&dest[5], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1315
12/18
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 768 times.
✓ Branch 9 taken 768 times.
✓ Branch 10 taken 1536 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1536 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 768 times.
✓ Branch 15 taken 768 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 768 times.
3072 output_pixel(&dest[6], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1316
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1536 times.
3072 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1317 3072 dest += 8;
1318 } else {
1319
12/18
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 36627172 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 768 times.
✓ Branch 5 taken 768 times.
✓ Branch 6 taken 768 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 768 times.
✓ Branch 10 taken 768 times.
✓ Branch 11 taken 36626404 times.
✓ Branch 12 taken 768 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 768 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 768 times.
36628708 output_pixel(&dest[3], av_clip_uintp2(((int)(R_B + Y2) >> 14) + (1<<15), 16));
1320
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 36627172 times.
36628708 output_pixel(&dest[4], av_clip_uintp2(((int)( G + Y2) >> 14) + (1<<15), 16));
1321
12/18
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 36627172 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 768 times.
✓ Branch 5 taken 768 times.
✓ Branch 6 taken 768 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 768 times.
✓ Branch 10 taken 768 times.
✓ Branch 11 taken 36626404 times.
✓ Branch 12 taken 768 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 768 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 768 times.
36628708 output_pixel(&dest[5], av_clip_uintp2(((int)(B_R + Y2) >> 14) + (1<<15), 16));
1322 36628708 dest += 6;
1323 }
1324 }
1325 } else {
1326 48 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1327 48 SUINT A1 = 0xffff<<14, A2 = 0xffff<<14;
1328 48 unsigned uvalpha1 = 4096 - uvalpha;
1329 av_assert2(uvalpha <= 4096U);
1330
1331
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 48 times.
12336 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1332 12288 SUINT Y1 = (buf0[i * 2] ) >> 2;
1333 12288 SUINT Y2 = (buf0[i * 2 + 1]) >> 2;
1334 12288 SUINT U = (int)((SUINT)ubuf0[i] * uvalpha1 + (SUINT)ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1335 12288 SUINT V = (int)((SUINT)vbuf0[i] * uvalpha1 + (SUINT)vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1336 int R, G, B;
1337
1338 12288 Y1 -= c->yuv2rgb_y_offset;
1339 12288 Y2 -= c->yuv2rgb_y_offset;
1340 12288 Y1 *= c->yuv2rgb_y_coeff;
1341 12288 Y2 *= c->yuv2rgb_y_coeff;
1342 12288 Y1 += (1 << 13) - (1 << 29);
1343 12288 Y2 += (1 << 13) - (1 << 29);
1344
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if (hasAlpha) {
1346 ✗ A1 = abuf0[i * 2 ] * (SUINT)(1 << 11);
1347 ✗ A2 = abuf0[i * 2 + 1] * (SUINT)(1 << 11);
1348
1349 ✗ A1 += 1 << 13;
1350 ✗ A2 += 1 << 13;
1351 }
1352
1353 12288 R = V * c->yuv2rgb_v2r_coeff;
1354 12288 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1355 12288 B = U * c->yuv2rgb_u2b_coeff;
1356
1357
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));
1358
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));
1359
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));
1360
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6144 times.
12288 if (eightbytes) {
1361
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
1362
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));
1363
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));
1364
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));
1365
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 3072 times.
6144 output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
1366 6144 dest += 8;
1367 } else {
1368
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));
1369
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));
1370
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));
1371 6144 dest += 6;
1372 }
1373 }
1374 }
1375 209708 }
1376
1377 static av_always_inline void
1378 2000 yuv2rgba64_full_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1379 const int32_t **lumSrc, int lumFilterSize,
1380 const int16_t *chrFilter, const int32_t **chrUSrc,
1381 const int32_t **chrVSrc, int chrFilterSize,
1382 const int32_t **alpSrc, uint16_t *dest, int dstW,
1383 int y, enum AVPixelFormat target, int hasAlpha,
1384 int eightbytes, int is_be)
1385 {
1386 int i;
1387 2000 int A = 0xffff<<14;
1388
1389
2/2
✓ Branch 0 taken 400000 times.
✓ Branch 1 taken 2000 times.
402000 for (i = 0; i < dstW; i++) {
1390 int j;
1391 400000 int Y = -0x40000000;
1392 400000 int U = -(128 << 23); // 19
1393 400000 int V = -(128 << 23);
1394 int R, G, B;
1395
1396
2/2
✓ Branch 0 taken 4800000 times.
✓ Branch 1 taken 400000 times.
5200000 for (j = 0; j < lumFilterSize; j++) {
1397 4800000 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
1398 }
1399
2/2
✓ Branch 0 taken 4800000 times.
✓ Branch 1 taken 400000 times.
5200000 for (j = 0; j < chrFilterSize; j++) {;
1400 4800000 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1401 4800000 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1402 }
1403
1404
2/2
✓ Branch 0 taken 160000 times.
✓ Branch 1 taken 240000 times.
400000 if (hasAlpha) {
1405 160000 A = -0x40000000;
1406
2/2
✓ Branch 0 taken 1920000 times.
✓ Branch 1 taken 160000 times.
2080000 for (j = 0; j < lumFilterSize; j++) {
1407 1920000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
1408 }
1409 160000 A >>= 1;
1410 160000 A += 0x20002000;
1411 }
1412
1413 // 8bit: 12+15=27; 16-bit: 12+19=31
1414 400000 Y >>= 14; // 10
1415 400000 Y += 0x10000;
1416 400000 U >>= 14;
1417 400000 V >>= 14;
1418
1419 // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit
1420 400000 Y -= c->yuv2rgb_y_offset;
1421 400000 Y *= c->yuv2rgb_y_coeff;
1422 400000 Y += (1 << 13) - (1<<29); // 21
1423 // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit
1424
1425 400000 R = (unsigned)V * c->yuv2rgb_v2r_coeff;
1426 400000 G = (unsigned)V * c->yuv2rgb_v2g_coeff + (unsigned)U * c->yuv2rgb_u2g_coeff;
1427 400000 B = (unsigned)U * c->yuv2rgb_u2b_coeff;
1428
1429 // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
1430
14/18
✓ Branch 0 taken 200000 times.
✓ Branch 1 taken 200000 times.
✓ Branch 2 taken 200000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120000 times.
✓ Branch 5 taken 80000 times.
✓ Branch 6 taken 120000 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 40000 times.
✓ Branch 9 taken 80000 times.
✓ Branch 10 taken 120000 times.
✓ Branch 11 taken 80000 times.
✓ Branch 12 taken 120000 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 80000 times.
✓ Branch 15 taken 40000 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 80000 times.
400000 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + (unsigned)Y)>>14) + (1<<15), 16));
1431
2/2
✓ Branch 0 taken 200000 times.
✓ Branch 1 taken 200000 times.
400000 output_pixel(&dest[1], av_clip_uintp2(((int)( G + (unsigned)Y)>>14) + (1<<15), 16));
1432
14/18
✓ Branch 0 taken 200000 times.
✓ Branch 1 taken 200000 times.
✓ Branch 2 taken 200000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120000 times.
✓ Branch 5 taken 80000 times.
✓ Branch 6 taken 120000 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 40000 times.
✓ Branch 9 taken 80000 times.
✓ Branch 10 taken 120000 times.
✓ Branch 11 taken 80000 times.
✓ Branch 12 taken 120000 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 80000 times.
✓ Branch 15 taken 40000 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 80000 times.
400000 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + (unsigned)Y)>>14) + (1<<15), 16));
1433
2/2
✓ Branch 0 taken 160000 times.
✓ Branch 1 taken 240000 times.
400000 if (eightbytes) {
1434
2/2
✓ Branch 0 taken 80000 times.
✓ Branch 1 taken 80000 times.
160000 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1435 160000 dest += 4;
1436 } else {
1437 240000 dest += 3;
1438 }
1439 }
1440 2000 }
1441
1442 static av_always_inline void
1443 ✗ yuv2rgba64_full_2_c_template(SwsInternal *c, const int32_t *buf[2],
1444 const int32_t *ubuf[2], const int32_t *vbuf[2],
1445 const int32_t *abuf[2], uint16_t *dest, int dstW,
1446 int yalpha_param, int uvalpha_param, int y,
1447 enum AVPixelFormat target, int hasAlpha, int eightbytes,
1448 int is_be)
1449 {
1450 ✗ unsigned yalpha = yalpha_param;
1451 ✗ unsigned uvalpha = uvalpha_param;
1452 ✗ const int32_t *buf0 = buf[0], *buf1 = buf[1],
1453 ✗ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1454 ✗ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1455 ✗ *abuf0 = hasAlpha ? abuf[0] : NULL,
1456 ✗ *abuf1 = hasAlpha ? abuf[1] : NULL;
1457 ✗ unsigned yalpha1 = 4096 - yalpha;
1458 ✗ unsigned uvalpha1 = 4096 - uvalpha;
1459 int i;
1460 ✗ int A = 0xffff<<14;
1461
1462 av_assert2(yalpha <= 4096U);
1463 av_assert2(uvalpha <= 4096U);
1464
1465 ✗ for (i = 0; i < dstW; i++) {
1466 ✗ unsigned Y = (int)(buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14;
1467 ✗ unsigned U = (int)(ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1468 ✗ unsigned V = (int)(vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1469 int R, G, B;
1470
1471 ✗ Y -= c->yuv2rgb_y_offset;
1472 ✗ Y *= c->yuv2rgb_y_coeff;
1473 ✗ Y += (1 << 13) - (1 << 29);
1474
1475 ✗ R = V * c->yuv2rgb_v2r_coeff;
1476 ✗ G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1477 ✗ B = U * c->yuv2rgb_u2b_coeff;
1478
1479 ✗ if (hasAlpha) {
1480 ✗ A = (int)(abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1;
1481
1482 ✗ A += 1 << 13;
1483 }
1484
1485 ✗ output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
1486 ✗ output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y) >> 14) + (1<<15), 16));
1487 ✗ output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
1488 ✗ if (eightbytes) {
1489 ✗ output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1490 ✗ dest += 4;
1491 } else {
1492 ✗ dest += 3;
1493 }
1494 }
1495 ✗ }
1496
1497 static av_always_inline void
1498 451392 yuv2rgba64_full_1_c_template(SwsInternal *c, const int32_t *buf0,
1499 const int32_t *ubuf[2], const int32_t *vbuf[2],
1500 const int32_t *abuf0, uint16_t *dest, int dstW,
1501 int uvalpha, int y, enum AVPixelFormat target,
1502 int hasAlpha, int eightbytes, int is_be)
1503 {
1504 451392 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1505 int i;
1506 451392 SUINT A = 0xffff<<14;
1507
1508
1/2
✓ Branch 0 taken 451392 times.
✗ Branch 1 not taken.
451392 if (uvalpha == 0) {
1509
2/2
✓ Branch 0 taken 156432384 times.
✓ Branch 1 taken 451392 times.
156883776 for (i = 0; i < dstW; i++) {
1510 156432384 SUINT Y = (buf0[i]) >> 2;
1511 156432384 SUINT U = (ubuf0[i] - (128 << 11)) >> 2;
1512 156432384 SUINT V = (vbuf0[i] - (128 << 11)) >> 2;
1513 int R, G, B;
1514
1515 156432384 Y -= c->yuv2rgb_y_offset;
1516 156432384 Y *= c->yuv2rgb_y_coeff;
1517 156432384 Y += (1 << 13) - (1 << 29);
1518
1519
2/2
✓ Branch 0 taken 442368 times.
✓ Branch 1 taken 155990016 times.
156432384 if (hasAlpha) {
1520 442368 A = abuf0[i] * (SUINT)(1 << 11);
1521
1522 442368 A += 1 << 13;
1523 }
1524
1525 156432384 R = V * c->yuv2rgb_v2r_coeff;
1526 156432384 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1527 156432384 B = U * c->yuv2rgb_u2b_coeff;
1528
1529
14/18
✓ Branch 0 taken 442368 times.
✓ Branch 1 taken 155990016 times.
✓ Branch 2 taken 442368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 331776 times.
✓ Branch 5 taken 110592 times.
✓ Branch 6 taken 331776 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 110592 times.
✓ Branch 9 taken 221184 times.
✓ Branch 10 taken 359424 times.
✓ Branch 11 taken 155630592 times.
✓ Branch 12 taken 359424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 239616 times.
✓ Branch 15 taken 119808 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239616 times.
156432384 output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
1530
2/2
✓ Branch 0 taken 442368 times.
✓ Branch 1 taken 155990016 times.
156432384 output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y) >> 14) + (1<<15), 16));
1531
14/18
✓ Branch 0 taken 442368 times.
✓ Branch 1 taken 155990016 times.
✓ Branch 2 taken 442368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 331776 times.
✓ Branch 5 taken 110592 times.
✓ Branch 6 taken 331776 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 110592 times.
✓ Branch 9 taken 221184 times.
✓ Branch 10 taken 359424 times.
✓ Branch 11 taken 155630592 times.
✓ Branch 12 taken 359424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 239616 times.
✓ Branch 15 taken 119808 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239616 times.
156432384 output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
1532
2/2
✓ Branch 0 taken 460800 times.
✓ Branch 1 taken 155971584 times.
156432384 if (eightbytes) {
1533
2/2
✓ Branch 0 taken 221184 times.
✓ Branch 1 taken 239616 times.
460800 output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1534 460800 dest += 4;
1535 } else {
1536 155971584 dest += 3;
1537 }
1538 }
1539 } else {
1540 ✗ const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1541 ✗ unsigned uvalpha1 = 4096 - uvalpha;
1542 ✗ SUINT A = 0xffff<<14;
1543 av_assert2(uvalpha <= 4096U);
1544
1545 ✗ for (i = 0; i < dstW; i++) {
1546 ✗ SUINT Y = (buf0[i] ) >> 2;
1547 ✗ SUINT U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1548 ✗ SUINT V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1549 int R, G, B;
1550
1551 ✗ Y -= c->yuv2rgb_y_offset;
1552 ✗ Y *= c->yuv2rgb_y_coeff;
1553 ✗ Y += (1 << 13) - (1 << 29);
1554
1555 ✗ if (hasAlpha) {
1556 ✗ A = abuf0[i] * (SUINT)(1 << 11);
1557
1558 ✗ A += 1 << 13;
1559 }
1560
1561 ✗ R = V * c->yuv2rgb_v2r_coeff;
1562 ✗ G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1563 ✗ B = U * c->yuv2rgb_u2b_coeff;
1564
1565 ✗ output_pixel(&dest[0], av_clip_uintp2(((int)(R_B + Y) >> 14) + (1<<15), 16));
1566 ✗ output_pixel(&dest[1], av_clip_uintp2(((int)( G + Y) >> 14) + (1<<15), 16));
1567 ✗ output_pixel(&dest[2], av_clip_uintp2(((int)(B_R + Y) >> 14) + (1<<15), 16));
1568 ✗ if (eightbytes) {
1569 ✗ output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14);
1570 ✗ dest += 4;
1571 } else {
1572 ✗ dest += 3;
1573 }
1574 }
1575 }
1576 451392 }
1577
1578 #undef output_pixel
1579 #undef r_b
1580 #undef b_r
1581
1582 #define YUV2PACKED16WRAPPER_EXT(name, base, ext, fmt, is_be, hasAlpha, eightbytes) \
1583 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
1584 const int16_t **_lumSrc, int lumFilterSize, \
1585 const int16_t *chrFilter, const int16_t **_chrUSrc, \
1586 const int16_t **_chrVSrc, int chrFilterSize, \
1587 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
1588 int y) \
1589 { \
1590 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
1591 **chrUSrc = (const int32_t **) _chrUSrc, \
1592 **chrVSrc = (const int32_t **) _chrVSrc, \
1593 **alpSrc = (const int32_t **) _alpSrc; \
1594 uint16_t *dest = (uint16_t *) _dest; \
1595 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1596 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1597 alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes, is_be); \
1598 } \
1599 \
1600 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *_buf[2], \
1601 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1602 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
1603 int yalpha, int uvalpha, int y) \
1604 { \
1605 const int32_t **buf = (const int32_t **) _buf, \
1606 **ubuf = (const int32_t **) _ubuf, \
1607 **vbuf = (const int32_t **) _vbuf, \
1608 **abuf = (const int32_t **) _abuf; \
1609 uint16_t *dest = (uint16_t *) _dest; \
1610 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1611 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1612 } \
1613 \
1614 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *_buf0, \
1615 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1616 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
1617 int uvalpha, int y) \
1618 { \
1619 const int32_t *buf0 = (const int32_t *) _buf0, \
1620 **ubuf = (const int32_t **) _ubuf, \
1621 **vbuf = (const int32_t **) _vbuf, \
1622 *abuf0 = (const int32_t *) _abuf0; \
1623 uint16_t *dest = (uint16_t *) _dest; \
1624 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1625 dstW, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1626 }
1627 #define YUV2PACKED16WRAPPER(name, base, ext, base_fmt, endianness, hasAlpha, eightbytes) \
1628 YUV2PACKED16WRAPPER_EXT(name, base, ext, base_fmt ## endianness, IS_BE(endianness), hasAlpha, eightbytes)
1629
1630 53040 YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48be, AV_PIX_FMT_RGB48, BE, 0, 0)
1631 838040 YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48le, AV_PIX_FMT_RGB48, LE, 0, 0)
1632 18480 YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48be, AV_PIX_FMT_BGR48, BE, 0, 0)
1633 19632 YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48le, AV_PIX_FMT_BGR48, LE, 0, 0)
1634 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64, BE, 1, 1)
1635 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64, LE, 1, 1)
1636 18480 YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64, BE, 0, 1)
1637 30000 YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64, LE, 0, 1)
1638 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64, BE, 1, 1)
1639 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64, LE, 1, 1)
1640 18480 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64, BE, 0, 1)
1641 18480 YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64, LE, 0, 1)
1642 21136 YUV2PACKED16WRAPPER(yuv2, ya16, ya16be, AV_PIX_FMT_YA16, BE, 1, 0)
1643 22288 YUV2PACKED16WRAPPER(yuv2, ya16, ya16le, AV_PIX_FMT_YA16, LE, 1, 0)
1644
1645 3104 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48be_full, AV_PIX_FMT_RGB48, BE, 0, 0)
1646 886880 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48le_full, AV_PIX_FMT_RGB48, LE, 0, 0)
1647 2704 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48be_full, AV_PIX_FMT_BGR48, BE, 0, 0)
1648 2896 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48le_full, AV_PIX_FMT_BGR48, LE, 0, 0)
1649 2704 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64be_full, AV_PIX_FMT_RGBA64, BE, 1, 1)
1650 2704 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64le_full, AV_PIX_FMT_RGBA64, LE, 1, 1)
1651 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64be_full, AV_PIX_FMT_RGBA64, BE, 0, 1)
1652 192 YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64le_full, AV_PIX_FMT_RGBA64, LE, 0, 1)
1653 2704 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64, BE, 1, 1)
1654 2704 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64, LE, 1, 1)
1655 ✗ YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64, BE, 0, 1)
1656 192 YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64, LE, 0, 1)
1657
1658 /*
1659 * Write out 2 RGB pixels in the target pixel format. This function takes a
1660 * R/G/B LUT as generated by ff_yuv2rgb_c_init_tables(), which takes care of
1661 * things like endianness conversion and shifting. The caller takes care of
1662 * setting the correct offset in these tables from the chroma (U/V) values.
1663 * This function then uses the luminance (Y1/Y2) values to write out the
1664 * correct RGB values into the destination buffer.
1665 */
1666 static av_always_inline void
1667 310298228 yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
1668 unsigned A1, unsigned A2,
1669 const void *_r, const void *_g, const void *_b, int y,
1670 enum AVPixelFormat target, int hasAlpha)
1671 {
1672
4/6
✓ Branch 0 taken 310298228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 310298228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 301836212 times.
✓ Branch 5 taken 8462016 times.
310298228 if (target == AV_PIX_FMT_ARGB || target == AV_PIX_FMT_RGBA ||
1673
2/2
✓ Branch 0 taken 28764744 times.
✓ Branch 1 taken 273071468 times.
339062972 target == AV_PIX_FMT_ABGR || target == AV_PIX_FMT_BGRA) {
1674 37226760 uint32_t *dest = (uint32_t *) _dest;
1675 37226760 const uint32_t *r = (const uint32_t *) _r;
1676 37226760 const uint32_t *g = (const uint32_t *) _g;
1677 37226760 const uint32_t *b = (const uint32_t *) _b;
1678
1679 #if CONFIG_SMALL
1680 int sh = hasAlpha ? ((target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24) : 0;
1681
1682 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
1683 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
1684 #else
1685
2/2
✓ Branch 0 taken 118400 times.
✓ Branch 1 taken 37108360 times.
37226760 if (hasAlpha) {
1686
3/4
✓ Branch 0 taken 41600 times.
✓ Branch 1 taken 76800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41600 times.
118400 int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
1687
1688 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0);
1689 118400 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
1690 118400 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
1691 } else {
1692 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
1693 int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
1694
1695 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0xFF);
1696 #endif
1697 37108360 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
1698 37108360 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
1699 }
1700 #endif
1701
4/4
✓ Branch 0 taken 147115078 times.
✓ Branch 1 taken 125956390 times.
✓ Branch 2 taken 27340910 times.
✓ Branch 3 taken 119774168 times.
273071468 } else if (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) {
1702 153297300 uint8_t *dest = (uint8_t *) _dest;
1703 153297300 const uint8_t *r = (const uint8_t *) _r;
1704 153297300 const uint8_t *g = (const uint8_t *) _g;
1705 153297300 const uint8_t *b = (const uint8_t *) _b;
1706
1707 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
1708 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
1709
1710
2/2
✓ Branch 0 taken 125956390 times.
✓ Branch 1 taken 27340910 times.
153297300 dest[i * 6 + 0] = r_b[Y1];
1711 153297300 dest[i * 6 + 1] = g[Y1];
1712
2/2
✓ Branch 0 taken 125956390 times.
✓ Branch 1 taken 27340910 times.
153297300 dest[i * 6 + 2] = b_r[Y1];
1713
2/2
✓ Branch 0 taken 125956390 times.
✓ Branch 1 taken 27340910 times.
153297300 dest[i * 6 + 3] = r_b[Y2];
1714 153297300 dest[i * 6 + 4] = g[Y2];
1715
2/2
✓ Branch 0 taken 125956390 times.
✓ Branch 1 taken 27340910 times.
153297300 dest[i * 6 + 5] = b_r[Y2];
1716 #undef r_b
1717 #undef b_r
1718
5/6
✓ Branch 0 taken 89022964 times.
✓ Branch 1 taken 30751204 times.
✓ Branch 2 taken 89022964 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35404360 times.
✓ Branch 5 taken 53618604 times.
119774168 } else if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565 ||
1719
3/4
✓ Branch 0 taken 35404360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28590536 times.
✓ Branch 3 taken 6813824 times.
35404360 target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555 ||
1720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28590536 times.
28590536 target == AV_PIX_FMT_RGB444 || target == AV_PIX_FMT_BGR444) {
1721 91183632 uint16_t *dest = (uint16_t *) _dest;
1722 91183632 const uint16_t *r = (const uint16_t *) _r;
1723 91183632 const uint16_t *g = (const uint16_t *) _g;
1724 91183632 const uint16_t *b = (const uint16_t *) _b;
1725 int dr1, dg1, db1, dr2, dg2, db2;
1726
1727
3/4
✓ Branch 0 taken 60432428 times.
✓ Branch 1 taken 30751204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60432428 times.
91183632 if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565) {
1728 30751204 dr1 = ff_dither_2x2_8[ y & 1 ][0];
1729 30751204 dg1 = ff_dither_2x2_4[ y & 1 ][0];
1730 30751204 db1 = ff_dither_2x2_8[(y & 1) ^ 1][0];
1731 30751204 dr2 = ff_dither_2x2_8[ y & 1 ][1];
1732 30751204 dg2 = ff_dither_2x2_4[ y & 1 ][1];
1733 30751204 db2 = ff_dither_2x2_8[(y & 1) ^ 1][1];
1734
3/4
✓ Branch 0 taken 6813824 times.
✓ Branch 1 taken 53618604 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6813824 times.
60432428 } else if (target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555) {
1735 53618604 dr1 = ff_dither_2x2_8[ y & 1 ][0];
1736 53618604 dg1 = ff_dither_2x2_8[ y & 1 ][1];
1737 53618604 db1 = ff_dither_2x2_8[(y & 1) ^ 1][0];
1738 53618604 dr2 = ff_dither_2x2_8[ y & 1 ][1];
1739 53618604 dg2 = ff_dither_2x2_8[ y & 1 ][0];
1740 53618604 db2 = ff_dither_2x2_8[(y & 1) ^ 1][1];
1741 } else {
1742 6813824 dr1 = ff_dither_4x4_16[ y & 3 ][0];
1743 6813824 dg1 = ff_dither_4x4_16[ y & 3 ][1];
1744 6813824 db1 = ff_dither_4x4_16[(y & 3) ^ 3][0];
1745 6813824 dr2 = ff_dither_4x4_16[ y & 3 ][1];
1746 6813824 dg2 = ff_dither_4x4_16[ y & 3 ][0];
1747 6813824 db2 = ff_dither_4x4_16[(y & 3) ^ 3][1];
1748 }
1749
1750 91183632 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1751 91183632 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1752
4/4
✓ Branch 0 taken 26968520 times.
✓ Branch 1 taken 1622016 times.
✓ Branch 2 taken 1622016 times.
✓ Branch 3 taken 25346504 times.
28590536 } else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) {
1753 3244032 uint32_t *dest = (uint32_t *) _dest;
1754 3244032 const uint32_t *r = (const uint32_t *) _r;
1755 3244032 const uint32_t *g = (const uint32_t *) _g;
1756 3244032 const uint32_t *b = (const uint32_t *) _b;
1757 3244032 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
1758 3244032 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
1759 } else /* 8/4 bits */ {
1760 25346504 uint8_t *dest = (uint8_t *) _dest;
1761 25346504 const uint8_t *r = (const uint8_t *) _r;
1762 25346504 const uint8_t *g = (const uint8_t *) _g;
1763 25346504 const uint8_t *b = (const uint8_t *) _b;
1764 int dr1, dg1, db1, dr2, dg2, db2;
1765
1766
3/4
✓ Branch 0 taken 4088832 times.
✓ Branch 1 taken 21257672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4088832 times.
25346504 if (target == AV_PIX_FMT_RGB8 || target == AV_PIX_FMT_BGR8) {
1767 21257672 const uint8_t * const d64 = ff_dither_8x8_73[y & 7];
1768 21257672 const uint8_t * const d32 = ff_dither_8x8_32[y & 7];
1769 21257672 dr1 = dg1 = d32[(i * 2 + 0) & 7];
1770 21257672 db1 = d64[(i * 2 + 0) & 7];
1771 21257672 dr2 = dg2 = d32[(i * 2 + 1) & 7];
1772 21257672 db2 = d64[(i * 2 + 1) & 7];
1773 } else {
1774 4088832 const uint8_t * const d64 = ff_dither_8x8_73 [y & 7];
1775 4088832 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
1776 4088832 dr1 = db1 = d128[(i * 2 + 0) & 7];
1777 4088832 dg1 = d64[(i * 2 + 0) & 7];
1778 4088832 dr2 = db2 = d128[(i * 2 + 1) & 7];
1779 4088832 dg2 = d64[(i * 2 + 1) & 7];
1780 }
1781
1782
3/4
✓ Branch 0 taken 25223624 times.
✓ Branch 1 taken 122880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25223624 times.
25346504 if (target == AV_PIX_FMT_RGB4 || target == AV_PIX_FMT_BGR4) {
1783 122880 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
1784 122880 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
1785 } else {
1786 25223624 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1787 25223624 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1788 }
1789 }
1790 310298228 }
1791
1792 static av_always_inline void
1793 1317436 yuv2rgb_X_c_template(SwsInternal *c, const int16_t *lumFilter,
1794 const int16_t **lumSrc, int lumFilterSize,
1795 const int16_t *chrFilter, const int16_t **chrUSrc,
1796 const int16_t **chrVSrc, int chrFilterSize,
1797 const int16_t **alpSrc, uint8_t *dest, int dstW,
1798 int y, enum AVPixelFormat target, int hasAlpha)
1799 {
1800 int i;
1801
1802
2/2
✓ Branch 0 taken 226546120 times.
✓ Branch 1 taken 1317436 times.
227863556 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1803 int j, A1, A2;
1804 226546120 int Y1 = 1 << 18;
1805 226546120 int Y2 = 1 << 18;
1806 226546120 int U = 1 << 18;
1807 226546120 int V = 1 << 18;
1808 const void *r, *g, *b;
1809
1810
2/2
✓ Branch 0 taken 241073032 times.
✓ Branch 1 taken 226546120 times.
467619152 for (j = 0; j < lumFilterSize; j++) {
1811 241073032 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
1812 241073032 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1813 }
1814
2/2
✓ Branch 0 taken 910765600 times.
✓ Branch 1 taken 226546120 times.
1137311720 for (j = 0; j < chrFilterSize; j++) {
1815 910765600 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1816 910765600 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1817 }
1818 226546120 Y1 >>= 19;
1819 226546120 Y2 >>= 19;
1820 226546120 U >>= 19;
1821 226546120 V >>= 19;
1822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226546120 times.
226546120 if (hasAlpha) {
1823 ✗ A1 = 1 << 18;
1824 ✗ A2 = 1 << 18;
1825 ✗ for (j = 0; j < lumFilterSize; j++) {
1826 ✗ A1 += alpSrc[j][i * 2 ] * (unsigned)lumFilter[j];
1827 ✗ A2 += alpSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
1828 }
1829 ✗ A1 >>= 19;
1830 ✗ A2 >>= 19;
1831 ✗ if ((A1 | A2) & 0x100) {
1832 ✗ A1 = av_clip_uint8(A1);
1833 ✗ A2 = av_clip_uint8(A2);
1834 }
1835 }
1836
1837 226546120 r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
1838 226546120 g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
1839 226546120 b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1840
1841
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226546120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226546120 times.
226546120 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1842 r, g, b, y, target, hasAlpha);
1843 }
1844 1317436 }
1845
1846 static av_always_inline void
1847 216 yuv2rgb_2_c_template(SwsInternal *c, const int16_t *buf[2],
1848 const int16_t *ubuf[2], const int16_t *vbuf[2],
1849 const int16_t *abuf[2], uint8_t *dest, int dstW,
1850 int yalpha, int uvalpha, int y,
1851 enum AVPixelFormat target, int hasAlpha)
1852 {
1853 216 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1854 216 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1855 216 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 *abuf0 = hasAlpha ? abuf[0] : NULL,
1857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 *abuf1 = hasAlpha ? abuf[1] : NULL;
1858 216 int yalpha1 = 4096 - yalpha;
1859 216 int uvalpha1 = 4096 - uvalpha;
1860 int i;
1861 av_assert2(yalpha <= 4096U);
1862 av_assert2(uvalpha <= 4096U);
1863
1864
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 216 times.
55512 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1865 55296 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
1866 55296 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
1867 55296 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
1868 55296 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
1869 int A1, A2;
1870 55296 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1871 55296 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1872 55296 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1873
1874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
55296 if (hasAlpha) {
1875 ✗ A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
1876 ✗ A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
1877 ✗ A1 = av_clip_uint8(A1);
1878 ✗ A2 = av_clip_uint8(A2);
1879 }
1880
1881
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55296 times.
55296 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1882 r, g, b, y, target, hasAlpha);
1883 }
1884 216 }
1885
1886 static av_always_inline void
1887 542516 yuv2rgb_1_c_template(SwsInternal *c, const int16_t *buf0,
1888 const int16_t *ubuf[2], const int16_t *vbuf[2],
1889 const int16_t *abuf0, uint8_t *dest, int dstW,
1890 int uvalpha, int y, enum AVPixelFormat target,
1891 int hasAlpha)
1892 {
1893 542516 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1894 int i;
1895
1896
2/2
✓ Branch 0 taken 497812 times.
✓ Branch 1 taken 44704 times.
542516 if (uvalpha == 0) {
1897
2/2
✓ Branch 0 taken 82234028 times.
✓ Branch 1 taken 497812 times.
82731840 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1898 82234028 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1899 82234028 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1900 82234028 int U = (ubuf0[i] + 64) >> 7;
1901 82234028 int V = (vbuf0[i] + 64) >> 7;
1902 int A1, A2;
1903 82234028 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1904 82234028 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1905 82234028 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1906
1907
2/2
✓ Branch 0 taken 11840 times.
✓ Branch 1 taken 82222188 times.
82234028 if (hasAlpha) {
1908 11840 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
1909 11840 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
1910 11840 A1 = av_clip_uint8(A1);
1911 11840 A2 = av_clip_uint8(A2);
1912 }
1913
1914
4/4
✓ Branch 0 taken 11840 times.
✓ Branch 1 taken 82222188 times.
✓ Branch 2 taken 11840 times.
✓ Branch 3 taken 82222188 times.
82234028 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1915 r, g, b, y, target, hasAlpha);
1916 }
1917 } else {
1918 44704 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1919 44704 int uvalpha1 = 4096 - uvalpha;
1920 av_assert2(uvalpha <= 4096U);
1921
1922
2/2
✓ Branch 0 taken 1462784 times.
✓ Branch 1 taken 44704 times.
1507488 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1923 1462784 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1924 1462784 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1925 1462784 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (128 << 11)) >> 19;
1926 1462784 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (128 << 11)) >> 19;
1927 int A1, A2;
1928 1462784 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
1929 1462784 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
1930 1462784 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
1931
1932
2/2
✓ Branch 0 taken 106560 times.
✓ Branch 1 taken 1356224 times.
1462784 if (hasAlpha) {
1933 106560 A1 = (abuf0[i * 2 ] + 64) >> 7;
1934 106560 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
1935 106560 A1 = av_clip_uint8(A1);
1936 106560 A2 = av_clip_uint8(A2);
1937 }
1938
1939
4/4
✓ Branch 0 taken 106560 times.
✓ Branch 1 taken 1356224 times.
✓ Branch 2 taken 106560 times.
✓ Branch 3 taken 1356224 times.
1462784 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1940 r, g, b, y, target, hasAlpha);
1941 }
1942 }
1943 542516 }
1944
1945 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1946 static void name ## ext ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
1947 const int16_t **lumSrc, int lumFilterSize, \
1948 const int16_t *chrFilter, const int16_t **chrUSrc, \
1949 const int16_t **chrVSrc, int chrFilterSize, \
1950 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1951 int y) \
1952 { \
1953 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1954 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1955 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1956 }
1957
1958 #define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1959 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1960 static void name ## ext ## _2_c(SwsInternal *c, const int16_t *buf[2], \
1961 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1962 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1963 int yalpha, int uvalpha, int y) \
1964 { \
1965 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1966 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1967 }
1968
1969 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1970 YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1971 static void name ## ext ## _1_c(SwsInternal *c, const int16_t *buf0, \
1972 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1973 const int16_t *abuf0, uint8_t *dest, int dstW, \
1974 int uvalpha, int y) \
1975 { \
1976 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1977 dstW, uvalpha, y, fmt, hasAlpha); \
1978 }
1979
1980 #if CONFIG_SMALL
1981 YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->needAlpha)
1982 YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->needAlpha)
1983 #else
1984 #if CONFIG_SWSCALE_ALPHA
1985 4800 YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1)
1986 2600 YUV2RGBWRAPPER(yuv2rgb,, a32, AV_PIX_FMT_RGB32, 1)
1987 #endif
1988 116352 YUV2RGBWRAPPER(yuv2rgb,, x32_1, AV_PIX_FMT_RGB32_1, 0)
1989 341008 YUV2RGBWRAPPER(yuv2rgb,, x32, AV_PIX_FMT_RGB32, 0)
1990 #endif
1991 1469580 YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
1992 320812 YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
1993 390096 YUV2RGBWRAPPER(yuv2rgb,, 16, AV_PIX_FMT_RGB565, 0)
1994 656096 YUV2RGBWRAPPER(yuv2rgb,, 15, AV_PIX_FMT_RGB555, 0)
1995 84736 YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0)
1996 247664 YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
1997 4704 YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
1998 45024 YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
1999 18432 YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0)
2000 18432 YUV2RGBWRAPPER(yuv2, rgb, x2bgr10, AV_PIX_FMT_X2BGR10, 0)
2001
2002 360702149 static av_always_inline void yuv2rgb_write_full(SwsInternal *c,
2003 uint8_t *dest, int i, int Y, int A, int U, int V,
2004 int y, enum AVPixelFormat target, int hasAlpha, int err[4])
2005 {
2006 int R, G, B;
2007
4/4
✓ Branch 0 taken 344218763 times.
✓ Branch 1 taken 16483386 times.
✓ Branch 2 taken 10831389 times.
✓ Branch 3 taken 333387374 times.
360702149 int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8;
2008
2009 360702149 Y -= c->yuv2rgb_y_offset;
2010 360702149 Y *= (unsigned)c->yuv2rgb_y_coeff;
2011 360702149 Y += 1U << 21;
2012 360702149 R = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2r_coeff;
2013 360702149 G = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2g_coeff + U*(unsigned)c->yuv2rgb_u2g_coeff;
2014 360702149 B = (unsigned)Y + U*(unsigned)c->yuv2rgb_u2b_coeff;
2015
2/2
✓ Branch 0 taken 47019099 times.
✓ Branch 1 taken 313683050 times.
360702149 if ((R | G | B) & 0xC0000000) {
2016 47019099 R = av_clip_uintp2(R, 30);
2017 47019099 G = av_clip_uintp2(G, 30);
2018 47019099 B = av_clip_uintp2(B, 30);
2019 }
2020
2021
9/10
✓ Branch 0 taken 319616 times.
✓ Branch 1 taken 158328937 times.
✓ Branch 2 taken 319616 times.
✓ Branch 3 taken 319616 times.
✓ Branch 4 taken 54653476 times.
✓ Branch 5 taken 55106983 times.
✓ Branch 6 taken 23872576 times.
✓ Branch 7 taken 23872576 times.
✓ Branch 8 taken 43908753 times.
✗ Branch 9 not taken.
360702149 switch(target) {
2022 319616 case AV_PIX_FMT_ARGB:
2023
2/2
✓ Branch 0 taken 301184 times.
✓ Branch 1 taken 18432 times.
319616 dest[0] = hasAlpha ? A : 255;
2024 319616 dest[1] = R >> 22;
2025 319616 dest[2] = G >> 22;
2026 319616 dest[3] = B >> 22;
2027 319616 break;
2028 158328937 case AV_PIX_FMT_RGB24:
2029 158328937 dest[0] = R >> 22;
2030 158328937 dest[1] = G >> 22;
2031 158328937 dest[2] = B >> 22;
2032 158328937 break;
2033 319616 case AV_PIX_FMT_RGBA:
2034 319616 dest[0] = R >> 22;
2035 319616 dest[1] = G >> 22;
2036 319616 dest[2] = B >> 22;
2037
2/2
✓ Branch 0 taken 301184 times.
✓ Branch 1 taken 18432 times.
319616 dest[3] = hasAlpha ? A : 255;
2038 319616 break;
2039 319616 case AV_PIX_FMT_ABGR:
2040
2/2
✓ Branch 0 taken 301184 times.
✓ Branch 1 taken 18432 times.
319616 dest[0] = hasAlpha ? A : 255;
2041 319616 dest[1] = B >> 22;
2042 319616 dest[2] = G >> 22;
2043 319616 dest[3] = R >> 22;
2044 319616 break;
2045 54653476 case AV_PIX_FMT_BGR24:
2046 54653476 dest[0] = B >> 22;
2047 54653476 dest[1] = G >> 22;
2048 54653476 dest[2] = R >> 22;
2049 54653476 break;
2050 55106983 case AV_PIX_FMT_BGRA:
2051 55106983 dest[0] = B >> 22;
2052 55106983 dest[1] = G >> 22;
2053 55106983 dest[2] = R >> 22;
2054
2/2
✓ Branch 0 taken 4193191 times.
✓ Branch 1 taken 50913792 times.
55106983 dest[3] = hasAlpha ? A : 255;
2055 55106983 break;
2056 23872576 case AV_PIX_FMT_X2RGB10LE:
2057 23872576 R >>= 20;
2058 23872576 G >>= 20;
2059 23872576 B >>= 20;
2060 23872576 AV_WL32(dest, (3U << 30) + (R << 20) + (G << 10) + B);
2061 23872576 break;
2062 23872576 case AV_PIX_FMT_X2BGR10LE:
2063 23872576 R >>= 20;
2064 23872576 G >>= 20;
2065 23872576 B >>= 20;
2066 23872576 AV_WL32(dest, (3U << 30) + (B << 20) + (G << 10) + R);
2067 23872576 break;
2068 43908753 case AV_PIX_FMT_BGR4_BYTE:
2069 case AV_PIX_FMT_RGB4_BYTE:
2070 case AV_PIX_FMT_BGR8:
2071 case AV_PIX_FMT_RGB8:
2072 {
2073 int r,g,b;
2074
2075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43908753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43908753 switch (c->opts.dither) {
2076 ✗ case SWS_DITHER_NONE:
2077 ✗ if (isrgb8) {
2078 ✗ r = av_clip_uintp2(R >> 27, 3);
2079 ✗ g = av_clip_uintp2(G >> 27, 3);
2080 ✗ b = av_clip_uintp2(B >> 28, 2);
2081 } else {
2082 ✗ r = av_clip_uintp2(R >> 29, 1);
2083 ✗ g = av_clip_uintp2(G >> 28, 2);
2084 ✗ b = av_clip_uintp2(B >> 29, 1);
2085 }
2086 ✗ break;
2087 43908753 default:
2088 case SWS_DITHER_AUTO:
2089 case SWS_DITHER_ED:
2090 43908753 R >>= 22;
2091 43908753 G >>= 22;
2092 43908753 B >>= 22;
2093 43908753 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;
2094 43908753 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;
2095 43908753 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;
2096 43908753 c->dither_error[0][i] = err[0];
2097 43908753 c->dither_error[1][i] = err[1];
2098 43908753 c->dither_error[2][i] = err[2];
2099
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 r = R >> (isrgb8 ? 5 : 7);
2100
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 g = G >> (isrgb8 ? 5 : 6);
2101
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 b = B >> (isrgb8 ? 6 : 7);
2102
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 r = av_clip(r, 0, isrgb8 ? 7 : 1);
2103
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 g = av_clip(g, 0, isrgb8 ? 7 : 3);
2104
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 b = av_clip(b, 0, isrgb8 ? 3 : 1);
2105
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 err[0] = R - r*(isrgb8 ? 36 : 255);
2106
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 err[1] = G - g*(isrgb8 ? 36 : 85);
2107
2/2
✓ Branch 0 taken 27314775 times.
✓ Branch 1 taken 16593978 times.
43908753 err[2] = B - b*(isrgb8 ? 85 : 255);
2108 43908753 break;
2109 ✗ case SWS_DITHER_A_DITHER:
2110 ✗ if (isrgb8) {
2111 /* see http://pippin.gimp.org/a_dither/ for details/origin */
2112 #define A_DITHER(u,v) (((((u)+((v)*236))*119)&0xff))
2113 ✗ r = (((R >> 19) + A_DITHER(i,y) -96)>>8);
2114 ✗ g = (((G >> 19) + A_DITHER(i + 17,y) - 96)>>8);
2115 ✗ b = (((B >> 20) + A_DITHER(i + 17*2,y) -96)>>8);
2116 ✗ r = av_clip_uintp2(r, 3);
2117 ✗ g = av_clip_uintp2(g, 3);
2118 ✗ b = av_clip_uintp2(b, 2);
2119 } else {
2120 ✗ r = (((R >> 21) + A_DITHER(i,y)-256)>>8);
2121 ✗ g = (((G >> 19) + A_DITHER(i + 17,y)-256)>>8);
2122 ✗ b = (((B >> 21) + A_DITHER(i + 17*2,y)-256)>>8);
2123 ✗ r = av_clip_uintp2(r, 1);
2124 ✗ g = av_clip_uintp2(g, 2);
2125 ✗ b = av_clip_uintp2(b, 1);
2126 }
2127 ✗ break;
2128 ✗ case SWS_DITHER_X_DITHER:
2129 ✗ if (isrgb8) {
2130 /* see http://pippin.gimp.org/a_dither/ for details/origin */
2131 #define X_DITHER(u,v) (((((u)^((v)*237))*181)&0x1ff)/2)
2132 ✗ r = (((R >> 19) + X_DITHER(i,y) - 96)>>8);
2133 ✗ g = (((G >> 19) + X_DITHER(i + 17,y) - 96)>>8);
2134 ✗ b = (((B >> 20) + X_DITHER(i + 17*2,y) - 96)>>8);
2135 ✗ r = av_clip_uintp2(r, 3);
2136 ✗ g = av_clip_uintp2(g, 3);
2137 ✗ b = av_clip_uintp2(b, 2);
2138 } else {
2139 ✗ r = (((R >> 21) + X_DITHER(i,y)-256)>>8);
2140 ✗ g = (((G >> 19) + X_DITHER(i + 17,y)-256)>>8);
2141 ✗ b = (((B >> 21) + X_DITHER(i + 17*2,y)-256)>>8);
2142 ✗ r = av_clip_uintp2(r, 1);
2143 ✗ g = av_clip_uintp2(g, 2);
2144 ✗ b = av_clip_uintp2(b, 1);
2145 }
2146
2147 ✗ break;
2148 }
2149
2150
2/2
✓ Branch 0 taken 8296989 times.
✓ Branch 1 taken 35611764 times.
43908753 if(target == AV_PIX_FMT_BGR4_BYTE) {
2151 8296989 dest[0] = r + 2*g + 8*b;
2152
2/2
✓ Branch 0 taken 8296989 times.
✓ Branch 1 taken 27314775 times.
35611764 } else if(target == AV_PIX_FMT_RGB4_BYTE) {
2153 8296989 dest[0] = b + 2*g + 8*r;
2154
2/2
✓ Branch 0 taken 16483386 times.
✓ Branch 1 taken 10831389 times.
27314775 } else if(target == AV_PIX_FMT_BGR8) {
2155 16483386 dest[0] = r + 8*g + 64*b;
2156
1/2
✓ Branch 0 taken 10831389 times.
✗ Branch 1 not taken.
10831389 } else if(target == AV_PIX_FMT_RGB8) {
2157 10831389 dest[0] = b + 4*g + 32*r;
2158 } else
2159 av_assert2(0);
2160 43908753 break;}
2161 }
2162 360702149 }
2163
2164 static av_always_inline void
2165 12356 yuv2rgb_full_X_c_template(SwsInternal *c, const int16_t *lumFilter,
2166 const int16_t **lumSrc, int lumFilterSize,
2167 const int16_t *chrFilter, const int16_t **chrUSrc,
2168 const int16_t **chrVSrc, int chrFilterSize,
2169 const int16_t **alpSrc, uint8_t *dest,
2170 int dstW, int y, enum AVPixelFormat target, int hasAlpha)
2171 {
2172 int i;
2173
4/4
✓ Branch 0 taken 10423 times.
✓ Branch 1 taken 1933 times.
✓ Branch 2 taken 822 times.
✓ Branch 3 taken 9601 times.
12356 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2174 12356 int err[4] = {0};
2175 12356 int A = 0; //init to silence warning
2176
2177
4/4
✓ Branch 0 taken 12156 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 11956 times.
✓ Branch 3 taken 200 times.
12356 if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2178
4/4
✓ Branch 0 taken 11556 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 11356 times.
11956 || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2179 1000 step = 1;
2180
2181
2/2
✓ Branch 0 taken 5224476 times.
✓ Branch 1 taken 12356 times.
5236832 for (i = 0; i < dstW; i++) {
2182 int j;
2183 5224476 int Y = 1<<9;
2184 5224476 int U = (1<<9)-(128 << 19);
2185 5224476 int V = (1<<9)-(128 << 19);
2186
2187
2/2
✓ Branch 0 taken 25372922 times.
✓ Branch 1 taken 5224476 times.
30597398 for (j = 0; j < lumFilterSize; j++) {
2188 25372922 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2189 }
2190
2/2
✓ Branch 0 taken 26832626 times.
✓ Branch 1 taken 5224476 times.
32057102 for (j = 0; j < chrFilterSize; j++) {
2191 26832626 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2192 26832626 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2193 }
2194 5224476 Y >>= 10;
2195 5224476 U >>= 10;
2196 5224476 V >>= 10;
2197
2/2
✓ Branch 0 taken 4212007 times.
✓ Branch 1 taken 1012469 times.
5224476 if (hasAlpha) {
2198 4212007 A = 1 << 18;
2199
2/2
✓ Branch 0 taken 19408028 times.
✓ Branch 1 taken 4212007 times.
23620035 for (j = 0; j < lumFilterSize; j++) {
2200 19408028 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2201 }
2202 4212007 A >>= 19;
2203
1/2
✓ Branch 0 taken 4212007 times.
✗ Branch 1 not taken.
4212007 if (A & 0x100)
2204 4212007 A = av_clip_uint8(A);
2205 }
2206 5224476 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2207 5224476 dest += step;
2208 }
2209 12356 c->dither_error[0][i] = err[0];
2210 12356 c->dither_error[1][i] = err[1];
2211 12356 c->dither_error[2][i] = err[2];
2212 12356 }
2213
2214 static av_always_inline void
2215 ✗ yuv2rgb_full_2_c_template(SwsInternal *c, const int16_t *buf[2],
2216 const int16_t *ubuf[2], const int16_t *vbuf[2],
2217 const int16_t *abuf[2], uint8_t *dest, int dstW,
2218 int yalpha, int uvalpha, int y,
2219 enum AVPixelFormat target, int hasAlpha)
2220 {
2221 ✗ const int16_t *buf0 = buf[0], *buf1 = buf[1],
2222 ✗ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2223 ✗ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2224 ✗ *abuf0 = hasAlpha ? abuf[0] : NULL,
2225 ✗ *abuf1 = hasAlpha ? abuf[1] : NULL;
2226 ✗ int yalpha1 = 4096 - yalpha;
2227 ✗ int uvalpha1 = 4096 - uvalpha;
2228 int i;
2229 ✗ int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2230 ✗ int err[4] = {0};
2231 ✗ int A = 0; // init to silcene warning
2232
2233 av_assert2(yalpha <= 4096U);
2234 av_assert2(uvalpha <= 4096U);
2235
2236 ✗ if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2237 ✗ || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2238 ✗ step = 1;
2239
2240 ✗ for (i = 0; i < dstW; i++) {
2241 ✗ int Y = ( buf0[i] * yalpha1 + buf1[i] * yalpha ) >> 10; //FIXME rounding
2242 ✗ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha-(128 << 19)) >> 10;
2243 ✗ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha-(128 << 19)) >> 10;
2244
2245 ✗ if (hasAlpha) {
2246 ✗ A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha + (1<<18)) >> 19;
2247 ✗ if (A & 0x100)
2248 ✗ A = av_clip_uint8(A);
2249 }
2250
2251 ✗ yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2252 ✗ dest += step;
2253 }
2254 ✗ c->dither_error[0][i] = err[0];
2255 ✗ c->dither_error[1][i] = err[1];
2256 ✗ c->dither_error[2][i] = err[2];
2257 ✗ }
2258
2259 static av_always_inline void
2260 1108365 yuv2rgb_full_1_c_template(SwsInternal *c, const int16_t *buf0,
2261 const int16_t *ubuf[2], const int16_t *vbuf[2],
2262 const int16_t *abuf0, uint8_t *dest, int dstW,
2263 int uvalpha, int y, enum AVPixelFormat target,
2264 int hasAlpha)
2265 {
2266 1108365 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
2267 int i;
2268
4/4
✓ Branch 0 taken 656585 times.
✓ Branch 1 taken 451780 times.
✓ Branch 2 taken 158440 times.
✓ Branch 3 taken 498145 times.
1108365 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
2269 1108365 int err[4] = {0};
2270
2271
4/4
✓ Branch 0 taken 1069672 times.
✓ Branch 1 taken 38693 times.
✓ Branch 2 taken 1030979 times.
✓ Branch 3 taken 38693 times.
1108365 if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
2272
4/4
✓ Branch 0 taken 954745 times.
✓ Branch 1 taken 76234 times.
✓ Branch 2 taken 45893 times.
✓ Branch 3 taken 908852 times.
1030979 || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
2273 199513 step = 1;
2274
2275
1/2
✓ Branch 0 taken 1108365 times.
✗ Branch 1 not taken.
1108365 if (uvalpha == 0) {
2276 1108365 int A = 0; //init to silence warning
2277
2/2
✓ Branch 0 taken 355477673 times.
✓ Branch 1 taken 1108365 times.
356586038 for (i = 0; i < dstW; i++) {
2278 355477673 int Y = buf0[i] * 4;
2279 355477673 int U = (ubuf0[i] - (128<<7)) * 4;
2280 355477673 int V = (vbuf0[i] - (128<<7)) * 4;
2281
2282
2/2
✓ Branch 0 taken 884736 times.
✓ Branch 1 taken 354592937 times.
355477673 if (hasAlpha) {
2283 884736 A = (abuf0[i] + 64) >> 7;
2284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 884736 times.
884736 if (A & 0x100)
2285 ✗ A = av_clip_uint8(A);
2286 }
2287
2288 355477673 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2289 355477673 dest += step;
2290 }
2291 } else {
2292 ✗ const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
2293 ✗ int A = 0; //init to silence warning
2294 ✗ int uvalpha1 = 4096 - uvalpha;
2295 av_assert2(uvalpha <= 4096U);
2296
2297 ✗ for (i = 0; i < dstW; i++) {
2298 ✗ int Y = buf0[i] * 4;
2299 ✗ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 19)) >> 10;
2300 ✗ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 19)) >> 10;
2301
2302 ✗ if (hasAlpha) {
2303 ✗ A = (abuf0[i] + 64) >> 7;
2304 ✗ if (A & 0x100)
2305 ✗ A = av_clip_uint8(A);
2306 }
2307
2308 ✗ yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
2309 ✗ dest += step;
2310 }
2311 }
2312
2313 1108365 c->dither_error[0][i] = err[0];
2314 1108365 c->dither_error[1][i] = err[1];
2315 1108365 c->dither_error[2][i] = err[2];
2316 1108365 }
2317
2318 #if CONFIG_SMALL
2319 YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2320 YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2321 YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2322 YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->needAlpha)
2323 #else
2324 #if CONFIG_SWSCALE_ALPHA
2325 18610 YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1)
2326 5408 YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, 1)
2327 5408 YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, 1)
2328 5408 YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, 1)
2329 #endif
2330 303504 YUV2RGBWRAPPER(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
2331 384 YUV2RGBWRAPPER(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
2332 384 YUV2RGBWRAPPER(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
2333 384 YUV2RGBWRAPPER(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
2334 #endif
2335 318524 YUV2RGBWRAPPER(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
2336 907426 YUV2RGBWRAPPER(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
2337
2338 77786 YUV2RGBWRAPPER(yuv2, rgb_full, bgr4_byte_full, AV_PIX_FMT_BGR4_BYTE, 0)
2339 77786 YUV2RGBWRAPPER(yuv2, rgb_full, rgb4_byte_full, AV_PIX_FMT_RGB4_BYTE, 0)
2340 153268 YUV2RGBWRAPPER(yuv2, rgb_full, bgr8_full, AV_PIX_FMT_BGR8, 0)
2341 92186 YUV2RGBWRAPPER(yuv2, rgb_full, rgb8_full, AV_PIX_FMT_RGB8, 0)
2342
2343 137488 YUV2RGBWRAPPER(yuv2, rgb_full, x2rgb10_full, AV_PIX_FMT_X2RGB10LE, 0)
2344 137488 YUV2RGBWRAPPER(yuv2, rgb_full, x2bgr10_full, AV_PIX_FMT_X2BGR10LE, 0)
2345
2346 static void
2347 2715644 yuv2gbrp_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2348 const int16_t **lumSrc, int lumFilterSize,
2349 const int16_t *chrFilter, const int16_t **chrUSrc,
2350 const int16_t **chrVSrc, int chrFilterSize,
2351 const int16_t **alpSrc, uint8_t **dest,
2352 int dstW, int y)
2353 {
2354 2715644 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2355 int i;
2356
4/4
✓ Branch 0 taken 126422 times.
✓ Branch 1 taken 2589222 times.
✓ Branch 2 taken 4304 times.
✓ Branch 3 taken 122118 times.
2715644 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrc;
2357 2715644 uint16_t **dest16 = (uint16_t**)dest;
2358 2715644 int SH = 22 + 8 - desc->comp[0].depth;
2359 2715644 int A = 0; // init to silence warning
2360
2361
2/2
✓ Branch 0 taken 951904144 times.
✓ Branch 1 taken 2715644 times.
954619788 for (i = 0; i < dstW; i++) {
2362 int j;
2363 951904144 int Y = 1 << 9;
2364 951904144 int U = (1 << 9) - (128 << 19);
2365 951904144 int V = (1 << 9) - (128 << 19);
2366 int R, G, B;
2367
2368
2/2
✓ Branch 0 taken 962204944 times.
✓ Branch 1 taken 951904144 times.
1914109088 for (j = 0; j < lumFilterSize; j++)
2369 962204944 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2370
2371
2/2
✓ Branch 0 taken 1907492800 times.
✓ Branch 1 taken 951904144 times.
2859396944 for (j = 0; j < chrFilterSize; j++) {
2372 1907492800 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2373 1907492800 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2374 }
2375
2376 951904144 Y >>= 10;
2377 951904144 U >>= 10;
2378 951904144 V >>= 10;
2379
2380
2/2
✓ Branch 0 taken 598464 times.
✓ Branch 1 taken 951305680 times.
951904144 if (hasAlpha) {
2381 598464 A = 1 << 18;
2382
2383
2/2
✓ Branch 0 taken 4214464 times.
✓ Branch 1 taken 598464 times.
4812928 for (j = 0; j < lumFilterSize; j++)
2384 4214464 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2385
2386
2/2
✓ Branch 0 taken 319080 times.
✓ Branch 1 taken 279384 times.
598464 if (A & 0xF8000000)
2387 319080 A = av_clip_uintp2(A, 27);
2388 }
2389
2390 951904144 Y -= c->yuv2rgb_y_offset;
2391 951904144 Y *= c->yuv2rgb_y_coeff;
2392 951904144 Y += 1 << (SH-1);
2393 951904144 R = Y + V * (unsigned)c->yuv2rgb_v2r_coeff;
2394 951904144 G = Y + V * (unsigned)c->yuv2rgb_v2g_coeff + U * (unsigned)c->yuv2rgb_u2g_coeff;
2395 951904144 B = Y + U * (unsigned)c->yuv2rgb_u2b_coeff;
2396
2397
2/2
✓ Branch 0 taken 280228960 times.
✓ Branch 1 taken 671675184 times.
951904144 if ((R | G | B) & 0xC0000000) {
2398 280228960 R = av_clip_uintp2(R, 30);
2399 280228960 G = av_clip_uintp2(G, 30);
2400 280228960 B = av_clip_uintp2(B, 30);
2401 }
2402
2403
2/2
✓ Branch 0 taken 660493456 times.
✓ Branch 1 taken 291410688 times.
951904144 if (SH != 22) {
2404 660493456 dest16[0][i] = G >> SH;
2405 660493456 dest16[1][i] = B >> SH;
2406 660493456 dest16[2][i] = R >> SH;
2407
2/2
✓ Branch 0 taken 539008 times.
✓ Branch 1 taken 659954448 times.
660493456 if (hasAlpha)
2408 539008 dest16[3][i] = A >> (SH - 3);
2409 } else {
2410 291410688 dest[0][i] = G >> 22;
2411 291410688 dest[1][i] = B >> 22;
2412 291410688 dest[2][i] = R >> 22;
2413
2/2
✓ Branch 0 taken 59456 times.
✓ Branch 1 taken 291351232 times.
291410688 if (hasAlpha)
2414 59456 dest[3][i] = A >> 19;
2415 }
2416 }
2417
4/4
✓ Branch 0 taken 1886980 times.
✓ Branch 1 taken 828664 times.
✓ Branch 3 taken 223704 times.
✓ Branch 4 taken 1663276 times.
2715644 if (SH != 22 && (!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2418
2/2
✓ Branch 0 taken 77448768 times.
✓ Branch 1 taken 223704 times.
77672472 for (i = 0; i < dstW; i++) {
2419 77448768 dest16[0][i] = av_bswap16(dest16[0][i]);
2420 77448768 dest16[1][i] = av_bswap16(dest16[1][i]);
2421 77448768 dest16[2][i] = av_bswap16(dest16[2][i]);
2422
2/2
✓ Branch 0 taken 269504 times.
✓ Branch 1 taken 77179264 times.
77448768 if (hasAlpha)
2423 269504 dest16[3][i] = av_bswap16(dest16[3][i]);
2424 }
2425 }
2426 2715644 }
2427
2428 static void
2429 43616 yuv2gbrpmsb_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2430 const int16_t **lumSrc, int lumFilterSize,
2431 const int16_t *chrFilter, const int16_t **chrUSrc,
2432 const int16_t **chrVSrc, int chrFilterSize,
2433 const int16_t **alpSrc, uint8_t **dest,
2434 int dstW, int y)
2435 {
2436 43616 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43616 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrc;
2438 43616 uint16_t **dest16 = (uint16_t**)dest;
2439 43616 int shift = 16 - desc->comp[0].depth;
2440 int i;
2441
2442 43616 yuv2gbrp_full_X_c(c, lumFilter, lumSrc, lumFilterSize,
2443 chrFilter, chrUSrc, chrVSrc, chrFilterSize,
2444 alpSrc, dest, dstW, y);
2445
2446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43616 times.
43616 if (desc->comp[0].depth <= 8)
2447 ✗ return;
2448
2449
2/2
✓ Branch 1 taken 21136 times.
✓ Branch 2 taken 22480 times.
43616 if ((!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2450
2/2
✓ Branch 0 taken 6789248 times.
✓ Branch 1 taken 21136 times.
6810384 for (i = 0; i < dstW; i++) {
2451 6789248 dest16[0][i] = av_bswap16(av_bswap16(dest16[0][i]) << shift);
2452 6789248 dest16[1][i] = av_bswap16(av_bswap16(dest16[1][i]) << shift);
2453 6789248 dest16[2][i] = av_bswap16(av_bswap16(dest16[2][i]) << shift);
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6789248 times.
6789248 if (hasAlpha)
2455 ✗ dest16[3][i] = av_bswap16(av_bswap16(dest16[3][i]) << shift);
2456 }
2457 } else {
2458
2/2
✓ Branch 0 taken 7213184 times.
✓ Branch 1 taken 22480 times.
7235664 for (i = 0; i < dstW; i++) {
2459 7213184 dest16[0][i] = dest16[0][i] << shift;
2460 7213184 dest16[1][i] = dest16[1][i] << shift;
2461 7213184 dest16[2][i] = dest16[2][i] << shift;
2462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7213184 times.
7213184 if (hasAlpha)
2463 ✗ dest16[3][i] = dest16[3][i] << shift;
2464 }
2465 }
2466 }
2467
2468 static void
2469 362796 yuv2gbrp16_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2470 const int16_t **lumSrcx, int lumFilterSize,
2471 const int16_t *chrFilter, const int16_t **chrUSrcx,
2472 const int16_t **chrVSrcx, int chrFilterSize,
2473 const int16_t **alpSrcx, uint8_t **dest,
2474 int dstW, int y)
2475 {
2476 362796 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2477 int i;
2478
4/4
✓ Branch 0 taken 27894 times.
✓ Branch 1 taken 334902 times.
✓ Branch 2 taken 820 times.
✓ Branch 3 taken 27074 times.
362796 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrcx;
2479 362796 uint16_t **dest16 = (uint16_t**)dest;
2480 362796 const int32_t **lumSrc = (const int32_t**)lumSrcx;
2481 362796 const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
2482 362796 const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
2483 362796 const int32_t **alpSrc = (const int32_t**)alpSrcx;
2484
2485
2/2
✓ Branch 0 taken 127389632 times.
✓ Branch 1 taken 362796 times.
127752428 for (i = 0; i < dstW; i++) {
2486 int j;
2487 127389632 int Y = -0x40000000;
2488 127389632 int U = -(128 << 23);
2489 127389632 int V = -(128 << 23);
2490 int R, G, B, A;
2491
2492
2/2
✓ Branch 0 taken 129578432 times.
✓ Branch 1 taken 127389632 times.
256968064 for (j = 0; j < lumFilterSize; j++)
2493 129578432 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2494
2495
2/2
✓ Branch 0 taken 218383808 times.
✓ Branch 1 taken 127389632 times.
345773440 for (j = 0; j < chrFilterSize; j++) {
2496 218383808 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2497 218383808 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2498 }
2499
2500 127389632 Y >>= 14;
2501 127389632 Y += 0x10000;
2502 127389632 U >>= 14;
2503 127389632 V >>= 14;
2504
2505
2/2
✓ Branch 0 taken 131872 times.
✓ Branch 1 taken 127257760 times.
127389632 if (hasAlpha) {
2506 131872 A = -0x40000000;
2507
2508
2/2
✓ Branch 0 taken 1226272 times.
✓ Branch 1 taken 131872 times.
1358144 for (j = 0; j < lumFilterSize; j++)
2509 1226272 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2510
2511 131872 A >>= 1;
2512 131872 A += 0x20002000;
2513 }
2514
2515 127389632 Y -= c->yuv2rgb_y_offset;
2516 127389632 Y *= c->yuv2rgb_y_coeff;
2517 127389632 Y += (1 << 13) - (1 << 29);
2518 127389632 R = V * c->yuv2rgb_v2r_coeff;
2519 127389632 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
2520 127389632 B = U * c->yuv2rgb_u2b_coeff;
2521
2522 127389632 dest16[2][i] = av_clip_uintp2(((Y + (int64_t)R) >> 14) + (1<<15), 16);
2523 127389632 dest16[0][i] = av_clip_uintp2(((Y + (int64_t)G) >> 14) + (1<<15), 16);
2524 127389632 dest16[1][i] = av_clip_uintp2(((Y + (int64_t)B) >> 14) + (1<<15), 16);
2525
2526
2/2
✓ Branch 0 taken 131872 times.
✓ Branch 1 taken 127257760 times.
127389632 if (hasAlpha)
2527 131872 dest16[3][i] = av_clip_uintp2(A, 30) >> 14;
2528 }
2529
2/2
✓ Branch 1 taken 124264 times.
✓ Branch 2 taken 238532 times.
362796 if ((!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2530
2/2
✓ Branch 0 taken 43533760 times.
✓ Branch 1 taken 124264 times.
43658024 for (i = 0; i < dstW; i++) {
2531 43533760 dest16[0][i] = av_bswap16(dest16[0][i]);
2532 43533760 dest16[1][i] = av_bswap16(dest16[1][i]);
2533 43533760 dest16[2][i] = av_bswap16(dest16[2][i]);
2534
2/2
✓ Branch 0 taken 72416 times.
✓ Branch 1 taken 43461344 times.
43533760 if (hasAlpha)
2535 72416 dest16[3][i] = av_bswap16(dest16[3][i]);
2536 }
2537 }
2538 362796 }
2539
2540 static void
2541 85027 yuv2gbrpf32_full_X_c(SwsInternal *c, const int16_t *lumFilter,
2542 const int16_t **lumSrcx, int lumFilterSize,
2543 const int16_t *chrFilter, const int16_t **chrUSrcx,
2544 const int16_t **chrVSrcx, int chrFilterSize,
2545 const int16_t **alpSrcx, uint8_t **dest,
2546 int dstW, int y)
2547 {
2548 85027 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.dst_format);
2549 int i;
2550
4/4
✓ Branch 0 taken 38193 times.
✓ Branch 1 taken 46834 times.
✓ Branch 2 taken 3633 times.
✓ Branch 3 taken 34560 times.
85027 int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrcx;
2551 85027 uint32_t **dest32 = (uint32_t**)dest;
2552 85027 const int32_t **lumSrc = (const int32_t**)lumSrcx;
2553 85027 const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
2554 85027 const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
2555 85027 const int32_t **alpSrc = (const int32_t**)alpSrcx;
2556 static const float float_mult = 1.0f / 65535.0f;
2557
2558
2/2
✓ Branch 0 taken 30880566 times.
✓ Branch 1 taken 85027 times.
30965593 for (i = 0; i < dstW; i++) {
2559 int j;
2560 30880566 int Y = -0x40000000;
2561 30880566 int U = -(128 << 23);
2562 30880566 int V = -(128 << 23);
2563 int R, G, B, A;
2564
2565
2/2
✓ Branch 0 taken 33069366 times.
✓ Branch 1 taken 30880566 times.
63949932 for (j = 0; j < lumFilterSize; j++)
2566 33069366 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2567
2568
2/2
✓ Branch 0 taken 114621750 times.
✓ Branch 1 taken 30880566 times.
145502316 for (j = 0; j < chrFilterSize; j++) {
2569 114621750 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2570 114621750 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2571 }
2572
2573 30880566 Y >>= 14;
2574 30880566 Y += 0x10000;
2575 30880566 U >>= 14;
2576 30880566 V >>= 14;
2577
2578
2/2
✓ Branch 0 taken 1935115 times.
✓ Branch 1 taken 28945451 times.
30880566 if (hasAlpha) {
2579 1935115 A = -0x40000000;
2580
2581
2/2
✓ Branch 0 taken 3029515 times.
✓ Branch 1 taken 1935115 times.
4964630 for (j = 0; j < lumFilterSize; j++)
2582 3029515 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2583
2584 1935115 A >>= 1;
2585 1935115 A += 0x20002000;
2586 }
2587
2588 30880566 Y -= c->yuv2rgb_y_offset;
2589 30880566 Y *= c->yuv2rgb_y_coeff;
2590 30880566 Y += (1 << 13) - (1 << 29);
2591 30880566 R = V * c->yuv2rgb_v2r_coeff;
2592 30880566 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
2593 30880566 B = U * c->yuv2rgb_u2b_coeff;
2594
2595 30880566 R = av_clip_uintp2(((Y + R) >> 14) + (1<<15), 16);
2596 30880566 G = av_clip_uintp2(((Y + G) >> 14) + (1<<15), 16);
2597 30880566 B = av_clip_uintp2(((Y + B) >> 14) + (1<<15), 16);
2598
2599 30880566 dest32[0][i] = av_float2int(float_mult * (float)G);
2600 30880566 dest32[1][i] = av_float2int(float_mult * (float)B);
2601 30880566 dest32[2][i] = av_float2int(float_mult * (float)R);
2602
2/2
✓ Branch 0 taken 1935115 times.
✓ Branch 1 taken 28945451 times.
30880566 if (hasAlpha)
2603 1935115 dest32[3][i] = av_float2int(float_mult * (float)(av_clip_uintp2(A, 30) >> 14));
2604 }
2605
2/2
✓ Branch 1 taken 23056 times.
✓ Branch 2 taken 61971 times.
85027 if ((!isBE(c->opts.dst_format)) != (!HAVE_BIGENDIAN)) {
2606
2/2
✓ Branch 0 taken 8021632 times.
✓ Branch 1 taken 23056 times.
8044688 for (i = 0; i < dstW; i++) {
2607 8021632 dest32[0][i] = av_bswap32(dest32[0][i]);
2608 8021632 dest32[1][i] = av_bswap32(dest32[1][i]);
2609 8021632 dest32[2][i] = av_bswap32(dest32[2][i]);
2610
2/2
✓ Branch 0 taken 57152 times.
✓ Branch 1 taken 7964480 times.
8021632 if (hasAlpha)
2611 57152 dest32[3][i] = av_bswap32(dest32[3][i]);
2612 }
2613 }
2614 85027 }
2615
2616 static void
2617 1152 yuv2ya8_1_c(SwsInternal *c, const int16_t *buf0,
2618 const int16_t *ubuf[2], const int16_t *vbuf[2],
2619 const int16_t *abuf0, uint8_t *dest, int dstW,
2620 int uvalpha, int y)
2621 {
2622 1152 int hasAlpha = !!abuf0;
2623 int i;
2624
2625
2/2
✓ Branch 0 taken 110592 times.
✓ Branch 1 taken 1152 times.
111744 for (i = 0; i < dstW; i++) {
2626 110592 int Y = (buf0[i] + 64) >> 7;
2627 int A;
2628
2629 110592 Y = av_clip_uint8(Y);
2630
2631
1/2
✓ Branch 0 taken 110592 times.
✗ Branch 1 not taken.
110592 if (hasAlpha) {
2632 110592 A = (abuf0[i] + 64) >> 7;
2633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110592 times.
110592 if (A & 0x100)
2634 ✗ A = av_clip_uint8(A);
2635 }
2636
2637 110592 dest[i * 2 ] = Y;
2638
1/2
✓ Branch 0 taken 110592 times.
✗ Branch 1 not taken.
110592 dest[i * 2 + 1] = hasAlpha ? A : 255;
2639 }
2640 1152 }
2641
2642 static void
2643 ✗ yuv2ya8_2_c(SwsInternal *c, const int16_t *buf[2],
2644 const int16_t *ubuf[2], const int16_t *vbuf[2],
2645 const int16_t *abuf[2], uint8_t *dest, int dstW,
2646 int yalpha, int uvalpha, int y)
2647 {
2648 ✗ int hasAlpha = abuf && abuf[0] && abuf[1];
2649 ✗ const int16_t *buf0 = buf[0], *buf1 = buf[1],
2650 ✗ *abuf0 = hasAlpha ? abuf[0] : NULL,
2651 ✗ *abuf1 = hasAlpha ? abuf[1] : NULL;
2652 ✗ int yalpha1 = 4096 - yalpha;
2653 int i;
2654
2655 av_assert2(yalpha <= 4096U);
2656
2657 ✗ for (i = 0; i < dstW; i++) {
2658 ✗ int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2659 int A;
2660
2661 ✗ Y = av_clip_uint8(Y);
2662
2663 ✗ if (hasAlpha) {
2664 ✗ A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2665 ✗ A = av_clip_uint8(A);
2666 }
2667
2668 ✗ dest[i * 2 ] = Y;
2669 ✗ dest[i * 2 + 1] = hasAlpha ? A : 255;
2670 }
2671 ✗ }
2672
2673 static void
2674 9992 yuv2ya8_X_c(SwsInternal *c, const int16_t *lumFilter,
2675 const int16_t **lumSrc, int lumFilterSize,
2676 const int16_t *chrFilter, const int16_t **chrUSrc,
2677 const int16_t **chrVSrc, int chrFilterSize,
2678 const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
2679 {
2680 9992 int hasAlpha = !!alpSrc;
2681 int i;
2682
2683
2/2
✓ Branch 0 taken 3486784 times.
✓ Branch 1 taken 9992 times.
3496776 for (i = 0; i < dstW; i++) {
2684 int j;
2685 3486784 int Y = 1 << 18, A = 1 << 18;
2686
2687
2/2
✓ Branch 0 taken 3926784 times.
✓ Branch 1 taken 3486784 times.
7413568 for (j = 0; j < lumFilterSize; j++)
2688 3926784 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2689
2690 3486784 Y >>= 19;
2691
2/2
✓ Branch 0 taken 19122 times.
✓ Branch 1 taken 3467662 times.
3486784 if (Y & 0x100)
2692 19122 Y = av_clip_uint8(Y);
2693
2694
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 3446784 times.
3486784 if (hasAlpha) {
2695
2/2
✓ Branch 0 taken 480000 times.
✓ Branch 1 taken 40000 times.
520000 for (j = 0; j < lumFilterSize; j++)
2696 480000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2697
2698 40000 A >>= 19;
2699
2700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40000 times.
40000 if (A & 0x100)
2701 ✗ A = av_clip_uint8(A);
2702 }
2703
2704 3486784 dest[2 * i ] = Y;
2705
2/2
✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 3446784 times.
3486784 dest[2 * i + 1] = hasAlpha ? A : 255;
2706 }
2707 9992 }
2708
2709 #define output_pixels(pos, val) \
2710 if (is_be) { \
2711 AV_WB16(pos, val); \
2712 } else { \
2713 AV_WL16(pos, val); \
2714 }
2715
2716 static av_always_inline void
2717 251936 yuv2ayuv64_X_c(SwsInternal *c, const int16_t *lumFilter,
2718 const int16_t **_lumSrc, int lumFilterSize,
2719 const int16_t *chrFilter, const int16_t **_chrUSrc,
2720 const int16_t **_chrVSrc, int chrFilterSize,
2721 const int16_t **_alpSrc, uint8_t *dest, int dstW, int y,
2722 int A_offset, int Y_offset, int U_offset, int V_offset, int is_be)
2723 {
2724 251936 const int32_t **lumSrc = (const int32_t **) _lumSrc,
2725 251936 **chrUSrc = (const int32_t **) _chrUSrc,
2726 251936 **chrVSrc = (const int32_t **) _chrVSrc,
2727 251936 **alpSrc = (const int32_t **) _alpSrc;
2728 251936 int hasAlpha = !!alpSrc;
2729 int i;
2730
2731
2/2
✓ Branch 0 taken 87380224 times.
✓ Branch 1 taken 251936 times.
87632160 for (i = 0; i < dstW; i++) {
2732 87380224 int Y = 1 << 14, U = 1 << 14;
2733 87380224 int V = 1 << 14, A = 1 << 14;
2734 int j;
2735
2736 87380224 Y -= 0x40000000;
2737 87380224 U -= 0x40000000;
2738 87380224 V -= 0x40000000;
2739 87380224 A -= 0x40000000;
2740
2741
2/2
✓ Branch 0 taken 89140224 times.
✓ Branch 1 taken 87380224 times.
176520448 for (j = 0; j < lumFilterSize; j++)
2742 89140224 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2743
2744
2/2
✓ Branch 0 taken 128068608 times.
✓ Branch 1 taken 87380224 times.
215448832 for (j = 0; j < chrFilterSize; j++)
2745 128068608 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2746
2747
2/2
✓ Branch 0 taken 128068608 times.
✓ Branch 1 taken 87380224 times.
215448832 for (j = 0; j < chrFilterSize; j++)
2748 128068608 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2749
2750
2/2
✓ Branch 0 taken 301184 times.
✓ Branch 1 taken 87079040 times.
87380224 if (hasAlpha)
2751
2/2
✓ Branch 0 taken 1181184 times.
✓ Branch 1 taken 301184 times.
1482368 for (j = 0; j < lumFilterSize; j++)
2752 1181184 A += alpSrc[j][i] * (unsigned)lumFilter[j];
2753
2754 87380224 Y = 0x8000 + av_clip_int16(Y >> 15);
2755 87380224 U = 0x8000 + av_clip_int16(U >> 15);
2756 87380224 V = 0x8000 + av_clip_int16(V >> 15);
2757
2/2
✓ Branch 0 taken 301184 times.
✓ Branch 1 taken 87079040 times.
87380224 if (hasAlpha)
2758 301184 A = 0x8000 + av_clip_int16(A >> 15);
2759
2760
6/6
✓ Branch 0 taken 43690112 times.
✓ Branch 1 taken 43690112 times.
✓ Branch 2 taken 150592 times.
✓ Branch 3 taken 43539520 times.
✓ Branch 4 taken 150592 times.
✓ Branch 5 taken 43539520 times.
87380224 output_pixels(dest + 8 * i + A_offset, hasAlpha ? A : 65535);
2761
2/2
✓ Branch 0 taken 43690112 times.
✓ Branch 1 taken 43690112 times.
87380224 output_pixels(dest + 8 * i + Y_offset, Y);
2762
2/2
✓ Branch 0 taken 43690112 times.
✓ Branch 1 taken 43690112 times.
87380224 output_pixels(dest + 8 * i + U_offset, U);
2763
2/2
✓ Branch 0 taken 43690112 times.
✓ Branch 1 taken 43690112 times.
87380224 output_pixels(dest + 8 * i + V_offset, V);
2764 }
2765 251936 }
2766
2767 #define YUV2AYUV64(pixfmt, BE_LE, A, Y, U, V, is_be) \
2768 static void \
2769 yuv2 ## pixfmt ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
2770 const int16_t **lumSrc, int lumFilterSize, \
2771 const int16_t *chrFilter, const int16_t **chrUSrc, \
2772 const int16_t **chrVSrc, int chrFilterSize, \
2773 const int16_t **alpSrc, uint8_t *dest, int dstW, int y) \
2774 { \
2775 yuv2ayuv64_X_c(c, lumFilter, lumSrc, lumFilterSize, \
2776 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2777 alpSrc, dest, dstW, y, A, Y, U, V, is_be); \
2778 }
2779
2780 10568 YUV2AYUV64(ayuv64, le, 0, 2, 4, 6, 0)
2781 10568 YUV2AYUV64(ayuv64, be, 0, 2, 4, 6, 1)
2782
2783 115400 YUV2AYUV64(xv48, le, 6, 2, 0, 4, 0)
2784 115400 YUV2AYUV64(xv48, be, 6, 2, 0, 4, 1)
2785
2786 #undef output_pixels
2787
2788 static av_always_inline void
2789 245172 yuv2v30_X_c_template(SwsInternal *c, const int16_t *lumFilter,
2790 const int16_t **lumSrc, int lumFilterSize,
2791 const int16_t *chrFilter, const int16_t **chrUSrc,
2792 const int16_t **chrVSrc, int chrFilterSize,
2793 const int16_t **alpSrc, uint8_t *dest, int dstW, int y,
2794 int shift)
2795 {
2796 int i;
2797
2/2
✓ Branch 0 taken 85109320 times.
✓ Branch 1 taken 245172 times.
85354492 for (i = 0; i < dstW; i++) {
2798 85109320 int Y = 1 << 16, U = 1 << 16, V = 1 << 16, A = 0x3;
2799 int j;
2800
2801
2/2
✓ Branch 0 taken 85989320 times.
✓ Branch 1 taken 85109320 times.
171098640 for (j = 0; j < lumFilterSize; j++)
2802 85989320 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2803
2804
2/2
✓ Branch 0 taken 120659912 times.
✓ Branch 1 taken 85109320 times.
205769232 for (j = 0; j < chrFilterSize; j++) {
2805 120659912 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2806 120659912 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2807 }
2808
2809 85109320 Y = av_clip_uintp2(Y >> 17, 10);
2810 85109320 U = av_clip_uintp2(U >> 17, 10);
2811 85109320 V = av_clip_uintp2(V >> 17, 10);
2812
2813
2/2
✓ Branch 0 taken 52721160 times.
✓ Branch 1 taken 32388160 times.
85109320 AV_WL32(dest + 4 * i, U << (shift + 0) |
2814 Y << (shift + 10) |
2815 (unsigned)V << (shift + 20) |
2816 (unsigned)A << (shift ? 0 : 30 /* xv30le = 30, v30xle = 0 */));
2817 }
2818 245172 }
2819
2820 #define V30LE_WRAPPER(name, shift) \
2821 static void yuv2 ## name ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
2822 const int16_t **lumSrc, int lumFilterSize, \
2823 const int16_t *chrFilter, const int16_t **chrUSrc, \
2824 const int16_t **chrVSrc, int chrFilterSize, \
2825 const int16_t **alpSrc, uint8_t *dest, int dstW, \
2826 int y) \
2827 { \
2828 yuv2v30_X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
2829 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2830 alpSrc, dest, dstW, y, shift); \
2831 }
2832
2833 92936 V30LE_WRAPPER(xv30le, 0)
2834 152236 V30LE_WRAPPER(v30xle, 2)
2835
2836 #define output_pixels(pos, val, shift, bits, output_shift) \
2837 if (is_be) { \
2838 AV_WB16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \
2839 } else { \
2840 AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \
2841 }
2842
2843 static void
2844 185872 yuv2xv36_X_c(SwsInternal *c, const int16_t *lumFilter,
2845 const int16_t **lumSrc, int lumFilterSize,
2846 const int16_t *chrFilter, const int16_t **chrUSrc,
2847 const int16_t **chrVSrc, int chrFilterSize,
2848 const int16_t **alpSrc, uint8_t *dest, int dstW, int y, int is_be)
2849 {
2850 int i;
2851
2/2
✓ Branch 0 taken 64776320 times.
✓ Branch 1 taken 185872 times.
64962192 for (i = 0; i < dstW; i++) {
2852 64776320 int Y = 1 << 14, U = 1 << 14, V = 1 << 14, A = 65535;
2853 int j;
2854
2855
2/2
✓ Branch 0 taken 65656320 times.
✓ Branch 1 taken 64776320 times.
130432640 for (j = 0; j < lumFilterSize; j++)
2856 65656320 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
2857
2858
2/2
✓ Branch 0 taken 85120512 times.
✓ Branch 1 taken 64776320 times.
149896832 for (j = 0; j < chrFilterSize; j++) {
2859 85120512 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2860 85120512 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2861 }
2862
2863
2/2
✓ Branch 0 taken 32388160 times.
✓ Branch 1 taken 32388160 times.
64776320 output_pixels(dest + 8 * i + 2, Y, 15, 12, 4)
2864
2/2
✓ Branch 0 taken 32388160 times.
✓ Branch 1 taken 32388160 times.
64776320 output_pixels(dest + 8 * i + 0, U, 15, 12, 4)
2865
2/2
✓ Branch 0 taken 32388160 times.
✓ Branch 1 taken 32388160 times.
64776320 output_pixels(dest + 8 * i + 4, V, 15, 12, 4)
2866
2/2
✓ Branch 0 taken 32388160 times.
✓ Branch 1 taken 32388160 times.
64776320 output_pixels(dest + 8 * i + 6, A, 0, 12, 4);
2867 }
2868 185872 }
2869
2870 #undef output_pixels
2871
2872 #define YUV2XV36(BE_LE, is_be) \
2873 static void \
2874 yuv2xv36 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
2875 const int16_t **lumSrc, int lumFilterSize, \
2876 const int16_t *chrFilter, const int16_t **chrUSrc, \
2877 const int16_t **chrVSrc, int chrFilterSize, \
2878 const int16_t **alpSrc, uint8_t *dest, int dstW, int y) \
2879 { \
2880 yuv2xv36_X_c(c, lumFilter, lumSrc, lumFilterSize, \
2881 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
2882 alpSrc, dest, dstW, y, is_be); \
2883 }
2884
2885 92936 YUV2XV36(le, 0)
2886 92936 YUV2XV36(be, 1)
2887
2888 #define output_pixels(pos, A, Y, U, V) \
2889 if (target == AV_PIX_FMT_AYUV) { \
2890 dest[pos + 0] = A; \
2891 dest[pos + 1] = Y; \
2892 dest[pos + 2] = U; \
2893 dest[pos + 3] = V; \
2894 } else if (target == AV_PIX_FMT_UYVA) { \
2895 dest[pos + 0] = U; \
2896 dest[pos + 1] = Y; \
2897 dest[pos + 2] = V; \
2898 dest[pos + 3] = A; \
2899 } else { /* AV_PIX_FMT_VUYA || AV_PIX_FMT_VUYX */ \
2900 dest[pos + 0] = V; \
2901 dest[pos + 1] = U; \
2902 dest[pos + 2] = Y; \
2903 dest[pos + 3] = A; \
2904 }
2905
2906 static av_always_inline void
2907 131876 yuv2ayuv_1_c_template(SwsInternal *c, const int16_t *buf0,
2908 const int16_t *ubuf[2], const int16_t *vbuf[2],
2909 const int16_t *abuf0, uint8_t *dest, int dstW,
2910 int uvalpha, int y, enum AVPixelFormat target)
2911 {
2912 131876 int hasAlpha = !!abuf0;
2913 int i;
2914
2915
1/2
✓ Branch 0 taken 131876 times.
✗ Branch 1 not taken.
131876 if (uvalpha < 2048) {
2916
2/2
✓ Branch 0 taken 44700104 times.
✓ Branch 1 taken 131876 times.
44831980 for (i = 0; i < dstW; i++) {
2917 44700104 int Y = (buf0[i] + 64) >> 7;
2918 44700104 int U = (ubuf[0][i] + 64) >> 7;
2919 44700104 int V = (vbuf[0][i] + 64) >> 7;
2920 44700104 int A = 255;
2921
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44700104 times.
44700104 if (Y & 0x100)
2923 ✗ Y = av_clip_uint8(Y);
2924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44700104 times.
44700104 if (U & 0x100)
2925 ✗ U = av_clip_uint8(U);
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44700104 times.
44700104 if (V & 0x100)
2927 ✗ V = av_clip_uint8(V);
2928
2929
2/2
✓ Branch 0 taken 331776 times.
✓ Branch 1 taken 44368328 times.
44700104 if (hasAlpha) {
2930 331776 A = (abuf0[i] + 64) >> 7;
2931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if (A & 0x100)
2932 ✗ A = av_clip_uint8(A);
2933 }
2934
2935
4/4
✓ Branch 0 taken 110592 times.
✓ Branch 1 taken 44589512 times.
✓ Branch 2 taken 15374792 times.
✓ Branch 3 taken 29214720 times.
44700104 output_pixels(i * 4, A, Y, U, V)
2936 }
2937 } else {
2938 ✗ for (i = 0; i < dstW; i++) {
2939 ✗ int Y = (buf0[i] + 64) >> 7;
2940 ✗ int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8;
2941 ✗ int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8;
2942 ✗ int A = 255;
2943
2944 ✗ if (Y & 0x100)
2945 ✗ Y = av_clip_uint8(Y);
2946 ✗ if (U & 0x100)
2947 ✗ U = av_clip_uint8(U);
2948 ✗ if (V & 0x100)
2949 ✗ V = av_clip_uint8(V);
2950
2951 ✗ if (hasAlpha) {
2952 ✗ A = (abuf0[i] + 64) >> 7;
2953 ✗ if (A & 0x100)
2954 ✗ A = av_clip_uint8(A);
2955 }
2956
2957 ✗ output_pixels(i * 4, A, Y, U, V)
2958 }
2959 }
2960 131876 }
2961
2962 static av_always_inline void
2963 ✗ yuv2ayuv_2_c_template(SwsInternal *c, const int16_t *buf[2],
2964 const int16_t *ubuf[2], const int16_t *vbuf[2],
2965 const int16_t *abuf[2], uint8_t *dest, int dstW,
2966 int yalpha, int uvalpha, int y,
2967 enum AVPixelFormat target)
2968 {
2969 ✗ int hasAlpha = abuf && abuf[0] && abuf[1];
2970 ✗ const int16_t *buf0 = buf[0], *buf1 = buf[1],
2971 ✗ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2972 ✗ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2973 ✗ *abuf0 = hasAlpha ? abuf[0] : NULL,
2974 ✗ *abuf1 = hasAlpha ? abuf[1] : NULL;
2975 ✗ int yalpha1 = 4096 - yalpha;
2976 ✗ int uvalpha1 = 4096 - uvalpha;
2977 int i;
2978
2979 av_assert2(yalpha <= 4096U);
2980 av_assert2(uvalpha <= 4096U);
2981
2982 ✗ for (i = 0; i < dstW; i++) {
2983 ✗ int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2984 ✗ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
2985 ✗ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
2986 ✗ int A = 255;
2987
2988 ✗ if (Y & 0x100)
2989 ✗ Y = av_clip_uint8(Y);
2990 ✗ if (U & 0x100)
2991 ✗ U = av_clip_uint8(U);
2992 ✗ if (V & 0x100)
2993 ✗ V = av_clip_uint8(V);
2994
2995 ✗ if (hasAlpha) {
2996 ✗ A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2997 ✗ A = av_clip_uint8(A);
2998 }
2999
3000 ✗ output_pixels(i * 4, A, Y, U, V)
3001 }
3002 ✗ }
3003
3004 static av_always_inline void
3005 40544 yuv2ayuv_X_c_template(SwsInternal *c, const int16_t *lumFilter,
3006 const int16_t **lumSrc, int lumFilterSize,
3007 const int16_t *chrFilter, const int16_t **chrUSrc,
3008 const int16_t **chrVSrc, int chrFilterSize,
3009 const int16_t **alpSrc, uint8_t *dest, int dstW,
3010 int y, enum AVPixelFormat target)
3011 {
3012 int i;
3013
3014
2/2
✓ Branch 0 taken 14149888 times.
✓ Branch 1 taken 40544 times.
14190432 for (i = 0; i < dstW; i++) {
3015 int j;
3016 14149888 int Y = 1 << 18, U = 1 << 18;
3017 14149888 int V = 1 << 18, A = 255;
3018
3019
2/2
✓ Branch 0 taken 15909888 times.
✓ Branch 1 taken 14149888 times.
30059776 for (j = 0; j < lumFilterSize; j++)
3020 15909888 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
3021
3022
2/2
✓ Branch 0 taken 57879552 times.
✓ Branch 1 taken 14149888 times.
72029440 for (j = 0; j < chrFilterSize; j++)
3023 57879552 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
3024
3025
2/2
✓ Branch 0 taken 57879552 times.
✓ Branch 1 taken 14149888 times.
72029440 for (j = 0; j < chrFilterSize; j++)
3026 57879552 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
3027
3028 14149888 Y >>= 19;
3029 14149888 U >>= 19;
3030 14149888 V >>= 19;
3031
3032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14149888 times.
14149888 if (Y & 0x100)
3033 ✗ Y = av_clip_uint8(Y);
3034
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 14149328 times.
14149888 if (U & 0x100)
3035 560 U = av_clip_uint8(U);
3036
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 14149880 times.
14149888 if (V & 0x100)
3037 8 V = av_clip_uint8(V);
3038
3039
2/2
✓ Branch 0 taken 120000 times.
✓ Branch 1 taken 14029888 times.
14149888 if (alpSrc) {
3040 120000 A = 1 << 18;
3041
3042
2/2
✓ Branch 0 taken 1440000 times.
✓ Branch 1 taken 120000 times.
1560000 for (j = 0; j < lumFilterSize; j++)
3043 1440000 A += alpSrc[j][i] * (unsigned)lumFilter[j];
3044
3045 120000 A >>= 19;
3046
3047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120000 times.
120000 if (A & 0x100)
3048 ✗ A = av_clip_uint8(A);
3049 }
3050
3051
4/4
✓ Branch 0 taken 3486784 times.
✓ Branch 1 taken 10663104 times.
✓ Branch 2 taken 3486784 times.
✓ Branch 3 taken 7176320 times.
14149888 output_pixels(i * 4, A, Y, U, V)
3052 }
3053 40544 }
3054
3055 #undef output_pixels
3056
3057 #define AYUVPACKEDWRAPPER(name, fmt) \
3058 static void yuv2 ## name ## _X_c(SwsInternal *c, const int16_t *lumFilter, \
3059 const int16_t **lumSrc, int lumFilterSize, \
3060 const int16_t *chrFilter, const int16_t **chrUSrc, \
3061 const int16_t **chrVSrc, int chrFilterSize, \
3062 const int16_t **alpSrc, uint8_t *dest, int dstW, \
3063 int y) \
3064 { \
3065 yuv2ayuv_X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
3066 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
3067 alpSrc, dest, dstW, y, fmt); \
3068 } \
3069 \
3070 static void yuv2 ## name ## _2_c(SwsInternal *c, const int16_t *buf[2], \
3071 const int16_t *ubuf[2], const int16_t *vbuf[2], \
3072 const int16_t *abuf[2], uint8_t *dest, int dstW, \
3073 int yalpha, int uvalpha, int y) \
3074 { \
3075 yuv2ayuv_2_c_template(c, buf, ubuf, vbuf, abuf, \
3076 dest, dstW, yalpha, uvalpha, y, fmt); \
3077 } \
3078 \
3079 static void yuv2 ## name ## _1_c(SwsInternal *c, const int16_t *buf0, \
3080 const int16_t *ubuf[2], const int16_t *vbuf[2], \
3081 const int16_t *abuf0, uint8_t *dest, int dstW, \
3082 int uvalpha, int y) \
3083 { \
3084 yuv2ayuv_1_c_template(c, buf0, ubuf, vbuf, \
3085 abuf0, dest, dstW, uvalpha, \
3086 y, fmt); \
3087 }
3088
3089 210464 AYUVPACKEDWRAPPER(vuyX, AV_PIX_FMT_VUYX)
3090 22288 AYUVPACKEDWRAPPER(ayuv, AV_PIX_FMT_AYUV)
3091 112088 AYUVPACKEDWRAPPER(uyva, AV_PIX_FMT_UYVA)
3092
3093 #define output_pixel(pos, val, bits) \
3094 AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
3095
3096 #define yuv2y2xx_wrapper(bits) \
3097 static void \
3098 yuv2y2 ## bits ## le_X_c(SwsInternal *c, const int16_t *lumFilter, \
3099 const int16_t **lumSrc, int lumFilterSize, \
3100 const int16_t *chrFilter, \
3101 const int16_t **chrUSrc, \
3102 const int16_t **chrVSrc, int chrFilterSize, \
3103 const int16_t **alpSrc, \
3104 uint8_t *dest, int dstW, int y) \
3105 { \
3106 int i, j; \
3107 int shift = 11 + 16 - bits; \
3108 int output_shift = 16 - bits; \
3109 for (i = 0; i < ((dstW + 1) >> 1); i++) { \
3110 int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1); \
3111 int U = 1 << (shift - 1), V = 1 << (shift - 1); \
3112 \
3113 for (j = 0; j < lumFilterSize; j++) { \
3114 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j]; \
3115 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j]; \
3116 } \
3117 \
3118 for (j = 0; j < chrFilterSize; j++) { \
3119 U += chrUSrc[j][i] * (unsigned)chrFilter[j]; \
3120 V += chrVSrc[j][i] * (unsigned)chrFilter[j]; \
3121 } \
3122 \
3123 output_pixel(dest + 8 * i + 0, Y1, bits); \
3124 output_pixel(dest + 8 * i + 2, U, bits); \
3125 output_pixel(dest + 8 * i + 4, Y2, bits); \
3126 output_pixel(dest + 8 * i + 6, V, bits); \
3127 } \
3128 }
3129
3130
6/6
✓ Branch 0 taken 16054656 times.
✓ Branch 1 taken 15834656 times.
✓ Branch 2 taken 20008320 times.
✓ Branch 3 taken 15834656 times.
✓ Branch 4 taken 15834656 times.
✓ Branch 5 taken 90056 times.
51987688 yuv2y2xx_wrapper(10)
3131
6/6
✓ Branch 0 taken 16054656 times.
✓ Branch 1 taken 15834656 times.
✓ Branch 2 taken 20008320 times.
✓ Branch 3 taken 15834656 times.
✓ Branch 4 taken 15834656 times.
✓ Branch 5 taken 90056 times.
51987688 yuv2y2xx_wrapper(12)
3132
3133 static void
3134 112520 yuv2y216le_X_c(SwsInternal *c, const int16_t *lumFilter,
3135 const int16_t **_lumSrc, int lumFilterSize,
3136 const int16_t *chrFilter,
3137 const int16_t **_chrUSrc,
3138 const int16_t **_chrVSrc, int chrFilterSize,
3139 const int16_t **_alpSrc,
3140 uint8_t *dest, int dstW, int y)
3141 {
3142 112520 const int32_t **lumSrc = (const int32_t **)_lumSrc;
3143 112520 const int32_t **chrUSrc = (const int32_t **)_chrUSrc;
3144 112520 const int32_t **chrVSrc = (const int32_t **)_chrVSrc;
3145 112520 int shift = 15;
3146
3147
2/2
✓ Branch 0 taken 19788320 times.
✓ Branch 1 taken 112520 times.
19900840 for (int i = 0; i < ((dstW + 1) >> 1); i++) {
3148 19788320 int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1);
3149 19788320 int U = 1 << (shift - 1), V = 1 << (shift - 1);
3150
3151 /* See yuv2planeX_16_c_template for details. */
3152 19788320 Y1 -= 0x40000000;
3153 19788320 U -= 0x40000000;
3154 19788320 Y2 -= 0x40000000;
3155 19788320 V -= 0x40000000;
3156
3157
2/2
✓ Branch 0 taken 20008320 times.
✓ Branch 1 taken 19788320 times.
39796640 for (int j = 0; j < lumFilterSize; j++) {
3158 20008320 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
3159 20008320 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
3160 }
3161
3162
2/2
✓ Branch 0 taken 23961984 times.
✓ Branch 1 taken 19788320 times.
43750304 for (int j = 0; j < chrFilterSize; j++) {
3163 23961984 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
3164 23961984 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
3165 }
3166
3167 19788320 AV_WL16(dest + 8 * i + 0, 0x8000 + av_clip_int16(Y1 >> shift));
3168 19788320 AV_WL16(dest + 8 * i + 2, 0x8000 + av_clip_int16(U >> shift));
3169 19788320 AV_WL16(dest + 8 * i + 4, 0x8000 + av_clip_int16(Y2 >> shift));
3170 19788320 AV_WL16(dest + 8 * i + 6, 0x8000 + av_clip_int16(V >> shift));
3171 }
3172 112520 }
3173
3174 static void
3175 128420 yuv2vyu444_1_c(SwsInternal *c, const int16_t *buf0,
3176 const int16_t *ubuf[2], const int16_t *vbuf[2],
3177 const int16_t *abuf0, uint8_t *dest, int dstW,
3178 int uvalpha, int y)
3179 {
3180 int i;
3181
3182
1/2
✓ Branch 0 taken 128420 times.
✗ Branch 1 not taken.
128420 if (uvalpha < 2048) {
3183
2/2
✓ Branch 0 taken 44368328 times.
✓ Branch 1 taken 128420 times.
44496748 for (i = 0; i < dstW; i++) {
3184 44368328 int Y = (buf0[i] + 64) >> 7;
3185 44368328 int U = (ubuf[0][i] + 64) >> 7;
3186 44368328 int V = (vbuf[0][i] + 64) >> 7;
3187
3188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44368328 times.
44368328 if (Y & 0x100)
3189 ✗ Y = av_clip_uint8(Y);
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44368328 times.
44368328 if (U & 0x100)
3191 ✗ U = av_clip_uint8(U);
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44368328 times.
44368328 if (V & 0x100)
3193 ✗ V = av_clip_uint8(V);
3194
3195 44368328 dest[3 * i ] = V;
3196 44368328 dest[3 * i + 1] = Y;
3197 44368328 dest[3 * i + 2] = U;
3198 }
3199 } else {
3200 ✗ for (i = 0; i < dstW; i++) {
3201 ✗ int Y = (buf0[i] + 64) >> 7;
3202 ✗ int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8;
3203 ✗ int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8;
3204
3205 ✗ if (Y & 0x100)
3206 ✗ Y = av_clip_uint8(Y);
3207 ✗ if (U & 0x100)
3208 ✗ U = av_clip_uint8(U);
3209 ✗ if (V & 0x100)
3210 ✗ V = av_clip_uint8(V);
3211
3212 ✗ dest[3 * i ] = V;
3213 ✗ dest[3 * i + 1] = Y;
3214 ✗ dest[3 * i + 2] = U;
3215 }
3216 }
3217 128420 }
3218
3219 static void
3220 ✗ yuv2vyu444_2_c(SwsInternal *c, const int16_t *buf[2],
3221 const int16_t *ubuf[2], const int16_t *vbuf[2],
3222 const int16_t *abuf[2], uint8_t *dest, int dstW,
3223 int yalpha, int uvalpha, int y)
3224 {
3225 ✗ const int16_t *buf0 = buf[0], *buf1 = buf[1],
3226 ✗ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
3227 ✗ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
3228 ✗ int yalpha1 = 4096 - yalpha;
3229 ✗ int uvalpha1 = 4096 - uvalpha;
3230 int i;
3231
3232 av_assert2(yalpha <= 4096U);
3233 av_assert2(uvalpha <= 4096U);
3234
3235 ✗ for (i = 0; i < dstW; i++) {
3236 ✗ int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
3237 ✗ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
3238 ✗ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
3239
3240 ✗ if (Y & 0x100)
3241 ✗ Y = av_clip_uint8(Y);
3242 ✗ if (U & 0x100)
3243 ✗ U = av_clip_uint8(U);
3244 ✗ if (V & 0x100)
3245 ✗ V = av_clip_uint8(V);
3246
3247 ✗ dest[3 * i ] = V;
3248 ✗ dest[3 * i + 1] = Y;
3249 ✗ dest[3 * i + 2] = U;
3250 }
3251 ✗ }
3252
3253 static void
3254 10568 yuv2vyu444_X_c(SwsInternal *c, const int16_t *lumFilter,
3255 const int16_t **lumSrc, int lumFilterSize,
3256 const int16_t *chrFilter, const int16_t **chrUSrc,
3257 const int16_t **chrVSrc, int chrFilterSize,
3258 const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
3259 {
3260 int i;
3261
3262
2/2
✓ Branch 0 taken 3689536 times.
✓ Branch 1 taken 10568 times.
3700104 for (i = 0; i < dstW; i++) {
3263 int j;
3264 3689536 int Y = 1 << 18, U = 1 << 18;
3265 3689536 int V = 1 << 18;
3266
3267
2/2
✓ Branch 0 taken 4129536 times.
✓ Branch 1 taken 3689536 times.
7819072 for (j = 0; j < lumFilterSize; j++)
3268 4129536 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
3269
3270
2/2
✓ Branch 0 taken 15078144 times.
✓ Branch 1 taken 3689536 times.
18767680 for (j = 0; j < chrFilterSize; j++)
3271 15078144 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
3272
3273
2/2
✓ Branch 0 taken 15078144 times.
✓ Branch 1 taken 3689536 times.
18767680 for (j = 0; j < chrFilterSize; j++)
3274 15078144 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
3275
3276 3689536 Y >>= 19;
3277 3689536 U >>= 19;
3278 3689536 V >>= 19;
3279
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3689536 times.
3689536 if (Y & 0x100)
3281 ✗ Y = av_clip_uint8(Y);
3282
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 3689390 times.
3689536 if (U & 0x100)
3283 146 U = av_clip_uint8(U);
3284
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3689534 times.
3689536 if (V & 0x100)
3285 2 V = av_clip_uint8(V);
3286
3287 3689536 dest[3 * i ] = V;
3288 3689536 dest[3 * i + 1] = Y;
3289 3689536 dest[3 * i + 2] = U;
3290 }
3291 10568 }
3292
3293 #undef output_pixel
3294
3295 576820 av_cold void ff_sws_init_output_funcs(SwsInternal *c,
3296 yuv2planar1_fn *yuv2plane1,
3297 yuv2planarX_fn *yuv2planeX,
3298 yuv2interleavedX_fn *yuv2nv12cX,
3299 yuv2packed1_fn *yuv2packed1,
3300 yuv2packed2_fn *yuv2packed2,
3301 yuv2packedX_fn *yuv2packedX,
3302 yuv2anyX_fn *yuv2anyX)
3303 {
3304 576820 enum AVPixelFormat dstFormat = c->opts.dst_format;
3305 576820 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
3306
3307
4/4
✓ Branch 1 taken 33137 times.
✓ Branch 2 taken 543683 times.
✓ Branch 4 taken 19238 times.
✓ Branch 5 taken 13899 times.
576820 if (isSemiPlanarYUV(dstFormat) && isDataInHighBits(dstFormat)) {
3308
2/2
✓ Branch 0 taken 9581 times.
✓ Branch 1 taken 9657 times.
19238 if (desc->comp[0].depth == 10) {
3309
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7488 times.
9581 *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c;
3310
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7488 times.
9581 *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c;
3311
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7488 times.
9581 *yuv2nv12cX = isBE(dstFormat) ? yuv2p010cX_BE_c : yuv2p010cX_LE_c;
3312
1/2
✓ Branch 0 taken 9657 times.
✗ Branch 1 not taken.
9657 } else if (desc->comp[0].depth == 12) {
3313
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7564 times.
9657 *yuv2plane1 = isBE(dstFormat) ? yuv2p012l1_BE_c : yuv2p012l1_LE_c;
3314
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7564 times.
9657 *yuv2planeX = isBE(dstFormat) ? yuv2p012lX_BE_c : yuv2p012lX_LE_c;
3315
2/2
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 7564 times.
9657 *yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c;
3316 } else
3317 ✗ av_assert0(0);
3318
4/4
✓ Branch 1 taken 13899 times.
✓ Branch 2 taken 543683 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 13742 times.
557582 } else if (isSemiPlanarYUV(dstFormat) && isNBPS(dstFormat)) {
3319
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if (desc->comp[0].depth == 10) {
3320
2/2
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 81 times.
157 *yuv2plane1 = isBE(dstFormat) ? yuv2nv20l1_BE_c : yuv2nv20l1_LE_c;
3321
2/2
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 81 times.
157 *yuv2planeX = isBE(dstFormat) ? yuv2nv20lX_BE_c : yuv2nv20lX_LE_c;
3322
2/2
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 81 times.
157 *yuv2nv12cX = isBE(dstFormat) ? yuv2nv20cX_BE_c : yuv2nv20cX_LE_c;
3323 } else
3324 ✗ av_assert0(0);
3325
2/2
✓ Branch 1 taken 37111 times.
✓ Branch 2 taken 520314 times.
557425 } else if (is16BPS(dstFormat)) {
3326
2/2
✓ Branch 1 taken 10195 times.
✓ Branch 2 taken 26916 times.
37111 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
3327
2/2
✓ Branch 1 taken 10195 times.
✓ Branch 2 taken 26916 times.
37111 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
3328
2/2
✓ Branch 1 taken 6233 times.
✓ Branch 2 taken 30878 times.
37111 if (isSemiPlanarYUV(dstFormat)) {
3329
2/2
✓ Branch 1 taken 2589 times.
✓ Branch 2 taken 3644 times.
6233 *yuv2nv12cX = isBE(dstFormat) ? yuv2nv12cX_16BE_c : yuv2nv12cX_16LE_c;
3330 }
3331
3/4
✓ Branch 1 taken 5902 times.
✓ Branch 2 taken 514412 times.
✓ Branch 4 taken 5902 times.
✗ Branch 5 not taken.
520314 } else if (isDataInHighBits(dstFormat) && isNBPS(dstFormat)) {
3332
2/2
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 3750 times.
5902 if (desc->comp[0].depth == 10) {
3333
2/2
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 1458 times.
2152 *yuv2planeX = isBE(dstFormat) ? yuv2msbplaneX_10BE_c : yuv2msbplaneX_10LE_c;
3334
2/2
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 1458 times.
2152 *yuv2plane1 = isBE(dstFormat) ? yuv2msbplane1_10BE_c : yuv2msbplane1_10LE_c;
3335
1/2
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
3750 } else if (desc->comp[0].depth == 12) {
3336
2/2
✓ Branch 1 taken 1493 times.
✓ Branch 2 taken 2257 times.
3750 *yuv2planeX = isBE(dstFormat) ? yuv2msbplaneX_12BE_c : yuv2msbplaneX_12LE_c;
3337
2/2
✓ Branch 1 taken 1493 times.
✓ Branch 2 taken 2257 times.
3750 *yuv2plane1 = isBE(dstFormat) ? yuv2msbplane1_12BE_c : yuv2msbplane1_12LE_c;
3338 } else
3339 ✗ av_assert0(0);
3340
2/2
✓ Branch 1 taken 57288 times.
✓ Branch 2 taken 457124 times.
514412 } else if (isNBPS(dstFormat)) {
3341
2/2
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 55282 times.
57288 if (desc->comp[0].depth == 9) {
3342
2/2
✓ Branch 1 taken 942 times.
✓ Branch 2 taken 1064 times.
2006 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
3343
2/2
✓ Branch 1 taken 942 times.
✓ Branch 2 taken 1064 times.
2006 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
3344
2/2
✓ Branch 0 taken 31444 times.
✓ Branch 1 taken 23838 times.
55282 } else if (desc->comp[0].depth == 10) {
3345
2/2
✓ Branch 1 taken 5253 times.
✓ Branch 2 taken 26191 times.
31444 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
3346
2/2
✓ Branch 1 taken 5253 times.
✓ Branch 2 taken 26191 times.
31444 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
3347
2/2
✓ Branch 0 taken 21957 times.
✓ Branch 1 taken 1881 times.
23838 } else if (desc->comp[0].depth == 12) {
3348
2/2
✓ Branch 1 taken 5248 times.
✓ Branch 2 taken 16709 times.
21957 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
3349
2/2
✓ Branch 1 taken 5248 times.
✓ Branch 2 taken 16709 times.
21957 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
3350
1/2
✓ Branch 0 taken 1881 times.
✗ Branch 1 not taken.
1881 } else if (desc->comp[0].depth == 14) {
3351
2/2
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 994 times.
1881 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
3352
2/2
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 994 times.
1881 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
3353 } else
3354 ✗ av_assert0(0);
3355
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 457014 times.
457124 } else if (dstFormat == AV_PIX_FMT_GRAYF32BE) {
3356 110 *yuv2planeX = yuv2planeX_floatBE_c;
3357 110 *yuv2plane1 = yuv2plane1_floatBE_c;
3358
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 456766 times.
457014 } else if (dstFormat == AV_PIX_FMT_GRAYF32LE) {
3359 248 *yuv2planeX = yuv2planeX_floatLE_c;
3360 248 *yuv2plane1 = yuv2plane1_floatLE_c;
3361 } else {
3362 456766 *yuv2plane1 = yuv2plane1_8_c;
3363 456766 *yuv2planeX = yuv2planeX_8_c;
3364
2/2
✓ Branch 1 taken 7509 times.
✓ Branch 2 taken 449257 times.
456766 if (isSemiPlanarYUV(dstFormat))
3365 7509 *yuv2nv12cX = yuv2nv12cX_c;
3366 }
3367
3368
2/2
✓ Branch 0 taken 525258 times.
✓ Branch 1 taken 51562 times.
576820 if(c->opts.flags & SWS_FULL_CHR_H_INT) {
3369
24/25
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 1716 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 41 times.
✓ Branch 8 taken 3982 times.
✓ Branch 9 taken 1416 times.
✓ Branch 10 taken 3707 times.
✓ Branch 11 taken 44 times.
✓ Branch 12 taken 46 times.
✓ Branch 13 taken 41 times.
✓ Branch 14 taken 388 times.
✓ Branch 15 taken 388 times.
✓ Branch 16 taken 740 times.
✓ Branch 17 taken 439 times.
✓ Branch 18 taken 599 times.
✓ Branch 19 taken 599 times.
✓ Branch 20 taken 29421 times.
✓ Branch 21 taken 484 times.
✓ Branch 22 taken 4526 times.
✓ Branch 23 taken 2592 times.
✗ Branch 24 not taken.
51562 switch (dstFormat) {
3370 88 case AV_PIX_FMT_RGBA:
3371 #if CONFIG_SMALL
3372 *yuv2packedX = yuv2rgba32_full_X_c;
3373 *yuv2packed2 = yuv2rgba32_full_2_c;
3374 *yuv2packed1 = yuv2rgba32_full_1_c;
3375 #else
3376 #if CONFIG_SWSCALE_ALPHA
3377
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 6 times.
88 if (c->needAlpha) {
3378 82 *yuv2packedX = yuv2rgba32_full_X_c;
3379 82 *yuv2packed2 = yuv2rgba32_full_2_c;
3380 82 *yuv2packed1 = yuv2rgba32_full_1_c;
3381 } else
3382 #endif /* CONFIG_SWSCALE_ALPHA */
3383 {
3384 6 *yuv2packedX = yuv2rgbx32_full_X_c;
3385 6 *yuv2packed2 = yuv2rgbx32_full_2_c;
3386 6 *yuv2packed1 = yuv2rgbx32_full_1_c;
3387 }
3388 #endif /* !CONFIG_SMALL */
3389 88 break;
3390 88 case AV_PIX_FMT_ARGB:
3391 #if CONFIG_SMALL
3392 *yuv2packedX = yuv2argb32_full_X_c;
3393 *yuv2packed2 = yuv2argb32_full_2_c;
3394 *yuv2packed1 = yuv2argb32_full_1_c;
3395 #else
3396 #if CONFIG_SWSCALE_ALPHA
3397
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 6 times.
88 if (c->needAlpha) {
3398 82 *yuv2packedX = yuv2argb32_full_X_c;
3399 82 *yuv2packed2 = yuv2argb32_full_2_c;
3400 82 *yuv2packed1 = yuv2argb32_full_1_c;
3401 } else
3402 #endif /* CONFIG_SWSCALE_ALPHA */
3403 {
3404 6 *yuv2packedX = yuv2xrgb32_full_X_c;
3405 6 *yuv2packed2 = yuv2xrgb32_full_2_c;
3406 6 *yuv2packed1 = yuv2xrgb32_full_1_c;
3407 }
3408 #endif /* !CONFIG_SMALL */
3409 88 break;
3410 1716 case AV_PIX_FMT_BGRA:
3411 #if CONFIG_SMALL
3412 *yuv2packedX = yuv2bgra32_full_X_c;
3413 *yuv2packed2 = yuv2bgra32_full_2_c;
3414 *yuv2packed1 = yuv2bgra32_full_1_c;
3415 #else
3416 #if CONFIG_SWSCALE_ALPHA
3417
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1538 times.
1716 if (c->needAlpha) {
3418 178 *yuv2packedX = yuv2bgra32_full_X_c;
3419 178 *yuv2packed2 = yuv2bgra32_full_2_c;
3420 178 *yuv2packed1 = yuv2bgra32_full_1_c;
3421 } else
3422 #endif /* CONFIG_SWSCALE_ALPHA */
3423 {
3424 1538 *yuv2packedX = yuv2bgrx32_full_X_c;
3425 1538 *yuv2packed2 = yuv2bgrx32_full_2_c;
3426 1538 *yuv2packed1 = yuv2bgrx32_full_1_c;
3427 }
3428 #endif /* !CONFIG_SMALL */
3429 1716 break;
3430 88 case AV_PIX_FMT_ABGR:
3431 #if CONFIG_SMALL
3432 *yuv2packedX = yuv2abgr32_full_X_c;
3433 *yuv2packed2 = yuv2abgr32_full_2_c;
3434 *yuv2packed1 = yuv2abgr32_full_1_c;
3435 #else
3436 #if CONFIG_SWSCALE_ALPHA
3437
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 6 times.
88 if (c->needAlpha) {
3438 82 *yuv2packedX = yuv2abgr32_full_X_c;
3439 82 *yuv2packed2 = yuv2abgr32_full_2_c;
3440 82 *yuv2packed1 = yuv2abgr32_full_1_c;
3441 } else
3442 #endif /* CONFIG_SWSCALE_ALPHA */
3443 {
3444 6 *yuv2packedX = yuv2xbgr32_full_X_c;
3445 6 *yuv2packed2 = yuv2xbgr32_full_2_c;
3446 6 *yuv2packed1 = yuv2xbgr32_full_1_c;
3447 }
3448 #endif /* !CONFIG_SMALL */
3449 88 break;
3450 44 case AV_PIX_FMT_RGBA64LE:
3451 #if CONFIG_SWSCALE_ALPHA
3452
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (c->needAlpha) {
3453 41 *yuv2packedX = yuv2rgba64le_full_X_c;
3454 41 *yuv2packed2 = yuv2rgba64le_full_2_c;
3455 41 *yuv2packed1 = yuv2rgba64le_full_1_c;
3456 } else
3457 #endif /* CONFIG_SWSCALE_ALPHA */
3458 {
3459 3 *yuv2packedX = yuv2rgbx64le_full_X_c;
3460 3 *yuv2packed2 = yuv2rgbx64le_full_2_c;
3461 3 *yuv2packed1 = yuv2rgbx64le_full_1_c;
3462 }
3463 44 break;
3464 41 case AV_PIX_FMT_RGBA64BE:
3465 #if CONFIG_SWSCALE_ALPHA
3466
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if (c->needAlpha) {
3467 41 *yuv2packedX = yuv2rgba64be_full_X_c;
3468 41 *yuv2packed2 = yuv2rgba64be_full_2_c;
3469 41 *yuv2packed1 = yuv2rgba64be_full_1_c;
3470 } else
3471 #endif /* CONFIG_SWSCALE_ALPHA */
3472 {
3473 ✗ *yuv2packedX = yuv2rgbx64be_full_X_c;
3474 ✗ *yuv2packed2 = yuv2rgbx64be_full_2_c;
3475 ✗ *yuv2packed1 = yuv2rgbx64be_full_1_c;
3476 }
3477 41 break;
3478 44 case AV_PIX_FMT_BGRA64LE:
3479 #if CONFIG_SWSCALE_ALPHA
3480
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (c->needAlpha) {
3481 41 *yuv2packedX = yuv2bgra64le_full_X_c;
3482 41 *yuv2packed2 = yuv2bgra64le_full_2_c;
3483 41 *yuv2packed1 = yuv2bgra64le_full_1_c;
3484 } else
3485 #endif /* CONFIG_SWSCALE_ALPHA */
3486 {
3487 3 *yuv2packedX = yuv2bgrx64le_full_X_c;
3488 3 *yuv2packed2 = yuv2bgrx64le_full_2_c;
3489 3 *yuv2packed1 = yuv2bgrx64le_full_1_c;
3490 }
3491 44 break;
3492 41 case AV_PIX_FMT_BGRA64BE:
3493 #if CONFIG_SWSCALE_ALPHA
3494
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if (c->needAlpha) {
3495 41 *yuv2packedX = yuv2bgra64be_full_X_c;
3496 41 *yuv2packed2 = yuv2bgra64be_full_2_c;
3497 41 *yuv2packed1 = yuv2bgra64be_full_1_c;
3498 } else
3499 #endif /* CONFIG_SWSCALE_ALPHA */
3500 {
3501 ✗ *yuv2packedX = yuv2bgrx64be_full_X_c;
3502 ✗ *yuv2packed2 = yuv2bgrx64be_full_2_c;
3503 ✗ *yuv2packed1 = yuv2bgrx64be_full_1_c;
3504 }
3505 41 break;
3506
3507 3982 case AV_PIX_FMT_RGB24:
3508 3982 *yuv2packedX = yuv2rgb24_full_X_c;
3509 3982 *yuv2packed2 = yuv2rgb24_full_2_c;
3510 3982 *yuv2packed1 = yuv2rgb24_full_1_c;
3511 3982 break;
3512 1416 case AV_PIX_FMT_BGR24:
3513 1416 *yuv2packedX = yuv2bgr24_full_X_c;
3514 1416 *yuv2packed2 = yuv2bgr24_full_2_c;
3515 1416 *yuv2packed1 = yuv2bgr24_full_1_c;
3516 1416 break;
3517 3707 case AV_PIX_FMT_RGB48LE:
3518 3707 *yuv2packedX = yuv2rgb48le_full_X_c;
3519 3707 *yuv2packed2 = yuv2rgb48le_full_2_c;
3520 3707 *yuv2packed1 = yuv2rgb48le_full_1_c;
3521 3707 break;
3522 44 case AV_PIX_FMT_BGR48LE:
3523 44 *yuv2packedX = yuv2bgr48le_full_X_c;
3524 44 *yuv2packed2 = yuv2bgr48le_full_2_c;
3525 44 *yuv2packed1 = yuv2bgr48le_full_1_c;
3526 44 break;
3527 46 case AV_PIX_FMT_RGB48BE:
3528 46 *yuv2packedX = yuv2rgb48be_full_X_c;
3529 46 *yuv2packed2 = yuv2rgb48be_full_2_c;
3530 46 *yuv2packed1 = yuv2rgb48be_full_1_c;
3531 46 break;
3532 41 case AV_PIX_FMT_BGR48BE:
3533 41 *yuv2packedX = yuv2bgr48be_full_X_c;
3534 41 *yuv2packed2 = yuv2bgr48be_full_2_c;
3535 41 *yuv2packed1 = yuv2bgr48be_full_1_c;
3536 41 break;
3537 388 case AV_PIX_FMT_BGR4_BYTE:
3538 388 *yuv2packedX = yuv2bgr4_byte_full_X_c;
3539 388 *yuv2packed2 = yuv2bgr4_byte_full_2_c;
3540 388 *yuv2packed1 = yuv2bgr4_byte_full_1_c;
3541 388 break;
3542 388 case AV_PIX_FMT_RGB4_BYTE:
3543 388 *yuv2packedX = yuv2rgb4_byte_full_X_c;
3544 388 *yuv2packed2 = yuv2rgb4_byte_full_2_c;
3545 388 *yuv2packed1 = yuv2rgb4_byte_full_1_c;
3546 388 break;
3547 740 case AV_PIX_FMT_BGR8:
3548 740 *yuv2packedX = yuv2bgr8_full_X_c;
3549 740 *yuv2packed2 = yuv2bgr8_full_2_c;
3550 740 *yuv2packed1 = yuv2bgr8_full_1_c;
3551 740 break;
3552 439 case AV_PIX_FMT_RGB8:
3553 439 *yuv2packedX = yuv2rgb8_full_X_c;
3554 439 *yuv2packed2 = yuv2rgb8_full_2_c;
3555 439 *yuv2packed1 = yuv2rgb8_full_1_c;
3556 439 break;
3557 599 case AV_PIX_FMT_X2RGB10LE:
3558 599 *yuv2packedX = yuv2x2rgb10_full_X_c;
3559 599 *yuv2packed2 = yuv2x2rgb10_full_2_c;
3560 599 *yuv2packed1 = yuv2x2rgb10_full_1_c;
3561 599 break;
3562 599 case AV_PIX_FMT_X2BGR10LE:
3563 599 *yuv2packedX = yuv2x2bgr10_full_X_c;
3564 599 *yuv2packed2 = yuv2x2bgr10_full_2_c;
3565 599 *yuv2packed1 = yuv2x2bgr10_full_1_c;
3566 599 break;
3567 29421 case AV_PIX_FMT_GBRP:
3568 case AV_PIX_FMT_GBRP9BE:
3569 case AV_PIX_FMT_GBRP9LE:
3570 case AV_PIX_FMT_GBRP10BE:
3571 case AV_PIX_FMT_GBRP10LE:
3572 case AV_PIX_FMT_GBRP12BE:
3573 case AV_PIX_FMT_GBRP12LE:
3574 case AV_PIX_FMT_GBRP14BE:
3575 case AV_PIX_FMT_GBRP14LE:
3576 case AV_PIX_FMT_GBRAP:
3577 case AV_PIX_FMT_GBRAP10BE:
3578 case AV_PIX_FMT_GBRAP10LE:
3579 case AV_PIX_FMT_GBRAP12BE:
3580 case AV_PIX_FMT_GBRAP12LE:
3581 case AV_PIX_FMT_GBRAP14BE:
3582 case AV_PIX_FMT_GBRAP14LE:
3583 29421 *yuv2anyX = yuv2gbrp_full_X_c;
3584 29421 break;
3585 484 case AV_PIX_FMT_GBRP10MSBBE:
3586 case AV_PIX_FMT_GBRP10MSBLE:
3587 case AV_PIX_FMT_GBRP12MSBBE:
3588 case AV_PIX_FMT_GBRP12MSBLE:
3589 484 *yuv2anyX = yuv2gbrpmsb_full_X_c;
3590 484 break;
3591 4526 case AV_PIX_FMT_GBRP16BE:
3592 case AV_PIX_FMT_GBRP16LE:
3593 case AV_PIX_FMT_GBRAP16BE:
3594 case AV_PIX_FMT_GBRAP16LE:
3595 4526 *yuv2anyX = yuv2gbrp16_full_X_c;
3596 4526 break;
3597 2592 case AV_PIX_FMT_GBRPF32BE:
3598 case AV_PIX_FMT_GBRPF32LE:
3599 case AV_PIX_FMT_GBRAPF32BE:
3600 case AV_PIX_FMT_GBRAPF32LE:
3601 2592 *yuv2anyX = yuv2gbrpf32_full_X_c;
3602 2592 break;
3603 }
3604
3/4
✓ Branch 0 taken 37023 times.
✓ Branch 1 taken 14539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37023 times.
51562 if (!*yuv2packedX && !*yuv2anyX)
3605 ✗ goto YUV_PACKED;
3606 } else {
3607 525258 YUV_PACKED:
3608
21/21
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 3550 times.
✓ Branch 5 taken 252 times.
✓ Branch 6 taken 123 times.
✓ Branch 7 taken 118 times.
✓ Branch 8 taken 5458 times.
✓ Branch 9 taken 4534 times.
✓ Branch 10 taken 8457 times.
✓ Branch 11 taken 3452 times.
✓ Branch 12 taken 9704 times.
✓ Branch 13 taken 10815 times.
✓ Branch 14 taken 636 times.
✓ Branch 15 taken 1161 times.
✓ Branch 16 taken 156 times.
✓ Branch 17 taken 265 times.
✓ Branch 18 taken 76 times.
✓ Branch 19 taken 76 times.
✓ Branch 20 taken 475901 times.
525258 switch (dstFormat) {
3609 170 case AV_PIX_FMT_RGBA64LE:
3610 #if CONFIG_SWSCALE_ALPHA
3611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if (c->needAlpha) {
3612 ✗ *yuv2packed1 = yuv2rgba64le_1_c;
3613 ✗ *yuv2packed2 = yuv2rgba64le_2_c;
3614 ✗ *yuv2packedX = yuv2rgba64le_X_c;
3615 } else
3616 #endif /* CONFIG_SWSCALE_ALPHA */
3617 {
3618 170 *yuv2packed1 = yuv2rgbx64le_1_c;
3619 170 *yuv2packed2 = yuv2rgbx64le_2_c;
3620 170 *yuv2packedX = yuv2rgbx64le_X_c;
3621 }
3622 170 break;
3623 118 case AV_PIX_FMT_RGBA64BE:
3624 #if CONFIG_SWSCALE_ALPHA
3625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (c->needAlpha) {
3626 ✗ *yuv2packed1 = yuv2rgba64be_1_c;
3627 ✗ *yuv2packed2 = yuv2rgba64be_2_c;
3628 ✗ *yuv2packedX = yuv2rgba64be_X_c;
3629 } else
3630 #endif /* CONFIG_SWSCALE_ALPHA */
3631 {
3632 118 *yuv2packed1 = yuv2rgbx64be_1_c;
3633 118 *yuv2packed2 = yuv2rgbx64be_2_c;
3634 118 *yuv2packedX = yuv2rgbx64be_X_c;
3635 }
3636 118 break;
3637 118 case AV_PIX_FMT_BGRA64LE:
3638 #if CONFIG_SWSCALE_ALPHA
3639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (c->needAlpha) {
3640 ✗ *yuv2packed1 = yuv2bgra64le_1_c;
3641 ✗ *yuv2packed2 = yuv2bgra64le_2_c;
3642 ✗ *yuv2packedX = yuv2bgra64le_X_c;
3643 } else
3644 #endif /* CONFIG_SWSCALE_ALPHA */
3645 {
3646 118 *yuv2packed1 = yuv2bgrx64le_1_c;
3647 118 *yuv2packed2 = yuv2bgrx64le_2_c;
3648 118 *yuv2packedX = yuv2bgrx64le_X_c;
3649 }
3650 118 break;
3651 118 case AV_PIX_FMT_BGRA64BE:
3652 #if CONFIG_SWSCALE_ALPHA
3653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (c->needAlpha) {
3654 ✗ *yuv2packed1 = yuv2bgra64be_1_c;
3655 ✗ *yuv2packed2 = yuv2bgra64be_2_c;
3656 ✗ *yuv2packedX = yuv2bgra64be_X_c;
3657 } else
3658 #endif /* CONFIG_SWSCALE_ALPHA */
3659 {
3660 118 *yuv2packed1 = yuv2bgrx64be_1_c;
3661 118 *yuv2packed2 = yuv2bgrx64be_2_c;
3662 118 *yuv2packedX = yuv2bgrx64be_X_c;
3663 }
3664 118 break;
3665 3550 case AV_PIX_FMT_RGB48LE:
3666 3550 *yuv2packed1 = yuv2rgb48le_1_c;
3667 3550 *yuv2packed2 = yuv2rgb48le_2_c;
3668 3550 *yuv2packedX = yuv2rgb48le_X_c;
3669 3550 break;
3670 252 case AV_PIX_FMT_RGB48BE:
3671 252 *yuv2packed1 = yuv2rgb48be_1_c;
3672 252 *yuv2packed2 = yuv2rgb48be_2_c;
3673 252 *yuv2packedX = yuv2rgb48be_X_c;
3674 252 break;
3675 123 case AV_PIX_FMT_BGR48LE:
3676 123 *yuv2packed1 = yuv2bgr48le_1_c;
3677 123 *yuv2packed2 = yuv2bgr48le_2_c;
3678 123 *yuv2packedX = yuv2bgr48le_X_c;
3679 123 break;
3680 118 case AV_PIX_FMT_BGR48BE:
3681 118 *yuv2packed1 = yuv2bgr48be_1_c;
3682 118 *yuv2packed2 = yuv2bgr48be_2_c;
3683 118 *yuv2packedX = yuv2bgr48be_X_c;
3684 118 break;
3685 5458 case AV_PIX_FMT_RGB32:
3686 case AV_PIX_FMT_BGR32:
3687 #if CONFIG_SMALL
3688 *yuv2packed1 = yuv2rgb32_1_c;
3689 *yuv2packed2 = yuv2rgb32_2_c;
3690 *yuv2packedX = yuv2rgb32_X_c;
3691 #else
3692 #if CONFIG_SWSCALE_ALPHA
3693
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 4710 times.
5458 if (c->needAlpha) {
3694 748 *yuv2packed1 = yuv2rgba32_1_c;
3695 748 *yuv2packed2 = yuv2rgba32_2_c;
3696 748 *yuv2packedX = yuv2rgba32_X_c;
3697 } else
3698 #endif /* CONFIG_SWSCALE_ALPHA */
3699 {
3700 4710 *yuv2packed1 = yuv2rgbx32_1_c;
3701 4710 *yuv2packed2 = yuv2rgbx32_2_c;
3702 4710 *yuv2packedX = yuv2rgbx32_X_c;
3703 }
3704 #endif /* !CONFIG_SMALL */
3705 5458 break;
3706 4534 case AV_PIX_FMT_RGB32_1:
3707 case AV_PIX_FMT_BGR32_1:
3708 #if CONFIG_SMALL
3709 *yuv2packed1 = yuv2rgb32_1_1_c;
3710 *yuv2packed2 = yuv2rgb32_1_2_c;
3711 *yuv2packedX = yuv2rgb32_1_X_c;
3712 #else
3713 #if CONFIG_SWSCALE_ALPHA
3714
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 3786 times.
4534 if (c->needAlpha) {
3715 748 *yuv2packed1 = yuv2rgba32_1_1_c;
3716 748 *yuv2packed2 = yuv2rgba32_1_2_c;
3717 748 *yuv2packedX = yuv2rgba32_1_X_c;
3718 } else
3719 #endif /* CONFIG_SWSCALE_ALPHA */
3720 {
3721 3786 *yuv2packed1 = yuv2rgbx32_1_1_c;
3722 3786 *yuv2packed2 = yuv2rgbx32_1_2_c;
3723 3786 *yuv2packedX = yuv2rgbx32_1_X_c;
3724 }
3725 #endif /* !CONFIG_SMALL */
3726 4534 break;
3727 8457 case AV_PIX_FMT_RGB24:
3728 8457 *yuv2packed1 = yuv2rgb24_1_c;
3729 8457 *yuv2packed2 = yuv2rgb24_2_c;
3730 8457 *yuv2packedX = yuv2rgb24_X_c;
3731 8457 break;
3732 3452 case AV_PIX_FMT_BGR24:
3733 3452 *yuv2packed1 = yuv2bgr24_1_c;
3734 3452 *yuv2packed2 = yuv2bgr24_2_c;
3735 3452 *yuv2packedX = yuv2bgr24_X_c;
3736 3452 break;
3737 9704 case AV_PIX_FMT_RGB565LE:
3738 case AV_PIX_FMT_RGB565BE:
3739 case AV_PIX_FMT_BGR565LE:
3740 case AV_PIX_FMT_BGR565BE:
3741 9704 *yuv2packed1 = yuv2rgb16_1_c;
3742 9704 *yuv2packed2 = yuv2rgb16_2_c;
3743 9704 *yuv2packedX = yuv2rgb16_X_c;
3744 9704 break;
3745 10815 case AV_PIX_FMT_RGB555LE:
3746 case AV_PIX_FMT_RGB555BE:
3747 case AV_PIX_FMT_BGR555LE:
3748 case AV_PIX_FMT_BGR555BE:
3749 10815 *yuv2packed1 = yuv2rgb15_1_c;
3750 10815 *yuv2packed2 = yuv2rgb15_2_c;
3751 10815 *yuv2packedX = yuv2rgb15_X_c;
3752 10815 break;
3753 636 case AV_PIX_FMT_RGB444LE:
3754 case AV_PIX_FMT_RGB444BE:
3755 case AV_PIX_FMT_BGR444LE:
3756 case AV_PIX_FMT_BGR444BE:
3757 636 *yuv2packed1 = yuv2rgb12_1_c;
3758 636 *yuv2packed2 = yuv2rgb12_2_c;
3759 636 *yuv2packedX = yuv2rgb12_X_c;
3760 636 break;
3761 1161 case AV_PIX_FMT_RGB8:
3762 case AV_PIX_FMT_BGR8:
3763 1161 *yuv2packed1 = yuv2rgb8_1_c;
3764 1161 *yuv2packed2 = yuv2rgb8_2_c;
3765 1161 *yuv2packedX = yuv2rgb8_X_c;
3766 1161 break;
3767 156 case AV_PIX_FMT_RGB4:
3768 case AV_PIX_FMT_BGR4:
3769 156 *yuv2packed1 = yuv2rgb4_1_c;
3770 156 *yuv2packed2 = yuv2rgb4_2_c;
3771 156 *yuv2packedX = yuv2rgb4_X_c;
3772 156 break;
3773 265 case AV_PIX_FMT_RGB4_BYTE:
3774 case AV_PIX_FMT_BGR4_BYTE:
3775 265 *yuv2packed1 = yuv2rgb4b_1_c;
3776 265 *yuv2packed2 = yuv2rgb4b_2_c;
3777 265 *yuv2packedX = yuv2rgb4b_X_c;
3778 265 break;
3779 76 case AV_PIX_FMT_X2RGB10LE:
3780 case AV_PIX_FMT_X2RGB10BE:
3781 76 *yuv2packed1 = yuv2x2rgb10_1_c;
3782 76 *yuv2packed2 = yuv2x2rgb10_2_c;
3783 76 *yuv2packedX = yuv2x2rgb10_X_c;
3784 76 break;
3785 76 case AV_PIX_FMT_X2BGR10LE:
3786 case AV_PIX_FMT_X2BGR10BE:
3787 76 *yuv2packed1 = yuv2x2bgr10_1_c;
3788 76 *yuv2packed2 = yuv2x2bgr10_2_c;
3789 76 *yuv2packedX = yuv2x2bgr10_X_c;
3790 76 break;
3791 }
3792 }
3793
24/24
✓ Branch 0 taken 1766 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 838 times.
✓ Branch 3 taken 753 times.
✓ Branch 4 taken 1067 times.
✓ Branch 5 taken 1213 times.
✓ Branch 6 taken 122 times.
✓ Branch 7 taken 122 times.
✓ Branch 8 taken 117 times.
✓ Branch 9 taken 1313 times.
✓ Branch 10 taken 117 times.
✓ Branch 11 taken 117 times.
✓ Branch 12 taken 122 times.
✓ Branch 13 taken 931 times.
✓ Branch 14 taken 526 times.
✓ Branch 15 taken 799 times.
✓ Branch 16 taken 799 times.
✓ Branch 17 taken 799 times.
✓ Branch 18 taken 985 times.
✓ Branch 19 taken 985 times.
✓ Branch 20 taken 748 times.
✓ Branch 21 taken 748 times.
✓ Branch 22 taken 934 times.
✓ Branch 23 taken 560029 times.
576820 switch (dstFormat) {
3794 1766 case AV_PIX_FMT_MONOWHITE:
3795 1766 *yuv2packed1 = yuv2monowhite_1_c;
3796 1766 *yuv2packed2 = yuv2monowhite_2_c;
3797 1766 *yuv2packedX = yuv2monowhite_X_c;
3798 1766 break;
3799 870 case AV_PIX_FMT_MONOBLACK:
3800 870 *yuv2packed1 = yuv2monoblack_1_c;
3801 870 *yuv2packed2 = yuv2monoblack_2_c;
3802 870 *yuv2packedX = yuv2monoblack_X_c;
3803 870 break;
3804 838 case AV_PIX_FMT_YUYV422:
3805 838 *yuv2packed1 = yuv2yuyv422_1_c;
3806 838 *yuv2packed2 = yuv2yuyv422_2_c;
3807 838 *yuv2packedX = yuv2yuyv422_X_c;
3808 838 break;
3809 753 case AV_PIX_FMT_YVYU422:
3810 753 *yuv2packed1 = yuv2yvyu422_1_c;
3811 753 *yuv2packed2 = yuv2yvyu422_2_c;
3812 753 *yuv2packedX = yuv2yvyu422_X_c;
3813 753 break;
3814 1067 case AV_PIX_FMT_UYVY422:
3815 1067 *yuv2packed1 = yuv2uyvy422_1_c;
3816 1067 *yuv2packed2 = yuv2uyvy422_2_c;
3817 1067 *yuv2packedX = yuv2uyvy422_X_c;
3818 1067 break;
3819 1213 case AV_PIX_FMT_VYU444:
3820 1213 *yuv2packed1 = yuv2vyu444_1_c;
3821 1213 *yuv2packed2 = yuv2vyu444_2_c;
3822 1213 *yuv2packedX = yuv2vyu444_X_c;
3823 1213 break;
3824 122 case AV_PIX_FMT_YA8:
3825 122 *yuv2packed1 = yuv2ya8_1_c;
3826 122 *yuv2packed2 = yuv2ya8_2_c;
3827 122 *yuv2packedX = yuv2ya8_X_c;
3828 122 break;
3829 122 case AV_PIX_FMT_YA16LE:
3830 122 *yuv2packed1 = yuv2ya16le_1_c;
3831 122 *yuv2packed2 = yuv2ya16le_2_c;
3832 122 *yuv2packedX = yuv2ya16le_X_c;
3833 122 break;
3834 117 case AV_PIX_FMT_YA16BE:
3835 117 *yuv2packed1 = yuv2ya16be_1_c;
3836 117 *yuv2packed2 = yuv2ya16be_2_c;
3837 117 *yuv2packedX = yuv2ya16be_X_c;
3838 117 break;
3839 1313 case AV_PIX_FMT_V30XLE:
3840 1313 *yuv2packedX = yuv2v30xle_X_c;
3841 1313 break;
3842 117 case AV_PIX_FMT_AYUV64LE:
3843 117 *yuv2packedX = yuv2ayuv64le_X_c;
3844 117 break;
3845 117 case AV_PIX_FMT_AYUV64BE:
3846 117 *yuv2packedX = yuv2ayuv64be_X_c;
3847 117 break;
3848 122 case AV_PIX_FMT_AYUV:
3849 122 *yuv2packed1 = yuv2ayuv_1_c;
3850 122 *yuv2packed2 = yuv2ayuv_2_c;
3851 122 *yuv2packedX = yuv2ayuv_X_c;
3852 122 break;
3853 931 case AV_PIX_FMT_VUYA:
3854 case AV_PIX_FMT_VUYX:
3855 931 *yuv2packed1 = yuv2vuyX_1_c;
3856 931 *yuv2packed2 = yuv2vuyX_2_c;
3857 931 *yuv2packedX = yuv2vuyX_X_c;
3858 931 break;
3859 526 case AV_PIX_FMT_UYVA:
3860 526 *yuv2packed1 = yuv2uyva_1_c;
3861 526 *yuv2packed2 = yuv2uyva_2_c;
3862 526 *yuv2packedX = yuv2uyva_X_c;
3863 526 break;
3864 799 case AV_PIX_FMT_XV30LE:
3865 799 *yuv2packedX = yuv2xv30le_X_c;
3866 799 break;
3867 799 case AV_PIX_FMT_XV36LE:
3868 799 *yuv2packedX = yuv2xv36le_X_c;
3869 799 break;
3870 799 case AV_PIX_FMT_XV36BE:
3871 799 *yuv2packedX = yuv2xv36be_X_c;
3872 799 break;
3873 985 case AV_PIX_FMT_XV48LE:
3874 985 *yuv2packedX = yuv2xv48le_X_c;
3875 985 break;
3876 985 case AV_PIX_FMT_XV48BE:
3877 985 *yuv2packedX = yuv2xv48be_X_c;
3878 985 break;
3879 748 case AV_PIX_FMT_Y210LE:
3880 748 *yuv2packedX = yuv2y210le_X_c;
3881 748 break;
3882 748 case AV_PIX_FMT_Y212LE:
3883 748 *yuv2packedX = yuv2y212le_X_c;
3884 748 break;
3885 934 case AV_PIX_FMT_Y216LE:
3886 934 *yuv2packedX = yuv2y216le_X_c;
3887 934 break;
3888 }
3889 576820 }
3890