[MPlayer-cvslog] r19815 - trunk/libmpdemux/demux_mkv.c

eugeni subversion at mplayerhq.hu
Tue Sep 12 23:33:11 CEST 2006


Author: eugeni
Date: Tue Sep 12 23:33:10 2006
New Revision: 19815

Modified:
   trunk/libmpdemux/demux_mkv.c

Log:
Fix movie duration calculation in case when TimecodeScale element comes after
Duration element.


Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Tue Sep 12 23:33:10 2006
@@ -663,6 +663,8 @@
   stream_t *s = demuxer->stream;
   uint64_t length, l;
   int il;
+  uint64_t tc_scale = 1000000;
+  long double duration;
 
   length = ebml_read_length (s, NULL);
   while (length > 0)
@@ -674,9 +676,9 @@
             uint64_t num = ebml_read_uint (s, &l);
             if (num == EBML_UINT_INVALID)
               return 1;
-            mkv_d->tc_scale = num;
+            tc_scale = num;
             mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + timecode scale: %"PRIu64"\n",
-                    mkv_d->tc_scale);
+                    tc_scale);
             break;
           }
 
@@ -685,9 +687,9 @@
             long double num = ebml_read_float (s, &l);
             if (num == EBML_FLOAT_INVALID)
               return 1;
-            mkv_d->duration = num * mkv_d->tc_scale / 1000000000.0;
-            mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3fs\n",
-                    mkv_d->duration);
+            duration = num;
+            mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3Lfs\n",
+                    duration * tc_scale / 1000000000.0);
             break;
           }
 
@@ -697,6 +699,8 @@
         }
       length -= l + il;
     }
+  mkv_d->tc_scale = tc_scale;
+  mkv_d->duration = duration * tc_scale / 1000000000.0;
   return 0;
 }
 



More information about the MPlayer-cvslog mailing list