1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-04-08 16:54:03 +02:00

backport configure bits for cpu runtime detection for libpostproc and libswscale

Originally committed as revision 21611 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
This commit is contained in:
Reinhard Tartler 2010-02-02 20:30:20 +00:00
parent de3196da60
commit 478394bab7
4 changed files with 21 additions and 18 deletions

3
configure vendored
View File

@ -103,6 +103,7 @@ show_help(){
echo " --disable-golomb disable Golomb code" echo " --disable-golomb disable Golomb code"
echo " --disable-mdct disable MDCT code" echo " --disable-mdct disable MDCT code"
echo " --disable-rdft disable RDFT code" echo " --disable-rdft disable RDFT code"
echo " --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)"
echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation" echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers" echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
echo " --enable-beos-netserver enable BeOS netserver" echo " --enable-beos-netserver enable BeOS netserver"
@ -805,6 +806,7 @@ CONFIG_LIST="
postproc postproc
powerpc_perf powerpc_perf
rdft rdft
runtime_cpudetect
shared shared
small small
static static
@ -2268,6 +2270,7 @@ if test "$extra_version" != ""; then
echo "version string suffix $extra_version" echo "version string suffix $extra_version"
fi fi
echo "big-endian ${bigendian-no}" echo "big-endian ${bigendian-no}"
echo "runtime cpu detection ${runtime_cpudetect-no}"
if enabled x86; then if enabled x86; then
echo "yasm ${yasm-no}" echo "yasm ${yasm-no}"
echo "MMX enabled ${mmx-no}" echo "MMX enabled ${mmx-no}"

View File

@ -63,7 +63,7 @@ int has_altivec(void)
if (err == 0) return has_vu != 0; if (err == 0) return has_vu != 0;
return 0; return 0;
#elif defined(RUNTIME_CPUDETECT) #elif CONFIG_RUNTIME_CPUDETECT
int proc_ver; int proc_ver;
// Support of mfspr PVR emulation added in Linux 2.6.17. // Support of mfspr PVR emulation added in Linux 2.6.17.
__asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver));

View File

@ -554,7 +554,7 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
//Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one //Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
//Plain C versions //Plain C versions
#if !(HAVE_MMX || HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT) #if !(HAVE_MMX || HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_C #define COMPILE_C
#endif #endif
@ -564,15 +564,15 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
#if ARCH_X86 #if ARCH_X86
#if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT) #if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_MMX #define COMPILE_MMX
#endif #endif
#if HAVE_MMX2 || defined (RUNTIME_CPUDETECT) #if HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_MMX2 #define COMPILE_MMX2
#endif #endif
#if (HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT) #if (HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_3DNOW #define COMPILE_3DNOW
#endif #endif
#endif /* ARCH_X86 */ #endif /* ARCH_X86 */
@ -645,7 +645,7 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
// Using ifs here as they are faster than function pointers although the // Using ifs here as they are faster than function pointers although the
// difference would not be measurable here but it is much better because // difference would not be measurable here but it is much better because
// someone might exchange the CPU whithout restarting MPlayer ;) // someone might exchange the CPU whithout restarting MPlayer ;)
#ifdef RUNTIME_CPUDETECT #if CONFIG_RUNTIME_CPUDETECT
#if ARCH_X86 #if ARCH_X86
// ordered per speed fastest first // ordered per speed fastest first
if(c->cpuCaps & PP_CPU_CAPS_MMX2) if(c->cpuCaps & PP_CPU_CAPS_MMX2)
@ -664,7 +664,7 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
#endif #endif
postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
#endif #endif
#else //RUNTIME_CPUDETECT #else //CONFIG_RUNTIME_CPUDETECT
#if HAVE_MMX2 #if HAVE_MMX2
postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
#elif HAVE_AMD3DNOW #elif HAVE_AMD3DNOW
@ -676,7 +676,7 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
#else #else
postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
#endif #endif
#endif //!RUNTIME_CPUDETECT #endif //!CONFIG_RUNTIME_CPUDETECT
} }
//static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, //static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,

View File

@ -955,27 +955,27 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
//Note: we have C, X86, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one //Note: we have C, X86, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
//Plain C versions //Plain C versions
#if ((!HAVE_MMX || !CONFIG_GPL) && !HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT) #if ((!HAVE_MMX || !CONFIG_GPL) && !HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_C #define COMPILE_C
#endif #endif
#if ARCH_PPC #if ARCH_PPC
#if HAVE_ALTIVEC || defined (RUNTIME_CPUDETECT) #if HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT
#define COMPILE_ALTIVEC #define COMPILE_ALTIVEC
#endif #endif
#endif //ARCH_PPC #endif //ARCH_PPC
#if ARCH_X86 #if ARCH_X86
#if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL #if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
#define COMPILE_MMX #define COMPILE_MMX
#endif #endif
#if (HAVE_MMX2 || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL #if (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
#define COMPILE_MMX2 #define COMPILE_MMX2
#endif #endif
#if ((HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL #if ((HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
#define COMPILE_3DNOW #define COMPILE_3DNOW
#endif #endif
#endif //ARCH_X86 #endif //ARCH_X86
@ -1636,7 +1636,7 @@ static void globalInit(void){
static SwsFunc getSwsFunc(int flags){ static SwsFunc getSwsFunc(int flags){
#if defined(RUNTIME_CPUDETECT) #if CONFIG_RUNTIME_CPUDETECT
#if ARCH_X86 && CONFIG_GPL #if ARCH_X86 && CONFIG_GPL
// ordered per speed fastest first // ordered per speed fastest first
if (flags & SWS_CPU_CAPS_MMX2) if (flags & SWS_CPU_CAPS_MMX2)
@ -1657,7 +1657,7 @@ static SwsFunc getSwsFunc(int flags){
#endif #endif
return swScale_C; return swScale_C;
#endif /* ARCH_X86 && CONFIG_GPL */ #endif /* ARCH_X86 && CONFIG_GPL */
#else //RUNTIME_CPUDETECT #else //CONFIG_RUNTIME_CPUDETECT
#if HAVE_MMX2 #if HAVE_MMX2
return swScale_MMX2; return swScale_MMX2;
#elif HAVE_AMD3DNOW #elif HAVE_AMD3DNOW
@ -1669,7 +1669,7 @@ static SwsFunc getSwsFunc(int flags){
#else #else
return swScale_C; return swScale_C;
#endif #endif
#endif //!RUNTIME_CPUDETECT #endif //!CONFIG_RUNTIME_CPUDETECT
} }
static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
@ -2193,7 +2193,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
__asm__ volatile("emms\n\t"::: "memory"); __asm__ volatile("emms\n\t"::: "memory");
#endif #endif
#if !defined(RUNTIME_CPUDETECT) //ensure that the flags match the compiled variant if cpudetect is off #if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN); flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
#if HAVE_MMX2 #if HAVE_MMX2
flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2; flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
@ -2206,7 +2206,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
#elif ARCH_BFIN #elif ARCH_BFIN
flags |= SWS_CPU_CAPS_BFIN; flags |= SWS_CPU_CAPS_BFIN;
#endif #endif
#endif /* RUNTIME_CPUDETECT */ #endif /* CONFIG_RUNTIME_CPUDETECT */
if (clip_table[512] != 255) globalInit(); if (clip_table[512] != 255) globalInit();
if (!rgb15to16) sws_rgb2rgb_init(flags); if (!rgb15to16) sws_rgb2rgb_init(flags);