@@ -242,10 +242,53 @@ pub struct CliOptions {
242
242
#[ clap( long, short, value_parser, help_heading = "DEBUGGING" ) ]
243
243
pub reconstruction : Option < PathBuf > ,
244
244
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_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_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_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
+
245
279
#[ clap( subcommand) ]
246
280
pub command : Option < Commands > ,
247
281
}
248
282
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
+
249
292
fn get_version ( ) -> & ' static str {
250
293
static VERSION_STR : Lazy < String > = Lazy :: new ( || {
251
294
format ! (
@@ -299,7 +342,7 @@ pub enum Commands {
299
342
#[ clap( long, short, value_parser) ]
300
343
save_config : Option < PathBuf > ,
301
344
/// 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 " ) ]
303
346
load_config : Option < PathBuf > ,
304
347
} ,
305
348
}
@@ -484,6 +527,18 @@ pub fn parse_cli() -> Result<ParsedCliOptions, CliError> {
484
527
} )
485
528
}
486
529
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_ratio : cli. ip_ratio ,
536
+ pb_ratio : cli. pb_ratio ,
537
+ b_ratio : cli. b_ratio ,
538
+ temporal_rdo_strength : cli. temporal_rdo_strength ,
539
+ }
540
+ }
541
+
487
542
fn parse_config ( matches : & CliOptions ) -> Result < EncoderConfig , CliError > {
488
543
let maybe_quantizer = matches. quantizer ;
489
544
let maybe_bitrate = matches. bitrate ;
@@ -674,5 +729,10 @@ fn parse_config(matches: &CliOptions) -> Result<EncoderConfig, CliError> {
674
729
cfg. speed_settings . scene_detection_mode = SceneDetectionSpeed :: None ;
675
730
}
676
731
732
+ #[ cfg( feature = "devel" ) ]
733
+ {
734
+ cfg. advanced_flags = parse_advanced_flags ( matches) ;
735
+ }
736
+
677
737
Ok ( cfg)
678
738
}
0 commit comments