2 * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
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.
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.
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
23 #include "libswscale/swscale.h"
24 #include "libswscale/swscale_internal.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/x86_cpu.h"
27 #include "libavutil/cpu.h"
28 #include "libavutil/pixdesc.h"
32 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
33 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
34 DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
35 DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
37 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
39 0x0200020002000200LL,};
41 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
43 0x0004000400040004LL,};
45 DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
46 DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
47 DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
48 DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
49 DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
50 DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
52 DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
53 DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
54 DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
57 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
58 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
59 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
61 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
62 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
63 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
64 #endif /* FAST_BGR2YV12 */
65 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
66 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
67 DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
73 #define COMPILE_TEMPLATE_MMX2 0
74 #define RENAME(a) a ## _MMX
75 #include "swscale_template.c"
81 #undef COMPILE_TEMPLATE_MMX2
82 #define COMPILE_TEMPLATE_MMX2 1
83 #define RENAME(a) a ## _MMX2
84 #include "swscale_template.c"
87 void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
88 int lastInLumBuf, int lastInChrBuf)
90 const int dstH= c->dstH;
91 const int flags= c->flags;
92 int16_t **lumPixBuf= c->lumPixBuf;
93 int16_t **chrUPixBuf= c->chrUPixBuf;
94 int16_t **alpPixBuf= c->alpPixBuf;
95 const int vLumBufSize= c->vLumBufSize;
96 const int vChrBufSize= c->vChrBufSize;
97 int16_t *vLumFilterPos= c->vLumFilterPos;
98 int16_t *vChrFilterPos= c->vChrFilterPos;
99 int16_t *vLumFilter= c->vLumFilter;
100 int16_t *vChrFilter= c->vChrFilter;
101 int32_t *lumMmxFilter= c->lumMmxFilter;
102 int32_t *chrMmxFilter= c->chrMmxFilter;
103 int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
104 const int vLumFilterSize= c->vLumFilterSize;
105 const int vChrFilterSize= c->vChrFilterSize;
106 const int chrDstY= dstY>>c->chrDstVSubSample;
107 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
108 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
110 c->blueDither= ff_dither8[dstY&1];
111 if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
112 c->greenDither= ff_dither8[dstY&1];
114 c->greenDither= ff_dither4[dstY&1];
115 c->redDither= ff_dither8[(dstY+1)&1];
116 if (dstY < dstH - 2) {
117 const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
118 const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
119 const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
122 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
123 const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
124 int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
125 for (i = 0; i < neg; i++)
126 tmpY[i] = lumSrcPtr[neg];
127 for ( ; i < end; i++)
128 tmpY[i] = lumSrcPtr[i];
129 for ( ; i < vLumFilterSize; i++)
134 const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
135 for (i = 0; i < neg; i++)
136 tmpA[i] = alpSrcPtr[neg];
137 for ( ; i < end; i++)
138 tmpA[i] = alpSrcPtr[i];
139 for ( ; i < vLumFilterSize; i++)
140 tmpA[i] = tmpA[i - 1];
144 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
145 const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
146 int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
147 for (i = 0; i < neg; i++) {
148 tmpU[i] = chrUSrcPtr[neg];
150 for ( ; i < end; i++) {
151 tmpU[i] = chrUSrcPtr[i];
153 for ( ; i < vChrFilterSize; i++) {
154 tmpU[i] = tmpU[i - 1];
159 if (flags & SWS_ACCURATE_RND) {
160 int s= APCK_SIZE / 8;
161 for (i=0; i<vLumFilterSize; i+=2) {
162 *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
163 *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
164 lumMmxFilter[s*i+APCK_COEF/4 ]=
165 lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
166 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
167 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
168 *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
169 *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
170 alpMmxFilter[s*i+APCK_COEF/4 ]=
171 alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
174 for (i=0; i<vChrFilterSize; i+=2) {
175 *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
176 *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
177 chrMmxFilter[s*i+APCK_COEF/4 ]=
178 chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
179 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
182 for (i=0; i<vLumFilterSize; i++) {
183 *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
186 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
187 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
188 *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
190 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
193 for (i=0; i<vChrFilterSize; i++) {
194 *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
197 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
204 static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
205 const int16_t **src, uint8_t *dest, int dstW,
206 const uint8_t *dither, int offset)
208 if(((int)dest) & 15){
209 return yuv2yuvX_MMX2(filter, filterSize, src, dest, dstW, dither, offset);
212 __asm__ volatile("movq (%0), %%xmm3\n\t"
213 "movdqa %%xmm3, %%xmm4\n\t"
214 "psrlq $24, %%xmm3\n\t"
215 "psllq $40, %%xmm4\n\t"
216 "por %%xmm4, %%xmm3\n\t"
220 __asm__ volatile("movq (%0), %%xmm3\n\t"
225 "pxor %%xmm0, %%xmm0\n\t"
226 "punpcklbw %%xmm0, %%xmm3\n\t"
227 "psraw $4, %%xmm3\n\t"
228 "movdqa %%xmm3, %%xmm4\n\t"
229 "movdqa %%xmm3, %%xmm7\n\t"
231 "mov %0, %%"REG_d" \n\t"\
232 "mov (%%"REG_d"), %%"REG_S" \n\t"\
233 ".p2align 4 \n\t" /* FIXME Unroll? */\
235 "movddup 8(%%"REG_d"), %%xmm0 \n\t" /* filterCoeff */\
236 "movdqa (%%"REG_S", %%"REG_c", 2), %%xmm2 \n\t" /* srcData */\
237 "movdqa 16(%%"REG_S", %%"REG_c", 2), %%xmm5 \n\t" /* srcData */\
238 "add $16, %%"REG_d" \n\t"\
239 "mov (%%"REG_d"), %%"REG_S" \n\t"\
240 "test %%"REG_S", %%"REG_S" \n\t"\
241 "pmulhw %%xmm0, %%xmm2 \n\t"\
242 "pmulhw %%xmm0, %%xmm5 \n\t"\
243 "paddw %%xmm2, %%xmm3 \n\t"\
244 "paddw %%xmm5, %%xmm4 \n\t"\
246 "psraw $3, %%xmm3 \n\t"\
247 "psraw $3, %%xmm4 \n\t"\
248 "packuswb %%xmm4, %%xmm3 \n\t"
249 "movntdq %%xmm3, (%1, %%"REG_c")\n\t"
250 "add $16, %%"REG_c" \n\t"\
251 "cmp %2, %%"REG_c" \n\t"\
252 "movdqa %%xmm7, %%xmm3\n\t"
253 "movdqa %%xmm7, %%xmm4\n\t"
254 "mov %0, %%"REG_d" \n\t"\
255 "mov (%%"REG_d"), %%"REG_S" \n\t"\
258 "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
259 : "%"REG_d, "%"REG_S, "%"REG_c
264 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
265 extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
266 SwsContext *c, int16_t *data, \
267 int dstW, const uint8_t *src, \
268 const int16_t *filter, \
269 const int16_t *filterPos, int filterSize)
271 #define SCALE_FUNCS(filter_n, opt) \
272 SCALE_FUNC(filter_n, 8, 15, opt); \
273 SCALE_FUNC(filter_n, 9, 15, opt); \
274 SCALE_FUNC(filter_n, 10, 15, opt); \
275 SCALE_FUNC(filter_n, 14, 15, opt); \
276 SCALE_FUNC(filter_n, 16, 15, opt); \
277 SCALE_FUNC(filter_n, 8, 19, opt); \
278 SCALE_FUNC(filter_n, 9, 19, opt); \
279 SCALE_FUNC(filter_n, 10, 19, opt); \
280 SCALE_FUNC(filter_n, 14, 19, opt); \
281 SCALE_FUNC(filter_n, 16, 19, opt)
283 #define SCALE_FUNCS_MMX(opt) \
284 SCALE_FUNCS(4, opt); \
285 SCALE_FUNCS(8, opt); \
288 #define SCALE_FUNCS_SSE(opt) \
289 SCALE_FUNCS(4, opt); \
290 SCALE_FUNCS(8, opt); \
291 SCALE_FUNCS(X4, opt); \
295 SCALE_FUNCS_MMX(mmx);
297 SCALE_FUNCS_SSE(sse2);
298 SCALE_FUNCS_SSE(ssse3);
299 SCALE_FUNCS_SSE(sse4);
301 #define VSCALEX_FUNC(size, opt) \
302 extern void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
303 const int16_t **src, uint8_t *dest, int dstW, \
304 const uint8_t *dither, int offset)
305 #define VSCALEX_FUNCS(opt) \
306 VSCALEX_FUNC(8, opt); \
307 VSCALEX_FUNC(9, opt); \
308 VSCALEX_FUNC(10, opt)
315 VSCALEX_FUNC(16, sse4);
318 #define VSCALE_FUNC(size, opt) \
319 extern void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
320 const uint8_t *dither, int offset)
321 #define VSCALE_FUNCS(opt1, opt2) \
322 VSCALE_FUNC(8, opt1); \
323 VSCALE_FUNC(9, opt2); \
324 VSCALE_FUNC(10, opt2); \
325 VSCALE_FUNC(16, opt1)
328 VSCALE_FUNCS(mmx, mmx2);
330 VSCALE_FUNCS(sse2, sse2);
331 VSCALE_FUNC(16, sse4);
332 VSCALE_FUNCS(avx, avx);
334 #define INPUT_Y_FUNC(fmt, opt) \
335 extern void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
336 int w, uint32_t *unused)
337 #define INPUT_UV_FUNC(fmt, opt) \
338 extern void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
339 const uint8_t *src, const uint8_t *unused1, \
340 int w, uint32_t *unused2)
341 #define INPUT_FUNC(fmt, opt) \
342 INPUT_Y_FUNC(fmt, opt); \
343 INPUT_UV_FUNC(fmt, opt)
344 #define INPUT_FUNCS(opt) \
345 INPUT_FUNC(uyvy, opt); \
346 INPUT_FUNC(yuyv, opt); \
347 INPUT_UV_FUNC(nv12, opt); \
348 INPUT_UV_FUNC(nv21, opt); \
349 INPUT_FUNC(rgba, opt); \
350 INPUT_FUNC(bgra, opt); \
351 INPUT_FUNC(argb, opt); \
352 INPUT_FUNC(abgr, opt); \
353 INPUT_FUNC(rgb24, opt); \
354 INPUT_FUNC(bgr24, opt)
363 void ff_sws_init_swScale_mmx(SwsContext *c)
365 int cpu_flags = av_get_cpu_flags();
367 if (cpu_flags & AV_CPU_FLAG_MMX)
368 sws_init_swScale_MMX(c);
370 if (cpu_flags & AV_CPU_FLAG_MMX2)
371 sws_init_swScale_MMX2(c);
372 if (cpu_flags & AV_CPU_FLAG_SSE3){
373 if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
374 c->yuv2planeX = yuv2yuvX_sse3;
379 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
380 if (c->srcBpc == 8) { \
381 hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
382 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
383 } else if (c->srcBpc == 9) { \
384 hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
385 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
386 } else if (c->srcBpc == 10) { \
387 hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
388 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
389 } else if (c->srcBpc == 14 || ((c->srcFormat==PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)) { \
390 hscalefn = c->dstBpc <= 10 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
391 ff_hscale14to19_ ## filtersize ## _ ## opt1; \
392 } else { /* c->srcBpc == 16 */ \
393 hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
394 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
397 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
398 switch (filtersize) { \
399 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
400 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
401 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
403 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case) \
405 case 16: do_16_case; break; \
406 case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
407 case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
408 default: /*vscalefn = ff_yuv2planeX_8_ ## opt;*/ break; \
410 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
412 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
413 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
414 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
415 default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
417 #define case_rgb(x, X, opt) \
418 case PIX_FMT_ ## X: \
419 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
420 if (!c->chrSrcHSubSample) \
421 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
424 if (cpu_flags & AV_CPU_FLAG_MMX) {
425 ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
426 ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
427 ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmx2, cpu_flags & AV_CPU_FLAG_MMX2);
429 switch (c->srcFormat) {
431 c->lumToYV12 = ff_yuyvToY_mmx;
433 c->alpToYV12 = ff_uyvyToY_mmx;
435 case PIX_FMT_YUYV422:
436 c->lumToYV12 = ff_yuyvToY_mmx;
437 c->chrToYV12 = ff_yuyvToUV_mmx;
439 case PIX_FMT_UYVY422:
440 c->lumToYV12 = ff_uyvyToY_mmx;
441 c->chrToYV12 = ff_uyvyToUV_mmx;
444 c->chrToYV12 = ff_nv12ToUV_mmx;
447 c->chrToYV12 = ff_nv21ToUV_mmx;
449 case_rgb(rgb24, RGB24, mmx);
450 case_rgb(bgr24, BGR24, mmx);
451 case_rgb(bgra, BGRA, mmx);
452 case_rgb(rgba, RGBA, mmx);
453 case_rgb(abgr, ABGR, mmx);
454 case_rgb(argb, ARGB, mmx);
459 if (cpu_flags & AV_CPU_FLAG_MMX2) {
460 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmx2,);
463 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
464 switch (filtersize) { \
465 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
466 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
467 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
468 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
471 if (cpu_flags & AV_CPU_FLAG_SSE2) {
472 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
473 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
474 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2,);
475 ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
477 switch (c->srcFormat) {
479 c->lumToYV12 = ff_yuyvToY_sse2;
481 c->alpToYV12 = ff_uyvyToY_sse2;
483 case PIX_FMT_YUYV422:
484 c->lumToYV12 = ff_yuyvToY_sse2;
485 c->chrToYV12 = ff_yuyvToUV_sse2;
487 case PIX_FMT_UYVY422:
488 c->lumToYV12 = ff_uyvyToY_sse2;
489 c->chrToYV12 = ff_uyvyToUV_sse2;
492 c->chrToYV12 = ff_nv12ToUV_sse2;
495 c->chrToYV12 = ff_nv21ToUV_sse2;
497 case_rgb(rgb24, RGB24, sse2);
498 case_rgb(bgr24, BGR24, sse2);
499 case_rgb(bgra, BGRA, sse2);
500 case_rgb(rgba, RGBA, sse2);
501 case_rgb(abgr, ABGR, sse2);
502 case_rgb(argb, ARGB, sse2);
507 if (cpu_flags & AV_CPU_FLAG_SSSE3) {
508 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
509 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
510 switch (c->srcFormat) {
511 case_rgb(rgb24, RGB24, ssse3);
512 case_rgb(bgr24, BGR24, ssse3);
517 if (cpu_flags & AV_CPU_FLAG_SSE4) {
518 /* Xto15 don't need special sse4 functions */
519 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
520 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
521 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
522 if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4);
523 if (c->dstBpc == 16 && !isBE(c->dstFormat))
524 c->yuv2plane1 = ff_yuv2plane1_16_sse4;
527 if (HAVE_AVX && cpu_flags & AV_CPU_FLAG_AVX) {
528 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx,);
529 ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
531 switch (c->srcFormat) {
532 case PIX_FMT_YUYV422:
533 c->chrToYV12 = ff_yuyvToUV_avx;
535 case PIX_FMT_UYVY422:
536 c->chrToYV12 = ff_uyvyToUV_avx;
539 c->chrToYV12 = ff_nv12ToUV_avx;
542 c->chrToYV12 = ff_nv21ToUV_avx;
544 case_rgb(rgb24, RGB24, avx);
545 case_rgb(bgr24, BGR24, avx);
546 case_rgb(bgra, BGRA, avx);
547 case_rgb(rgba, RGBA, avx);
548 case_rgb(abgr, ABGR, avx);
549 case_rgb(argb, ARGB, avx);