aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc-at-google.com@ffmpeg.org>2016-11-23 11:21:56 -0800
committerMichael Niedermayer <michael@niedermayer.cc>2016-11-23 22:35:25 +0100
commit29fb49194bedc74ac9be0b49b6b42dcfeb6222d9 (patch)
tree169ea4c414e9f6e073a1119244f1205fe64bd8bd /libavutil
parentdd10e7253abf280c603941613a4cc27ca347b76d (diff)
downloadffmpeg-29fb49194bedc74ac9be0b49b6b42dcfeb6222d9.tar.gz
avutil/cpu: remove the |checked| static variable
Remove the |checked| variable because the invalid value of -1 for |flags| can be used to indicate the same condition. Also rename |flags| to |cpu_flags| because there are a local variable and a function parameter named |flags| in the same file. Co-author: Dmitry Vyukov of Google Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/cpu.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index f5785fc13f..73317c4d4c 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -44,7 +44,20 @@
#include <unistd.h>
#endif
-static int flags, checked;
+static int cpu_flags = -1;
+
+static int get_cpu_flags(void)
+{
+ if (ARCH_AARCH64)
+ return ff_get_cpu_flags_aarch64();
+ if (ARCH_ARM)
+ return ff_get_cpu_flags_arm();
+ if (ARCH_PPC)
+ return ff_get_cpu_flags_ppc();
+ if (ARCH_X86)
+ return ff_get_cpu_flags_x86();
+ return 0;
+}
void av_force_cpu_flags(int arg){
if ( (arg & ( AV_CPU_FLAG_3DNOW |
@@ -69,33 +82,22 @@ void av_force_cpu_flags(int arg){
arg |= AV_CPU_FLAG_MMX;
}
- flags = arg;
- checked = arg != -1;
+ cpu_flags = arg;
}
int av_get_cpu_flags(void)
{
- if (checked)
- return flags;
-
- if (ARCH_AARCH64)
- flags = ff_get_cpu_flags_aarch64();
- if (ARCH_ARM)
- flags = ff_get_cpu_flags_arm();
- if (ARCH_PPC)
- flags = ff_get_cpu_flags_ppc();
- if (ARCH_X86)
- flags = ff_get_cpu_flags_x86();
-
- checked = 1;
+ int flags = cpu_flags;
+ if (flags == -1) {
+ flags = get_cpu_flags();
+ cpu_flags = flags;
+ }
return flags;
}
void av_set_cpu_flags_mask(int mask)
{
- checked = 0;
- flags = av_get_cpu_flags() & mask;
- checked = 1;
+ cpu_flags = get_cpu_flags() & mask;
}
int av_parse_cpu_flags(const char *s)