From 6e769846626f9185b59f3967e8b4ebe11497d878 Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Sat, 27 Dec 2014 20:35:39 +0300 Subject: [PATCH] Fix negative percentages in final stats output They were caused by integer overflow when encoding long UHD video. --- encoder/encoder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/encoder/encoder.c b/encoder/encoder.c index a2d1ccad..4f412b50 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -4094,14 +4094,14 @@ void x264_encoder_close ( x264_t *h ) if( h->stat.i_frame_count[SLICE_TYPE_I] > 0 ) { int64_t *i_mb_count = h->stat.i_mb_count[SLICE_TYPE_I]; - double i_count = h->stat.i_frame_count[SLICE_TYPE_I] * h->mb.i_mb_count / 100.0; + double i_count = (double)h->stat.i_frame_count[SLICE_TYPE_I] * h->mb.i_mb_count / 100.0; x264_print_intra( i_mb_count, i_count, b_print_pcm, buf ); x264_log( h, X264_LOG_INFO, "mb I %s\n", buf ); } if( h->stat.i_frame_count[SLICE_TYPE_P] > 0 ) { int64_t *i_mb_count = h->stat.i_mb_count[SLICE_TYPE_P]; - double i_count = h->stat.i_frame_count[SLICE_TYPE_P] * h->mb.i_mb_count / 100.0; + double i_count = (double)h->stat.i_frame_count[SLICE_TYPE_P] * h->mb.i_mb_count / 100.0; int64_t *i_mb_size = i_mb_count_size[SLICE_TYPE_P]; x264_print_intra( i_mb_count, i_count, b_print_pcm, buf ); x264_log( h, X264_LOG_INFO, @@ -4117,7 +4117,7 @@ void x264_encoder_close ( x264_t *h ) if( h->stat.i_frame_count[SLICE_TYPE_B] > 0 ) { int64_t *i_mb_count = h->stat.i_mb_count[SLICE_TYPE_B]; - double i_count = h->stat.i_frame_count[SLICE_TYPE_B] * h->mb.i_mb_count / 100.0; + double i_count = (double)h->stat.i_frame_count[SLICE_TYPE_B] * h->mb.i_mb_count / 100.0; double i_mb_list_count; int64_t *i_mb_size = i_mb_count_size[SLICE_TYPE_B]; int64_t list_count[3] = {0}; /* 0 == L0, 1 == L1, 2 == BI */ -- 2.40.0