changeset 19809:99d375aab4db

Fix movie duration calculation in case when TimecodeScale element comes after Duration element.
author eugeni
date Tue, 12 Sep 2006 21:33:10 +0000
parents 5385740067a1
children 7dfc3d2bb54b
files libmpdemux/demux_mkv.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Tue Sep 12 16:24:23 2006 +0000
+++ b/libmpdemux/demux_mkv.c	Tue Sep 12 21:33:10 2006 +0000
@@ -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;
 }