[xiph-commits] r14179 - in trunk/speex: . libspeex

jm at svn.xiph.org jm at svn.xiph.org
Sat Nov 17 18:46:57 PST 2007


Author: jm
Date: 2007-11-17 18:46:57 -0800 (Sat, 17 Nov 2007)
New Revision: 14179

Modified:
   trunk/speex/TODO
   trunk/speex/libspeex/stereo.c
Log:
fixed-point: stereo entirely converted


Modified: trunk/speex/TODO
===================================================================
--- trunk/speex/TODO	2007-11-18 00:17:40 UTC (rev 14178)
+++ trunk/speex/TODO	2007-11-18 02:46:57 UTC (rev 14179)
@@ -9,6 +9,7 @@
 
 
 Eventually:
+Fix last frame of speexenc
 Merge TriMedia stuff
 packet dump
 Do VAD properly

Modified: trunk/speex/libspeex/stereo.c
===================================================================
--- trunk/speex/libspeex/stereo.c	2007-11-18 00:17:40 UTC (rev 14178)
+++ trunk/speex/libspeex/stereo.c	2007-11-18 02:46:57 UTC (rev 14179)
@@ -145,10 +145,12 @@
 {
    int i, tmp;
    spx_word32_t e_left=0, e_right=0, e_tot=0;
-   spx_word32_t balance;
-   float e_ratio;
+   spx_word32_t balance, e_ratio;
    spx_word32_t largest, smallest;
    int balance_id;
+#ifdef FIXED_POINT
+   int shift;
+#endif
    
    /* In band marker */
    speex_bits_pack(bits, 14, 5);
@@ -177,16 +179,16 @@
       largest = e_right;
       smallest = e_left;
    }
+
+   /* Balance quantization */
 #ifdef FIXED_POINT
-   {
-      int shift = spx_ilog2(largest)-15;
-      largest = VSHR32(largest, shift-4);
-      smallest = VSHR32(smallest, shift);
-      balance = DIV32(largest, ADD32(smallest, 1));
-      if (balance > 32767)
-         balance = 32767;
-      balance_id = scal_quant(balance, balance_bounds, 32);
-   }
+   shift = spx_ilog2(largest)-15;
+   largest = VSHR32(largest, shift-4);
+   smallest = VSHR32(smallest, shift);
+   balance = DIV32(largest, ADD32(smallest, 1));
+   if (balance > 32767)
+      balance = 32767;
+   balance_id = scal_quant(EXTRACT16(balance), balance_bounds, 32);
 #else
    balance=(largest+1.)/(smallest+1.);
    balance=4*log(balance);
@@ -194,15 +196,22 @@
    if (balance_id>30)
       balance_id=31;
 #endif
-   /*fprintf (stderr, "%d %d %d\n", largest, smallest, balance_id);*/
-   /*Quantization*/
    
    speex_bits_pack(bits, balance_id, 5);
    
+   /* "coherence" quantisation */
+#ifdef FIXED_POINT
+   shift = spx_ilog2(e_tot);
+   e_tot = VSHR32(e_tot, shift-25);
+   e_left = VSHR32(e_left, shift-10);
+   e_right = VSHR32(e_right, shift-10);
+   e_ratio = DIV32(e_tot, e_left+e_right+1);
+#else
    e_ratio = e_tot/(1.+e_left+e_right);
-
-   /* FIXME: this is a hack */
-   tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 4);
+#endif
+   
+   tmp=scal_quant(EXTRACT16(e_ratio), e_ratio_quant_bounds, 4);
+   /*fprintf (stderr, "%d %d %d %d\n", largest, smallest, balance_id, e_ratio);*/
    speex_bits_pack(bits, tmp, 2);
 }
 



More information about the commits mailing list