fixed-point: starting conversion of the new PLC
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Thu, 31 Dec 2009 03:40:24 +0000 (22:40 -0500)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Thu, 31 Dec 2009 03:40:24 +0000 (22:40 -0500)
libcelt/celt.c
libcelt/plc.c

index 2e206e7..527e323 100644 (file)
@@ -55,6 +55,7 @@
 #include <stdarg.h>
 
 #define LPC_ORDER 24
+/* #define NEW_PLC */
 #if !defined(FIXED_POINT) || defined(NEW_PLC)
 #include "plc.c"
 #endif
@@ -1286,7 +1287,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
    for (c=0;c<C;c++)
    {
       celt_word32 e[MAX_PERIOD];
-      float exc[MAX_PERIOD];
+      celt_word16 exc[MAX_PERIOD];
       float ac[LPC_ORDER+1];
       float decay = 1;
       float S1=0;
@@ -1294,7 +1295,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
 
       offset = MAX_PERIOD-pitch_index;
       for (i=0;i<MAX_PERIOD;i++)
-         exc[i] = st->out_mem[i*C+c];
+         exc[i] = SHR32(st->out_mem[i*C+c], SIG_SHIFT);
 
       if (st->loss_count == 0)
       {
@@ -1340,7 +1341,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
             offset -= pitch_index;
             decay *= decay;
          }
-         e[i] = decay*exc[offset+i];
+         e[i] = decay*SHL32(EXTEND32(exc[offset+i]), SIG_SHIFT);
          S1 += st->out_mem[offset+i]*1.*st->out_mem[offset+i];
       }
 
index 8eb12d5..8d6d9a5 100644 (file)
@@ -42,12 +42,16 @@ int          p
       if (error<.00001*ac[0])
          break;
    }
+#ifdef FIXED_POINT
+   for (i=0;i<p;i++)
+      lpc[i] = (1./4096)*floor(.5+4096*lpc[i]);
+#endif
    return error;
 }
 
-void fir(const float *x,
+void fir(const celt_word16 *x,
          const float *num,
-         float *y,
+         celt_word16 *y,
          int N,
          int ord,
          float *mem)
@@ -95,7 +99,7 @@ void iir(const celt_word32 *x,
 }
 
 void _celt_autocorr(
-                   const float *x,   /*  in: [0...n-1] samples x   */
+                   const celt_word16 *x,   /*  in: [0...n-1] samples x   */
                    float       *ac,  /* out: [0...lag-1] ac values */
                    const celt_word16       *window,
                    int          overlap,