fixed an old bug in QCONST (and made it 16-bit clean)
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 22 Apr 2006 04:57:02 +0000 (04:57 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 22 Apr 2006 04:57:02 +0000 (04:57 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@11234 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/fixed_debug.h

index 7403a18..262d1de 100644 (file)
@@ -40,8 +40,9 @@
 extern long long spx_mips;
 #define MIPS_INC spx_mips++,
 
-#define QCONST16(x,bits) ((spx_word16_t)((x)*(1<<(bits))+(1<<((bits)-1))))
-#define QCONST32(x,bits) ((spx_word32_t)((x)*(1<<(bits))+(1<<((bits)-1))))
+#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
+#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
+
 
 #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
 #define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL)