diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-24 10:03:26 -0400 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-24 10:03:26 -0400 |
commit | e66149e714006d099d1ebfcca3f22ca74fc7dcf4 (patch) | |
tree | 4be376903a92797c2c9f3c7e560a7c21247ace19 /libswscale/x86 | |
parent | 75abcdb3915e3abb2dc6b5f7d101c177dcfdb626 (diff) | |
download | ffmpeg-e66149e714006d099d1ebfcca3f22ca74fc7dcf4.tar.gz |
swscale: force --enable-runtime-cpudetect and remove SWS_CPU_CAPS_*.
Diffstat (limited to 'libswscale/x86')
-rw-r--r-- | libswscale/x86/rgb2rgb.c | 21 | ||||
-rw-r--r-- | libswscale/x86/swscale_template.c | 7 | ||||
-rw-r--r-- | libswscale/x86/yuv2rgb_mmx.c | 70 | ||||
-rw-r--r-- | libswscale/x86/yuv2rgb_template.c | 31 |
4 files changed, 64 insertions, 65 deletions
diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index e84bc1bcc9..cf901affe6 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -27,6 +27,7 @@ #include "config.h" #include "libavutil/x86_cpu.h" +#include "libavutil/cpu.h" #include "libavutil/bswap.h" #include "libswscale/rgb2rgb.h" #include "libswscale/swscale.h" @@ -122,16 +123,16 @@ DECLARE_ASM_CONST(8, uint64_t, blue_15mask) = 0x0000001f0000001fULL; 32-bit C version, and and&add trick by Michael Niedermayer */ -void rgb2rgb_init_x86(int flags) +void rgb2rgb_init_x86(void) { -#if HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX - if (flags & SWS_CPU_CAPS_SSE2) - rgb2rgb_init_SSE2(); - else if (flags & SWS_CPU_CAPS_MMX2) - rgb2rgb_init_MMX2(); - else if (flags & SWS_CPU_CAPS_3DNOW) - rgb2rgb_init_3DNOW(); - else if (flags & SWS_CPU_CAPS_MMX) + int cpu_flags = av_get_cpu_flags(); + + if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) rgb2rgb_init_MMX(); -#endif /* HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX */ + if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW) + rgb2rgb_init_3DNOW(); + if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) + rgb2rgb_init_MMX2(); + if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2) + rgb2rgb_init_SSE2(); } diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index d719721693..e9e093780d 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2721,10 +2721,11 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); - if (flags & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory"); + if (COMPILE_TEMPLATE_MMX2) __asm__ volatile("sfence":::"memory"); /* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */ - if (flags & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory"); - else __asm__ volatile("emms" :::"memory"); + if (COMPILE_TEMPLATE_AMD3DNOW) __asm__ volatile("femms" :::"memory"); + else __asm__ volatile("emms" :::"memory"); + /* store changed local vars back in the context */ c->dstY= dstY; c->lumBufIndex= lumBufIndex; diff --git a/libswscale/x86/yuv2rgb_mmx.c b/libswscale/x86/yuv2rgb_mmx.c index ff3a93db36..23d4c42700 100644 --- a/libswscale/x86/yuv2rgb_mmx.c +++ b/libswscale/x86/yuv2rgb_mmx.c @@ -34,6 +34,7 @@ #include "libswscale/swscale.h" #include "libswscale/swscale_internal.h" #include "libavutil/x86_cpu.h" +#include "libavutil/cpu.h" #define DITHER1XBPP // only for MMX @@ -46,57 +47,58 @@ DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL; DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL; //MMX versions +#if HAVE_MMX #undef RENAME -#undef HAVE_MMX2 -#undef HAVE_AMD3DNOW -#define HAVE_MMX2 0 -#define HAVE_AMD3DNOW 0 +#undef COMPILE_TEMPLATE_MMX2 +#define COMPILE_TEMPLATE_MMX2 0 #define RENAME(a) a ## _MMX #include "yuv2rgb_template.c" +#endif /* HAVE_MMX */ //MMX2 versions +#if HAVE_MMX2 #undef RENAME -#undef HAVE_MMX2 -#define HAVE_MMX2 1 +#undef COMPILE_TEMPLATE_MMX2 +#define COMPILE_TEMPLATE_MMX2 1 #define RENAME(a) a ## _MMX2 #include "yuv2rgb_template.c" +#endif /* HAVE_MMX2 */ SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c) { - if (c->flags & SWS_CPU_CAPS_MMX2) { + int cpu_flags = av_get_cpu_flags(); + + if (c->srcFormat != PIX_FMT_YUV420P && + c->srcFormat != PIX_FMT_YUVA420P) + return NULL; + + if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { switch (c->dstFormat) { - case PIX_FMT_RGB32: - if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { - if (HAVE_7REGS) return yuva420_rgb32_MMX2; - break; - } else return yuv420_rgb32_MMX2; - case PIX_FMT_BGR32: - if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { - if (HAVE_7REGS) return yuva420_bgr32_MMX2; - break; - } else return yuv420_bgr32_MMX2; case PIX_FMT_RGB24: return yuv420_rgb24_MMX2; case PIX_FMT_BGR24: return yuv420_bgr24_MMX2; - case PIX_FMT_RGB565: return yuv420_rgb16_MMX2; - case PIX_FMT_RGB555: return yuv420_rgb15_MMX2; } } - if (c->flags & SWS_CPU_CAPS_MMX) { + + if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { switch (c->dstFormat) { - case PIX_FMT_RGB32: - if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { - if (HAVE_7REGS) return yuva420_rgb32_MMX; - break; - } else return yuv420_rgb32_MMX; - case PIX_FMT_BGR32: - if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { - if (HAVE_7REGS) return yuva420_bgr32_MMX; - break; - } else return yuv420_bgr32_MMX; - case PIX_FMT_RGB24: return yuv420_rgb24_MMX; - case PIX_FMT_BGR24: return yuv420_bgr24_MMX; - case PIX_FMT_RGB565: return yuv420_rgb16_MMX; - case PIX_FMT_RGB555: return yuv420_rgb15_MMX; + case PIX_FMT_RGB32: + if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { +#if HAVE_7REGS + return yuva420_rgb32_MMX; +#endif + break; + } else return yuv420_rgb32_MMX; + case PIX_FMT_BGR32: + if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { +#if HAVE_7REGS + return yuva420_bgr32_MMX; +#endif + break; + } else return yuv420_bgr32_MMX; + case PIX_FMT_RGB24: return yuv420_rgb24_MMX; + case PIX_FMT_BGR24: return yuv420_bgr24_MMX; + case PIX_FMT_RGB565: return yuv420_rgb16_MMX; + case PIX_FMT_RGB555: return yuv420_rgb15_MMX; } } diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c index cf8f0d3cfb..5d1fa5b309 100644 --- a/libswscale/x86/yuv2rgb_template.c +++ b/libswscale/x86/yuv2rgb_template.c @@ -25,14 +25,7 @@ #undef EMMS #undef SFENCE -#if HAVE_AMD3DNOW -/* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */ -#define EMMS "femms" -#else -#define EMMS "emms" -#endif - -#if HAVE_MMX2 +#if COMPILE_TEMPLATE_MMX2 #define MOVNTQ "movntq" #define SFENCE "sfence" #else @@ -159,7 +152,8 @@ } \ #define YUV2RGB_ENDFUNC \ - __asm__ volatile (SFENCE"\n\t"EMMS); \ + __asm__ volatile (SFENCE"\n\t" \ + "emms \n\t"); \ return srcSliceH; \ #define IF0(x) @@ -188,6 +182,7 @@ "paddusb "GREEN_DITHER"(%4), %%mm2\n\t" \ "paddusb "RED_DITHER"(%4), %%mm1\n\t" \ +#if !COMPILE_TEMPLATE_MMX2 static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, @@ -243,6 +238,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[], YUV2RGB_OPERANDS YUV2RGB_ENDFUNC } +#endif /* !COMPILE_TEMPLATE_MMX2 */ #define RGB_PACK24(blue, red)\ "packuswb %%mm3, %%mm0 \n" /* R0 R2 R4 R6 R1 R3 R5 R7 */\ @@ -259,7 +255,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[], "punpckhwd %%mm6, %%mm5 \n" /* R4 G4 B4 R5 R6 G6 B6 R7 */\ RGB_PACK24_B -#if HAVE_MMX2 +#if COMPILE_TEMPLATE_MMX2 DECLARE_ASM_CONST(8, int16_t, mask1101[4]) = {-1,-1, 0,-1}; DECLARE_ASM_CONST(8, int16_t, mask0010[4]) = { 0, 0,-1, 0}; DECLARE_ASM_CONST(8, int16_t, mask0110[4]) = { 0,-1,-1, 0}; @@ -366,6 +362,7 @@ static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[], MOVNTQ " %%mm5, 16(%1)\n\t" \ MOVNTQ " %%mm"alpha", 24(%1)\n\t" \ +#if !COMPILE_TEMPLATE_MMX2 static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, @@ -386,12 +383,12 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[], YUV2RGB_ENDFUNC } +#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { -#if HAVE_7REGS int y, h_size; YUV2RGB_LOOP(4) @@ -406,10 +403,8 @@ static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[], YUV2RGB_ENDLOOP(4) YUV2RGB_OPERANDS_ALPHA YUV2RGB_ENDFUNC -#else - return 0; -#endif } +#endif static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[], int srcStride[], @@ -431,12 +426,12 @@ static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[], YUV2RGB_ENDFUNC } +#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { -#if HAVE_7REGS int y, h_size; YUV2RGB_LOOP(4) @@ -451,7 +446,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], YUV2RGB_ENDLOOP(4) YUV2RGB_OPERANDS_ALPHA YUV2RGB_ENDFUNC -#else - return 0; -#endif } +#endif + +#endif /* !COMPILE_TEMPLATE_MMX2 */ |