changeset 2389:cde14f83579b libavformat

Don't pre-scale default_duration to avoid precision loss in fps calculation. closes Issue95
author aurel
date Thu, 16 Aug 2007 22:01:54 +0000
parents 338cb0b4e0da
children de8377107b07
files matroskadec.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/matroskadec.c	Thu Aug 16 21:55:37 2007 +0000
+++ b/matroskadec.c	Thu Aug 16 22:01:54 2007 +0000
@@ -1089,7 +1089,7 @@
                             if ((res = ebml_read_uint (matroska, &id,
                                                        &num)) < 0)
                                 break;
-                            track->default_duration = num/matroska->time_scale;
+                            track->default_duration = num;
                             break;
                         }
 
@@ -1100,7 +1100,7 @@
                                                        &num)) < 0)
                                 break;
                             if (!track->default_duration)
-                            track->default_duration = 1000000000/(matroska->time_scale*num);
+                            track->default_duration = 1000000000/num;
                             break;
                         }
 
@@ -1407,7 +1407,7 @@
                 uint64_t num;
                 if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
                     break;
-                track->default_duration = num / matroska->time_scale;
+                track->default_duration = num;
                 break;
             }
 
@@ -2174,7 +2174,7 @@
 
             if (track->default_duration)
                 av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
-                          track->default_duration, 1000, 30000);
+                          track->default_duration, 1000000000, 30000);
 
             if(extradata){
                 st->codec->extradata = extradata;
@@ -2283,7 +2283,7 @@
         return res;
     }
     if (duration == AV_NOPTS_VALUE)
-        duration = matroska->tracks[track]->default_duration;
+        duration = matroska->tracks[track]->default_duration / matroska->time_scale;
 
     /* block_time (relative to cluster time) */
     block_time = AV_RB16(data);