From 4d851f8dcf951d380e935ef14ae01db813adfc2d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 4 Mar 2012 16:08:48 +0100 Subject: cpu: add av_set_cpu_flags_mask(). --- libavutil/avutil.h | 2 +- libavutil/cpu.c | 12 +++++++++++- libavutil/cpu.h | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'libavutil') diff --git a/libavutil/avutil.h b/libavutil/avutil.h index e4219eb..21fc737 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -152,7 +152,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 24 +#define LIBAVUTIL_VERSION_MINOR 25 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 25895d6..e72f723 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -19,9 +19,11 @@ #include "cpu.h" #include "config.h" +static int cpuflags_mask, checked; + int av_get_cpu_flags(void) { - static int flags, checked; + static int flags; if (checked) return flags; @@ -30,10 +32,18 @@ int av_get_cpu_flags(void) if (ARCH_PPC) flags = ff_get_cpu_flags_ppc(); if (ARCH_X86) flags = ff_get_cpu_flags_x86(); + flags &= cpuflags_mask; checked = 1; + return flags; } +void av_set_cpu_flags_mask(int mask) +{ + cpuflags_mask = mask; + checked = 0; +} + #ifdef TEST #undef printf diff --git a/libavutil/cpu.h b/libavutil/cpu.h index df7bf44..361fe98 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -48,6 +48,14 @@ */ int av_get_cpu_flags(void); +/** + * Set a mask on flags returned by av_get_cpu_flags(). + * This function is mainly useful for testing. + * + * @warning this function is not thread safe. + */ +void av_set_cpu_flags_mask(int mask); + /* The following CPU-specific functions shall not be called directly. */ int ff_get_cpu_flags_arm(void); int ff_get_cpu_flags_ppc(void); -- cgit v1.1 From a9c5b6f6020c3fad6bf59985518e08453e002cdf Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 6 Mar 2012 12:47:23 -0800 Subject: cpu: initialize mask to -1, so that by default, optimizations are used. --- libavutil/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavutil') diff --git a/libavutil/cpu.c b/libavutil/cpu.c index e72f723..c44075b 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "config.h" -static int cpuflags_mask, checked; +static int cpuflags_mask = -1, checked; int av_get_cpu_flags(void) { -- cgit v1.1