[vlc-commits] [Git][videolan/vlc][3.0.x] demux: ts: fix seek issues in some streams

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed May 10 08:16:04 UTC 2023



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


Commits:
292c4756 by Russell Greene at 2023-05-10T07:59:08+00:00
demux: ts: fix seek issues in some streams

Fixes #27646

Currently, VLC's SeekToTime algorithm for MPEG Transport Streams involves a number of arbitrary restrictions when searching for PCR timestamps. It rejects packets whose PIDs are not included in the current program and it also rejects packets that do not contain a payload as well as packets that do not contain the payload start indicator.

However, per the official documentation describing the MPEG-TS format (ITU-T H.222.0 version 7.0) there are no such restrictions placed on where the PCR can be set (nor are there official recommendations on it). It specifies that the PCR is part of the adaptation field, and it's perfectly valid to make a packet with "adaptation field only" and no payload.

References:
 * Chapter 2.4.3.3:
   - Table 2-3: "The transport packets with PID values 0x0000, 0x0001, and 0x0010-0x1FFE are allowed to carry a PCR."
   - Table 2-5: "'10': Adaptation_field only, no payload"
   - Table 2-6: PCR is an optional part of the adaptation field, see 2.4.3.5 for details
 * Chapter 2.4.4.10: See PCR_PID

Our observation of the existing algorithm is that the restrictions on the contents of the packet and the type of stream are intended more for the subsequent "ParsePESHeader" call, as those restrictions make sense when using that mechanism as a fallback method to find the PCR. However, by including these restrictions prior to the line that gets the PCR if "p_pmt->i_pid_pcr == i_pid", it's rejecting packets that could have otherwise provided PCR information.

By moving the restrictions to later within the algorithm, we allow for any packets containing a matching PCR_PID to potentially supply that PCR information. This resolves seeking issues on any video that was created with PCRs set on packets without payloads.

(cherry picked from commit 80c4515fac992580486967c724ef56d8cbfd0246)
Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

- - - - -


1 changed file:

- modules/demux/mpeg/ts.c


Changes:

=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -1946,11 +1946,7 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
 
             int i_pid = PIDGet( p_pkt );
             ts_pid_t *p_pid = GetPID(p_sys, i_pid);
-            if( i_pid != 0x1FFF && p_pid->type == TYPE_STREAM &&
-                ts_stream_Find_es( p_pid->u.p_stream, p_pmt ) &&
-               (p_pkt->p_buffer[1] & 0xC0) == 0x40 && /* Payload start but not corrupt */
-               (p_pkt->p_buffer[3] & 0xD0) == 0x10    /* Has payload but is not encrypted */
-            )
+            if( i_pid != 0x1FFF )
             {
                 unsigned i_skip = 4;
                 if ( p_pkt->p_buffer[3] & 0x20 ) // adaptation field
@@ -1963,7 +1959,11 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
                     }
                 }
 
-                if( i_pcr == -1 )
+                if( i_pcr == -1 && p_pid->type == TYPE_STREAM &&
+                    ts_stream_Find_es( p_pid->u.p_stream, p_pmt ) &&
+                   (p_pkt->p_buffer[1] & 0xC0) == 0x40 && /* Payload start but not corrupt */
+                   (p_pkt->p_buffer[3] & 0xD0) == 0x10    /* Has payload but is not encrypted */
+                )
                 {
                     vlc_tick_t i_dts = -1;
                     vlc_tick_t i_pts = -1;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/292c4756f79a9bd3097eaef234737e274bde3f68

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/292c4756f79a9bd3097eaef234737e274bde3f68
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