]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/converter/float32tos16.c
* New float32to* converter modules, courtesy of Xavier Maillard
[vlc] / modules / audio_filter / converter / float32tos16.c
index d4f1819f1a6b551d79546b37c845c8e9c0bc81fa..8a77a36fe9b5392ecba580c3c2de72ac6dd261b7 100644 (file)
@@ -2,7 +2,7 @@
  * float32tos16.c : converter from float32 to signed 16 bits integer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: float32tos16.c,v 1.5 2002/08/13 16:11:15 sam Exp $
+ * $Id: float32tos16.c,v 1.6 2002/08/13 22:42:23 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -96,11 +96,12 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
         else *p_out = *p_in * 32768.0;
 #else
         /* This is walken's trick based on IEEE float format. */
-        s32 * p_value = (s32 *)p_in;
-        *p_in += 384.0;
-        if ( *p_value > 0x43c07fff ) *p_out = 32767;
-        else if ( *p_value < 0x43bf8000 ) *p_out = -32768;
-        else *p_out = *p_value - 0x43c00000;
+        float f_in = *p_in + 384.0;
+        s32 i_in;
+        i_in = *(s32 *)&f_in;
+        if ( i_in > 0x43c07fff ) *p_out = 32767;
+        else if ( i_in < 0x43bf8000 ) *p_out = -32768;
+        else *p_out = i_in - 0x43c00000;
 #endif
         p_in++; p_out++;
     }