changeset 1912:98a74cfd12d4 libavformat

scale duration and default_duration
author aurel
date Tue, 13 Mar 2007 00:01:24 +0000
parents 2ce053f3d996
children 1c1df2f4090b
files matroska.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/matroska.c	Mon Mar 12 21:58:29 2007 +0000
+++ b/matroska.c	Tue Mar 13 00:01:24 2007 +0000
@@ -254,7 +254,7 @@
     unsigned char *codec_priv;
     int codec_priv_size;
 
-    int64_t default_duration;
+    uint64_t default_duration;
     MatroskaTrackFlags flags;
 } MatroskaTrack;
 
@@ -1307,7 +1307,7 @@
                             if ((res = ebml_read_uint (matroska, &id,
                                                        &num)) < 0)
                                 break;
-                            track->default_duration = num;
+                            track->default_duration = num/matroska->time_scale;
                             break;
                         }
 
@@ -1317,7 +1317,7 @@
                             if ((res = ebml_read_float(matroska, &id,
                                                        &num)) < 0)
                                 break;
-                            track->default_duration = 1000000000 * (1. / num);
+                            track->default_duration = 1000000000/(matroska->time_scale*num);
                             break;
                         }
 
@@ -1620,7 +1620,7 @@
                 uint64_t num;
                 if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
                     break;
-                track->default_duration = num;
+                track->default_duration = num / matroska->time_scale;
                 break;
             }
 
@@ -2357,7 +2357,7 @@
 
             if (track->default_duration)
                 av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
-                          track->default_duration, 1000000000, 30000);
+                          track->default_duration, 1000, 30000);
 
             if(extradata){
                 st->codec->extradata = extradata;
@@ -2646,6 +2646,7 @@
             case MATROSKA_ID_BLOCKDURATION: {
                 if ((res = ebml_read_uint(matroska, &id, &duration)) < 0)
                     break;
+                duration /= matroska->time_scale;
                 break;
             }
 
@@ -2691,7 +2692,7 @@
         if (duration != AV_NOPTS_VALUE)
             pkt->duration = duration;
         else if (track >= 0 && track < matroska->num_tracks)
-            pkt->duration = matroska->tracks[track]->default_duration / matroska->time_scale;
+            pkt->duration = matroska->tracks[track]->default_duration;
     }
 
     return res;