shithub: opus-tools

Download patch

ref: d1354febb0fad9e5e9016530666e5b5974c2aba7
parent: 53fa20951694bd4193addd8f9da413494e345751
author: Gregory Maxwell <greg@xiph.org>
date: Mon Jul 23 07:48:17 EDT 2012

Autoconf -msse for mingw/32bit builds, kill some warnings.

Also default to -O3/-ffast-math which is a ~3% speed
gain for opusdec while resampling on x86_64.

--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,17 @@
   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
 fi])
 
+if test "x$CFLAGS" = "x-g -O2"; then
+saved_CFLAGS="$CFLAGS"
+CFLAGS="-O3 -ffast-math"
+AC_MSG_CHECKING([if ${CC} supports -O3 -ffast-math])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
+      [ AC_MSG_RESULT([yes])
+        saved_CFLAGS="-O3 -ffast-math" ],
+        AC_MSG_RESULT([no]))
+CFLAGS="$saved_CFLAGS"
+fi
+
 dnl check for Ogg
 HAVE_OGG=no
 
@@ -172,10 +183,6 @@
 fi
 
 
-dnl Enable stack-protector-all only on x86 where it's well supported.
-dnl on some platforms it causes crashes. Hopefully the OS's default's
-dnl include this on platforms that work but have been missed here.
-
 on_x86=no
 case "$host_cpu" in
 i[[3456]]86 | x86_64)
@@ -182,6 +189,21 @@
   on_x86=yes
   ;;
 esac
+
+if test "x$on_x86" = "xyes"; then
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -msse"
+AC_MSG_CHECKING([if ${CC} supports -msse])
+AC_LINK_IFELSE([AC_LANG_SOURCE([void main(void){char foo;}])],
+      [ AC_MSG_RESULT([yes])
+        SSE="-msse"; ac_build_sse=yes ],
+        AC_MSG_RESULT([no]))
+CFLAGS="$saved_CFLAGS $SSE"
+fi
+
+dnl Enable stack-protector-all only on x86 where it's well supported.
+dnl on some platforms it causes crashes. Hopefully the OS's default's
+dnl include this on platforms that work but have been missed here.
 
 ac_build_stack_protector=no
 if test "x$ac_cv_c_compiler_gnu" = "xyes" && test "x$on_x86" = "xyes"; then
--- a/src/resample.c
+++ b/src/resample.c
@@ -337,7 +337,6 @@
    const int frac_advance = st->frac_advance;
    const spx_uint32_t den_rate = st->den_rate;
    spx_word32_t sum;
-   int j;
 
    while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len))
    {
@@ -345,6 +344,7 @@
       const spx_word16_t *iptr = & in[last_sample];
 
 #ifndef OVERRIDE_INNER_PRODUCT_SINGLE
+      int j;
       sum = 0;
       for(j=0;j<N;j++) sum += MULT16_16(sinct[j], iptr[j]);
 
@@ -394,7 +394,6 @@
    const int frac_advance = st->frac_advance;
    const spx_uint32_t den_rate = st->den_rate;
    double sum;
-   int j;
 
    while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len))
    {
@@ -402,6 +401,7 @@
       const spx_word16_t *iptr = & in[last_sample];
 
 #ifndef OVERRIDE_INNER_PRODUCT_DOUBLE
+      int j;
       double accum[4] = {0,0,0,0};
 
       for(j=0;j<N;j+=4) {
@@ -441,7 +441,6 @@
    const int int_advance = st->int_advance;
    const int frac_advance = st->frac_advance;
    const spx_uint32_t den_rate = st->den_rate;
-   int j;
    spx_word32_t sum;
 
    while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len))
@@ -458,6 +457,7 @@
 
 
 #ifndef OVERRIDE_INTERPOLATE_PRODUCT_SINGLE
+      int j;
       spx_word32_t accum[4] = {0,0,0,0};
 
       for(j=0;j<N;j++) {
@@ -503,7 +503,6 @@
    const int int_advance = st->int_advance;
    const int frac_advance = st->frac_advance;
    const spx_uint32_t den_rate = st->den_rate;
-   int j;
    spx_word32_t sum;
 
    while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len))
@@ -520,6 +519,7 @@
 
 
 #ifndef OVERRIDE_INTERPOLATE_PRODUCT_DOUBLE
+      int j;
       double accum[4] = {0,0,0,0};
 
       for(j=0;j<N;j++) {
--- a/src/resample_sse.h
+++ b/src/resample_sse.h
@@ -41,7 +41,7 @@
 #else
 #include <intrin.h>
 
-static inline int query_cpu_support_sse()
+static inline int query_cpu_support_sse(void)
 {
    static int initialized = 0;
    static int return_value;