]> iEval git - fdkaac.git/commitdiff
fix corner case of progress display
authornu774 <honeycomb77@gmail.com>
Wed, 9 Jan 2013 07:39:39 +0000 (16:39 +0900)
committernu774 <honeycomb77@gmail.com>
Wed, 9 Jan 2013 07:39:39 +0000 (16:39 +0900)
src/progress.c

index fb693487cc3204e7b27dd98a246aa424aed101d2..e872a4f58cfb1c80dd4ebab1d4f1306122ffcdc8 100644 (file)
@@ -6,6 +6,8 @@
 #  include "config.h"
 #endif
 #include <stdio.h>
+#include <limits.h>
+#include <float.h>
 #include <time.h>
 #if HAVE_STDINT_H
 #  include <stdint.h>
@@ -51,11 +53,14 @@ void aacenc_progress_init(aacenc_progress_t *progress, int64_t total,
 void aacenc_progress_update(aacenc_progress_t *progress, int64_t current,
                             int period)
 {
-    int percent = 100.0 * current / progress->total + .5;
     double seconds = current / progress->timescale;
     double ellapsed = (aacenc_timer() - progress->start) / 1000.0;
-    double eta = ellapsed * (progress->total / (double)current - 1.0);
-    double speed = ellapsed ? seconds / ellapsed : 0.0;
+    double speed = ellapsed ? seconds / ellapsed : 1.0;
+    int percent = progress->total ? 100.0 * current / progress->total + .5
+                                  : 100;
+    double eta = current ? ellapsed * (progress->total / (double)current - 1.0)
+                         : progress->total ? DBL_MAX : 0;
+
     if (current < progress->processed + period)
         return;
 
This page took 0.028674 seconds and 4 git commands to generate.