[vlc-commits] packetizer/dts: fix NEXT_SYNC detection when there is padding

Thomas Guillem git at videolan.org
Wed Jan 11 13:18:05 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jan 10 18:21:25 2017 +0100| [2fc5034f04ebf53827088a3b480e8c71a877ed44] | committer: Thomas Guillem

packetizer/dts: fix NEXT_SYNC detection when there is padding

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

 modules/packetizer/dts.c | 51 ++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/modules/packetizer/dts.c b/modules/packetizer/dts.c
index 5799470..1bd9350 100644
--- a/modules/packetizer/dts.c
+++ b/modules/packetizer/dts.c
@@ -57,6 +57,7 @@ struct decoder_sys_t
     int i_state;
 
     block_bytestream_t bytestream;
+    size_t i_next_offset;
 
     /*
      * Common properties
@@ -204,39 +205,43 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
                 break;
             }
 
+            p_sys->i_next_offset = p_sys->dts.i_frame_size;
             p_sys->i_state = STATE_NEXT_SYNC;
 
         case STATE_NEXT_SYNC:
             /* Check if next expected frame contains the sync word */
-            if( block_PeekOffsetBytes( &p_sys->bytestream,
-                                       p_sys->dts.i_frame_size, p_header, 6 )
-                != VLC_SUCCESS )
+            while( p_sys->i_state == STATE_NEXT_SYNC )
             {
-                if( p_block == NULL ) /* drain */
+                if( block_PeekOffsetBytes( &p_sys->bytestream,
+                                           p_sys->i_next_offset, p_header, 6 )
+                                           != VLC_SUCCESS )
                 {
-                    p_sys->i_state = STATE_GET_DATA;
-                    break;
+                    if( p_block == NULL ) /* drain */
+                    {
+                        p_sys->i_state = STATE_GET_DATA;
+                        break;
+                    }
+                    /* Need more data */
+                    return NULL;
                 }
-                /* Need more data */
-                return NULL;
-            }
 
-            if( p_header[0] == 0 && p_header[1] == 0 )
-            {
-                /* DTS wav files and audio CD's use stuffing */
-                p_sys->i_state = STATE_GET_DATA;
-                break;
-            }
+                if( p_header[0] == 0 )
+                {
+                    /* DTS wav files, audio CD's and some mkvs use stuffing */
+                    p_sys->i_next_offset++;
+                    continue;
+                }
 
-            if( !vlc_dts_header_IsSync( p_header, 6 ) )
-            {
-                msg_Dbg( p_dec, "emulated sync word "
-                         "(no sync on following frame)" );
-                p_sys->i_state = STATE_NOSYNC;
-                block_SkipByte( &p_sys->bytestream );
-                break;
+                if( !vlc_dts_header_IsSync( p_header, 6 ) )
+                {
+                    msg_Dbg( p_dec, "emulated sync word "
+                             "(no sync on following frame)" );
+                    p_sys->i_state = STATE_NOSYNC;
+                    block_SkipByte( &p_sys->bytestream );
+                    break;
+                }
+                p_sys->i_state = STATE_SEND_DATA;
             }
-            p_sys->i_state = STATE_SEND_DATA;
             break;
 
         case STATE_GET_DATA:



More information about the vlc-commits mailing list