swscale: x86: Add some forgotten 12-bit planar YUV cases
[libav.git] / libswscale / x86 / swscale.c
1 /*
2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of Libav.
5 *
6 * Libav 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 * Libav 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 Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <inttypes.h>
22 #include "config.h"
23 #include "libswscale/swscale.h"
24 #include "libswscale/swscale_internal.h"
25 #include "libavutil/attributes.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/x86/cpu.h"
28 #include "libavutil/cpu.h"
29 #include "libavutil/pixdesc.h"
30
31 #if HAVE_INLINE_ASM
32
33 #define DITHER1XBPP
34
35 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
36 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
37 DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
38 DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
39
40 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
41 0x0103010301030103LL,
42 0x0200020002000200LL,};
43
44 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
45 0x0602060206020602LL,
46 0x0004000400040004LL,};
47
48 DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
49 DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
50 DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
51 DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
52 DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
53 DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
54
55 DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
56 DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
57 DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
58
59 #ifdef FAST_BGR2YV12
60 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
61 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
62 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
63 #else
64 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
65 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
66 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
67 #endif /* FAST_BGR2YV12 */
68 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
69 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
70 DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
71
72 //MMX versions
73 #if HAVE_MMX_INLINE
74 #undef RENAME
75 #define COMPILE_TEMPLATE_MMXEXT 0
76 #define RENAME(a) a ## _mmx
77 #include "swscale_template.c"
78 #endif
79
80 // MMXEXT versions
81 #if HAVE_MMXEXT_INLINE
82 #undef RENAME
83 #undef COMPILE_TEMPLATE_MMXEXT
84 #define COMPILE_TEMPLATE_MMXEXT 1
85 #define RENAME(a) a ## _mmxext
86 #include "swscale_template.c"
87 #endif
88
89 void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
90 int lastInLumBuf, int lastInChrBuf)
91 {
92 const int dstH= c->dstH;
93 const int flags= c->flags;
94 int16_t **lumPixBuf= c->lumPixBuf;
95 int16_t **chrUPixBuf= c->chrUPixBuf;
96 int16_t **alpPixBuf= c->alpPixBuf;
97 const int vLumBufSize= c->vLumBufSize;
98 const int vChrBufSize= c->vChrBufSize;
99 int32_t *vLumFilterPos= c->vLumFilterPos;
100 int32_t *vChrFilterPos= c->vChrFilterPos;
101 int16_t *vLumFilter= c->vLumFilter;
102 int16_t *vChrFilter= c->vChrFilter;
103 int32_t *lumMmxFilter= c->lumMmxFilter;
104 int32_t *chrMmxFilter= c->chrMmxFilter;
105 int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
106 const int vLumFilterSize= c->vLumFilterSize;
107 const int vChrFilterSize= c->vChrFilterSize;
108 const int chrDstY= dstY>>c->chrDstVSubSample;
109 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
110 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
111
112 c->blueDither= ff_dither8[dstY&1];
113 if (c->dstFormat == AV_PIX_FMT_RGB555 || c->dstFormat == AV_PIX_FMT_BGR555)
114 c->greenDither= ff_dither8[dstY&1];
115 else
116 c->greenDither= ff_dither4[dstY&1];
117 c->redDither= ff_dither8[(dstY+1)&1];
118 if (dstY < dstH - 2) {
119 const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
120 const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
121 const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
122 int i;
123
124 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
125 const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
126 int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
127 for (i = 0; i < neg; i++)
128 tmpY[i] = lumSrcPtr[neg];
129 for ( ; i < end; i++)
130 tmpY[i] = lumSrcPtr[i];
131 for ( ; i < vLumFilterSize; i++)
132 tmpY[i] = tmpY[i-1];
133 lumSrcPtr = tmpY;
134
135 if (alpSrcPtr) {
136 const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
137 for (i = 0; i < neg; i++)
138 tmpA[i] = alpSrcPtr[neg];
139 for ( ; i < end; i++)
140 tmpA[i] = alpSrcPtr[i];
141 for ( ; i < vLumFilterSize; i++)
142 tmpA[i] = tmpA[i - 1];
143 alpSrcPtr = tmpA;
144 }
145 }
146 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
147 const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
148 int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
149 for (i = 0; i < neg; i++) {
150 tmpU[i] = chrUSrcPtr[neg];
151 }
152 for ( ; i < end; i++) {
153 tmpU[i] = chrUSrcPtr[i];
154 }
155 for ( ; i < vChrFilterSize; i++) {
156 tmpU[i] = tmpU[i - 1];
157 }
158 chrUSrcPtr = tmpU;
159 }
160
161 if (flags & SWS_ACCURATE_RND) {
162 int s= APCK_SIZE / 8;
163 for (i=0; i<vLumFilterSize; i+=2) {
164 *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
165 *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
166 lumMmxFilter[s*i+APCK_COEF/4 ]=
167 lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
168 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
169 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
170 *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
171 *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
172 alpMmxFilter[s*i+APCK_COEF/4 ]=
173 alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
174 }
175 }
176 for (i=0; i<vChrFilterSize; i+=2) {
177 *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
178 *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
179 chrMmxFilter[s*i+APCK_COEF/4 ]=
180 chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
181 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
182 }
183 } else {
184 for (i=0; i<vLumFilterSize; i++) {
185 *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
186 lumMmxFilter[4*i+2]=
187 lumMmxFilter[4*i+3]=
188 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
189 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
190 *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
191 alpMmxFilter[4*i+2]=
192 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
193 }
194 }
195 for (i=0; i<vChrFilterSize; i++) {
196 *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
197 chrMmxFilter[4*i+2]=
198 chrMmxFilter[4*i+3]=
199 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
200 }
201 }
202 }
203 }
204
205 #endif /* HAVE_INLINE_ASM */
206
207 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
208 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
209 SwsContext *c, int16_t *data, \
210 int dstW, const uint8_t *src, \
211 const int16_t *filter, \
212 const int32_t *filterPos, int filterSize)
213
214 #define SCALE_FUNCS(filter_n, opt) \
215 SCALE_FUNC(filter_n, 8, 15, opt); \
216 SCALE_FUNC(filter_n, 9, 15, opt); \
217 SCALE_FUNC(filter_n, 10, 15, opt); \
218 SCALE_FUNC(filter_n, 12, 15, opt); \
219 SCALE_FUNC(filter_n, 16, 15, opt); \
220 SCALE_FUNC(filter_n, 8, 19, opt); \
221 SCALE_FUNC(filter_n, 9, 19, opt); \
222 SCALE_FUNC(filter_n, 10, 19, opt); \
223 SCALE_FUNC(filter_n, 12, 19, opt); \
224 SCALE_FUNC(filter_n, 16, 19, opt)
225
226 #define SCALE_FUNCS_MMX(opt) \
227 SCALE_FUNCS(4, opt); \
228 SCALE_FUNCS(8, opt); \
229 SCALE_FUNCS(X, opt)
230
231 #define SCALE_FUNCS_SSE(opt) \
232 SCALE_FUNCS(4, opt); \
233 SCALE_FUNCS(8, opt); \
234 SCALE_FUNCS(X4, opt); \
235 SCALE_FUNCS(X8, opt)
236
237 #if ARCH_X86_32
238 SCALE_FUNCS_MMX(mmx);
239 #endif
240 SCALE_FUNCS_SSE(sse2);
241 SCALE_FUNCS_SSE(ssse3);
242 SCALE_FUNCS_SSE(sse4);
243
244 #define VSCALEX_FUNC(size, opt) \
245 void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
246 const int16_t **src, uint8_t *dest, int dstW, \
247 const uint8_t *dither, int offset)
248 #define VSCALEX_FUNCS(opt) \
249 VSCALEX_FUNC(8, opt); \
250 VSCALEX_FUNC(9, opt); \
251 VSCALEX_FUNC(10, opt)
252
253 #if ARCH_X86_32
254 VSCALEX_FUNCS(mmxext);
255 #endif
256 VSCALEX_FUNCS(sse2);
257 VSCALEX_FUNCS(sse4);
258 VSCALEX_FUNC(16, sse4);
259 VSCALEX_FUNCS(avx);
260
261 #define VSCALE_FUNC(size, opt) \
262 void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
263 const uint8_t *dither, int offset)
264 #define VSCALE_FUNCS(opt1, opt2) \
265 VSCALE_FUNC(8, opt1); \
266 VSCALE_FUNC(9, opt2); \
267 VSCALE_FUNC(10, opt2); \
268 VSCALE_FUNC(16, opt1)
269
270 #if ARCH_X86_32
271 VSCALE_FUNCS(mmx, mmxext);
272 #endif
273 VSCALE_FUNCS(sse2, sse2);
274 VSCALE_FUNC(16, sse4);
275 VSCALE_FUNCS(avx, avx);
276
277 #define INPUT_Y_FUNC(fmt, opt) \
278 void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
279 int w, uint32_t *unused)
280 #define INPUT_UV_FUNC(fmt, opt) \
281 void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
282 const uint8_t *src, const uint8_t *unused1, \
283 int w, uint32_t *unused2)
284 #define INPUT_FUNC(fmt, opt) \
285 INPUT_Y_FUNC(fmt, opt); \
286 INPUT_UV_FUNC(fmt, opt)
287 #define INPUT_FUNCS(opt) \
288 INPUT_FUNC(uyvy, opt); \
289 INPUT_FUNC(yuyv, opt); \
290 INPUT_UV_FUNC(nv12, opt); \
291 INPUT_UV_FUNC(nv21, opt); \
292 INPUT_FUNC(rgba, opt); \
293 INPUT_FUNC(bgra, opt); \
294 INPUT_FUNC(argb, opt); \
295 INPUT_FUNC(abgr, opt); \
296 INPUT_FUNC(rgb24, opt); \
297 INPUT_FUNC(bgr24, opt)
298
299 #if ARCH_X86_32
300 INPUT_FUNCS(mmx);
301 #endif
302 INPUT_FUNCS(sse2);
303 INPUT_FUNCS(ssse3);
304 INPUT_FUNCS(avx);
305
306 av_cold void ff_sws_init_swscale_x86(SwsContext *c)
307 {
308 int cpu_flags = av_get_cpu_flags();
309
310 #if HAVE_MMX_INLINE
311 if (INLINE_MMX(cpu_flags))
312 sws_init_swscale_mmx(c);
313 #endif
314 #if HAVE_MMXEXT_INLINE
315 if (INLINE_MMXEXT(cpu_flags))
316 sws_init_swscale_mmxext(c);
317 #endif
318
319 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
320 if (c->srcBpc == 8) { \
321 hscalefn = c->dstBpc <= 15 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
322 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
323 } else if (c->srcBpc == 9) { \
324 hscalefn = c->dstBpc <= 15 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
325 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
326 } else if (c->srcBpc == 10) { \
327 hscalefn = c->dstBpc <= 15 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
328 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
329 } else if (c->srcBpc == 12) { \
330 hscalefn = c->dstBpc <= 15 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
331 ff_hscale12to19_ ## filtersize ## _ ## opt1; \
332 } else if (c->srcBpc == 16) { \
333 hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
334 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
335 } \
336 } while (0)
337 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
338 switch (filtersize) { \
339 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
340 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
341 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
342 }
343 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
344 switch(c->dstBpc){ \
345 case 16: do_16_case; break; \
346 case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
347 case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
348 case 8: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
349 }
350 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
351 switch(c->dstBpc){ \
352 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
353 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
354 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
355 case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
356 }
357 #define case_rgb(x, X, opt) \
358 case AV_PIX_FMT_ ## X: \
359 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
360 if (!c->chrSrcHSubSample) \
361 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
362 break
363 #if ARCH_X86_32
364 if (EXTERNAL_MMX(cpu_flags)) {
365 ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
366 ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
367 ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT);
368
369 switch (c->srcFormat) {
370 case AV_PIX_FMT_YA8:
371 c->lumToYV12 = ff_yuyvToY_mmx;
372 if (c->alpPixBuf)
373 c->alpToYV12 = ff_uyvyToY_mmx;
374 break;
375 case AV_PIX_FMT_YUYV422:
376 c->lumToYV12 = ff_yuyvToY_mmx;
377 c->chrToYV12 = ff_yuyvToUV_mmx;
378 break;
379 case AV_PIX_FMT_UYVY422:
380 c->lumToYV12 = ff_uyvyToY_mmx;
381 c->chrToYV12 = ff_uyvyToUV_mmx;
382 break;
383 case AV_PIX_FMT_NV12:
384 c->chrToYV12 = ff_nv12ToUV_mmx;
385 break;
386 case AV_PIX_FMT_NV21:
387 c->chrToYV12 = ff_nv21ToUV_mmx;
388 break;
389 case_rgb(rgb24, RGB24, mmx);
390 case_rgb(bgr24, BGR24, mmx);
391 case_rgb(bgra, BGRA, mmx);
392 case_rgb(rgba, RGBA, mmx);
393 case_rgb(abgr, ABGR, mmx);
394 case_rgb(argb, ARGB, mmx);
395 default:
396 break;
397 }
398 }
399 if (EXTERNAL_MMXEXT(cpu_flags)) {
400 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1);
401 }
402 #endif /* ARCH_X86_32 */
403 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
404 switch (filtersize) { \
405 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
406 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
407 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
408 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
409 break; \
410 }
411 if (EXTERNAL_SSE2(cpu_flags)) {
412 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
413 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
414 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
415 HAVE_ALIGNED_STACK || ARCH_X86_64);
416 ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
417
418 switch (c->srcFormat) {
419 case AV_PIX_FMT_YA8:
420 c->lumToYV12 = ff_yuyvToY_sse2;
421 if (c->alpPixBuf)
422 c->alpToYV12 = ff_uyvyToY_sse2;
423 break;
424 case AV_PIX_FMT_YUYV422:
425 c->lumToYV12 = ff_yuyvToY_sse2;
426 c->chrToYV12 = ff_yuyvToUV_sse2;
427 break;
428 case AV_PIX_FMT_UYVY422:
429 c->lumToYV12 = ff_uyvyToY_sse2;
430 c->chrToYV12 = ff_uyvyToUV_sse2;
431 break;
432 case AV_PIX_FMT_NV12:
433 c->chrToYV12 = ff_nv12ToUV_sse2;
434 break;
435 case AV_PIX_FMT_NV21:
436 c->chrToYV12 = ff_nv21ToUV_sse2;
437 break;
438 case_rgb(rgb24, RGB24, sse2);
439 case_rgb(bgr24, BGR24, sse2);
440 case_rgb(bgra, BGRA, sse2);
441 case_rgb(rgba, RGBA, sse2);
442 case_rgb(abgr, ABGR, sse2);
443 case_rgb(argb, ARGB, sse2);
444 default:
445 break;
446 }
447 }
448 if (EXTERNAL_SSSE3(cpu_flags)) {
449 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
450 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
451 switch (c->srcFormat) {
452 case_rgb(rgb24, RGB24, ssse3);
453 case_rgb(bgr24, BGR24, ssse3);
454 default:
455 break;
456 }
457 }
458 if (EXTERNAL_SSE4(cpu_flags)) {
459 /* Xto15 don't need special sse4 functions */
460 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
461 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
462 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
463 if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
464 HAVE_ALIGNED_STACK || ARCH_X86_64);
465 if (c->dstBpc == 16 && !isBE(c->dstFormat))
466 c->yuv2plane1 = ff_yuv2plane1_16_sse4;
467 }
468
469 if (EXTERNAL_AVX(cpu_flags)) {
470 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
471 HAVE_ALIGNED_STACK || ARCH_X86_64);
472 ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
473
474 switch (c->srcFormat) {
475 case AV_PIX_FMT_YUYV422:
476 c->chrToYV12 = ff_yuyvToUV_avx;
477 break;
478 case AV_PIX_FMT_UYVY422:
479 c->chrToYV12 = ff_uyvyToUV_avx;
480 break;
481 case AV_PIX_FMT_NV12:
482 c->chrToYV12 = ff_nv12ToUV_avx;
483 break;
484 case AV_PIX_FMT_NV21:
485 c->chrToYV12 = ff_nv21ToUV_avx;
486 break;
487 case_rgb(rgb24, RGB24, avx);
488 case_rgb(bgr24, BGR24, avx);
489 case_rgb(bgra, BGRA, avx);
490 case_rgb(rgba, RGBA, avx);
491 case_rgb(abgr, ABGR, avx);
492 case_rgb(argb, ARGB, avx);
493 default:
494 break;
495 }
496 }
497 }