From ce3a422466b4df055f5b67116483eee20676939c Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 2 Oct 2005 05:50:35 +0000 Subject: [PATCH] cli: fix a crash on piped input. git-svn-id: svn://svn.videolan.org/x264/trunk@311 df754926-b1dd-0310-bc7b-ec298dee348c --- x264.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/x264.c b/x264.c index a6b66381..b1fdc4c0 100644 --- a/x264.c +++ b/x264.c @@ -1136,13 +1136,19 @@ static int Encode( x264_param_t *param, cli_opt_t *opt ) /* update status line (up to 1000 times per input file) */ if( opt->b_progress && param->i_log_level < X264_LOG_DEBUG && - i_frame * 1000 / i_frame_total > i_progress ) + ( i_frame_total ? i_frame * 1000 / i_frame_total > i_progress + : i_frame % 10 == 0 ) ) { int64_t i_elapsed = x264_mdate() - i_start; double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0; - i_progress = i_frame * 1000 / i_frame_total; - fprintf( stderr, "encoded frames: %d/%d (%.1f%%), %.2f fps \r", i_frame, - i_frame_total, (float)i_progress / 10, fps ); + if( i_frame_total ) + { + i_progress = i_frame * 1000 / i_frame_total; + fprintf( stderr, "encoded frames: %d/%d (%.1f%%), %.2f fps \r", i_frame, + i_frame_total, (float)i_progress / 10, fps ); + } + else + fprintf( stderr, "encoded frames: %d, %.2f fps \r", i_frame, fps ); fflush( stderr ); // needed in windows } } -- 2.40.0