diff options
author | Martijn van Beurden <mvanb1@gmail.com> | 2020-07-05 19:42:39 +0200 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2021-03-15 13:46:20 +1100 |
commit | ae288c067c03bc3404eff67063958bfe854f5a01 (patch) | |
tree | db9cf115d51bd863165d959564b39231e1be7bc8 /src | |
parent | ced7f6829d14e38128bf0ba66412cc0541246c46 (diff) | |
download | flac-ae288c067c03bc3404eff67063958bfe854f5a01.tar.gz |
Fix compression ratio display for very small files
Because the compression ratio was calculated before processing
the input of the last frame, it did not include the size of this
last frame. This patch moves the calculation of the compression
ratio after the new input has been processed. Now the compression
ratio on very small files is correctly displayed.
Diffstat (limited to 'src')
-rw-r--r-- | src/flac/encode.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/flac/encode.c b/src/flac/encode.c index a7fbfdf5..30543645 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -2463,14 +2463,14 @@ void encoder_progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64 const FLAC__uint64 uesize = e->unencoded_size; - e->progress = e->total_samples_to_encode ? (double)samples_written / (double)e->total_samples_to_encode : 0; - e->compression_ratio = (e->progress && uesize) ? (double)e->bytes_written / ((double)uesize * min(1.0, e->progress)) : 0; - (void)encoder, (void)total_frames_estimate; e->bytes_written = bytes_written; e->samples_written = samples_written; + e->progress = e->total_samples_to_encode ? (double)samples_written / (double)e->total_samples_to_encode : 0; + e->compression_ratio = (e->progress && uesize) ? (double)e->bytes_written / ((double)uesize * min(1.0, e->progress)) : 0; + if(e->total_samples_to_encode > 0 && frames_written - e->old_frames_written > e->stats_frames_interval) { print_stats(e); e->old_frames_written = frames_written; |