Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change rolling average window to all frames #46

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/video.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::cmp::min;
use std::collections::BTreeMap;
use std::io::stderr;
use std::sync::{mpsc, Arc, Mutex};
Expand Down Expand Up @@ -483,15 +482,15 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
};

let mut results = BTreeMap::new();
let mut avg = 0f64;
let mut rolling_mean = 0f64;
for score in result_rx {
if verbose {
println!("Frame {}: {:.8}", score.0, score.1);
}

results.insert(score.0, score.1);
avg = avg + (score.1 - avg) / (min(results.len(), 10) as f64);
progress.set_message(format!(", avg: {:.1$}", avg, 2));
rolling_mean = rolling_mean + (score.1 - rolling_mean) / (results.len() as f64);
progress.set_message(format!(", mean: {:.1$}", rolling_mean, 2));
progress.inc(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit confusing to use a parameter for the width here (i.e. :.1$) when we can just use a constant :.2:

Suggested change
progress.set_message(format!(", mean: {:.1$}", rolling_mean, 2));
progress.set_message(format!(", mean: {rolling_mean:.2}"));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't even know it was possible this way, I should really read the rust docs on formatting strings...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to include this change in the PR? It might look a bit weird with me already approving, but I think this is an improvement.

}

Expand Down
Loading