]> git.sesse.net Git - vlc/commitdiff
* Really fixed strict aliasing breakage here and there.
authorSam Hocevar <sam@videolan.org>
Fri, 6 Aug 2004 17:28:36 +0000 (17:28 +0000)
committerSam Hocevar <sam@videolan.org>
Fri, 6 Aug 2004 17:28:36 +0000 (17:28 +0000)
modules/audio_filter/converter/float32tos16.c
modules/audio_filter/converter/s16tofloat32.c
modules/gui/skins2/x11/x11_window.cpp
modules/video_output/x11/xcommon.c
modules/visualization/visual/effects.c

index 87503f23acbd98711511c9e074456d646453ee44..bfd53f600a3746cb5b857aef076d967ca2c90afb 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.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++;
     }
index 2b8f323b4c258c8e4a3cf75b99e49f3a70706524..9aaca7103e92481caeb3ab27c468944c799574a2 100644 (file)
@@ -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--;
index 0541dbb9c02af416645243110b89a060c46c2883..f1ca4117e3db323a12c99aeb7803490fcc67e7b6 100644 (file)
@@ -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 */
index 1be7adc1c47c325ecccc7d8e970472345fc8ae76..c565cffcbfcc765723d408285bce1a2e3a65f9a2 100644 (file)
@@ -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 );
 }
 
 /*****************************************************************************
index 81f39f15b85645cdb321d3696bd60b5f29697e4a..03d324ad8bd58f937230e2ea98157ae203c27026 100644 (file)
@@ -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: ClĂ©ment 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++ ;
     }