Signed-off-by: Muhammad Faiz <mfc...@gmail.com> --- configure | 42 ++++++++++++++++++++++++++++++++++ libavutil/x86/intrinsic.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 libavutil/x86/intrinsic.h
diff --git a/configure b/configure index 3299b1b..8f89e1e 100755 --- a/configure +++ b/configure @@ -386,6 +386,7 @@ Optimization options (experts only): --disable-neon disable NEON optimizations --disable-inline-asm disable use of inline assembly --disable-yasm disable use of nasm/yasm assembly + --disable-intrinsic disable use of intrinsic --disable-mipsdsp disable MIPS DSP ASE R1 optimizations --disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations --disable-msa disable MSA optimizations @@ -932,6 +933,25 @@ check_yasm(){ check_cmd $yasmexe $YASMFLAGS -Werror "$@" -o $TMPO $TMPS } +check_intrinsic_x86(){ + log check_intrinsic "$@" + name="$1_intrinsic" + include="$2" + attr="av_intrinsic_$1" + type="$3" + code="$4" + shift 4 + disable $name + { + cat "$source_path/libavutil/x86/intrinsic.h" + cat <<EOF + +#include <$include> +$attr void foo($type *a, $type *b) { $code; } +EOF + } | check_cc "$@" && enable $name +} + ld_o(){ eval printf '%s\\n' $LD_O } @@ -1748,6 +1768,7 @@ HAVE_LIST_CMDLINE=" inline_asm symver yasm + intrinsic " HAVE_LIST_PUB=" @@ -1948,6 +1969,7 @@ HAVE_LIST=" $ARCH_EXT_LIST $(add_suffix _external $ARCH_EXT_LIST) $(add_suffix _inline $ARCH_EXT_LIST) + $(add_suffix _intrinsic $ARCH_EXT_LIST) $ARCH_FEATURES $ATOMICS_LIST $BUILTIN_LIST @@ -3062,6 +3084,7 @@ enable safe_bitstream_reader enable static enable swscale_alpha enable valgrind_backtrace +enable intrinsic sws_max_filter_size_default=256 set_default sws_max_filter_size @@ -5276,6 +5299,25 @@ EOF enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"' enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"' + if enabled intrinsic; then + enabled mmx && check_intrinsic_x86 mmx mmintrin.h __m64 "*a = _mm_add_pi32(*a, *b)" + enabled mmxext && check_intrinsic_x86 mmxext xmmintrin.h __m64 "*a = _mm_max_pu8(*a, *b)" + enabled amd3dnow && check_intrinsic_x86 amd3dnow mm3dnow.h __m64 "*a = _m_pfadd(*a, *b)" + enabled amd3dnowext && check_intrinsic_x86 amd3dnowext mm3dnow.h __m64 "*a = _m_pfnacc(*a, *b)" + enabled sse && check_intrinsic_x86 sse xmmintrin.h __m128 "*a = _mm_add_ps(*a, *b)" + enabled sse2 && check_intrinsic_x86 sse2 emmintrin.h __m128d "*a = _mm_add_pd(*a, *b)" + enabled sse3 && check_intrinsic_x86 sse3 pmmintrin.h __m128 "*a = _mm_hadd_ps(*a, *b)" + enabled ssse3 && check_intrinsic_x86 ssse3 tmmintrin.h __m128i "*a = _mm_hadd_epi16(*a, *b)" + enabled sse4 && check_intrinsic_x86 sse4 smmintrin.h __m128 "*a = _mm_ceil_ps(*b)" + enabled sse42 && check_intrinsic_x86 sse42 smmintrin.h __m128i "*a = _mm_cmpistrm(*a, *b, 0)" + enabled avx && check_intrinsic_x86 avx immintrin.h __m256 "*a = _mm256_add_ps(*a, *b)" + enabled avx2 && check_intrinsic_x86 avx2 immintrin.h __m256i "*a = _mm256_add_epi8(*a, *b)" + enabled fma3 && check_intrinsic_x86 fma3 immintrin.h __m256 "*a = _mm256_fmadd_ps(*a, *b, *b)" + enabled fma4 && check_intrinsic_x86 fma4 x86intrin.h __m128 "*a = _mm_macc_ps(*a, *b, *b)" + enabled xop && check_intrinsic_x86 xop x86intrin.h __m128i "*a = _mm_macc_epi16(*a, *b, *a)" + enabled aesni && check_intrinsic_x86 aesni wmmintrin.h __m128i "*a = _mm_aesdec_si128(*a, *b)" + fi + if ! disabled_any asm mmx yasm; then if check_cmd $yasmexe --version; then enabled x86_64 && yasm_extra="-m amd64" diff --git a/libavutil/x86/intrinsic.h b/libavutil/x86/intrinsic.h new file mode 100644 index 0000000..d424cd8 --- /dev/null +++ b/libavutil/x86/intrinsic.h @@ -0,0 +1,58 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_X86_INTRINSIC_H +#define AVUTIL_X86_INTRINSIC_H + +#ifdef __GNUC__ +# define av_intrinsic_mmx __attribute__((__target__("mmx"))) +# define av_intrinsic_mmxext __attribute__((__target__("sse"))) +# define av_intrinsic_amd3dnow __attribute__((__target__("3dnow"))) +# define av_intrinsic_amd3dnowext __attribute__((__target__("3dnow"))) +# define av_intrinsic_sse __attribute__((__target__("sse"))) +# define av_intrinsic_sse2 __attribute__((__target__("sse2"))) +# define av_intrinsic_sse3 __attribute__((__target__("sse3"))) +# define av_intrinsic_ssse3 __attribute__((__target__("ssse3"))) +# define av_intrinsic_sse4 __attribute__((__target__("sse4.1"))) +# define av_intrinsic_sse42 __attribute__((__target__("sse4.2"))) +# define av_intrinsic_avx __attribute__((__target__("avx"))) +# define av_intrinsic_avx2 __attribute__((__target__("avx2"))) +# define av_intrinsic_fma3 __attribute__((__target__("fma"))) +# define av_intrinsic_fma4 __attribute__((__target__("fma4"))) +# define av_intrinsic_xop __attribute__((__target__("xop"))) +# define av_intrinsic_aesni __attribute__((__target__("aes"))) +#else +# define av_intrinsic_mmx +# define av_intrinsic_mmxext +# define av_intrinsic_amd3dnow +# define av_intrinsic_amd3dnowext +# define av_intrinsic_sse +# define av_intrinsic_sse2 +# define av_intrinsic_sse3 +# define av_intrinsic_ssse3 +# define av_intrinsic_sse4 +# define av_intrinsic_sse42 +# define av_intrinsic_avx +# define av_intrinsic_avx2 +# define av_intrinsic_fma +# define av_intrinsic_fma4 +# define av_intrinsic_xop +# define av_intrinsic_aesni +#endif + +#endif /* AVUTIL_X86_INTRINSIC_H */ -- 2.5.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel