changeset 10149:bb1d5c054148

Delayed the parsing of the cues for the case that the KaxInfos (and therefore the timecode scale) is located after the meta seek stuff.
author mosu
date Thu, 22 May 2003 07:49:48 +0000
parents 139b44930abc
children b34ede44dada
files libmpdemux/demux_mkv.cpp
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.cpp	Wed May 21 21:18:29 2003 +0000
+++ b/libmpdemux/demux_mkv.cpp	Thu May 22 07:49:48 2003 +0000
@@ -896,7 +896,7 @@
   mkv_track_t *track;
   sh_audio_t *sh_a;
   sh_video_t *sh_v;
-  uint64_t seek_pos, current_pos;
+  uint64_t seek_pos, current_pos, cues_pos;
   int seek_element_is_cue;
 
 #ifdef USE_ICONV
@@ -962,6 +962,8 @@
     mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n");
     
     mkv_d->segment = (KaxSegment *)l0;
+    mkv_d->tc_scale = MKVD_TIMECODESCALE;
+    cues_pos = 0;
 
     upper_lvl_el = 0;
     exit_loop = 0;
@@ -976,8 +978,6 @@
         // General info about this Matroska file
         mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment information...\n");
         
-        mkv_d->tc_scale = MKVD_TIMECODESCALE;
-
         l2 = es->FindNextElement(l1->Generic().Context, upper_lvl_el,
                                  0xFFFFFFFFL, true, 1);
         while (l2 != NULL) {
@@ -1340,14 +1340,8 @@
             } // while (l3 != NULL)
 
             if (!mkv_d->cues_found && (seek_pos > 0) &&
-                seek_element_is_cue && (s->end_pos != 0)) {
-              current_pos = io.getFilePointer();
-              io.setFilePointer(mkv_d->segment->GetGlobalPosition(seek_pos));
-              mkv_d->cues_found = parse_cues(mkv_d);
-              if (s->eof)
-                stream_reset(s);
-              io.setFilePointer(current_pos);
-            }
+                seek_element_is_cue && (s->end_pos != 0))
+              cues_pos = mkv_d->segment->GetGlobalPosition(seek_pos);
 
           } else
             mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |  + unknown element, level 2: "
@@ -1411,6 +1405,19 @@
       return 0;
     }
 
+    // If we have found an entry for the cues in the meta seek data but no
+    // cues at the front of the file then read them now. This way the
+    // timecode scale will have been initialized correctly.
+    if (cues_pos && !mkv_d->cues_found) {
+      current_pos = io.getFilePointer();
+      io.setFilePointer(cues_pos);
+      mkv_d->cues_found = parse_cues(mkv_d);
+      if (s->eof)
+        stream_reset(s);
+      io.setFilePointer(current_pos);
+    }
+
+
   } catch (exception &ex) {
     mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] caught exception\n");
     return 0;