[vlc-commits] MKV: factorize the es_out_Send() and es_out_Control() calls
Steve Lhomme
git at videolan.org
Thu Mar 19 16:07:50 CET 2015
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Mar 19 13:12:37 2015 +0000| [38de02fe5c4102351436c7f058db297486f5b03f] | committer: Jean-Baptiste Kempf
MKV: factorize the es_out_Send() and es_out_Control() calls
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38de02fe5c4102351436c7f058db297486f5b03f
---
modules/demux/mkv/mkv.cpp | 51 ++------------------------------------
modules/demux/mkv/util.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++-
modules/demux/mkv/util.hpp | 1 +
3 files changed, 60 insertions(+), 50 deletions(-)
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index e6eb2ed..c0c115c 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -532,7 +532,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
msg_Dbg( p_demux, "sending header (%d bytes)", tk->i_data_init );
p_init = MemToBlock( tk->p_data_init, tk->i_data_init, 0 );
- if( p_init ) es_out_Send( p_demux->out, tk->p_es, p_init );
+ if( p_init ) send_Block( p_demux, tk, p_init, 1, 0 );
}
tk->b_inited = true;
@@ -643,14 +643,6 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
block_Release( p_block );
return;
}
- else if( tk->fmt.i_cat == AUDIO_ES )
- {
- if( tk->i_chans_to_reorder )
- aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer,
- tk->fmt.audio.i_channels,
- tk->pi_chan_table, tk->fmt.i_codec );
-
- }
p_block->i_dts = p_block->i_pts = i_pts;
}
else
@@ -678,47 +670,8 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
p_block->i_dts = min( i_pts, tk->i_last_dts + ( mtime_t )tk->i_default_duration );
}
}
- if( p_block->i_dts > VLC_TS_INVALID &&
- ( tk->fmt.i_cat == VIDEO_ES || tk->fmt.i_cat == AUDIO_ES ) )
- {
- tk->i_last_dts = p_block->i_dts;
- }
-
-#if 0
-msg_Dbg( p_demux, "block (track=%d) i_dts: %"PRId64" / i_pts: %"PRId64, tk->i_number, p_block->i_dts, p_block->i_pts);
-#endif
- if( !tk->b_no_duration )
- {
- p_block->i_length = i_duration * tk-> f_timecodescale *
- (double) p_segment->i_timescale / ( 1000.0 * i_number_frames );
- }
-
- // find the latest DTS for an active track
- mtime_t i_ts_max = INT64_MIN;
- for( size_t i = 0; i < p_segment->tracks.size(); i++ )
- {
- mkv_track_t *tk = p_segment->tracks[i];
- if( tk->i_last_dts > VLC_TS_INVALID )
- i_ts_max = __MAX( i_ts_max, tk->i_last_dts );
- }
-
- // find the earliest DTS less than 10 clock ticks away from the latest DTS
- mtime_t i_ts_min = INT64_MAX;
- for( size_t i = 0; i < p_segment->tracks.size(); i++ )
- {
- mkv_track_t *tk = p_segment->tracks[i];
- if( tk->i_last_dts > VLC_TS_INVALID && tk->i_last_dts + 10 * CLOCK_FREQ >= i_ts_max )
- i_ts_min = __MIN( i_ts_min, tk->i_last_dts );
- }
-
- // the PCR is the earliest active DTS if we found one
- if( i_ts_min != INT64_MAX && ( i_ts_min > p_sys->i_pcr || p_sys->i_pcr == VLC_TS_INVALID ) )
- {
- p_sys->i_pcr = i_ts_min;
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_ts_min );
- }
- es_out_Send( p_demux->out, tk->p_es, p_block );
+ send_Block( p_demux, tk, p_block, i_number_frames, i_duration );
/* use time stamp only for first block */
i_pts = ( tk->i_default_duration )?
diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index 7a0cfcd..8b0f80a 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -236,13 +236,69 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, m
{
for( size_t i = 0; i < p_sys->i_subpackets; i++)
{
- es_out_Send( p_demux->out, p_tk->p_es, p_sys->p_subpackets[i]);
+ send_Block( p_demux, p_tk, p_sys->p_subpackets[i], 1, 0 );
p_sys->p_subpackets[i] = NULL;
}
p_sys->i_subpacket = 0;
}
}
+void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsigned int i_number_frames, mtime_t i_duration )
+{
+ demux_sys_t *p_sys = p_demux->p_sys;
+ matroska_segment_c *p_segment = p_sys->p_current_segment->CurrentSegment();
+
+ if( p_tk->fmt.i_cat == AUDIO_ES && p_tk->i_chans_to_reorder )
+ {
+ aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer,
+ p_tk->fmt.audio.i_channels,
+ p_tk->pi_chan_table, p_tk->fmt.i_codec );
+ }
+
+ if( p_block->i_dts > VLC_TS_INVALID &&
+ ( p_tk->fmt.i_cat == VIDEO_ES || p_tk->fmt.i_cat == AUDIO_ES ) )
+ {
+ p_tk->i_last_dts = p_block->i_dts;
+ }
+
+ if( !p_tk->b_no_duration )
+ {
+ p_block->i_length = i_duration * p_tk->f_timecodescale *
+ (double) p_segment->i_timescale / ( 1000.0 * i_number_frames );
+ }
+
+ // find the latest DTS for an active track
+ mtime_t i_ts_max = INT64_MIN;
+ for( size_t j = 0; j < p_segment->tracks.size(); j++ )
+ {
+ mkv_track_t *tk = p_segment->tracks[j];
+ if( tk->i_last_dts > VLC_TS_INVALID )
+ i_ts_max = __MAX( i_ts_max, tk->i_last_dts );
+ }
+
+ // find the earliest DTS less than 10 clock ticks away from the latest DTS
+ mtime_t i_ts_min = INT64_MAX;
+ for( size_t j = 0; j < p_segment->tracks.size(); j++ )
+ {
+ mkv_track_t *tk = p_segment->tracks[j];
+ if( tk->i_last_dts > VLC_TS_INVALID && tk->i_last_dts + 10 * CLOCK_FREQ >= i_ts_max )
+ i_ts_min = __MIN( i_ts_min, tk->i_last_dts );
+ }
+
+ // the PCR is the earliest active DTS if we found one
+ if( i_ts_min != INT64_MAX && ( i_ts_min > p_sys->i_pcr || p_sys->i_pcr == VLC_TS_INVALID ) )
+ {
+ p_sys->i_pcr = i_ts_min;
+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_ts_min );
+ }
+
+#if 0
+msg_Dbg( p_demux, "block (track=%d) i_dts: %"PRId64" / i_pts: %"PRId64, p_tk->i_number, p_block->i_dts, p_block->i_pts);
+#endif
+
+ es_out_Send( p_demux->out, p_tk->p_es, p_block);
+}
+
int32_t Cook_PrivateTrackData::Init()
{
i_subpackets = (size_t) i_sub_packet_h * (size_t) i_frame_size / (size_t) i_subpacket_size;
diff --git a/modules/demux/mkv/util.hpp b/modules/demux/mkv/util.hpp
index c181ad2..8c6cc6a 100644
--- a/modules/demux/mkv/util.hpp
+++ b/modules/demux/mkv/util.hpp
@@ -32,6 +32,7 @@ block_t *block_zlib_decompress( vlc_object_t *p_this, block_t *p_in_block );
block_t *MemToBlock( uint8_t *p_mem, size_t i_mem, size_t offset);
void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, mtime_t i_pts);
+void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsigned int i_number_frames, mtime_t i_duration );
struct real_audio_private
More information about the vlc-commits
mailing list