[xiph-commits] r13419 - trunk/ghost/libghost

jm at svn.xiph.org jm at svn.xiph.org
Tue Jul 31 23:24:05 PDT 2007


Author: jm
Date: 2007-07-31 23:24:05 -0700 (Tue, 31 Jul 2007)
New Revision: 13419

Modified:
   trunk/ghost/libghost/testghost.c
Log:
Saturating properly in case the signal is pretty high.


Modified: trunk/ghost/libghost/testghost.c
===================================================================
--- trunk/ghost/libghost/testghost.c	2007-07-31 15:40:36 UTC (rev 13418)
+++ trunk/ghost/libghost/testghost.c	2007-08-01 06:24:05 UTC (rev 13419)
@@ -102,7 +102,14 @@
          float_in[i] = short_in[i];
       ghost_encode(state, float_in);
       for (i=0;i<BLOCK_SIZE;i++)
-         short_in[i] = float_in[i];
+      {
+         if (float_in[i] > 32767)
+            short_in[i] = 32767;
+         else if (float_in[i] < -32768)
+            short_in[i] = -32768;
+         else 
+            short_in[i] = float_in[i];
+      }
       fwrite(short_in, sizeof(short), BLOCK_SIZE, fout);
    }
    ghost_encoder_state_destroy(state);



More information about the commits mailing list