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

François Cartegnie gitlab at videolan.org
Wed Jun 9 14:42:42 UTC 2021



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
8a51b4f9 by Francois Cartegnie at 2021-06-09T11:02:45+02:00
demux: ts: check adaptation field when reading PCR

- - - - -
a4ddf154 by Francois Cartegnie at 2021-06-09T11:02:45+02:00
demux: ts: improve desync debug messages

- - - - -


1 changed file:

- modules/demux/mpeg/ts.c


Changes:

=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -1822,7 +1822,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;
 
@@ -1831,6 +1832,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 ?" );
@@ -1846,10 +1848,15 @@ static stime_t GetPCR( const block_t *p_pkt )
 
     stime_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 = ( (stime_t)p[6] << 25 ) |



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7ef4e1effe76ef9b33db0ca8f740c1b93cc6c8d9...a4ddf154af1dbf2ade9ba0bd72ff0c4a02ae7269

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7ef4e1effe76ef9b33db0ca8f740c1b93cc6c8d9...a4ddf154af1dbf2ade9ba0bd72ff0c4a02ae7269
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list