@@ -242,10 +242,53 @@ pub struct CliOptions {
242242 #[ clap( long, short, value_parser, help_heading = "DEBUGGING" ) ]
243243 pub reconstruction : Option < PathBuf > ,
244244
245+ /// Controls the strength of the deblock filter, as a multiplier to the default.
246+ #[ cfg( feature = "devel" ) ]
247+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
248+ pub deblock_strength : f32 ,
249+ /// Controls the sharpness of the deblock filter. Accepts a value from 0-7.
250+ #[ cfg( feature = "devel" ) ]
251+ #[ clap( long, value_parser = clap:: value_parser!( u8 ) . range( 0 ..=7 ) , default_value_t=0 , help_heading = "ADVANCED" ) ]
252+ pub deblock_sharpness : u8 ,
253+ /// Controls the ratio between intra frame and inter frame quantizers, as a multiplier.
254+ /// Higher values create a higher quantizer difference, while lower values
255+ /// create a lower quantizer difference. A value of 0.0 would mean that I and P quantizers
256+ /// are the same.
257+ #[ cfg( feature = "devel" ) ]
258+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
259+ pub ip_qidx_ratio : f32 ,
260+ /// Controls the ratio between "P"-frame and "B"-frame quantizers, as a multiplier.
261+ /// Default is 1.0. Higher values create a higher quantizer difference, while lower values
262+ /// create a lower quantizer difference. A value of 0.0 would mean that P and B quantizers
263+ /// are the same.
264+ #[ cfg( feature = "devel" ) ]
265+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
266+ pub pb_qidx_ratio : f32 ,
267+ /// Controls the ratio between frame quantizers in the levels of the pyramid betweem "B"-frames,
268+ /// as a multiplier. Default is 1.0. Higher values create a higher quantizer difference,
269+ /// while lower values create a lower quantizer difference. A value of 0.0 would mean that
270+ /// B0 and B1 quantizers are the same.
271+ #[ cfg( feature = "devel" ) ]
272+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
273+ pub b_qidx_ratio : f32 ,
274+ /// Controls the strength of temporal RDO, as a multiplier to the default.
275+ #[ cfg( feature = "devel" ) ]
276+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
277+ pub temporal_rdo_strength : f32 ,
278+
245279 #[ clap( subcommand) ]
246280 pub command : Option < Commands > ,
247281}
248282
283+ #[ cfg( feature = "devel" ) ]
284+ fn positive_float ( input : & str ) -> Result < f32 , String > {
285+ let value = input. parse :: < f32 > ( ) . map_err ( |e| e. to_string ( ) ) ?;
286+ if value < 0.0 {
287+ return Err ( "Value must not be negative" . to_string ( ) ) ;
288+ }
289+ Ok ( value)
290+ }
291+
249292fn get_version ( ) -> & ' static str {
250293 static VERSION_STR : Lazy < String > = Lazy :: new ( || {
251294 format ! (
@@ -299,7 +342,7 @@ pub enum Commands {
299342 #[ clap( long, short, value_parser) ]
300343 save_config : Option < PathBuf > ,
301344 /// Load the encoder configuration from a toml file
302- #[ clap( long, short, value_parser, conflicts_with = "save-config " ) ]
345+ #[ clap( long, short, value_parser, conflicts_with = "save_config " ) ]
303346 load_config : Option < PathBuf > ,
304347 } ,
305348}
@@ -484,6 +527,18 @@ pub fn parse_cli() -> Result<ParsedCliOptions, CliError> {
484527 } )
485528}
486529
530+ #[ cfg( feature = "devel" ) ]
531+ const fn parse_advanced_flags ( cli : & CliOptions ) -> AdvancedTuning {
532+ AdvancedTuning {
533+ deblock_strength : cli. deblock_strength ,
534+ deblock_sharpness : cli. deblock_sharpness ,
535+ ip_qidx_ratio : cli. ip_qidx_ratio ,
536+ pb_qidx_ratio : cli. pb_qidx_ratio ,
537+ b_qidx_ratio : cli. b_qidx_ratio ,
538+ temporal_rdo_strength : cli. temporal_rdo_strength ,
539+ }
540+ }
541+
487542fn parse_config ( matches : & CliOptions ) -> Result < EncoderConfig , CliError > {
488543 let maybe_quantizer = matches. quantizer ;
489544 let maybe_bitrate = matches. bitrate ;
@@ -674,5 +729,10 @@ fn parse_config(matches: &CliOptions) -> Result<EncoderConfig, CliError> {
674729 cfg. speed_settings . scene_detection_mode = SceneDetectionSpeed :: None ;
675730 }
676731
732+ #[ cfg( feature = "devel" ) ]
733+ {
734+ cfg. advanced_flags = parse_advanced_flags ( matches) ;
735+ }
736+
677737 Ok ( cfg)
678738}
0 commit comments