Skip to content

Commit

Permalink
wip: fix off-by-one error on --start parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
superyu1337 committed Dec 1, 2024
1 parent 5a4b99d commit 1e948f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ enum Commands {
frame_threads: Option<usize>,

/// Frame to start comparison at.
/// 1 is the first frame.
#[arg(long, short)]
start: Option<usize>,
///
#[arg(long, short, default_value_t = 0)]
start: usize,

/// How many frames to compare.
/// If left unspecified, all frames will be compared.
Expand Down
7 changes: 3 additions & 4 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: Option<usize>,
start_frame: usize,
frames_to_compare: Option<usize>,
inc: usize,
graph: bool,
Expand Down Expand Up @@ -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: Option<usize>,
start_frame: usize,
frames_to_compare: Option<usize>,
inc: usize,
graph: bool,
Expand All @@ -346,7 +346,7 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
}


if start_frame.is_some() {
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"
Expand Down Expand Up @@ -408,7 +408,6 @@ fn compare_videos_inner<D: Decoder + 'static, E: Decoder + 'static>(
let dst_bd = dst_config.bit_depth;

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

Expand Down

0 comments on commit 1e948f4

Please sign in to comment.