@@ -11,7 +11,7 @@ use ffmpeg::args::FfmpegArgs;
1111use ffmpeg:: report_files:: { extract_vmaf_score, get_latest_ffmpeg_report_file, read_last_line_at} ;
1212use permutation:: permutation:: Permutation ;
1313
14- use crate :: engine:: { log_benchmark_header , run_encode, spawn_ffmpeg_child} ;
14+ use crate :: engine:: { log_permutation_header , run_encode, spawn_ffmpeg_child} ;
1515use crate :: progressbar;
1616use crate :: progressbar:: draw_yellow_bar;
1717use crate :: result:: { log_results_to_file, PermutationResult } ;
@@ -46,11 +46,20 @@ impl PermutationEngine {
4646 let ctrl_channel = setup_ctrl_channel ( ) ;
4747 let mut target_quality_found = false ;
4848
49+ let mut ignore_factor = 1 as c_float ;
4950 let mut calc_time: Option < Duration > = None ;
5051 for i in 0 ..self . permutations . clone ( ) . len ( ) {
5152 let permutation_start_time = SystemTime :: now ( ) ;
5253 let mut permutation = self . permutations [ i] . clone ( ) ;
53- log_benchmark_header ( i, & self . permutations , calc_time) ;
54+ log_permutation_header ( i, & self . permutations , calc_time, ignore_factor) ;
55+
56+ // if this permutation was added to the list of duplicates, skip to save calculation time
57+ if will_be_duplicate ( & self . dup_results , & permutation) {
58+ draw_yellow_bar ( permutation. get_metadata ( ) . frames ) ;
59+ println ! ( "\n !!! Above encoder settings will produce identical vmaf score as other permutations, skipping... \n " ) ;
60+ continue ;
61+ }
62+
5463 let mut result = run_encode ( permutation. clone ( ) , & ctrl_channel) ;
5564 calc_time = Option :: from ( permutation_start_time. elapsed ( ) . unwrap ( ) ) ;
5665
@@ -66,28 +75,28 @@ impl PermutationEngine {
6675
6776 // take the vmaf calculation time into account for the total ETA calculation
6877 calc_time = Option :: from ( permutation_start_time. elapsed ( ) . unwrap ( ) ) ;
69-
70- // if this permutation was added to the list of duplicates, skip to save calculation time
71- if will_be_duplicate ( & self . dup_results , & result) {
72- draw_yellow_bar ( permutation. get_metadata ( ) . frames ) ;
73- println ! ( "\n !!! Above encoder settings will produce identical vmaf score as other permutations, skipping... \n " ) ;
74- continue ;
75- }
7678 }
7779
78- let is_bitrate_permutation_over = i == self . permutations . len ( ) - 1 || self . permutations [ i + 1 ] . clone ( ) . bitrate != permutation. bitrate ;
79- self . add_result ( result, is_bitrate_permutation_over) ;
80+ let is_initial_bitrate_permutation_over = i == self . permutations . len ( ) - 1 || self . permutations [ i + 1 ] . clone ( ) . bitrate != permutation. bitrate ;
81+ self . add_result ( result, is_initial_bitrate_permutation_over) ;
82+
83+ // we'll calculate the ignore factor of permutations that will be skipped
84+ if is_initial_bitrate_permutation_over {
85+ // % of permutations that we will actually permute over past the initial bitrate
86+ let perm_count = self . results . len ( ) + self . dup_results . len ( ) ;
87+ ignore_factor = self . results . len ( ) as c_float / perm_count as c_float ;
88+ }
8089
8190 // stop if we've found the target quality, and we're done permuting over the current bitrate
82- if target_quality_found && is_bitrate_permutation_over {
91+ if target_quality_found && is_initial_bitrate_permutation_over {
8392 println ! ( "Found VMAF score >= {}, stopping permutations..." , TARGET_QUALITY ) ;
8493 break ;
8594 }
8695 }
8796
8897 // produce output files and other logging here
8998 let runtime_str = format_dhms ( runtime. elapsed ( ) . unwrap ( ) . as_secs ( ) ) ;
90- log_results_to_file ( self . results . clone ( ) , & runtime_str, Vec :: new ( ) , 0 , true ) ;
99+ log_results_to_file ( self . results . clone ( ) , & runtime_str, self . dup_results . clone ( ) , self . permutations [ 0 ] . bitrate , false ) ;
91100 println ! ( "Benchmark runtime: {}" , runtime_str) ;
92101 }
93102
@@ -156,9 +165,9 @@ fn check_encode_quality(mut p: Permutation, ctrl_channel: &Result<Receiver<()>,
156165 return vmaf_score;
157166}
158167
159- fn will_be_duplicate ( duplicates : & Vec < PermutationResult > , result : & PermutationResult ) -> bool {
168+ fn will_be_duplicate ( duplicates : & Vec < PermutationResult > , next_permutation : & Permutation ) -> bool {
160169 for dup in duplicates {
161- if dup. encoder_settings == result . encoder_settings {
170+ if dup. encoder_settings == next_permutation . encoder_settings {
162171 return true ;
163172 }
164173 }
0 commit comments