MCPcopy Create free account
hub / github.com/Proryanator/encoder-benchmark / run

Method run

engine/src/permutation_engine.rs:49–133  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

47 }
48
49 pub fn run(&mut self) {
50 let runtime = SystemTime::now();
51 let ctrl_channel = setup_ctrl_channel();
52 let mut target_quality_found = false;
53
54 let mut ignore_factor = 1 as c_float;
55 let mut calc_time: Option<Duration> = None;
56 for i in 0..self.permutations.clone().len() {
57 let permutation_start_time = SystemTime::now();
58 let mut permutation = self.permutations[i].clone();
59 log_permutation_header(i, &self.permutations, calc_time, ignore_factor);
60
61 // if this permutation was added to the list of duplicates, skip to save calculation time
62 if !permutation.allow_duplicates
63 && permutation.check_quality
64 && will_be_duplicate(&self.dup_results, &permutation)
65 {
66 draw_yellow_bar(permutation.get_metadata().frames);
67 println!("\n!!! Above encoder settings will produce identical vmaf score as other permutations, skipping... \n");
68 continue;
69 }
70
71 let mut result = run_encode(permutation.clone(), &ctrl_channel);
72 calc_time = Option::from(permutation_start_time.elapsed().unwrap());
73
74 if !result.was_overloaded && permutation.check_quality.clone() {
75 let vmaf_start_time = SystemTime::now();
76 result.vmaf_score = check_encode_quality(
77 &mut permutation.clone(),
78 &ctrl_channel,
79 permutation.verbose,
80 i,
81 )
82 .expect("Failed to check encode quality");
83
84 result.vmaf_calculation_time = vmaf_start_time.elapsed().unwrap().as_secs();
85
86 // if this is higher than the target quality, stop at this bitrate during benchmark
87 if result.vmaf_score >= TARGET_QUALITY {
88 target_quality_found = true;
89 }
90
91 // take the vmaf calculation time into account for the total ETA calculation
92 calc_time = Option::from(permutation_start_time.elapsed().unwrap());
93 }
94
95 let is_initial_bitrate_permutation_over = i == self.permutations.len() - 1
96 || self.permutations[i + 1].clone().bitrate != permutation.bitrate;
97 self.add_result(
98 result,
99 is_initial_bitrate_permutation_over,
100 permutation.check_quality,
101 permutation.allow_duplicates,
102 );
103
104 // we'll calculate the ignore factor of permutations that will be skipped
105 if is_initial_bitrate_permutation_over {
106 // % of permutations that we will actually permute over past the initial bitrate

Callers

nothing calls this directly

Calls 9

setup_ctrl_channelFunction · 0.85
log_permutation_headerFunction · 0.85
will_be_duplicateFunction · 0.85
draw_yellow_barFunction · 0.85
run_encodeFunction · 0.85
check_encode_qualityFunction · 0.85
log_results_to_fileFunction · 0.85
get_metadataMethod · 0.80
add_resultMethod · 0.80

Tested by

no test coverage detected