diff options
author | Diego Biurrun <diego@biurrun.de> | 2012-08-29 19:01:05 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2012-09-08 18:18:34 +0200 |
commit | e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6 (patch) | |
tree | 5118ee396e1879c3f90dfc1898e9bbd868e4b583 /libavresample | |
parent | 6a0200f24de51eeb94a3a1f75ee105786a6e088d (diff) | |
download | ffmpeg-e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6.tar.gz |
x86: Replace checks for CPU extensions and flags by convenience macros
This separates code relying on inline from that relying on external
assembly and fixes instances where the coalesced check was incorrect.
Diffstat (limited to 'libavresample')
-rw-r--r-- | libavresample/x86/audio_convert_init.c | 15 | ||||
-rw-r--r-- | libavresample/x86/audio_mix_init.c | 19 |
2 files changed, 17 insertions, 17 deletions
diff --git a/libavresample/x86/audio_convert_init.c b/libavresample/x86/audio_convert_init.c index a3589c6957..879108dff1 100644 --- a/libavresample/x86/audio_convert_init.c +++ b/libavresample/x86/audio_convert_init.c @@ -20,6 +20,7 @@ #include "config.h" #include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" #include "libavresample/audio_convert.h" /* flat conversions */ @@ -144,16 +145,15 @@ extern void ff_conv_flt_to_fltp_6ch_avx (float *const *dst, float *src, int len, av_cold void ff_audio_convert_init_x86(AudioConvert *ac) { -#if HAVE_YASM int mm_flags = av_get_cpu_flags(); - if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) { + if (EXTERNAL_MMX(mm_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, 0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx); } - if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { + if (EXTERNAL_SSE(mm_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, @@ -161,7 +161,7 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 2, 16, 4, "SSE", ff_conv_flt_to_fltp_2ch_sse); } - if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) { + if (EXTERNAL_SSE2(mm_flags)) { if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, 0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2); @@ -206,7 +206,7 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 6, 16, 4, "SSE2", ff_conv_flt_to_fltp_6ch_sse2); } - if (mm_flags & AV_CPU_FLAG_SSSE3 && HAVE_SSE) { + if (EXTERNAL_SSSE3(mm_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, @@ -220,13 +220,13 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 6, 16, 4, "SSSE3", ff_conv_flt_to_s16p_6ch_ssse3); } - if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { + if (EXTERNAL_SSE4(mm_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, 0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4); } - if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { + if (EXTERNAL_AVX(mm_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32, 0, 32, 16, "AVX", ff_conv_s32_to_flt_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, @@ -260,5 +260,4 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 6, 16, 4, "AVX", ff_conv_flt_to_fltp_6ch_avx); } -#endif } diff --git a/libavresample/x86/audio_mix_init.c b/libavresample/x86/audio_mix_init.c index 1b472afc2f..72b2397ad6 100644 --- a/libavresample/x86/audio_mix_init.c +++ b/libavresample/x86/audio_mix_init.c @@ -20,6 +20,7 @@ #include "config.h" #include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" #include "libavresample/audio_mix.h" extern void ff_mix_2_to_1_fltp_flt_sse(float **src, float **matrix, int len, @@ -105,7 +106,7 @@ DEFINE_MIX_3_8_TO_1_2(7) DEFINE_MIX_3_8_TO_1_2(8) #define SET_MIX_3_8_TO_1_2(chan) \ - if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { \ + if (EXTERNAL_SSE(mm_flags)) { \ ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\ chan, 1, 16, 4, "SSE", \ ff_mix_ ## chan ## _to_1_fltp_flt_sse); \ @@ -113,7 +114,7 @@ DEFINE_MIX_3_8_TO_1_2(8) chan, 2, 16, 4, "SSE", \ ff_mix_## chan ##_to_2_fltp_flt_sse); \ } \ - if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) { \ + if (EXTERNAL_SSE2(mm_flags)) { \ ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\ chan, 1, 16, 8, "SSE2", \ ff_mix_ ## chan ## _to_1_s16p_flt_sse2); \ @@ -121,7 +122,7 @@ DEFINE_MIX_3_8_TO_1_2(8) chan, 2, 16, 8, "SSE2", \ ff_mix_ ## chan ## _to_2_s16p_flt_sse2); \ } \ - if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { \ + if (EXTERNAL_SSE4(mm_flags)) { \ ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\ chan, 1, 16, 8, "SSE4", \ ff_mix_ ## chan ## _to_1_s16p_flt_sse4); \ @@ -129,7 +130,7 @@ DEFINE_MIX_3_8_TO_1_2(8) chan, 2, 16, 8, "SSE4", \ ff_mix_ ## chan ## _to_2_s16p_flt_sse4); \ } \ - if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { \ + if (EXTERNAL_AVX(mm_flags)) { \ int ptr_align = 32; \ int smp_align = 8; \ if (ARCH_X86_32 || chan >= 6) { \ @@ -149,7 +150,7 @@ DEFINE_MIX_3_8_TO_1_2(8) chan, 2, 16, 8, "AVX", \ ff_mix_ ## chan ## _to_2_s16p_flt_avx); \ } \ - if (mm_flags & AV_CPU_FLAG_FMA4 && HAVE_FMA4) { \ + if (EXTERNAL_FMA4(mm_flags)) { \ int ptr_align = 32; \ int smp_align = 8; \ if (ARCH_X86_32 || chan >= 6) { \ @@ -175,13 +176,13 @@ av_cold void ff_audio_mix_init_x86(AudioMix *am) #if HAVE_YASM int mm_flags = av_get_cpu_flags(); - if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { + if (EXTERNAL_SSE(mm_flags)) { ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT, 2, 1, 16, 8, "SSE", ff_mix_2_to_1_fltp_flt_sse); ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT, 1, 2, 16, 4, "SSE", ff_mix_1_to_2_fltp_flt_sse); } - if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) { + if (EXTERNAL_SSE2(mm_flags)) { ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT, 2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_flt_sse2); ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8, @@ -189,13 +190,13 @@ av_cold void ff_audio_mix_init_x86(AudioMix *am) ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT, 1, 2, 16, 8, "SSE2", ff_mix_1_to_2_s16p_flt_sse2); } - if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { + if (EXTERNAL_SSE4(mm_flags)) { ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT, 2, 1, 16, 8, "SSE4", ff_mix_2_to_1_s16p_flt_sse4); ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT, 1, 2, 16, 8, "SSE4", ff_mix_1_to_2_s16p_flt_sse4); } - if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { + if (EXTERNAL_AVX(mm_flags)) { ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT, 2, 1, 32, 16, "AVX", ff_mix_2_to_1_fltp_flt_avx); ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT, |