[vlc-commits] packetizer: a52: merge eac3 dependent blocks into independent ones

Thomas Guillem git at videolan.org
Thu Apr 12 10:12:57 CEST 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Apr 10 13:20:22 2018 +0200| [06a2882a43ab17f9c160b5f67c16e9e76735cbf4] | committer: Thomas Guillem

packetizer: a52: merge eac3 dependent blocks into independent ones

This fixes a regression from 4d41590a5513605e1204f37bd6e9afd7cf772d6e that
caused a wrong pts increment with eac3 dependent streams.

(cherry picked from commit 01d446d5f924ea23b85fdb192ad08bacaf63b6ca)
(cherry picked from commit 19676efa36d8aeaf8d7b75ac30d155d21226ed57)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/packetizer/a52.c | 46 ++++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/modules/packetizer/a52.c b/modules/packetizer/a52.c
index 5f9639e3e7..f9972a7649 100644
--- a/modules/packetizer/a52.c
+++ b/modules/packetizer/a52.c
@@ -70,6 +70,7 @@ struct decoder_sys_t
     bool    b_discontuinity;
 
     vlc_a52_header_t frame;
+    size_t  i_input_size;
 };
 
 static void PacketizeFlush( decoder_t *p_dec )
@@ -89,7 +90,7 @@ static block_t *GetOutBuffer( decoder_t *p_dec )
 
     assert( p_sys->frame.i_rate > 0 );
 
-    block_t *p_block = block_Alloc( p_sys->frame.i_size );
+    block_t *p_block = block_Alloc( p_sys->i_input_size );
     if( p_block == NULL )
         return NULL;
 
@@ -206,8 +207,8 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
             }
 
             /* Check if frame is valid and get frame info */
-            vlc_a52_header_t a52;
-            if( vlc_a52_header_Parse( &a52, p_header, VLC_A52_HEADER_SIZE ) )
+            if( vlc_a52_header_Parse( &p_sys->frame, p_header,
+                                      VLC_A52_HEADER_SIZE ) != VLC_SUCCESS )
             {
                 msg_Dbg( p_dec, "emulated sync word" );
                 block_SkipByte( &p_sys->bytestream );
@@ -215,30 +216,25 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
                 break;
             }
 
-            if( a52.b_eac3 && a52.eac3.strmtyp != EAC3_STRMTYP_INDEPENDENT )
+            if( p_sys->frame.b_eac3 && p_sys->frame.eac3.strmtyp == EAC3_STRMTYP_DEPENDENT )
             {
-                /* Use the channel configuration of the independent stream */
-                if( !p_sys->frame.i_blocks_per_sync_frame )
-                {
-                    /* Not synced on main stream yet */
-                    block_SkipByte( &p_sys->bytestream );
-                    p_sys->i_state = STATE_NOSYNC;
-                    break;
-                }
-                p_sys->frame.i_samples = a52.i_samples;
-                p_sys->frame.i_size = a52.i_size;
+                msg_Warn( p_dec, "starting with dependent stream, skip it" );
+                p_sys->i_state = STATE_NOSYNC;
+                if( block_SkipBytes( &p_sys->bytestream,
+                                     p_sys->frame.i_size ) != VLC_SUCCESS )
+                    return NULL;
+                break;
             }
-            else
-                p_sys->frame = a52;
 
+            p_sys->i_input_size = p_sys->frame.i_size;
             p_sys->i_state = STATE_NEXT_SYNC;
             /* fallthrough */
 
         case STATE_NEXT_SYNC:
             /* Check if next expected frame contains the sync word */
-            if( block_PeekOffsetBytes( &p_sys->bytestream,
-                                       p_sys->frame.i_size, p_header, 2 )
-                != VLC_SUCCESS )
+            if( block_PeekOffsetBytes( &p_sys->bytestream, p_sys->i_input_size,
+                                       p_header, VLC_A52_HEADER_SIZE )
+                                       != VLC_SUCCESS )
             {
                 if( p_block == NULL ) /* drain */
                 {
@@ -249,7 +245,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
                 return NULL;
             }
 
-            if( p_header[0] == 0 && p_header[1] == 0 )
+            if( p_header[0] == 0 || p_header[1] == 0 )
             {
                 /* A52 wav files and audio CD's use stuffing */
                 p_sys->i_state = STATE_GET_DATA;
@@ -264,13 +260,19 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
                 block_SkipByte( &p_sys->bytestream );
                 break;
             }
+
+            vlc_a52_header_t a52;
+            if( !vlc_a52_header_Parse( &a52, p_header, VLC_A52_HEADER_SIZE )
+             && a52.b_eac3 && a52.eac3.strmtyp == EAC3_STRMTYP_DEPENDENT )
+                p_sys->i_input_size += a52.i_size;
+
             p_sys->i_state = STATE_GET_DATA;
             break;
 
         case STATE_GET_DATA:
             /* Make sure we have enough data. */
             if( block_WaitBytes( &p_sys->bytestream,
-                                 p_sys->frame.i_size ) != VLC_SUCCESS )
+                                 p_sys->i_input_size ) != VLC_SUCCESS )
             {
                 /* Need more data */
                 return NULL;
@@ -287,7 +289,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
             /* Copy the whole frame into the buffer. When we reach this point
              * we already know we have enough data available. */
             block_GetBytes( &p_sys->bytestream, p_out_buffer->p_buffer,
-                            __MIN( p_sys->frame.i_size, p_out_buffer->i_buffer ) );
+                            p_out_buffer->i_buffer );
 
             p_sys->i_state = STATE_NOSYNC;
 



More information about the vlc-commits mailing list