]> granicus.if.org Git - libvpx/commitdiff
vpxenc: fix time and fps calculation in 2-pass encoding
authorYunqing Wang <yunqingwang@google.com>
Wed, 29 Feb 2012 13:24:53 +0000 (08:24 -0500)
committerYunqing Wang <yunqingwang@google.com>
Wed, 29 Feb 2012 20:44:56 +0000 (15:44 -0500)
When we do 2-pass encoding, elapsed time is accumulated through
whole 2-pass process, which gives incorrect time and fps results
for second pass. This change fixed that by resetting the time
accumulator for second pass.

Change-Id: Ie6cbf0d0e66e6874e7071305e253c6267529cf20

vpxenc.c

index 7d6758a7d6678fda6165ea7423d659a18fdc0e19..a4435293953ee8e2af73fc6a09f676394947e673 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -2071,6 +2071,9 @@ static void setup_pass(struct stream_state  *stream,
         : VPX_RC_ONE_PASS;
     if (pass)
         stream->config.cfg.rc_twopass_stats_in = stats_get(&stream->stats);
+
+    stream->cx_time = 0;
+    stream->nbytes = 0;
 }
 
 
@@ -2378,7 +2381,7 @@ int main(int argc, const char **argv_)
                     fprintf(stderr,
                             "\rPass %d/%d frame %4d/%-4d %7"PRId64"B \033[K",
                             pass + 1, global.passes, frames_in,
-                            streams->frames_out, streams->nbytes);
+                            streams->frames_out, (int64_t)streams->nbytes);
                 else
                     fprintf(stderr,
                             "\rPass %d/%d frame %4d %7lu %s (%.2f fps)\033[K",
@@ -2412,10 +2415,10 @@ int main(int argc, const char **argv_)
         FOREACH_STREAM(fprintf(
             stderr,
             "\rPass %d/%d frame %4d/%-4d %7"PRId64"B %7lub/f %7"PRId64"b/s"
-            " %7lu %s (%.2f fps)\033[K\n", pass + 1,
-            global.passes, frames_in, stream->frames_out, stream->nbytes,
+            " %7"PRId64" %s (%.2f fps)\033[K\n", pass + 1,
+            global.passes, frames_in, stream->frames_out, (int64_t)stream->nbytes,
             frames_in ? (unsigned long)(stream->nbytes * 8 / frames_in) : 0,
-            frames_in ? stream->nbytes * 8
+            frames_in ? (int64_t)stream->nbytes * 8
                         * (int64_t)global.framerate.num / global.framerate.den
                         / frames_in
                       : 0,