* 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>
*
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++;
}