From: nu774 Date: Wed, 9 Jan 2013 07:39:39 +0000 (+0900) Subject: fix corner case of progress display X-Git-Tag: v0.0.9~3 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=00799c5e4471047908d35faf85a032927bbf294d;p=fdkaac.git fix corner case of progress display --- diff --git a/src/progress.c b/src/progress.c index fb69348..e872a4f 100644 --- a/src/progress.c +++ b/src/progress.c @@ -6,6 +6,8 @@ # include "config.h" #endif #include +#include +#include #include #if HAVE_STDINT_H # include @@ -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;