@@ -176,7 +176,6 @@ pub struct CliOptions {
176176 pub still_picture : bool ,
177177 /// Uses grain synthesis to add photon noise to the resulting encode.
178178 /// Takes a strength value 0-64.
179- #[ cfg( feature = "unstable" ) ]
180179 #[ clap(
181180 long,
182181 conflicts_with = "film-grain-table" ,
@@ -185,6 +184,17 @@ pub struct CliOptions {
185184 help_heading = "ENCODE SETTINGS"
186185 ) ]
187186 pub photon_noise : u8 ,
187+ /// Enable spatio-temporal denoising, intended to be used with grain synthesis.
188+ /// Takes a strength value 0-50.
189+ ///
190+ /// Default strength is 1/2 of photon noise strength,
191+ /// or 4 if a photon noise table is specified.
192+ #[ clap(
193+ long,
194+ value_parser = clap:: value_parser!( u8 ) . range( 0 ..=50 ) ,
195+ help_heading = "ENCODE SETTINGS"
196+ ) ]
197+ pub denoise : Option < u8 > ,
188198 /// Uses a film grain table file to apply grain synthesis to the encode.
189199 /// Uses the same table file format as aomenc and svt-av1.
190200 #[ clap(
@@ -334,7 +344,6 @@ pub struct ParsedCliOptions {
334344 pub save_config : Option < PathBuf > ,
335345 #[ cfg( feature = "unstable" ) ]
336346 pub slots : usize ,
337- #[ cfg( feature = "unstable" ) ]
338347 pub generate_grain_strength : u8 ,
339348}
340349
@@ -482,7 +491,6 @@ pub fn parse_cli() -> Result<ParsedCliOptions, CliError> {
482491 save_config : save_config_path,
483492 #[ cfg( feature = "unstable" ) ]
484493 slots,
485- #[ cfg( feature = "unstable" ) ]
486494 generate_grain_strength : matches. photon_noise ,
487495 } )
488496}
@@ -676,7 +684,19 @@ fn parse_config(matches: &CliOptions) -> Result<EncoderConfig, CliError> {
676684 . expect ( "Failed to parse film grain table" ) ;
677685 if !table. is_empty ( ) {
678686 cfg. film_grain_params = Some ( table) ;
687+ cfg. denoise_strength = 4 ;
688+ }
689+ } else if matches. photon_noise > 0 {
690+ cfg. denoise_strength = matches. photon_noise / 2 ;
691+ // We have to know the video resolution before we can generate a table,
692+ // so we must handle that elsewhere.
693+ }
694+ // A user set denoise strength overrides the defaults above
695+ if let Some ( denoise_str) = matches. denoise {
696+ if denoise_str > 50 {
697+ panic ! ( "Denoising strength must be between 0-50" ) ;
679698 }
699+ cfg. denoise_strength = denoise_str;
680700 }
681701
682702 if let Some ( frame_rate) = matches. frame_rate {
0 commit comments