* float32tos16.c : converter from float32 to signed 16 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: float32tos16.c,v 1.14 2003/12/04 16:02:54 sam Exp $
+ * $Id$
*
* 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. */
- float f_in = *p_in + 384.0;
- int32_t i_in;
- i_in = *(int32_t *)(intptr_t)&f_in;
- if ( i_in > 0x43c07fff ) *p_out = 32767;
- else if ( i_in < 0x43bf8000 ) *p_out = -32768;
- else *p_out = i_in - 0x43c00000;
+ union { float f; int32_t i; } u;
+ u.f = *p_in + 384.0;
+ if ( u.i > 0x43c07fff ) *p_out = 32767;
+ else if ( u.i < 0x43bf8000 ) *p_out = -32768;
+ else *p_out = u.i - 0x43c00000;
#endif
p_in++; p_out++;
}
* s16tofloat32.c : converter from signed 16 bits integer to float32
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: s16tofloat32.c,v 1.7 2003/12/04 16:02:54 sam Exp $
+ * $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/* This is walken's trick based on IEEE float format. On my PIII
* this takes 16 seconds to perform one billion conversions, instead
* of 19 seconds for the above division. */
- int32_t i_out = *p_in + 0x43c00000;
- float f_out = *(float *)(intptr_t)&i_out;
- *p_out = f_out - 384.0;
+ union { float f; int32_t i; } u;
+ u.i = *p_in + 0x43c00000;
+ *p_out = u.f - 384.0;
#endif
p_in--; p_out--;
{
int i_ret, i_format;
unsigned long i, i_items, i_bytesafter;
- Atom net_wm_supported, net_wm_state, net_wm_state_on_top, *p_args = NULL;
+ Atom net_wm_supported, net_wm_state, net_wm_state_on_top;
+ union { Atom *p_atom; unsigned char *p_char; } p_args;
+
+ p_args.p_atom = NULL;
net_wm_supported = XInternAtom( XDISPLAY, "_NET_SUPPORTED", False );
0, 16384, False, AnyPropertyType,
&net_wm_supported,
&i_format, &i_items, &i_bytesafter,
- (unsigned char **)(intptr_t)&p_args );
+ (unsigned char **)&p_args );
if( i_ret != Success || i_items == 0 ) return; /* Not supported */
for( i = 0; i < i_items; i++ )
{
- if( p_args[i] == net_wm_state_on_top ) break;
+ if( p_args.p_atom[i] == net_wm_state_on_top ) break;
}
- XFree( p_args );
+ XFree( p_args.p_atom );
if( i == i_items ) return; /* Not supported */
/* Switch "on top" status */
{
int i_ret, i_format;
unsigned long i, i_items, i_bytesafter;
- Atom net_wm_supported, *p_args = NULL;
+ Atom net_wm_supported;
+ union { Atom *p_atom; unsigned char *p_char; } p_args;
+
+ p_args.p_atom = NULL;
p_vout->p_sys->b_net_wm_state_fullscreen = VLC_FALSE;
p_vout->p_sys->b_net_wm_state_above = VLC_FALSE;
0, 16384, False, AnyPropertyType,
&net_wm_supported,
&i_format, &i_items, &i_bytesafter,
- (unsigned char **)(intptr_t)&p_args );
+ (unsigned char **)&p_args );
if( i_ret != Success || i_items == 0 ) return;
for( i = 0; i < i_items; i++ )
{
- if( p_args[i] == p_vout->p_sys->net_wm_state_fullscreen )
+ if( p_args.p_atom[i] == p_vout->p_sys->net_wm_state_fullscreen )
{
msg_Dbg( p_vout,
"Window manager supports _NET_WM_STATE_FULLSCREEN" );
p_vout->p_sys->b_net_wm_state_fullscreen = VLC_TRUE;
}
- else if( p_args[i] == p_vout->p_sys->net_wm_state_above )
+ else if( p_args.p_atom[i] == p_vout->p_sys->net_wm_state_above )
{
msg_Dbg( p_vout, "Window manager supports _NET_WM_STATE_ABOVE" );
p_vout->p_sys->b_net_wm_state_above = VLC_TRUE;
}
- else if( p_args[i] == p_vout->p_sys->net_wm_state_below )
+ else if( p_args.p_atom[i] == p_vout->p_sys->net_wm_state_below )
{
msg_Dbg( p_vout, "Window manager supports _NET_WM_STATE_BELOW" );
p_vout->p_sys->b_net_wm_state_below = VLC_TRUE;
}
- else if( p_args[i] == p_vout->p_sys->net_wm_state_stays_on_top )
+ else if( p_args.p_atom[i] == p_vout->p_sys->net_wm_state_stays_on_top )
{
msg_Dbg( p_vout,
"Window manager supports _NET_WM_STATE_STAYS_ON_TOP" );
}
}
- XFree( p_args );
+ XFree( p_args.p_atom );
}
/*****************************************************************************
* effects.c : Effects for the visualization system
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: effects.c,v 1.10 2003/12/04 16:02:54 sam Exp $
+ * $Id$
*
* Authors: Clément Stenac <zorglub@via.ecp.fr>
*
/* Pasted from float32tos16.c */
for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
{
- float f_in = *p_buffl + 384.0;
- int32_t i_in;
- i_in = *(int32_t *)(intptr_t)&f_in;
- if(i_in > 0x43c07fff ) * p_buffs = 32767;
- else if ( i_in < 0x43bf8000 ) *p_buffs = -32768;
- else *p_buffs = i_in - 0x43c00000;
+ union { float f; int32_t i; } u;
+ u.f = *p_buffl + 384.0;
+ if(u.i > 0x43c07fff ) * p_buffs = 32767;
+ else if ( u.i < 0x43bf8000 ) *p_buffs = -32768;
+ else *p_buffs = u.i - 0x43c00000;
p_buffl++ ; p_buffs++ ;
}