]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix a couple nasty rounding errors.
authorRodeo <tdskywalker@gmail.com>
Sun, 3 May 2015 22:03:42 +0000 (22:03 +0000)
committerRodeo <tdskywalker@gmail.com>
Sun, 3 May 2015 22:03:42 +0000 (22:03 +0000)
The results could be off by almost 4% with 30fps sources.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7154 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBRange.m
macosx/HBTitle.m

index b49d5b44758a867b0fcc2d1c1125e7b53beb946b..d4e785b309de123458eff8572a9252b544ececc6 100644 (file)
@@ -88,7 +88,7 @@ NSString *HBRangeChangedNotification = @"HBRangeChangedNotification";
     else if (self.type == HBRangeTypeFrames)
     {
         hb_title_t *title = self.title.hb_title;
-        int duration = (self.frameStop - self.frameStart) / (title->vrate.num / title->vrate.den);
+        int duration = (self.frameStop - self.frameStart) / (title->vrate.num / (double)title->vrate.den);
         return [NSString stringWithFormat: @"%02d:%02d:%02d", duration / 3600, ( duration / 60 ) % 60, duration % 60];
     }
 
index be5158327b669ef19db1670b4e44e633a607d657..f2e5b4fb387d52b02cf3775ca8efc6e8d33b3f4c 100644 (file)
@@ -114,7 +114,7 @@ extern NSString *keySubTrackSrtCharCode;
 
 - (int)frames
 {
-    return self.duration * (self.hb_title->vrate.num / self.hb_title->vrate.den);
+    return (self.hb_title->duration / 90000.) * (self.hb_title->vrate.num / (double)self.hb_title->vrate.den);
 }
 
 - (NSString *)timeCode