Skip to content

Commit 5ec173c

Browse files
committed
Add support for vmaf-subsample
Add vmaf-subsample as an alternative to probing-rate as it is more accurate while still providing a speed benefit compared to without it
1 parent e69826f commit 5ec173c

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

av1an-core/src/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ impl Av1anContext {
368368
temp_res.as_str(),
369369
tq.vmaf_scaler.as_str(),
370370
1,
371+
1,
371372
tq.vmaf_filter.as_deref(),
372373
tq.vmaf_threads,
373374
) {

av1an-core/src/target_quality.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct TargetQuality {
2525
pub vmaf_threads: usize,
2626
pub model: Option<PathBuf>,
2727
pub probing_rate: usize,
28+
pub vmaf_subsample: usize,
2829
pub probes: u32,
2930
pub target: f64,
3031
pub min_q: u32,
@@ -252,6 +253,7 @@ impl TargetQuality {
252253
&self.vmaf_res,
253254
&self.vmaf_scaler,
254255
self.probing_rate,
256+
self.vmaf_subsample,
255257
self.vmaf_filter.as_deref(),
256258
self.vmaf_threads,
257259
)?;

av1an-core/src/vmaf.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub fn plot(
122122
res: &str,
123123
scaler: &str,
124124
sample_rate: usize,
125+
subsample: usize,
125126
filter: Option<&str>,
126127
threads: usize,
127128
) -> Result<(), Box<EncoderCrash>> {
@@ -156,6 +157,7 @@ pub fn plot(
156157
res,
157158
scaler,
158159
sample_rate,
160+
subsample,
159161
filter,
160162
threads,
161163
)?;
@@ -172,6 +174,7 @@ pub fn run_vmaf(
172174
res: &str,
173175
scaler: &str,
174176
sample_rate: usize,
177+
subsample: usize,
175178
vmaf_filter: Option<&str>,
176179
threads: usize,
177180
) -> Result<(), Box<EncoderCrash>> {
@@ -193,16 +196,18 @@ pub fn run_vmaf(
193196

194197
let vmaf = if let Some(model) = model {
195198
format!(
196-
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:model_path={}:n_threads={}",
199+
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:model_path={}:n_threads={}:n_subsample={}",
197200
ffmpeg::escape_path_in_filter(stat_file),
198201
ffmpeg::escape_path_in_filter(&model),
199-
threads
202+
threads,
203+
subsample,
200204
)
201205
} else {
202206
format!(
203-
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:n_threads={}",
207+
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:n_threads={}:n_subsample={}",
204208
ffmpeg::escape_path_in_filter(stat_file),
205-
threads
209+
threads,
210+
subsample,
206211
)
207212
};
208213

av1an/src/main.rs

+5
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ pub struct CliOpts {
514514
#[clap(long, default_value_t = 1, help_heading = "Target Quality")]
515515
pub probing_rate: u32,
516516

517+
/// Vmaf subsample to speedup VMAF calculation
518+
#[clap(long, default_value_t = 1, help_heading = "Target Quality")]
519+
pub vmaf_subsample: usize,
520+
517521
/// Use encoding settings for probes specified by --video-params rather than faster, less accurate settings
518522
///
519523
/// Note that this always performs encoding in one-pass mode, regardless of --passes.
@@ -572,6 +576,7 @@ impl CliOpts {
572576
video_params: video_params.clone(),
573577
probe_slow: self.probe_slow,
574578
probing_rate: adapt_probing_rate(self.probing_rate as usize),
579+
vmaf_subsample: self.vmaf_subsample,
575580
}
576581
})
577582
}

0 commit comments

Comments
 (0)