00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <inttypes.h>
00022 #include "config.h"
00023 #include "libswscale/swscale.h"
00024 #include "libswscale/swscale_internal.h"
00025 #include "libavutil/intreadwrite.h"
00026 #include "libavutil/x86_cpu.h"
00027 #include "libavutil/cpu.h"
00028 #include "libavutil/pixdesc.h"
00029
00030 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
00031 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
00032 DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
00033 DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
00034 DECLARE_ASM_CONST(8, uint64_t, bm00001111)=0x00000000FFFFFFFFLL;
00035 DECLARE_ASM_CONST(8, uint64_t, bm00000111)=0x0000000000FFFFFFLL;
00036 DECLARE_ASM_CONST(8, uint64_t, bm11111000)=0xFFFFFFFFFF000000LL;
00037 DECLARE_ASM_CONST(8, uint64_t, bm01010101)=0x00FF00FF00FF00FFLL;
00038
00039 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
00040 0x0103010301030103LL,
00041 0x0200020002000200LL,};
00042
00043 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
00044 0x0602060206020602LL,
00045 0x0004000400040004LL,};
00046
00047 DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
00048 DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
00049 DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
00050 DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
00051 DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
00052 DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
00053
00054 DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
00055 DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
00056 DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
00057
00058 #ifdef FAST_BGR2YV12
00059 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
00060 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
00061 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
00062 #else
00063 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
00064 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
00065 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
00066 #endif
00067 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
00068 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
00069 DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
00070
00071 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toY1Coeff) = 0x0C88000040870C88ULL;
00072 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toY2Coeff) = 0x20DE4087000020DEULL;
00073 DECLARE_ASM_CONST(8, uint64_t, ff_rgb24toY1Coeff) = 0x20DE0000408720DEULL;
00074 DECLARE_ASM_CONST(8, uint64_t, ff_rgb24toY2Coeff) = 0x0C88408700000C88ULL;
00075 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toYOffset) = 0x0008010000080100ULL;
00076
00077 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUV)[2][4] = {
00078 {0x38380000DAC83838ULL, 0xECFFDAC80000ECFFULL, 0xF6E40000D0E3F6E4ULL, 0x3838D0E300003838ULL},
00079 {0xECFF0000DAC8ECFFULL, 0x3838DAC800003838ULL, 0x38380000D0E33838ULL, 0xF6E4D0E30000F6E4ULL},
00080 };
00081
00082 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUVOffset)= 0x0040010000400100ULL;
00083
00084
00085 #if HAVE_MMX
00086 #undef RENAME
00087 #define COMPILE_TEMPLATE_MMX2 0
00088 #define RENAME(a) a ## _MMX
00089 #include "swscale_template.c"
00090 #endif
00091
00092
00093 #if HAVE_MMX2
00094 #undef RENAME
00095 #undef COMPILE_TEMPLATE_MMX2
00096 #define COMPILE_TEMPLATE_MMX2 1
00097 #define RENAME(a) a ## _MMX2
00098 #include "swscale_template.c"
00099 #endif
00100
00101 void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
00102 int lastInLumBuf, int lastInChrBuf)
00103 {
00104 const int dstH= c->dstH;
00105 const int flags= c->flags;
00106 int16_t **lumPixBuf= c->lumPixBuf;
00107 int16_t **chrUPixBuf= c->chrUPixBuf;
00108 int16_t **alpPixBuf= c->alpPixBuf;
00109 const int vLumBufSize= c->vLumBufSize;
00110 const int vChrBufSize= c->vChrBufSize;
00111 int32_t *vLumFilterPos= c->vLumFilterPos;
00112 int32_t *vChrFilterPos= c->vChrFilterPos;
00113 int16_t *vLumFilter= c->vLumFilter;
00114 int16_t *vChrFilter= c->vChrFilter;
00115 int32_t *lumMmxFilter= c->lumMmxFilter;
00116 int32_t *chrMmxFilter= c->chrMmxFilter;
00117 int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
00118 const int vLumFilterSize= c->vLumFilterSize;
00119 const int vChrFilterSize= c->vChrFilterSize;
00120 const int chrDstY= dstY>>c->chrDstVSubSample;
00121 const int firstLumSrcY= vLumFilterPos[dstY];
00122 const int firstChrSrcY= vChrFilterPos[chrDstY];
00123
00124 c->blueDither= ff_dither8[dstY&1];
00125 if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
00126 c->greenDither= ff_dither8[dstY&1];
00127 else
00128 c->greenDither= ff_dither4[dstY&1];
00129 c->redDither= ff_dither8[(dstY+1)&1];
00130 if (dstY < dstH - 2) {
00131 const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
00132 const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
00133 const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
00134 int i;
00135
00136 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
00137 const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
00138 int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
00139 for (i = 0; i < neg; i++)
00140 tmpY[i] = lumSrcPtr[neg];
00141 for ( ; i < end; i++)
00142 tmpY[i] = lumSrcPtr[i];
00143 for ( ; i < vLumFilterSize; i++)
00144 tmpY[i] = tmpY[i-1];
00145 lumSrcPtr = tmpY;
00146
00147 if (alpSrcPtr) {
00148 const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
00149 for (i = 0; i < neg; i++)
00150 tmpA[i] = alpSrcPtr[neg];
00151 for ( ; i < end; i++)
00152 tmpA[i] = alpSrcPtr[i];
00153 for ( ; i < vLumFilterSize; i++)
00154 tmpA[i] = tmpA[i - 1];
00155 alpSrcPtr = tmpA;
00156 }
00157 }
00158 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
00159 const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
00160 int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
00161 for (i = 0; i < neg; i++) {
00162 tmpU[i] = chrUSrcPtr[neg];
00163 }
00164 for ( ; i < end; i++) {
00165 tmpU[i] = chrUSrcPtr[i];
00166 }
00167 for ( ; i < vChrFilterSize; i++) {
00168 tmpU[i] = tmpU[i - 1];
00169 }
00170 chrUSrcPtr = tmpU;
00171 }
00172
00173 if (flags & SWS_ACCURATE_RND) {
00174 int s= APCK_SIZE / 8;
00175 for (i=0; i<vLumFilterSize; i+=2) {
00176 *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
00177 *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
00178 lumMmxFilter[s*i+APCK_COEF/4 ]=
00179 lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
00180 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
00181 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
00182 *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
00183 *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
00184 alpMmxFilter[s*i+APCK_COEF/4 ]=
00185 alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
00186 }
00187 }
00188 for (i=0; i<vChrFilterSize; i+=2) {
00189 *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
00190 *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
00191 chrMmxFilter[s*i+APCK_COEF/4 ]=
00192 chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
00193 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
00194 }
00195 } else {
00196 for (i=0; i<vLumFilterSize; i++) {
00197 *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
00198 lumMmxFilter[4*i+2]=
00199 lumMmxFilter[4*i+3]=
00200 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
00201 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
00202 *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
00203 alpMmxFilter[4*i+2]=
00204 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
00205 }
00206 }
00207 for (i=0; i<vChrFilterSize; i++) {
00208 *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
00209 chrMmxFilter[4*i+2]=
00210 chrMmxFilter[4*i+3]=
00211 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
00212 }
00213 }
00214 }
00215 }
00216
00217 #if HAVE_MMX2
00218 static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
00219 const int16_t **src, uint8_t *dest, int dstW,
00220 const uint8_t *dither, int offset)
00221 {
00222 if(((int)dest) & 15){
00223 return yuv2yuvX_MMX2(filter, filterSize, src, dest, dstW, dither, offset);
00224 }
00225 if (offset) {
00226 __asm__ volatile("movq (%0), %%xmm3\n\t"
00227 "movdqa %%xmm3, %%xmm4\n\t"
00228 "psrlq $24, %%xmm3\n\t"
00229 "psllq $40, %%xmm4\n\t"
00230 "por %%xmm4, %%xmm3\n\t"
00231 :: "r"(dither)
00232 );
00233 } else {
00234 __asm__ volatile("movq (%0), %%xmm3\n\t"
00235 :: "r"(dither)
00236 );
00237 }
00238 __asm__ volatile(
00239 "pxor %%xmm0, %%xmm0\n\t"
00240 "punpcklbw %%xmm0, %%xmm3\n\t"
00241 "psraw $4, %%xmm3\n\t"
00242 "movdqa %%xmm3, %%xmm4\n\t"
00243 "movdqa %%xmm3, %%xmm7\n\t"
00244 "movl %3, %%ecx\n\t"
00245 "mov %0, %%"REG_d" \n\t"\
00246 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00247 ".p2align 4 \n\t" \
00248 "1: \n\t"\
00249 "movddup 8(%%"REG_d"), %%xmm0 \n\t" \
00250 "movdqa (%%"REG_S", %%"REG_c", 2), %%xmm2 \n\t" \
00251 "movdqa 16(%%"REG_S", %%"REG_c", 2), %%xmm5 \n\t" \
00252 "add $16, %%"REG_d" \n\t"\
00253 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00254 "test %%"REG_S", %%"REG_S" \n\t"\
00255 "pmulhw %%xmm0, %%xmm2 \n\t"\
00256 "pmulhw %%xmm0, %%xmm5 \n\t"\
00257 "paddw %%xmm2, %%xmm3 \n\t"\
00258 "paddw %%xmm5, %%xmm4 \n\t"\
00259 " jnz 1b \n\t"\
00260 "psraw $3, %%xmm3 \n\t"\
00261 "psraw $3, %%xmm4 \n\t"\
00262 "packuswb %%xmm4, %%xmm3 \n\t"
00263 "movntdq %%xmm3, (%1, %%"REG_c")\n\t"
00264 "add $16, %%"REG_c" \n\t"\
00265 "cmp %2, %%"REG_c" \n\t"\
00266 "movdqa %%xmm7, %%xmm3\n\t"
00267 "movdqa %%xmm7, %%xmm4\n\t"
00268 "mov %0, %%"REG_d" \n\t"\
00269 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00270 "jb 1b \n\t"\
00271 :: "g" (filter),
00272 "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
00273 : "%"REG_d, "%"REG_S, "%"REG_c
00274 );
00275 }
00276 #endif
00277
00278 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
00279 extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
00280 SwsContext *c, int16_t *data, \
00281 int dstW, const uint8_t *src, \
00282 const int16_t *filter, \
00283 const int32_t *filterPos, int filterSize)
00284
00285 #define SCALE_FUNCS(filter_n, opt) \
00286 SCALE_FUNC(filter_n, 8, 15, opt); \
00287 SCALE_FUNC(filter_n, 9, 15, opt); \
00288 SCALE_FUNC(filter_n, 10, 15, opt); \
00289 SCALE_FUNC(filter_n, 14, 15, opt); \
00290 SCALE_FUNC(filter_n, 16, 15, opt); \
00291 SCALE_FUNC(filter_n, 8, 19, opt); \
00292 SCALE_FUNC(filter_n, 9, 19, opt); \
00293 SCALE_FUNC(filter_n, 10, 19, opt); \
00294 SCALE_FUNC(filter_n, 14, 19, opt); \
00295 SCALE_FUNC(filter_n, 16, 19, opt)
00296
00297 #define SCALE_FUNCS_MMX(opt) \
00298 SCALE_FUNCS(4, opt); \
00299 SCALE_FUNCS(8, opt); \
00300 SCALE_FUNCS(X, opt)
00301
00302 #define SCALE_FUNCS_SSE(opt) \
00303 SCALE_FUNCS(4, opt); \
00304 SCALE_FUNCS(8, opt); \
00305 SCALE_FUNCS(X4, opt); \
00306 SCALE_FUNCS(X8, opt)
00307
00308 #if ARCH_X86_32
00309 SCALE_FUNCS_MMX(mmx);
00310 #endif
00311 SCALE_FUNCS_SSE(sse2);
00312 SCALE_FUNCS_SSE(ssse3);
00313 SCALE_FUNCS_SSE(sse4);
00314
00315 #define VSCALEX_FUNC(size, opt) \
00316 extern void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
00317 const int16_t **src, uint8_t *dest, int dstW, \
00318 const uint8_t *dither, int offset)
00319 #define VSCALEX_FUNCS(opt) \
00320 VSCALEX_FUNC(8, opt); \
00321 VSCALEX_FUNC(9, opt); \
00322 VSCALEX_FUNC(10, opt)
00323
00324 #if ARCH_X86_32
00325 VSCALEX_FUNCS(mmx2);
00326 #endif
00327 VSCALEX_FUNCS(sse2);
00328 VSCALEX_FUNCS(sse4);
00329 VSCALEX_FUNC(16, sse4);
00330 VSCALEX_FUNCS(avx);
00331
00332 #define VSCALE_FUNC(size, opt) \
00333 extern void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
00334 const uint8_t *dither, int offset)
00335 #define VSCALE_FUNCS(opt1, opt2) \
00336 VSCALE_FUNC(8, opt1); \
00337 VSCALE_FUNC(9, opt2); \
00338 VSCALE_FUNC(10, opt2); \
00339 VSCALE_FUNC(16, opt1)
00340
00341 #if ARCH_X86_32
00342 VSCALE_FUNCS(mmx, mmx2);
00343 #endif
00344 VSCALE_FUNCS(sse2, sse2);
00345 VSCALE_FUNC(16, sse4);
00346 VSCALE_FUNCS(avx, avx);
00347
00348 #define INPUT_UV_FUNC(fmt, opt) \
00349 extern void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
00350 const uint8_t *src, const uint8_t *unused1, \
00351 int w, uint32_t *unused2)
00352 #define INPUT_FUNC(fmt, opt) \
00353 extern void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
00354 int w, uint32_t *unused); \
00355 INPUT_UV_FUNC(fmt, opt)
00356 #define INPUT_FUNCS(opt) \
00357 INPUT_FUNC(uyvy, opt); \
00358 INPUT_FUNC(yuyv, opt); \
00359 INPUT_UV_FUNC(nv12, opt); \
00360 INPUT_UV_FUNC(nv21, opt)
00361
00362 #if ARCH_X86_32
00363 INPUT_FUNCS(mmx);
00364 #endif
00365 INPUT_FUNCS(sse2);
00366 INPUT_FUNCS(avx);
00367
00368 void ff_sws_init_swScale_mmx(SwsContext *c)
00369 {
00370 int cpu_flags = av_get_cpu_flags();
00371
00372 if (cpu_flags & AV_CPU_FLAG_MMX)
00373 sws_init_swScale_MMX(c);
00374 #if HAVE_MMX2
00375 if (cpu_flags & AV_CPU_FLAG_MMX2)
00376 sws_init_swScale_MMX2(c);
00377 if (cpu_flags & AV_CPU_FLAG_SSE3){
00378 if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
00379 c->yuv2planeX = yuv2yuvX_sse3;
00380 }
00381 #endif
00382
00383 #if HAVE_YASM
00384 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
00385 if (c->srcBpc == 8) { \
00386 hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
00387 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
00388 } else if (c->srcBpc == 9) { \
00389 hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
00390 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
00391 } else if (c->srcBpc == 10) { \
00392 hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
00393 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
00394 } else if (c->srcBpc == 14 || ((c->srcFormat==PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)) { \
00395 hscalefn = c->dstBpc <= 10 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
00396 ff_hscale14to19_ ## filtersize ## _ ## opt1; \
00397 } else { \
00398 hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
00399 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
00400 } \
00401 } while (0)
00402 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
00403 switch (filtersize) { \
00404 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
00405 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
00406 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
00407 }
00408 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case) \
00409 switch(c->dstBpc){ \
00410 case 16: break; \
00411 case 10: if (!isBE(c->dstFormat)) break; \
00412 case 9: if (!isBE(c->dstFormat)) break; \
00413 default: break; \
00414 }
00415 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
00416 switch(c->dstBpc){ \
00417 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
00418 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
00419 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
00420 default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
00421 }
00422 #if ARCH_X86_32
00423 if (cpu_flags & AV_CPU_FLAG_MMX) {
00424 ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
00425 ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
00426 ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmx2, cpu_flags & AV_CPU_FLAG_MMX2);
00427
00428 switch (c->srcFormat) {
00429 case PIX_FMT_Y400A:
00430 c->lumToYV12 = ff_yuyvToY_mmx;
00431 if (c->alpPixBuf)
00432 c->alpToYV12 = ff_uyvyToY_mmx;
00433 break;
00434 case PIX_FMT_YUYV422:
00435 c->lumToYV12 = ff_yuyvToY_mmx;
00436 c->chrToYV12 = ff_yuyvToUV_mmx;
00437 break;
00438 case PIX_FMT_UYVY422:
00439 c->lumToYV12 = ff_uyvyToY_mmx;
00440 c->chrToYV12 = ff_uyvyToUV_mmx;
00441 break;
00442 case PIX_FMT_NV12:
00443 c->chrToYV12 = ff_nv12ToUV_mmx;
00444 break;
00445 case PIX_FMT_NV21:
00446 c->chrToYV12 = ff_nv21ToUV_mmx;
00447 break;
00448 default:
00449 break;
00450 }
00451 }
00452 if (cpu_flags & AV_CPU_FLAG_MMX2) {
00453 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmx2,);
00454 }
00455 #endif
00456 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
00457 switch (filtersize) { \
00458 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
00459 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
00460 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
00461 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
00462 break; \
00463 }
00464 if (cpu_flags & AV_CPU_FLAG_SSE2) {
00465 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
00466 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
00467 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2,);
00468 ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
00469
00470 switch (c->srcFormat) {
00471 case PIX_FMT_Y400A:
00472 c->lumToYV12 = ff_yuyvToY_sse2;
00473 if (c->alpPixBuf)
00474 c->alpToYV12 = ff_uyvyToY_sse2;
00475 break;
00476 case PIX_FMT_YUYV422:
00477 c->lumToYV12 = ff_yuyvToY_sse2;
00478 c->chrToYV12 = ff_yuyvToUV_sse2;
00479 break;
00480 case PIX_FMT_UYVY422:
00481 c->lumToYV12 = ff_uyvyToY_sse2;
00482 c->chrToYV12 = ff_uyvyToUV_sse2;
00483 break;
00484 case PIX_FMT_NV12:
00485 c->chrToYV12 = ff_nv12ToUV_sse2;
00486 break;
00487 case PIX_FMT_NV21:
00488 c->chrToYV12 = ff_nv21ToUV_sse2;
00489 break;
00490 }
00491 }
00492 if (cpu_flags & AV_CPU_FLAG_SSSE3) {
00493 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
00494 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
00495 }
00496 if (cpu_flags & AV_CPU_FLAG_SSE4) {
00497
00498 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
00499 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
00500 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
00501 if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4);
00502 if (c->dstBpc == 16 && !isBE(c->dstFormat))
00503 c->yuv2plane1 = ff_yuv2plane1_16_sse4;
00504 }
00505
00506 if (HAVE_AVX && cpu_flags & AV_CPU_FLAG_AVX) {
00507 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx,);
00508 ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
00509
00510 switch (c->srcFormat) {
00511 case PIX_FMT_YUYV422:
00512 c->chrToYV12 = ff_yuyvToUV_avx;
00513 break;
00514 case PIX_FMT_UYVY422:
00515 c->chrToYV12 = ff_uyvyToUV_avx;
00516 break;
00517 case PIX_FMT_NV12:
00518 c->chrToYV12 = ff_nv12ToUV_avx;
00519 break;
00520 case PIX_FMT_NV21:
00521 c->chrToYV12 = ff_nv21ToUV_avx;
00522 break;
00523 default:
00524 break;
00525 }
00526 }
00527 #endif
00528 }