[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: demux: ts: check adaptation field when reading PCR

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Jul 3 07:50:10 UTC 2021



Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC


Commits:
e381cd4b by Francois Cartegnie at 2021-07-02T09:13:44+02:00
demux: ts: check adaptation field when reading PCR

(cherry picked from commit 8a51b4f97bbc2b1bec8ba8bec7caee0518895569)

- - - - -
4c537f29 by Francois Cartegnie at 2021-07-02T09:13:45+02:00
demux: ts: improve desync debug messages

(cherry picked from commit a4ddf154af1dbf2ade9ba0bd72ff0c4a02ae7269)

- - - - -


1 changed file:

- modules/demux/mpeg/ts.c


Changes:

=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -1766,7 +1766,8 @@ static block_t* ReadTSPacket( demux_t *p_demux )
                 }
                 i_skip++;
             }
-            msg_Dbg( p_demux, "skipping %d bytes of garbage", i_skip );
+            msg_Dbg( p_demux, "skipping %d bytes of garbage at %"PRIu64,
+                     i_skip, vlc_stream_Tell( p_sys->stream ) );
             if (vlc_stream_Read( p_sys->stream, NULL, i_skip ) != i_skip)
                 return NULL;
 
@@ -1775,6 +1776,7 @@ static block_t* ReadTSPacket( demux_t *p_demux )
                 break;
             }
         }
+        msg_Dbg( p_demux, "resynced at %" PRIu64, vlc_stream_Tell( p_sys->stream ) );
         if( !( p_pkt = vlc_stream_Block( p_sys->stream, p_sys->i_packet_size ) ) )
         {
             msg_Dbg( p_demux, "eof ?" );
@@ -1790,10 +1792,15 @@ static mtime_t GetPCR( const block_t *p_pkt )
 
     mtime_t i_pcr = -1;
 
-    if( likely(p_pkt->i_buffer > 11) &&
-        ( p[3]&0x20 ) && /* adaptation */
-        ( p[5]&0x10 ) &&
-        ( p[4] >= 7 ) )
+    if(unlikely(p_pkt->i_buffer < 12))
+        return i_pcr;
+
+    const uint8_t i_adaption = p[3] & 0x30;
+
+    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
+          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
+        ( p[4] >= 7 )  &&
+        ( p[5] & 0x10 ) ) /* PCR carry flag */
     {
         /* PCR is 33 bits */
         i_pcr = ( (mtime_t)p[6] << 25 ) |



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44ed58ee9d9271c0ae08d52f8a9411026a783804...4c537f29b0ca27377badf7b7ed77bc4b0b4a9f32

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44ed58ee9d9271c0ae08d52f8a9411026a783804...4c537f29b0ca27377badf7b7ed77bc4b0b4a9f32
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list