[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: mkv: turn the PCR update into a function
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue Nov 23 18:34:32 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
7a5eede4 by Steve Lhomme at 2021-11-23T17:53:48+00:00
demux: mkv: turn the PCR update into a function
- - - - -
a18356f3 by Steve Lhomme at 2021-11-23T17:53:48+00:00
demux: mkv: make sure we send the first valid PCR before we send a valid block
Negative or VLC_TICK_INVALID timestamps are not sent as a PCR but there might
still be such blocks sent before the PCR.
- - - - -
3 changed files:
- modules/demux/mkv/mkv.cpp
- modules/demux/mkv/util.cpp
- modules/demux/mkv/util.hpp
Changes:
=====================================
modules/demux/mkv/mkv.cpp
=====================================
@@ -822,40 +822,12 @@ static int Demux( demux_t *p_demux)
}
}
- /* update pcr */
+ if (UpdatePCR( p_demux ) != VLC_SUCCESS)
{
- vlc_tick_t i_pcr = VLC_TICK_INVALID;
-
- typedef matroska_segment_c::tracks_map_t tracks_map_t;
-
- for( tracks_map_t::const_iterator it = p_segment->tracks.begin(); it != p_segment->tracks.end(); ++it )
- {
- mkv_track_t &track = *it->second;
-
- if( track.i_last_dts == VLC_TICK_INVALID )
- continue;
-
- if( track.fmt.i_cat != VIDEO_ES && track.fmt.i_cat != AUDIO_ES )
- continue;
-
- if( track.i_last_dts < i_pcr || i_pcr == VLC_TICK_INVALID )
- {
- i_pcr = track.i_last_dts;
- }
- }
-
- if( i_pcr != VLC_TICK_INVALID && i_pcr > p_sys->i_pcr )
- {
- if( es_out_SetPCR( p_demux->out, i_pcr ) )
- {
- msg_Err( p_demux, "ES_OUT_SET_PCR failed, aborting." );
- delete block;
- delete additions;
- return VLC_DEMUXER_EGENERIC;
- }
-
- p_sys->i_pcr = i_pcr;
- }
+ msg_Err( p_demux, "ES_OUT_SET_PCR failed, aborting." );
+ delete block;
+ delete additions;
+ return VLC_DEMUXER_EGENERIC;
}
/* set pts */
=====================================
modules/demux/mkv/util.cpp
=====================================
@@ -311,6 +311,45 @@ error:
return NULL;
}
+int UpdatePCR( demux_t * p_demux )
+{
+ demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
+ matroska_segment_c *p_segment = p_sys->p_current_vsegment->CurrentSegment();
+
+ vlc_tick_t i_pcr = VLC_TICK_INVALID;
+
+ typedef matroska_segment_c::tracks_map_t tracks_map_t;
+
+ for( tracks_map_t::const_iterator it = p_segment->tracks.begin(); it != p_segment->tracks.end(); ++it )
+ {
+ mkv_track_t &track = *it->second;
+
+ if( track.i_last_dts == VLC_TICK_INVALID )
+ continue;
+
+ if( track.fmt.i_cat != VIDEO_ES && track.fmt.i_cat != AUDIO_ES )
+ continue;
+
+ if( track.i_last_dts < i_pcr || i_pcr == VLC_TICK_INVALID )
+ {
+ i_pcr = track.i_last_dts;
+ }
+ }
+
+ if( i_pcr != VLC_TICK_INVALID && i_pcr > p_sys->i_pcr )
+ {
+ if( es_out_SetPCR( p_demux->out, i_pcr ) )
+ {
+ msg_Err( p_demux, "ES_OUT_SET_PCR failed, aborting." );
+ return VLC_EGENERIC;
+ }
+
+ p_sys->i_pcr = i_pcr;
+ }
+
+ return VLC_SUCCESS;
+}
+
void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsigned int i_number_frames, int64_t i_duration )
{
demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
@@ -341,6 +380,9 @@ void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsig
p_tk->b_discontinuity = false;
}
+ if ( p_sys->i_pcr == VLC_TICK_INVALID )
+ UpdatePCR( p_demux );
+
es_out_Send( p_demux->out, p_tk->p_es, p_block);
}
=====================================
modules/demux/mkv/util.hpp
=====================================
@@ -36,6 +36,7 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, v
block_t *WEBVTT_Repack_Sample(block_t *p_block, bool b_webm = false,
const uint8_t * = NULL, size_t = 0);
void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsigned int i_number_frames, int64_t i_duration );
+int UpdatePCR( demux_t * p_demux );
struct real_audio_private
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c651b10d33dc0fb7b9670208f93f94f850ba8ca4...a18356f3f364b8d673b267bddab5dd64f1c12b72
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c651b10d33dc0fb7b9670208f93f94f850ba8ca4...a18356f3f364b8d673b267bddab5dd64f1c12b72
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list