[vlc-devel] commit: Always use swab. (Laurent Aimar )

git version control git at videolan.org
Sun Apr 12 15:34:17 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Apr 12 15:25:09 2009 +0200| [c5b59dc44c20173f7c0dc26e24c220f5cedcc011] | committer: Laurent Aimar 

Always use swab.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5b59dc44c20173f7c0dc26e24c220f5cedcc011
---

 modules/audio_filter/converter/a52tospdif.c |   14 --------------
 modules/audio_filter/converter/dtstospdif.c |   14 +-------------
 modules/audio_filter/converter/float.c      |   16 +---------------
 modules/demux/mpeg/es.c                     |   11 -----------
 4 files changed, 2 insertions(+), 53 deletions(-)

diff --git a/modules/audio_filter/converter/a52tospdif.c b/modules/audio_filter/converter/a52tospdif.c
index 58f463b..f438551 100644
--- a/modules/audio_filter/converter/a52tospdif.c
+++ b/modules/audio_filter/converter/a52tospdif.c
@@ -90,10 +90,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
      */
     static const uint8_t p_sync_le[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
     static const uint8_t p_sync_be[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 };
-#ifndef HAVE_SWAB
-    uint8_t * p_tmp;
-    uint16_t i;
-#endif
     uint16_t i_frame_size = p_in_buf->i_nb_bytes / 2;
     uint8_t * p_in = p_in_buf->p_buffer;
     uint8_t * p_out = p_out_buf->p_buffer;
@@ -113,17 +109,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
         p_out[5] = p_in[5] & 0x7; /* bsmod */
         p_out[6] = (i_frame_size << 4) & 0xff;
         p_out[7] = (i_frame_size >> 4) & 0xff;
-#ifdef HAVE_SWAB
         swab( p_in, &p_out[8], i_frame_size * 2 );
-#else
-        p_tmp = &p_out[8];
-        for( i = i_frame_size; i-- ; )
-        {
-            p_tmp[0] = p_in[1];
-            p_tmp[1] = p_in[0];
-            p_tmp += 2; p_in += 2;
-        }
-#endif
     }
     vlc_memset( p_out + 8 + i_frame_size * 2, 0,
                 AOUT_SPDIF_SIZE - i_frame_size * 2 - 8 );
diff --git a/modules/audio_filter/converter/dtstospdif.c b/modules/audio_filter/converter/dtstospdif.c
index 70cb64f..d55446d 100644
--- a/modules/audio_filter/converter/dtstospdif.c
+++ b/modules/audio_filter/converter/dtstospdif.c
@@ -191,20 +191,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
             /* We are dealing with a big endian bitstream and a little endian output
              * or a little endian bitstream and a big endian output.
              * Byteswap the stream */
-#ifdef HAVE_SWAB
             swab( p_in, p_out + 8, i_length );
-#else
-            uint16_t i;
-            uint8_t * p_tmp, tmp;
-            p_tmp = p_out + 8;
-            for( i = i_length / 2 ; i-- ; )
-            {
-                tmp = p_in[0]; /* in-place filter */
-                p_tmp[0] = p_in[1];
-                p_tmp[1] = tmp;
-                p_tmp += 2; p_in += 2;
-            }
-#endif
+
             /* If i_length is odd, we have to adjust swapping a bit.. */
             if( i_length & 1 )
             {
diff --git a/modules/audio_filter/converter/float.c b/modules/audio_filter/converter/float.c
index e2419a6..223aa1e 100644
--- a/modules/audio_filter/converter/float.c
+++ b/modules/audio_filter/converter/float.c
@@ -551,28 +551,14 @@ static void Do_S16ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
     int16_t * p_in;
     float * p_out = (float *)p_out_buf->p_buffer + i - 1;
 
-#ifdef HAVE_SWAB
     int16_t p_swabbed[i];
 
     swab( p_in_buf->p_buffer, p_swabbed, i * sizeof(int16_t) );
     p_in = p_swabbed + i - 1;
 
-#else
-    uint8_t p_tmp[2];
-    p_in = (int16_t *)p_in_buf->p_buffer + i - 1;
-#endif
 
     while( i-- )
-    {
-#ifndef HAVE_SWAB
-        p_tmp[0] = ((uint8_t *)p_in)[1];
-        p_tmp[1] = ((uint8_t *)p_in)[0];
-        *p_out = (float)( *(int16_t *)p_tmp ) / 32768.0;
-#else
-        *p_out = (float)*p_in / 32768.0;
-#endif
-        p_in--; p_out--;
-    }
+        *p_out-- = (float)*p_in-- / 32768.0;
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 2;
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 2fdbcd1..862f102 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -221,18 +221,7 @@ static int Demux( demux_t *p_demux )
     if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block_in->i_buffer > 0 )
     {
         /* Convert to big endian */
-#ifdef HAVE_SWAB
         swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
-#else
-        uint8_t *p_tmp = p_block_in->p_buffer;
-        for( int i = p_block_in->i_buffer / 2 ; i-- ; )
-        {
-            uint8_t tmp = p_tmp[0];
-            p_tmp[0] = p_tmp[1];
-            p_tmp[1] = tmp;
-            p_tmp += 2;
-        }
-#endif
     }
 
     p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? 1 : 0;




More information about the vlc-devel mailing list