[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: pva: move the timestamps reading after the block is created

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 21 10:03:38 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
fa9ae6e5 by Steve Lhomme at 2025-08-21T09:48:22+00:00
demux: pva: move the timestamps reading after the block is created

No need to do it before and check for errors later.

- - - - -
d92f1d5e by Steve Lhomme at 2025-08-21T09:48:22+00:00
demux: pva: avoid using data that were not read

We only use up to 14 + 1 + 5 bytes in the data we peek.

We need at least 9 bytes to read the amount of data to skip.

- - - - -


1 changed file:

- modules/demux/pva.c


Changes:

=====================================
modules/demux/pva.c
=====================================
@@ -396,19 +396,19 @@ static void ParsePES( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     block_t     *p_pes = p_sys->p_pes;
-    uint8_t     hdr[30];
+    uint8_t     hdr[20];
 
     unsigned    i_skip;
-    ts_90khz_t  i_dts = TS_90KHZ_INVALID;
-    ts_90khz_t  i_pts = TS_90KHZ_INVALID;
+    ts_90khz_t  i_dts;
+    ts_90khz_t  i_pts;
 
     p_sys->p_pes = NULL;
 
     /* FIXME find real max size */
-    block_ChainExtract( p_pes, hdr, 30 );
+    size_t hdr_read = block_ChainExtract( p_pes, hdr, ARRAY_SIZE(hdr) );
 
     /* See §2.4.3.6 of ISO 13818-1 */
-    if( hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 1 )
+    if( hdr_read < 9 || hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 1 )
     {
         msg_Warn( p_demux, "invalid hdr [0x%2.2x:%2.2x:%2.2x:%2.2x]",
                   hdr[0], hdr[1],hdr[2],hdr[3] );
@@ -420,15 +420,6 @@ static void ParsePES( demux_t *p_demux )
 
     /* we assume mpeg2 PES */
     i_skip = hdr[8] + 9;
-    if( hdr[7]&0x80 )    /* has pts */
-    {
-        i_pts = GetPESTimestamp( &hdr[9] );
-
-        if( hdr[7]&0x40 )    /* has dts */
-        {
-             i_dts = GetPESTimestamp( &hdr[14] );
-        }
-    }
 
     p_pes = block_ChainGather( p_pes );
     if( unlikely(p_pes == NULL) )
@@ -442,11 +433,18 @@ static void ParsePES( demux_t *p_demux )
     p_pes->i_buffer -= i_skip;
     p_pes->p_buffer += i_skip;
 
-    if( i_dts != TS_90KHZ_INVALID )
-        p_pes->i_dts = FROM_SCALE(i_dts);
-    if( i_pts != TS_90KHZ_INVALID )
+    if( hdr[7]&0x80 && hdr_read >= (9+1+5) )    /* has pts */
+    {
+        i_pts = GetPESTimestamp( &hdr[9] );
         p_pes->i_pts = FROM_SCALE(i_pts);
 
+        if( hdr[7]&0x40 && hdr_read >= (14+1+5) )    /* has dts */
+        {
+            i_dts = GetPESTimestamp( &hdr[14] );
+            p_pes->i_dts = FROM_SCALE(i_dts);
+        }
+    }
+
     /* Set PCR */
     if( p_pes->i_pts != VLC_TICK_INVALID )
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7e05533166e179194e2f9c4376004a3db82aa071...d92f1d5ea463d08f06f9c3634b2713e7f344fc40

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


VideoLAN code repository instance


More information about the vlc-commits mailing list