oggopus: bump draft date and version for 06 publication.
[opus.git] / configure.ac
index 0ba4a80..9b2f51f 100644 (file)
@@ -189,6 +189,10 @@ AC_ARG_ENABLE([rtcd],
     [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],,
     [enable_rtcd=yes])
 
+AC_ARG_ENABLE([intrinsics],
+    [AS_HELP_STRING([--enable-intrinsics], [Enable intrinsics optimizations (only for fixed point x86)])],,
+    [enable_intrinsics=no])
+
 rtcd_support=no
 cpu_arm=no
 
@@ -317,6 +321,14 @@ AS_IF([test x"${enable_asm}" = x"yes"],[
                     [rtcd_support=ARM"$rtcd_support"],
                     [rtcd_support="no"]
                 )
+                AC_MSG_CHECKING([for apple style tools])
+                AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
+#ifndef __APPLE__
+#error 1
+#endif],[])],
+                    [AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"],
+                    [AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""])
+                AC_SUBST(ARM2GNU_PARAMS)
             ],
             [
                 AC_MSG_WARN(
@@ -333,9 +345,113 @@ AS_IF([test x"${enable_asm}" = x"yes"],[
 
 AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
 AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],
-    [test x"${inline_optimization:0:3}" = x"ARM"])
+    [test x"${inline_optimization%% *}" = x"ARM"])
 AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],
-    [test x"${asm_optimization:0:3}" = x"ARM"])
+    [test x"${asm_optimization%% *}" = x"ARM"])
+
+AM_CONDITIONAL([HAVE_SSE4_1], [false])
+AM_CONDITIONAL([HAVE_SSE2], [false])
+AS_IF([test x"$enable_intrinsics" = x"yes"],[
+AS_IF([test x"$enable_float" = x"no"],
+[AS_IF([test x"$host_cpu" = x"i386" -o x"$host_cpu" = x"i686" -o x"$host_cpu" = x"x86_64"],[
+    AS_IF([test x"$enable_rtcd" = x"yes"],[
+            get_cpuid_by_asm="no"
+            AC_MSG_CHECKING([Get CPU Info])
+            AC_LINK_IFELSE(AC_LANG_PROGRAM([
+                 #include <stdio.h>
+            ],[
+                 unsigned int CPUInfo0;
+                 unsigned int CPUInfo1;
+                 unsigned int CPUInfo2;
+                 unsigned int CPUInfo3;
+                 unsigned int InfoType;
+                 __asm__ __volatile__ (
+                 "cpuid11":
+                 "=a" (CPUInfo0),
+                 "=b" (CPUInfo1),
+                 "=c" (CPUInfo2),
+                 "=d" (CPUInfo3) :
+                 "a" (InfoType), "c" (0)
+                );
+            ]),
+            [get_cpuid_by_asm="yes"
+             AC_MSG_RESULT([Inline Assembly])],
+             [AC_LINK_IFELSE(AC_LANG_PROGRAM([
+                 #include <cpuid.h>
+            ],[
+                 unsigned int CPUInfo0;
+                 unsigned int CPUInfo1;
+                 unsigned int CPUInfo2;
+                 unsigned int CPUInfo3;
+                 unsigned int InfoType;
+                 __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
+            ]),
+            [AC_MSG_RESULT([C method])],
+            [AC_MSG_ERROR([not support Get CPU Info, please disable intrinsics ])])])
+
+       AC_MSG_CHECKING([sse4.1])
+       TMP_CFLAGS="$CFLAGS"
+       gcc -Q --help=target | grep "\-msse4.1 "
+       AS_IF([test x"$?" = x"0"],[
+            CFLAGS="$CFLAGS -msse4.1"
+            AC_CHECK_HEADER(xmmintrin.h, [], [AC_MSG_ERROR([Couldn't find xmmintrin.h])])
+            AC_CHECK_HEADER(emmintrin.h, [], [AC_MSG_ERROR([Couldn't find emmintrin.h])])
+            AC_CHECK_HEADER(smmintrin.h, [], [AC_MSG_ERROR([Couldn't find smmintrin.h])],[
+            #ifdef HAVE_XMMINSTRIN_H
+                 #include <xmmintrin.h>
+                 #endif
+                 #ifdef HAVE_EMMINSTRIN_H
+                 #include <emmintrin.h>
+                 #endif
+            ])
+
+            AC_LINK_IFELSE(AC_LANG_PROGRAM([
+                 #include <xmmintrin.h>
+                 #include <emmintrin.h>
+                 #include <smmintrin.h>
+            ],[
+                 __m128i mtest = _mm_setzero_si128();
+                 mtest = _mm_cmpeq_epi64(mtest, mtest);
+            ]),
+            [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([Compiler & linker failure for sse4.1, please disable intrinsics])])
+
+            CFLAGS="$TMP_CFLAGS"
+            AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], [1], [For x86 sse4.1 instrinsics optimizations])
+            AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], [1], [For x86 sse2 instrinsics optimizations])
+            rtcd_support="x86 sse4.1"
+            AM_CONDITIONAL([HAVE_SSE4_1], [true])
+            AM_CONDITIONAL([HAVE_SSE2], [true])
+            AS_IF([test x"$get_cpuid_by_asm" = x"yes"],[AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
+            [AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by C method])])
+             ],[
+               gcc -Q --help=target | grep "\-msse2 "
+               AC_MSG_CHECKING([sse2])
+               AS_IF([test x"$?" = x"0"],[
+                   AC_MSG_RESULT([yes])
+                   CFLAGS="$CFLAGS -msse2"
+                   AC_CHECK_HEADER(xmmintrin.h, [], [AC_MSG_ERROR([Couldn't find xmmintrin.h])])
+                   AC_CHECK_HEADER(emmintrin.h, [], [AC_MSG_ERROR([Couldn't find emmintrin.h])])
+
+                   AC_LINK_IFELSE(AC_LANG_PROGRAM([
+                        #include <xmmintrin.h>
+                        #include <emmintrin.h>
+                   ],[
+                        __m128i mtest = _mm_setzero_si128();
+                   ]),
+                   [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([Compiler & linker failure for sse2, please disable intrinsics])])
+
+                  CFLAGS="$TMP_CFLAGS"
+                  AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], [1], [For x86 sse2 instrinsics optimize])
+                  rtcd_support="x86 sse2"
+                  AM_CONDITIONAL([HAVE_SSE2], [true])
+                  AS_IF([test x"$get_cpuid_by_asm" = x"yes"],[AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
+                  [AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])])
+            ],[enable_intrinsics="no"])
+        ])
+    ], [enable_intrinsics="no"])
+])
+], [enable_intrinsics="no"])
+])
 
 AS_IF([test x"$enable_rtcd" = x"yes"],[
     AS_IF([test x"$rtcd_support" != x"no"],[
@@ -443,6 +559,7 @@ AC_MSG_NOTICE([
       Fixed point debugging: ......... ${enable_fixed_point_debug}
       Inline Assembly Optimizations: . ${inline_optimization}
       External Assembly Optimizations: ${asm_optimization}
+      Intrinsics Optimizations.......: ${enable_intrinsics}
       Run-time CPU detection: ........ ${rtcd_support}
       Custom modes: .................. ${enable_custom_modes}
       Assertion checking: ............ ${enable_assertions}