Skip to content

Commit

Permalink
wip: rename --start to --skip-frames. Helptext changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
superyu1337 committed Dec 1, 2024
1 parent 1e948f4 commit ab50b11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
16 changes: 7 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ enum Commands {

/// How many worker threads to use for decoding & calculating scores.
/// Note: Memory usage increases linearly with the number of workers.
#[arg(long, short)]
#[arg(long, short, verbatim_doc_comment)]
frame_threads: Option<usize>,

/// Frame to start comparison at.
///
#[arg(long, short, default_value_t = 0)]
start: usize,
/// The amount of frames to skip.
#[arg(long, default_value_t = 0)]
skip_frames: usize,

/// How many frames to compare.
/// If left unspecified, all frames will be compared.
/// Limit the amount of frames to compare.
#[arg(long)]
frames: Option<usize>,

Expand Down Expand Up @@ -110,7 +108,7 @@ fn main() {
source,
distorted,
frame_threads,
start,
skip_frames,
frames,
increment,
graph,
Expand Down Expand Up @@ -148,7 +146,7 @@ fn main() {
&source,
&distorted,
frame_threads,
start,
skip_frames,
frames,
inc,
graph,
Expand Down
27 changes: 9 additions & 18 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn compare_videos(
source: &str,
distorted: &str,
frame_threads: usize,
start_frame: usize,
skip_frames: usize,
frames_to_compare: Option<usize>,
inc: usize,
graph: bool,
Expand Down Expand Up @@ -225,7 +225,7 @@ pub fn compare_videos(
None,
distorted_frame_count,
frame_threads,
start_frame,
skip_frames,
frames_to_compare,
inc,
graph,
Expand Down Expand Up @@ -258,7 +258,7 @@ pub fn compare_videos(
source_frame_count,
None,
frame_threads,
start_frame,
skip_frames,
frames_to_compare,
inc,
graph,
Expand Down Expand Up @@ -300,7 +300,7 @@ pub fn compare_videos(
source_frame_count,
distorted_frame_count,
frame_threads,
start_frame,
skip_frames,
frames_to_compare,
inc,
graph,
Expand All @@ -323,7 +323,7 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
source_frame_count: Option<usize>,
distorted_frame_count: Option<usize>,
frame_threads: usize,
start_frame: usize,
skip_frames: usize,
frames_to_compare: Option<usize>,
inc: usize,
graph: bool,
Expand All @@ -345,15 +345,6 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
}
}


if start_frame != 0 {
assert!(
source_frame_count.is_some() || distorted_frame_count.is_some(),
"--start-frame was used, but we could not get source or distorted frame count"
)
}


let source_info = source.get_video_details();
let distorted_info = distorted.get_video_details();
if src_matrix == MatrixCoefficients::Unspecified {
Expand Down Expand Up @@ -409,13 +400,13 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(

let current_frame = 0usize;
let end_frame = frames_to_compare
.map(|frames_to_compare| start_frame + (frames_to_compare * inc));
.map(|frames_to_compare| skip_frames + (frames_to_compare * inc));

let video_compare = Arc::new(
Mutex::new(
VideoCompare {
current_frame,
next_frame: start_frame,
next_frame: skip_frames,
source,
distorted,
}
Expand Down Expand Up @@ -479,8 +470,8 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
let progress = if stderr().is_tty() && !verbose {
let frame_count = source_frame_count.or(distorted_frame_count);
let pb = if let Some(frame_count) = frame_count {
let fc = frames_to_compare.unwrap_or(frame_count - start_frame)
.min(((frame_count - start_frame) as f64 / inc as f64).ceil() as usize);
let fc = frames_to_compare.unwrap_or(frame_count - skip_frames)
.min(((frame_count - skip_frames) as f64 / inc as f64).ceil() as usize);

ProgressBar::new(fc as u64)
.with_style(pretty_progress_style())
Expand Down

0 comments on commit ab50b11

Please sign in to comment.