[vlc-commits] [Git][videolan/vlc][master] 2 commits: dvdnav: use the dvd playtime as PCR
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Apr 23 11:23:49 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
502add7d by Alaric Senat at 2026-04-23T10:58:28+00:00
dvdnav: use the dvd playtime as PCR
Using the PS SCR value as a PCR isn't correct in the DVD use case. DVDs
are made of multiple non-continuous PS streams that aren't constrained
to have a consistent SCR across streams.
Basically, each VOB changes might trigger a PCR reset. This was fine in
VLC 3, but now the PCR is used to drive the clock and the seek bar which
leads to hazardous behaviors, the most noticeable now is the seekbar
incorrect timestamps.
This patch uses the DVD playtime as the PCR and adapts the DTS instead.
This ensure a continuous PCR curve even on VOB changes.
- - - - -
19b7d37d by Alaric Senat at 2026-04-23T10:58:28+00:00
dvdnav: use explicit macros for timestamp scaling
- - - - -
1 changed file:
- modules/access/dvdnav.c
Changes:
=====================================
modules/access/dvdnav.c
=====================================
@@ -168,6 +168,12 @@ typedef struct
int i_vobu_index;
int i_vobu_flush;
+ /* Reference timestamps of the current cell. */
+ struct {
+ vlc_tick_t dvd;
+ vlc_tick_t ps;
+ } cell_ts;
+
vlc_mouse_t oldmouse;
} demux_sys_t;
@@ -276,6 +282,9 @@ static int CommonOpen( vlc_object_t *p_this,
return VLC_EGENERIC;
}
+ p_sys->cell_ts.dvd = VLC_TICK_INVALID;
+ p_sys->cell_ts.ps = VLC_TICK_INVALID;
+
ps_track_init( p_sys->tk );
p_sys->b_readahead = b_readahead;
vlc_mouse_Init( &p_sys->oldmouse );
@@ -647,7 +656,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( p_sys->i_pgc_length > 0 )
{
*va_arg( args, vlc_tick_t * ) =
- dvdnav_get_current_time( p_sys->dvdnav ) * 100 / 9;
+ FROM_SCALE_NZ( dvdnav_get_current_time(p_sys->dvdnav) );
return VLC_SUCCESS;
}
break;
@@ -656,7 +665,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
{
vlc_tick_t i_time = va_arg( args, vlc_tick_t );
if( dvdnav_jump_to_sector_by_time( p_sys->dvdnav,
- i_time * 9 / 100,
+ TO_SCALE_NZ(i_time),
SEEK_SET ) == DVDNAV_STATUS_OK )
return VLC_SUCCESS;
msg_Err( p_demux, "can't set time to %" PRId64, i_time );
@@ -1114,6 +1123,9 @@ static int Demux( demux_t *p_demux )
p_sys->i_pgc_length = FROM_SCALE_NZ(event->pgc_length);
p_sys->i_vobu_index = 0;
p_sys->i_vobu_flush = 0;
+ p_sys->cell_ts.dvd = VLC_TICK_INVALID;
+ p_sys->cell_ts.ps = VLC_TICK_INVALID;
+ es_out_Control( p_sys->p_tf_out, ES_OUT_RESET_PCR );
for( int i=0; i<PS_TK_COUNT; i++ )
p_sys->tk[i].i_next_block_flags |= BLOCK_FLAG_CELL_DISCONTINUITY;
@@ -1516,7 +1528,21 @@ static int DemuxBlock( demux_t *p_demux, const uint8_t *p, int32_t len )
if( !ps_pkt_parse_pack( p_pkt->p_buffer, p_pkt->i_buffer,
&i_scr, &i_mux_rate ) )
{
- es_out_SetPCR( p_sys->p_tf_out, i_scr );
+ if ( p_sys->cell_ts.dvd == VLC_TICK_INVALID ||
+ p_sys->cell_ts.ps == VLC_TICK_INVALID )
+ {
+ p_sys->cell_ts.dvd =
+ FROM_SCALE( dvdnav_get_current_time(p_sys->dvdnav) );
+ p_sys->cell_ts.ps = i_scr;
+ }
+
+ /* Shift the cell scr with the dvd playtime to have a
+ * continuous PCR. */
+ const vlc_tick_t pcr =
+ p_sys->cell_ts.dvd + (i_scr - p_sys->cell_ts.ps);
+ es_out_SetPCR( p_sys->p_tf_out, pcr );
+
+
if( i_mux_rate > 0 ) p_sys->i_mux_rate = i_mux_rate;
}
block_Release( p_pkt );
@@ -1546,6 +1572,14 @@ static int DemuxBlock( demux_t *p_demux, const uint8_t *p, int32_t len )
else tk->i_next_block_flags = BLOCK_FLAG_CELL_DISCONTINUITY;
}
p_pkt->i_flags |= i_next_block_flags;
+
+ const vlc_tick_t shift = p_sys->cell_ts.dvd - p_sys->cell_ts.ps;
+ /* Shift native timestamp in respect of the DVD current time. */
+ if( p_pkt->i_dts != VLC_TICK_INVALID )
+ p_pkt->i_dts += shift;
+ if( p_pkt->i_pts != VLC_TICK_INVALID )
+ p_pkt->i_pts += shift;
+
es_out_Send( p_sys->p_tf_out, tk->es, p_pkt );
}
else
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8654d2f27e918be876323b679f941e1dc6421b6e...19b7d37db9cb744ab6500bd4743f5fd9e735c4d4
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8654d2f27e918be876323b679f941e1dc6421b6e...19b7d37db9cb744ab6500bd4743f5fd9e735c4d4
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list