Commit b5c2d452 authored by Sam Hocevar's avatar Sam Hocevar

* Really fixed strict aliasing breakage here and there.

parent 7e6650a1
......@@ -2,7 +2,7 @@
* 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>
*
......@@ -92,12 +92,11 @@ 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. */
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++;
}
......
......@@ -2,7 +2,7 @@
* 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>
*
......@@ -95,9 +95,9 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
/* 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--;
......
......@@ -176,7 +176,10 @@ void X11Window::toggleOnTop( bool onTop ) const
{
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 );
......@@ -185,7 +188,7 @@ void X11Window::toggleOnTop( bool onTop ) const
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 */
......@@ -195,10 +198,10 @@ void X11Window::toggleOnTop( bool onTop ) const
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 */
......
......@@ -2187,7 +2187,10 @@ static void TestNetWMSupport( vout_thread_t *p_vout )
{
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;
......@@ -2203,7 +2206,7 @@ static void TestNetWMSupport( vout_thread_t *p_vout )
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;
......@@ -2224,23 +2227,23 @@ static void TestNetWMSupport( vout_thread_t *p_vout )
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" );
......@@ -2248,7 +2251,7 @@ static void TestNetWMSupport( vout_thread_t *p_vout )
}
}
XFree( p_args );
XFree( p_args.p_atom );
}
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* 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: Clment Stenac <zorglub@via.ecp.fr>
*
......@@ -146,12 +146,11 @@ int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
/* 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++ ;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment