]> git.sesse.net Git - vlc/commitdiff
* ./modules/audio_filter/converter/s16tofloat32swab.c: compilation fix for
authorSam Hocevar <sam@videolan.org>
Wed, 18 Sep 2002 12:20:37 +0000 (12:20 +0000)
committerSam Hocevar <sam@videolan.org>
Wed, 18 Sep 2002 12:20:37 +0000 (12:20 +0000)
    systems which don't have swab(). Fixed a memory leak.

modules/audio_filter/converter/s16tofloat32swab.c

index 34df7e52d1920f350dc169e03cc6e7180a167c2c..7d25de80801b503f9cccff7b7e74afdc8d62f8a2 100644 (file)
@@ -3,7 +3,7 @@
  *                  with endianness change
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: s16tofloat32swab.c,v 1.1 2002/09/18 01:28:04 henri Exp $
+ * $Id: s16tofloat32swab.c,v 1.2 2002/09/18 12:20:37 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Henri Fallon <henri@videolan.org>
 #include <string.h>
 
 #include <vlc/vlc.h>
+
+#ifdef HAVE_UNISTD_H
+#   include <unistd.h>
+#endif
+
 #include "audio_output.h"
 #include "aout_internal.h"
 
@@ -94,25 +99,29 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
 
 #ifdef HAVE_SWAB
     s16 * p_swabbed = malloc( i * sizeof(s16) );
-    swab( p_in_buf->p_buffer, p_swabbed, 
-          i * sizeof(s16) );
+    swab( p_in_buf->p_buffer, p_swabbed, i * sizeof(s16) );
     
-    p_in = p_swabbed +i - 1;
+    p_in = p_swabbed + i - 1;
 #else
-    byte_t temp;
+    byte_t p_tmp[2];
 #endif
    
     while( i-- )
     {
 #ifndef HAVE_SWAB
-        temp = *(byte_t*)p_in;
-        *(byte_t*)p_in = *(byte_t*)p_in+1;
-        *(byte_t*)p_in+1 = temp;
-#endif
+        p_tmp[0] = ((byte_t*)p_in)[1];
+        p_tmp[1] = ((byte_t*)p_in)[0];
+        *p_out = (float)*p_tmp / 32768.0;
+#else
         *p_out = (float)*p_in / 32768.0;
+#endif
         p_in--; p_out--;
     }
 
+#ifdef HAVE_SWAB
+    free( p_swabbed );
+#endif
+
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2;
 }