shithub: opus

Download patch

ref: fc8b605c1712a9b64b587835dde75920e0df71c6
parent: 59647fdb655bf6dc363c155b23bc817d195dc17d
author: Gregory Maxwell <[email protected]>
date: Wed Sep 28 13:09:23 EDT 2011

Eliminate signed overflow in constant, minor makefile.draft updates.

--- a/Makefile.draft
+++ b/Makefile.draft
@@ -7,16 +7,16 @@
 # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
 # USE_ALLOCA: Use alloca() for stack allocation
 # If none is defined, then the fallback is a non-threadsafe global array
-CFLAGS += -DUSE_ALLOCA
-#CFLAGS += -DVAR_ARRAYS
+CFLAGS := -DUSE_ALLOCA $(CFLAGS)
+#CFLAGS := -DVAR_ARRAYS $(CFLAGS)
 
 # These options affect performance
 # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
 #      inline: Don't use the 'inline' keyword (for ANSI C compilers)
 #    restrict: Don't use the 'restrict' keyword (for pre-C99 compilers)
-#CFLAGS += -DHAVE_LRINTF
-#CFLAGS += -Dinline=
-CFLAGS += -Drestrict=
+#CFLAGS := -DHAVE_LRINTF $(CFLAGS)
+#CFLAGS := -Dinline= $(CFLAGS)
+CFLAGS := -Drestrict= $(CFLAGS)
 
 ###################### END OF OPTIONS ######################
 
@@ -53,6 +53,25 @@
 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
 endif
 
+CINCLUDES += silk/ \
+        silk/float/ \
+        silk/fixed/ \
+	celt/ \
+	src/
+
+# VPATH e.g. VPATH = src:../headers
+VPATH = ./ \
+        silk/interface \
+        silk/src_FIX \
+        silk/src_FLP \
+        silk/src_SigProc_FIX \
+        silk/src_SigProc_FLP \
+        test
+
+LIBS = m
+
+LDLIBDIRS = ./
+
 CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
 CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
@@ -73,21 +92,7 @@
 
 # Directives
 
-CINCLUDES += silk/ \
-        silk/float/ \
-        silk/fixed/ \
-	celt/ \
-	src/
 
-# VPATH e.g. VPATH = src:../headers
-VPATH = ./ \
-        silk/interface \
-        silk/src_FIX \
-        silk/src_FLP \
-        silk/src_SigProc_FIX \
-        silk/src_SigProc_FLP \
-        test
-
 # Variable definitions
 LIB_NAME = opus
 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
@@ -101,10 +106,6 @@
 
 OPUSCOMPARE_SRCS_C = src/opus_compare.c
 OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
-
-LIBS = m
-
-LDLIBDIRS = ./
 
 # Rules
 default: all
--- a/silk/ana_filt_bank_1.c
+++ b/silk/ana_filt_bank_1.c
@@ -32,9 +32,8 @@
 #include "SigProc_FIX.h"
 
 /* Coefficients for 2-band filter bank based on first-order allpass filters */
-/* old*/
-static opus_int16 A_fb1_20[ 1 ] = {  5394 << 1 };
-static opus_int16 A_fb1_21[ 1 ] = { 20623 << 1 };        /* wrap-around to negative number is intentional */
+static opus_int16 A_fb1_20 = 5394 << 1;
+static opus_int16 A_fb1_21 = -24290; /* (opus_int16)(20623 << 1) */
 
 /* Split signal into two decimated bands using first-order allpass filters */
 void silk_ana_filt_bank_1(
@@ -55,7 +54,7 @@
 
         /* All-pass section for even input sample */
         Y      = silk_SUB32( in32, S[ 0 ] );
-        X      = silk_SMLAWB( Y, Y, A_fb1_21[ 0 ] );
+        X      = silk_SMLAWB( Y, Y, A_fb1_21 );
         out_1  = silk_ADD32( S[ 0 ], X );
         S[ 0 ] = silk_ADD32( in32, X );
 
@@ -64,7 +63,7 @@
 
         /* All-pass section for odd input sample, and add to output of previous section */
         Y      = silk_SUB32( in32, S[ 1 ] );
-        X      = silk_SMULWB( Y, A_fb1_20[ 0 ] );
+        X      = silk_SMULWB( Y, A_fb1_20 );
         out_2  = silk_ADD32( S[ 1 ], X );
         S[ 1 ] = silk_ADD32( in32, X );