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