]> git.sesse.net Git - vlc/blobdiff - modules/demux/mkv/mkv.cpp
Merge branch 'master' of git://git.videolan.org/vlc
[vlc] / modules / demux / mkv / mkv.cpp
index 0f5b902db89fd28f52bd5426a590772df19095d7..7dec8d7676d93adb7545c5f39216a63ee9642251 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * mkv.cpp : matroska demuxer
  *****************************************************************************
- * Copyright (C) 2003-2004 the VideoLAN team
+ * Copyright (C) 2003-2005, 2008, 2010 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -69,8 +69,7 @@ vlc_module_begin ()
             N_("Dummy Elements"),
             N_("Read and discard unknown EBML elements (not good for broken files)."), true );
 
-    add_shortcut( "mka" )
-    add_shortcut( "mkv" )
+    add_shortcut( "mka", "mkv" )
 vlc_module_end ()
 
 class demux_sys_t;
@@ -139,14 +138,14 @@ static int Open( vlc_object_t * p_this )
         goto error;
     }
 
-    if (var_InheritInteger( p_demux, "mkv-preload-local-dir" ))
+    if (var_InheritBool( p_demux, "mkv-preload-local-dir" ))
     {
         /* get the files from the same dir from the same family (based on p_demux->psz_path) */
-        if (p_demux->psz_path[0] != '\0' && !strcmp(p_demux->psz_access, ""))
+        if (p_demux->psz_file && !strcmp(p_demux->psz_access, ""))
         {
             // assume it's a regular file
             // get the directory path
-            s_path = p_demux->psz_path;
+            s_path = p_demux->psz_file;
             if (s_path.at(s_path.length() - 1) == DIR_SEP_CHAR)
             {
                 s_path = s_path.substr(0,s_path.length()-1);
@@ -171,9 +170,9 @@ static int Open( vlc_object_t * p_this )
                         s_filename = s_path + DIR_SEP_CHAR + psz_file;
 
 #ifdef WIN32
-                        if (!strcasecmp(s_filename.c_str(), p_demux->psz_path))
+                        if (!strcasecmp(s_filename.c_str(), p_demux->psz_file))
 #else
-                        if (!s_filename.compare(p_demux->psz_path))
+                        if (!s_filename.compare(p_demux->psz_file))
 #endif
                         {
                             free (psz_file);
@@ -421,7 +420,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_it
     }
 
     /* seek without index or without date */
-    if( f_percent >= 0 && (var_InheritInteger( p_demux, "mkv-seek-percent" ) || !p_segment->b_cues || i_date < 0 ))
+    if( f_percent >= 0 && (var_InheritBool( p_demux, "mkv-seek-percent" ) || !p_segment->b_cues || i_date < 0 ))
     {
         if( p_sys->f_duration >= 0 && p_segment->b_cues )
         {
@@ -474,10 +473,9 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
     demux_sys_t        *p_sys = p_demux->p_sys;
     matroska_segment_c *p_segment = p_sys->p_current_segment->Segment();
 
-    size_t          i_track;
-    unsigned int    i;
-    bool            b;
+    if( !p_segment ) return;
 
+    size_t          i_track;
     if( p_segment->BlockFindTrackIndex( &i_track, block, simpleblock ) )
     {
         msg_Err( p_demux, "invalid track number" );
@@ -498,6 +496,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
 
     if ( tk->fmt.i_cat != NAV_ES )
     {
+        bool b;
         es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, tk->p_es, &b );
 
         if( !b )
@@ -520,7 +519,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
     tk->b_inited = true;
 
 
-    for( i = 0;
+    for( unsigned int i = 0;
          (block != NULL && i < block->NumberFrames()) || (simpleblock != NULL && i < simpleblock->NumberFrames());
          i++ )
     {
@@ -589,6 +588,11 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
                 p_block->i_pts = VLC_TS_INVALID;
                 p_block->i_dts = i_pts;
             }
+            else if( tk->b_pts_only )
+            {
+                p_block->i_pts = i_pts;
+                p_block->i_dts = i_pts;
+            }
             else
             {
                 p_block->i_pts = i_pts;
@@ -596,7 +600,6 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
                     p_block->i_dts = p_block->i_pts;
                 else
                     p_block->i_dts = min( i_pts, tk->i_last_dts + (mtime_t)(tk->i_default_duration >> 10));
-                p_sys->i_pts = p_block->i_dts;
             }
         }
         tk->i_last_dts = p_block->i_dts;
@@ -673,10 +676,9 @@ static int Demux( demux_t *p_demux)
         KaxBlock *block;
         KaxSimpleBlock *simpleblock;
         int64_t i_block_duration = 0;
-        int64_t i_block_ref1;
-        int64_t i_block_ref2;
-
-        if( p_segment->BlockGet( block, simpleblock, &i_block_ref1, &i_block_ref2, &i_block_duration ) )
+        bool b_key_picture;
+        bool b_discardable_picture;
+        if( p_segment->BlockGet( block, simpleblock, &b_key_picture, &b_discardable_picture, &i_block_duration ) )
         {
             if ( p_vsegment->Edition() && p_vsegment->Edition()->b_ordered )
             {
@@ -760,7 +762,7 @@ static int Demux( demux_t *p_demux)
             continue;
         }
 
-        BlockDecode( p_demux, block, simpleblock, p_sys->i_pts, i_block_duration, i_block_ref1 >= 0 || i_block_ref2 > 0 );
+        BlockDecode( p_demux, block, simpleblock, p_sys->i_pts, i_block_duration, b_key_picture || b_discardable_picture );
 
         delete block;
         i_block_count++;