vlc | branch: master | Thomas Guillem <tho...@gllm.fr> | Wed Jul 11 14:10:46 
2018 +0200| [a5359226bea6501eaef7050d703762301e618238] | committer: Thomas 
Guillem

packetizer/dts_header: fix wrong usage of swab

Pointer should not overlap.

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

 modules/packetizer/dts_header.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/packetizer/dts_header.c b/modules/packetizer/dts_header.c
index 943b062036..7a2b258a97 100644
--- a/modules/packetizer/dts_header.c
+++ b/modules/packetizer/dts_header.c
@@ -45,7 +45,8 @@ static void BufLeToBe( uint8_t *p_out, const uint8_t *p_in, 
int i_in )
     }
 }
 
-static int Buf14To16( uint8_t *p_out, const uint8_t *p_in, int i_in, int i_le )
+static int Buf14To16( uint8_t *p_out, const uint8_t *p_in, int i_in, int i_le,
+                      int i_out_le )
 {
     unsigned char tmp, cur = 0;
     int bits_in, bits_out = 0;
@@ -77,7 +78,10 @@ static int Buf14To16( uint8_t *p_out, const uint8_t *p_in, 
int i_in, int i_le )
 
         if( bits_out == 8 )
         {
-            p_out[i_out] = cur;
+            if( i_out % 2 )
+                p_out[i_out - i_out_le] = cur;
+            else
+                p_out[i_out + i_out_le] = cur;
             cur = 0;
             bits_out = 0;
             i_out++;
@@ -321,9 +325,7 @@ ssize_t vlc_dts_header_Convert14b16b( void *p_dst, size_t 
i_dst,
         return -1;
 
     int i_ret = Buf14To16( p_dst, p_src, i_src,
-                           bitstream_type == DTS_SYNC_CORE_14BITS_LE );
-    if( b_out_le ) /* since Buf14To16 convert to BE */
-        swab( p_dst, p_dst, i_ret );
+                           bitstream_type == DTS_SYNC_CORE_14BITS_LE, b_out_le 
);
     return i_ret;
 }
 
@@ -353,7 +355,7 @@ int vlc_dts_header_Parse( vlc_dts_header_t *p_header,
         {
             uint8_t conv_buf[VLC_DTS_HEADER_SIZE];
             Buf14To16( conv_buf, p_buffer, VLC_DTS_HEADER_SIZE,
-                       bitstream_type == DTS_SYNC_CORE_14BITS_LE );
+                       bitstream_type == DTS_SYNC_CORE_14BITS_LE, 0 );
             return dts_header_ParseCore( p_header, conv_buf, true );
         }
         case DTS_SYNC_SUBSTREAM:

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to