ref: 0ac2b2fe0b7354b4a4b293adbfa3d20be8b62df2
parent: 454d1d0c21a28d899865aa4ae1eafec60be66197
author: Gregory Maxwell <[email protected]>
date: Thu May 21 19:08:46 EDT 2009
The change to FLOAT2INT16 in a8734e0f would break float input for fixed point compilation because SCALEIN is a no-op in fixed point mode but the float interface is still normally +/- 1.0. This patch adds a seperate define for the scaling factor so people can adjust it for unusual input levels.
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -37,6 +37,7 @@
#include "celt_types.h"
+#define CELT_SIG_SCALE 32768.
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
#ifdef ENABLE_ASSERTIONS
@@ -217,8 +218,8 @@
#define DIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b))
#define PDIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b))
-#define SCALEIN(a) ((a)*32768.)
-#define SCALEOUT(a) ((a)*(1/32768.))
+#define SCALEIN(a) ((a)*CELT_SIG_SCALE)
+#define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE))
#endif /* !FIXED_POINT */
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -158,7 +158,7 @@
static inline celt_int16_t FLOAT2INT16(float x)
{
- x = SCALEIN(x);
+ x = x*CELT_SIG_SCALE;
x = MAX32(x, -32768);
x = MIN32(x, 32767);
return (celt_int16_t)float2int(x);