shithub: opus

Download patch

ref: 2aaa0fee93a4a507d30c18b6b7ace9be07401db7
parent: 8600f69f796f48c359439577d092293e167be58e
author: Jean-Marc Valin <[email protected]>
date: Fri Feb 29 11:07:40 EST 2008

fixed-point: overflow debugging now works again.

--- a/libcelt/_kiss_fft_guts.h
+++ b/libcelt/_kiss_fft_guts.h
@@ -61,6 +61,8 @@
 #define TRIG_UPSCALE 65536
 #define TWID_MAX 2147483647
 #endif
+#define EXT32(a) (a)
+
 #else /* DOUBLE_PRECISION */
 
 # define FRACBITS 15
@@ -67,6 +69,7 @@
 # define SAMPPROD celt_int32_t 
 #define SAMP_MAX 32767
 #define TRIG_UPSCALE 1
+#define EXT32(a) EXTEND32(a)
 
 #endif /* !DOUBLE_PRECISION */
 
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Jean-Marc Valin */
+/* Copyright (C) 2003-2008 Jean-Marc Valin */
 /**
    @file fixed_debug.h
    @brief Fixed-point operations with debugging
@@ -170,6 +170,8 @@
 
 #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+#define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
 
 //#define SHR(a,shift) ((a) >> (shift))
 //#define SHL(a,shift) ((a) << (shift))
--- a/libcelt/kiss_fftr.c
+++ b/libcelt/kiss_fftr.c
@@ -109,11 +109,11 @@
 
    for ( k=1;k <= ncfft/2 ; ++k )
    {
-      f2k.r = SHR32(SUB32(EXTEND32(freqdata[2*k]), EXTEND32(freqdata[2*(ncfft-k)])),1);
-      f2k.i = PSHR32(ADD32(EXTEND32(freqdata[2*k+1]), EXTEND32(freqdata[2*(ncfft-k)+1])),1);
+      f2k.r = SHR32(SUB32(EXT32(freqdata[2*k]), EXT32(freqdata[2*(ncfft-k)])),1);
+      f2k.i = PSHR32(ADD32(EXT32(freqdata[2*k+1]), EXT32(freqdata[2*(ncfft-k)+1])),1);
       
-      f1k.r = SHR32(ADD32(EXTEND32(freqdata[2*k]), EXTEND32(freqdata[2*(ncfft-k)])),1);
-      f1k.i = SHR32(SUB32(EXTEND32(freqdata[2*k+1]), EXTEND32(freqdata[2*(ncfft-k)+1])),1);
+      f1k.r = SHR32(ADD32(EXT32(freqdata[2*k]), EXT32(freqdata[2*(ncfft-k)])),1);
+      f1k.i = SHR32(SUB32(EXT32(freqdata[2*k+1]), EXT32(freqdata[2*(ncfft-k)+1])),1);
       
       C_MULC( tw , f2k , st->super_twiddles[k]);