@@ -249,10 +249,53 @@ pub struct CliOptions {
249
249
#[ clap( long, short, value_parser, help_heading = "DEBUGGING" ) ]
250
250
pub reconstruction : Option < PathBuf > ,
251
251
252
+ /// Controls the strength of the deblock filter, as a multiplier to the default.
253
+ #[ cfg( feature = "devel" ) ]
254
+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
255
+ pub deblock_strength : f32 ,
256
+ /// Controls the sharpness of the deblock filter. Accepts a value from 0-7.
257
+ #[ cfg( feature = "devel" ) ]
258
+ #[ clap( long, value_parser = clap:: value_parser!( u8 ) . range( 0 ..=7 ) , default_value_t=0 , help_heading = "ADVANCED" ) ]
259
+ pub deblock_sharpness : u8 ,
260
+ /// Controls the ratio between intra frame and inter frame quantizers, as a multiplier.
261
+ /// Higher values create a higher quantizer difference, while lower values
262
+ /// create a lower quantizer difference. A value of 0.0 would mean that I and P 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 ip_ratio : f32 ,
267
+ /// Controls the ratio between "P"-frame and "B"-frame quantizers, as a multiplier.
268
+ /// Default is 1.0. Higher values create a higher quantizer difference, while lower values
269
+ /// create a lower quantizer difference. A value of 0.0 would mean that P and B quantizers
270
+ /// are the same.
271
+ #[ cfg( feature = "devel" ) ]
272
+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
273
+ pub pb_ratio : f32 ,
274
+ /// Controls the ratio between frame quantizers in the levels of the pyramid betweem "B"-frames,
275
+ /// as a multiplier. Default is 1.0. Higher values create a higher quantizer difference,
276
+ /// while lower values create a lower quantizer difference. A value of 0.0 would mean that
277
+ /// B0 and B1 quantizers are the same.
278
+ #[ cfg( feature = "devel" ) ]
279
+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
280
+ pub b_ratio : f32 ,
281
+ /// Controls the strength of temporal RDO, as a multiplier to the default.
282
+ #[ cfg( feature = "devel" ) ]
283
+ #[ clap( long, value_parser = positive_float, default_value_t=1.0f32 , help_heading = "ADVANCED" ) ]
284
+ pub temporal_rdo_strength : f32 ,
285
+
252
286
#[ clap( subcommand) ]
253
287
pub command : Option < Commands > ,
254
288
}
255
289
290
+ #[ cfg( feature = "devel" ) ]
291
+ fn positive_float ( input : & str ) -> Result < f32 , String > {
292
+ let value = input. parse :: < f32 > ( ) . map_err ( |e| e. to_string ( ) ) ?;
293
+ if value < 0.0 {
294
+ return Err ( "Value must not be negative" . to_string ( ) ) ;
295
+ }
296
+ Ok ( value)
297
+ }
298
+
256
299
fn get_version ( ) -> & ' static str {
257
300
static VERSION_STR : Lazy < String > = Lazy :: new ( || {
258
301
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 ;
@@ -689,5 +744,10 @@ fn parse_config(matches: &CliOptions) -> Result<EncoderConfig, CliError> {
689
744
cfg. speed_settings . scene_detection_mode = SceneDetectionSpeed :: None ;
690
745
}
691
746
747
+ #[ cfg( feature = "devel" ) ]
748
+ {
749
+ cfg. advanced_flags = parse_advanced_flags ( matches) ;
750
+ }
751
+
692
752
Ok ( cfg)
693
753
}
0 commit comments