[vlc-devel] [PATCH 05/11] mkv: store priority tracks
Denis Charmet
typx at dinauz.org
Mon May 23 10:37:15 CEST 2016
On 2016-05-21 02:17, Filip Roséen wrote:
> When seeking, we should prioritize tracks depending on what type of ES
> they are; this patch addes a data-member to matroska_segment_c that
> will
> keep track of which tracks are more important than other.
>
> It also adds logic to ParseTracks that will initialize this
> data-member
> with the appropriate track-ids.
> ---
> modules/demux/mkv/matroska_segment.hpp | 1 +
> modules/demux/mkv/matroska_segment_parse.cpp | 30
> ++++++++++++++++++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/modules/demux/mkv/matroska_segment.hpp
> b/modules/demux/mkv/matroska_segment.hpp
> index c39c275..0aa01be 100644
> --- a/modules/demux/mkv/matroska_segment.hpp
> +++ b/modules/demux/mkv/matroska_segment.hpp
> @@ -93,6 +93,7 @@ public:
>
> /* all tracks */
> tracks_map_t tracks;
> + std::vector<mkv_track_t::track_id_t> priority_tracks;
>
> /* from seekhead */
> int i_seekhead_count;
> diff --git a/modules/demux/mkv/matroska_segment_parse.cpp
> b/modules/demux/mkv/matroska_segment_parse.cpp
> index 413bd16..affb934 100644
> --- a/modules/demux/mkv/matroska_segment_parse.cpp
> +++ b/modules/demux/mkv/matroska_segment_parse.cpp
> @@ -712,6 +712,36 @@ void matroska_segment_c::ParseTracks( KaxTracks
> *tracks )
>
> TrackHandlers::Dispatcher().iterate(
> tracks->begin(), tracks->end(), TrackHandlers::Payload( payload
> ) );
> +
> + // find track(s) with highest priority //
> + {
> + int score = -1;
> + int es_type = -1;
> +
> + for( tracks_map_t::const_iterator it = this->tracks.begin();
> it != this->tracks.end(); ++it )
> + {
> + int track_score = -1;
> +
> + switch( it->second.fmt.i_cat )
> + {
> + case VIDEO_ES: ++track_score;
> + case AUDIO_ES: ++track_score;
> + case SPU_ES: ++track_score;
> + default:
> + if( score < track_score )
> + {
> + es_type = it->second.fmt.i_cat;
> + score = track_score;
> + }
> + }
> + }
> +
> + for( tracks_map_t::const_iterator it = this->tracks.begin();
> it != this->tracks.end(); ++it )
> + {
> + if( it->second.fmt.i_cat == es_type )
> + priority_tracks.push_back( it->first );
> + }
> + }
matroska_segment_c::ComputeTrackPriority already has the loops and
boolean to tell you if the file has audio, video plus knowledge of
possibly disabled tracks. I'd rather see that inside this function than
here.
> }
>
>
> /*****************************************************************************
Regards,
--
Denis Charmet - TypX
Le mauvais esprit est un art de vivre
More information about the vlc-devel
mailing list