[vlc-commits] [Git][videolan/vlc][3.0.x] 3 commits: demux: pva: fix PTS computation

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Aug 26 05:42:19 UTC 2025



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
a79c2014 by Steve Lhomme at 2025-08-26T05:24:08+00:00
demux: pva: fix PTS computation

On 4.0 the MPEG macros are used since 65838ea0fee8d7634cb00baf1310478b56bbd8b1.
The last part uses an offset of 4 in the buffer. This is also the case
for the computed DTS in 3.0.

- - - - -
214783ab by Steve Lhomme at 2025-08-26T05:24:08+00:00
demux: pva: move the timestamps reading after the block is created

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

(cherry picked from commit fa9ae6e57af6670bfab68451a6cf7ce515387a20) (edited)
edited:
- 3.0 doesn't have the MPEG timestamp helpers

- - - - -
12c23251 by Steve Lhomme at 2025-08-26T05:24:08+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.

(cherry picked from commit d92f1d5ea463d08f06f9c3634b2713e7f344fc40)

- - - - -


1 changed file:

- modules/demux/pva.c


Changes:

=====================================
modules/demux/pva.c
=====================================
@@ -391,19 +391,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] );
@@ -415,23 +415,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 = ((ts_90khz_t)(hdr[ 9]&0x0e ) << 29)|
-                 (ts_90khz_t)(hdr[10] << 22)|
-                ((ts_90khz_t)(hdr[11]&0xfe) << 14)|
-                 (ts_90khz_t)(hdr[12] << 7)|
-                 (ts_90khz_t)(hdr[12] >> 1);
-
-        if( hdr[7]&0x40 )    /* has dts */
-        {
-             i_dts = ((ts_90khz_t)(hdr[14]&0x0e ) << 29)|
-                     (ts_90khz_t)(hdr[15] << 22)|
-                    ((ts_90khz_t)(hdr[16]&0xfe) << 14)|
-                     (ts_90khz_t)(hdr[17] << 7)|
-                     (ts_90khz_t)(hdr[18] >> 1);
-        }
-    }
 
     p_pes = block_ChainGather( p_pes );
     if( unlikely(p_pes == NULL) )
@@ -445,11 +428,26 @@ 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 = ((ts_90khz_t)(hdr[ 9]&0x0e ) << 29)|
+                 (ts_90khz_t)(hdr[10] << 22)|
+                ((ts_90khz_t)(hdr[11]&0xfe) << 14)|
+                 (ts_90khz_t)(hdr[12] << 7)|
+                 (ts_90khz_t)(hdr[13] >> 1);
         p_pes->i_pts = FROM_SCALE(i_pts);
 
+        if( hdr[7]&0x40 && hdr_read >= (14+1+5) )    /* has dts */
+        {
+             i_dts = ((ts_90khz_t)(hdr[14]&0x0e ) << 29)|
+                     (ts_90khz_t)(hdr[15] << 22)|
+                    ((ts_90khz_t)(hdr[16]&0xfe) << 14)|
+                     (ts_90khz_t)(hdr[17] << 7)|
+                     (ts_90khz_t)(hdr[18] >> 1);
+            p_pes->i_dts = FROM_SCALE(i_dts);
+        }
+    }
+
     /* Set PCR */
     if( p_pes->i_pts > 0 )
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8e148227c552b218cbe365d42f9cf60b5fb9f008...12c232514def241d81bc4a5358043048d73c52a4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8e148227c552b218cbe365d42f9cf60b5fb9f008...12c232514def241d81bc4a5358043048d73c52a4
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