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

Rewrite argument parsing to use Clap's derives #2962

Merged
merged 2 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ dump_lookahead_data = ["byteorder", "image"]
arg_enum_proc_macro = "0.3"
bitstream-io = "1"
cfg-if = "1.0"
clap = { version = "3.1", optional = true, default-features = false, features = [
"color",
"std",
"wrap_help",
] }
clap = { version = "3.2.6", optional = true, default-features = false, features = ["color", "std", "wrap_help", "derive"] }
clap_complete = { version = "3", optional = true }
libc = "0.2"
y4m = { version = "0.7", optional = true }
Expand Down Expand Up @@ -101,6 +97,7 @@ arrayref = "0.3.6"
const_fn_assert = "0.1.2"
nom = { version = "7.0.0", optional = true }
new_debug_unreachable = "1.0.4"
once_cell = "1.13.0"

[dependencies.image]
version = "0.23"
Expand Down
3 changes: 2 additions & 1 deletion ivf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#![warn(clippy::doc_markdown)]
#![warn(clippy::missing_errors_doc)]
#![warn(clippy::missing_panics_doc)]
#![warn(clippy::undocumented_unsafe_blocks)]
// FIXME: Temporarily disabled due to https://github.com/rust-lang/rust-clippy/issues/9142
#![allow(clippy::undocumented_unsafe_blocks)]

/// Simple ivf muxer
///
Expand Down
4 changes: 2 additions & 2 deletions src/api/config/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub struct EncoderConfig {
/// [`with_speed_preset()`]: struct.EncoderConfig.html#method.with_speed_preset
impl Default for EncoderConfig {
fn default() -> Self {
const DEFAULT_SPEED: usize = 6;
const DEFAULT_SPEED: u8 = 6;
Self::with_speed_preset(DEFAULT_SPEED)
}
}
Expand All @@ -130,7 +130,7 @@ impl EncoderConfig {
/// than 10, it will result in the same settings as 10.
///
/// [`from_preset()`]: struct.SpeedSettings.html#method.from_preset
pub fn with_speed_preset(speed: usize) -> Self {
pub fn with_speed_preset(speed: u8) -> Self {
EncoderConfig {
width: 640,
height: 480,
Expand Down
2 changes: 1 addition & 1 deletion src/api/config/speedsettings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Default for SpeedSettings {

impl SpeedSettings {
/// Set the speed setting according to a numeric speed preset.
pub fn from_preset(speed: usize) -> Self {
pub fn from_preset(speed: u8) -> Self {
// The default settings are equivalent to speed 0
let mut settings = SpeedSettings::default();

Expand Down
4 changes: 2 additions & 2 deletions src/api/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::sync::Arc;
use interpolate_name::interpolate_test;

fn setup_config(
w: usize, h: usize, speed: usize, quantizer: usize, bit_depth: usize,
w: usize, h: usize, speed: u8, quantizer: usize, bit_depth: usize,
chroma_sampling: ChromaSampling, min_keyint: u64, max_keyint: u64,
bitrate: i32, low_latency: bool, switch_frame_interval: u64,
no_scene_detection: bool, rdo_lookahead_frames: usize,
Expand Down Expand Up @@ -44,7 +44,7 @@ fn setup_config(
}

fn setup_encoder<T: Pixel>(
w: usize, h: usize, speed: usize, quantizer: usize, bit_depth: usize,
w: usize, h: usize, speed: u8, quantizer: usize, bit_depth: usize,
chroma_sampling: ChromaSampling, min_keyint: u64, max_keyint: u64,
bitrate: i32, low_latency: bool, switch_frame_interval: u64,
no_scene_detection: bool, rdo_lookahead_frames: usize,
Expand Down
Loading