From 8e57c956bd0152f7d1fd3e7a5f4c74b8299a85d2 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 13 Sep 2009 11:03:23 +0200 Subject: improved sse2 detection --- acinclude.m4 | 222 +++++++++------------------------------------------- configure.in | 31 +++++--- plugins/ffap/ffap.c | 76 +++++++++--------- 3 files changed, 98 insertions(+), 231 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 81aeedfb..64cf8f41 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,12 +1,24 @@ # =========================================================================== -# http://autoconf-archive.cryp.to/ax_check_compiler_flags.html +# http://www.nongnu.org/autoconf-archive/ax_check_compiler_flags.html # =========================================================================== # +# SYNOPSIS +# +# AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE]) +# +# DESCRIPTION # -# COPYLEFT +# Check whether the given compiler FLAGS work with the current language's +# compiler, or whether they give an error. (Warnings, however, are +# ignored.) # -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# LICENSE +# +# Copyright (c) 2009 Steven G. Johnson +# Copyright (c) 2009 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -21,205 +33,43 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . # +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. AC_DEFUN([AX_CHECK_COMPILER_FLAGS], [AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1]) dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname: AS_LITERAL_IF([$1], - [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [ + [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [ ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, - AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) + AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes, + AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no) _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])], [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, - eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) + eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes, + eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no) _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS]) -eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1) +eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]) AC_MSG_RESULT($ax_check_compiler_flags) if test "x$ax_check_compiler_flags" = xyes; then - m4_default([$2], :) + m4_default([$2], :) else - m4_default([$3], :) + m4_default([$3], :) fi ])dnl AX_CHECK_COMPILER_FLAGS - - -# =========================================================================== -# http://autoconf-archive.cryp.to/ax_gcc_x86_cpuid.html -# =========================================================================== -# -# -# COPYLEFT -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program 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 General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# - - -AC_DEFUN([AX_GCC_X86_CPUID], -[AC_REQUIRE([AC_PROG_CC]) -AC_LANG_PUSH([C]) -AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, - [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ - int op = $1, eax, ebx, ecx, edx; - FILE *f; - /* 64-bit code is easy */ - if (sizeof(long) == 8) { - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - } else { - __asm__("pushl %%ebx \n\t" - "cpuid \n\t" - "movl %%ebx, %1 \n\t" - "popl %%ebx \n\t" - : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - } - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; -])], - [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown])]) -AC_LANG_POP([C]) -]) - - -# =========================================================================== -# http://www.nongnu.org/autoconf-archive/ax_ext.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_EXT -# -# DESCRIPTION -# -# Find supported SIMD extensions by requesting cpuid. When an SIMD -# extension is found, the -m"simdextensionname" is added to SIMD_FLAGS -# (only if compilator support it) (ie : if "sse2" is available "-msse2" is -# added to SIMD_FLAGS) -# -# This macro calls: -# -# AC_SUBST(SIMD_FLAGS) -# -# And defines: -# -# HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 -# -# LICENSE -# -# Copyright (c) 2008 Christophe Tournayre -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. - -AC_DEFUN([AX_EXT], -[ - AC_REQUIRE([AX_GCC_X86_CPUID]) - - AX_GCC_X86_CPUID(0x00000001) - ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3` - edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4` - if test "x$edx" = "xunknown"; then - ax_have_mmx_ext=no - ax_have_sse_ext=no - ax_have_sse_ext=no - ax_have_sse2_ext=no - ax_have_sse3_ext=no - ax_have_ssse3_ext=no - else - - AC_CACHE_CHECK([whether mmx is supported], [ax_have_mmx_ext], - [ - ax_have_mmx_ext=no - if test "$((0x$edx>>23&0x01))" = 1; then - ax_have_mmx_ext=yes - fi - ]) - - AC_CACHE_CHECK([whether sse is supported], [ax_have_sse_ext], - [ - ax_have_sse_ext=no - if test "$((0x$edx>>25&0x01))" = 1; then - ax_have_sse_ext=yes - fi - ]) - - AC_CACHE_CHECK([whether sse2 is supported], [ax_have_sse2_ext], - [ - ax_have_sse2_ext=no - if test "$((0x$edx>>26&0x01))" = 1; then - ax_have_sse2_ext=yes - fi - ]) - - AC_CACHE_CHECK([whether sse3 is supported], [ax_have_sse3_ext], - [ - ax_have_sse3_ext=no - if test "$((0x$ecx&0x01))" = 1; then - ax_have_sse3_ext=yes - fi - ]) - - AC_CACHE_CHECK([whether ssse3 is supported], [ax_have_ssse3_ext], - [ - ax_have_ssse3_ext=no - if test "$((0x$ecx>>9&0x01))" = 1; then - ax_have_ssse3_ext=yes - fi - ]) - - if test "$ax_have_mmx_ext" = yes; then - AC_DEFINE(HAVE_MMX,,[Support mmx instructions]) - AX_CHECK_COMPILER_FLAGS(-mmmx, SIMD_FLAGS="$SIMD_FLAGS -mmmx", []) - fi - - if test "$ax_have_sse_ext" = yes; then - AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions]) - AX_CHECK_COMPILER_FLAGS(-msse, SIMD_FLAGS="$SIMD_FLAGS -msse", []) - fi - - if test "$ax_have_sse2_ext" = yes; then - AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions]) - AX_CHECK_COMPILER_FLAGS(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", []) - fi - - if test "$ax_have_sse3_ext" = yes; then - AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions]) - AX_CHECK_COMPILER_FLAGS(-msse3, SIMD_FLAGS="$SIMD_FLAGS -msse3", []) - fi - - if test "$ax_have_ssse3_ext" = yes; then - AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions]) - fi - fi - - AC_SUBST(SIMD_FLAGS) -]) - diff --git a/configure.in b/configure.in index fa5fb6c0..f837e41c 100644 --- a/configure.in +++ b/configure.in @@ -11,27 +11,40 @@ AC_PROG_CC AC_PROG_CXX AC_STDC_HEADERS AC_PROG_INSTALL -dnl AC_PROG_RANLIB AC_PROG_LIBTOOL LT_INIT AC_CONFIG_MACRO_DIR([m4]) AC_C_BIGENDIAN -test "x$prefix" = xNONE && prefix=$ac_default_prefix +case "$host" in + i386-*-* | i486-*-* | i586-*-* | i686-*-* | i86pc-*-*) + AC_DEFINE(ARCH_X86_32, 1, [x86]) + ;; + x86_64-*-*) + AC_DEFINE(ARCH_X86_64, 1, [x86_64]) + ;; + powerpc-*-* ) + AC_DEFINE(ARCH_PPC_32, 1, [ppc32]) + ;; + powerpc64-*-* ) + AC_DEFINE(ARCH_PPC_64, 1, [ppc64]) + ;; + *) + AC_DEFINE(ARCH_UNKNOWN, 1, [unknown]) + ;; +esac -dnl AC_DEFINE([PREFIX], [], [Installation prefix]) -dnl AC_DEFINE_UNQUOTED(PREFIX, "${prefix}") -dnl -dnl AC_DEFINE([LIBDIR], [], [Library path]) -dnl LIBDIR="${libdir}" -dnl AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR") +test "x$prefix" = xNONE && prefix=$ac_default_prefix CFLAGS="$CFLAGS -D_GNU_SOURCE -DLIBDIR=\\\"$libdir\\\" -DPREFIX=\\\"$prefix\\\"" CPPFLAGS="$CFLAGS" PKG_CHECK_MODULES(DEPS, gtk+-2.0 >= 2.12 gthread-2.0 glib-2.0 samplerate alsa) -AX_EXT() +AX_CHECK_COMPILER_FLAGS(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2";HAVE_SSE2=1, []) +if test ${HAVE_SSE2}; then + AC_DEFINE(HAVE_SSE2,1,[Support SSE2 instructions]) +fi dnl lastfm plugin AC_CHECK_LIB([curl], [main], [HAVE_CURL=1]) diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c index 2b9be8df..3a18daa1 100644 --- a/plugins/ffap/ffap.c +++ b/plugins/ffap/ffap.c @@ -18,6 +18,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* + main changes compared to ffmpeg: + demuxer and decoder joined into 1 module + no mallocs/reallocs during decoding + streaming through fixed ringbuffer (small mem footprint) +*/ + #if HAVE_CONFIG_H #include "config.h" #endif @@ -1140,9 +1148,39 @@ static void init_filter(APEContext * ctx, APEFilter *f, int16_t * buf, int order #ifdef HAVE_SSE2 -#if __WORDSIZE==64 +#if ARCH_X86_64 +# define REG_a "eax" +# define REG_b "ebx" +# define REG_c "ecx" +# define REG_d "edx" +# define REG_D "edi" +# define REG_S "esi" +# define PTR_SIZE "4" +# define REG_SP "esp" +# define REG_BP "ebp" +# define REGBP ebp +# define REGa eax +# define REGb ebx +# define REGc ecx +# define REGd edx +# define REGSP esp typedef int64_t x86_reg; -#elif __WORDSIZE==32 +#elif ARCH_X86_32 +# define REG_a "rax" +# define REG_b "rbx" +# define REG_c "rcx" +# define REG_d "rdx" +# define REG_D "rdi" +# define REG_S "rsi" +# define PTR_SIZE "8" +# define REG_SP "rsp" +# define REG_BP "rbp" +# define REGBP rbp +# define REGa rax +# define REGb rbx +# define REGc rcx +# define REGd rdx +# define REGSP rsp typedef int32_t x86_reg; #else #warning unknown arch @@ -1715,40 +1753,6 @@ static DB_decoder_t plugin = { #ifdef HAVE_SSE2 -#if __WORDSIZE==64 -# define REG_a "rax" -# define REG_b "rbx" -# define REG_c "rcx" -# define REG_d "rdx" -# define REG_D "rdi" -# define REG_S "rsi" -# define PTR_SIZE "8" -# define REG_SP "rsp" -# define REG_BP "rbp" -# define REGBP rbp -# define REGa rax -# define REGb rbx -# define REGc rcx -# define REGd rdx -# define REGSP rsp -#else -# define REG_a "eax" -# define REG_b "ebx" -# define REG_c "ecx" -# define REG_d "edx" -# define REG_D "edi" -# define REG_S "esi" -# define PTR_SIZE "4" -# define REG_SP "esp" -# define REG_BP "ebp" -# define REGBP ebp -# define REGa eax -# define REGb ebx -# define REGc ecx -# define REGd edx -# define REGSP esp -#endif - #define FF_MM_MMX 0x0001 ///< standard MMX #define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW #define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext -- cgit v1.2.3