Skip to content

Commit

Permalink
Enforce a frame limit of 1 in still picture mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rzumer committed Sep 8, 2020
1 parent 3d935e2 commit 414e6d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl<T: Pixel> ContextInner<T> {
let seq = Sequence::new(enc);
ContextInner {
frame_count: 0,
limit: None,
limit: if enc.still_picture { Some(1) } else { None },
inter_cfg: InterConfig::new(enc),
output_frameno: 0,
frames_processed: 0,
Expand Down
7 changes: 6 additions & 1 deletion src/bin/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,15 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
MetricsEnabled::None
};

let limit = matches.value_of("LIMIT").unwrap().parse().unwrap();
if enc.still_picture && limit > 1 {
panic!("A limit cannot be set above 1 in still picture mode");
}

Ok(CliOptions {
io,
enc,
limit: matches.value_of("LIMIT").unwrap().parse().unwrap(),
limit,
// Use `occurrences_of()` because `is_present()` is always true
// if a parameter has a default value.
color_range_specified: matches.occurrences_of("PIXEL_RANGE") > 0,
Expand Down

0 comments on commit 414e6d8

Please sign in to comment.