[vlc-commits] demux:mkv: read the track type early to init the ES properly

Steve Lhomme git at videolan.org
Sat Jul 8 18:38:40 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Jul  6 11:42:21 2017 +0200| [88d89028713fa11371974fed62fef859ab569db6] | committer: Jean-Baptiste Kempf

demux:mkv: read the track type early to init the ES properly

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88d89028713fa11371974fed62fef859ab569db6
---

 modules/demux/mkv/matroska_segment_parse.cpp | 35 +++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 9abed7b684..ef9f45cdc9 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -225,7 +225,33 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
     track.i_last_dts             = 0;
     track.i_skip_until_fpos      = -1;
 
-    es_format_Init( &track.fmt, UNKNOWN_ES, 0 );
+    EbmlUInteger *pTrackType = static_cast<EbmlUInteger*>(m->FindElt(EBML_INFO(KaxTrackType)));
+    uint8 ttype;
+    if (likely(pTrackType != NULL))
+        ttype = (uint8) *pTrackType;
+    else
+        ttype = 0;
+
+    switch( ttype )
+    {
+        case track_audio:
+            es_format_Init( &track.fmt, AUDIO_ES, 0);
+            track.fmt.audio.i_channels = 1;
+            track.fmt.audio.i_rate = 8000;
+            break;
+        case track_video:
+            es_format_Init( &track.fmt, VIDEO_ES, 0);
+            break;
+        case track_subtitle:
+            es_format_Init( &track.fmt, SPU_ES, 0);
+            break;
+        case track_buttons:
+            es_format_Init( &track.fmt, SPU_ES, 0);
+            break;
+        default:
+            es_format_Init( &track.fmt, UNKNOWN_ES, 0);
+            break;
+    }
 
     track.fmt.psz_language       = strdup("English");
     track.fmt.psz_description    = NULL;
@@ -303,25 +329,18 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
             {
                 case track_audio:
                     psz_type = "audio";
-                    vars.tk->fmt.i_cat = AUDIO_ES;
-                    vars.tk->fmt.audio.i_channels = 1;
-                    vars.tk->fmt.audio.i_rate = 8000;
                     break;
                 case track_video:
                     psz_type = "video";
-                    vars.tk->fmt.i_cat = VIDEO_ES;
                     break;
                 case track_subtitle:
                     psz_type = "subtitle";
-                    vars.tk->fmt.i_cat = SPU_ES;
                     break;
                 case track_buttons:
                     psz_type = "buttons";
-                    vars.tk->fmt.i_cat = SPU_ES;
                     break;
                 default:
                     psz_type = "unknown";
-                    vars.tk->fmt.i_cat = UNKNOWN_ES;
                     break;
             }
 



More information about the vlc-commits mailing list