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