[vlc-commits] Use mkv track flags to define the priority of ES

Denis Charmet git at videolan.org
Fri Feb 24 00:11:40 CET 2012


vlc/vlc-2.0 | branch: master | Denis Charmet <typx at dinauz.org> | Fri Feb 24 00:07:00 2012 +0100| [7323dd8a1f9ad8b7e6edb11efdce58d4b882af26] | committer: Jean-Baptiste Kempf

Use mkv track flags to define the priority of ES

Fix #6199

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit a2790164362bddf5e18c1d0e577e5c7787cc1be6)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=7323dd8a1f9ad8b7e6edb11efdce58d4b882af26
---

 modules/demux/mkv/matroska_segment.cpp       |   39 ++++++++++++++++++++++---
 modules/demux/mkv/matroska_segment_parse.cpp |    4 ++-
 modules/demux/mkv/mkv.hpp                    |    1 +
 3 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 9f0c1dc..16557e6 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -922,17 +922,42 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
     /* add all es */
     msg_Dbg( &sys.demuxer, "found %d es", (int)tracks.size() );
 
+    bool b_has_default_video = false;
+    bool b_has_default_audio = false;
+    /* check for default */
+    for(size_t i_track = 0; i_track < tracks.size(); i_track++)
+    {
+        mkv_track_t *p_tk = tracks[i_track];
+        es_format_t *p_fmt = &p_tk->fmt;
+        if( p_fmt->i_cat == VIDEO_ES )
+            b_has_default_video |=
+                p_tk->b_enabled && ( p_tk->b_default || p_tk->b_forced );
+        else if( p_fmt->i_cat == AUDIO_ES )
+            b_has_default_audio |=
+                p_tk->b_enabled && ( p_tk->b_default || p_tk->b_forced );
+    }
+
     for( size_t i_track = 0; i_track < tracks.size(); i_track++ )
     {
         mkv_track_t *p_tk = tracks[i_track];
         es_format_t *p_fmt = &p_tk->fmt;
 
-        if( p_fmt->i_cat == UNKNOWN_ES || !p_tk->psz_codec )
+        if( unlikely( p_fmt->i_cat == UNKNOWN_ES || !p_tk->psz_codec ) )
         {
             msg_Warn( &sys.demuxer, "invalid track[%d, n=%d]", (int)i_track, p_tk->i_number );
             p_tk->p_es = NULL;
             continue;
         }
+        else if( unlikely( !b_has_default_video && p_fmt->i_cat == VIDEO_ES ) )
+        {
+            p_tk->b_default = true;
+            b_has_default_video = true;
+        }
+        else if( unlikely( !b_has_default_audio &&  p_fmt->i_cat == AUDIO_ES ) )
+        {
+            p_tk->b_default = true;
+            b_has_default_audio = true;
+        }
 
         if( !strcmp( p_tk->psz_codec, "V_MS/VFW/FOURCC" ) )
         {
@@ -1334,10 +1359,14 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             msg_Err( &sys.demuxer, "unknown codec id=`%s'", p_tk->psz_codec );
             p_tk->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
         }
-        if( p_tk->b_default )
-        {
-            p_tk->fmt.i_priority = 1000;
-        }
+        if( unlikely( !p_tk->b_enabled ) )
+            p_tk->fmt.i_priority = -2;
+        else if( p_tk->b_forced )
+            p_tk->fmt.i_priority = 1;
+        else if( p_tk->b_default )
+            p_tk->fmt.i_priority = 0;
+        else
+            p_tk->fmt.i_priority = -1;
 
         p_tk->p_es = es_out_Add( sys.demuxer.out, &p_tk->fmt );
 
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 0466d94..0f93193 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -179,6 +179,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
 
     tk->b_default              = true;
     tk->b_enabled              = true;
+    tk->b_forced               = false;
     tk->b_silent               = false;
     tk->i_number               = tracks.size() - 1;
     tk->i_extra_data           = 0;
@@ -254,7 +255,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
         {
             KaxTrackFlagEnabled &fenb = *(KaxTrackFlagEnabled*)l;
 
-            // tk->b_enabled = uint32( fenb );
+            tk->b_enabled = uint32( fenb );
             msg_Dbg( &sys.demuxer, "|   |   |   + Track Enabled=%u", uint32( fenb ) );
         }
         else  if( MKV_IS_ID( l, KaxTrackFlagDefault ) )
@@ -267,6 +268,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
         else  if( MKV_IS_ID( l, KaxTrackFlagForced ) ) // UNUSED
         {
             KaxTrackFlagForced &ffor = *(KaxTrackFlagForced*)l;
+            tk->b_forced = uint32( ffor );
 
             msg_Dbg( &sys.demuxer, "|   |   |   + Track Forced=%u", uint32( ffor ) );
         }
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index de64aec..f30e370 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -180,6 +180,7 @@ struct mkv_track_t
 
     bool         b_default;
     bool         b_enabled;
+    bool         b_forced;
     unsigned int i_number;
 
     unsigned int i_extra_data;



More information about the vlc-commits mailing list