Skip to content

Commit

Permalink
Add support for vmaf-subsample
Browse files Browse the repository at this point in the history
Add vmaf-subsample as an alternative to probing-rate as it is more accurate while still providing a speed benefit compared to without it
  • Loading branch information
luigi311 committed Apr 23, 2024
1 parent e69826f commit 5ec173c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions av1an-core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ impl Av1anContext {
temp_res.as_str(),
tq.vmaf_scaler.as_str(),
1,
1,
tq.vmaf_filter.as_deref(),
tq.vmaf_threads,
) {
Expand Down
2 changes: 2 additions & 0 deletions av1an-core/src/target_quality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct TargetQuality {
pub vmaf_threads: usize,
pub model: Option<PathBuf>,
pub probing_rate: usize,
pub vmaf_subsample: usize,
pub probes: u32,
pub target: f64,
pub min_q: u32,
Expand Down Expand Up @@ -252,6 +253,7 @@ impl TargetQuality {
&self.vmaf_res,
&self.vmaf_scaler,
self.probing_rate,
self.vmaf_subsample,
self.vmaf_filter.as_deref(),
self.vmaf_threads,
)?;
Expand Down
13 changes: 9 additions & 4 deletions av1an-core/src/vmaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn plot(
res: &str,
scaler: &str,
sample_rate: usize,
subsample: usize,
filter: Option<&str>,
threads: usize,
) -> Result<(), Box<EncoderCrash>> {
Expand Down Expand Up @@ -156,6 +157,7 @@ pub fn plot(
res,
scaler,
sample_rate,
subsample,
filter,
threads,
)?;
Expand All @@ -172,6 +174,7 @@ pub fn run_vmaf(
res: &str,
scaler: &str,
sample_rate: usize,
subsample: usize,
vmaf_filter: Option<&str>,
threads: usize,
) -> Result<(), Box<EncoderCrash>> {
Expand All @@ -193,16 +196,18 @@ pub fn run_vmaf(

let vmaf = if let Some(model) = model {
format!(
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:model_path={}:n_threads={}",
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:model_path={}:n_threads={}:n_subsample={}",
ffmpeg::escape_path_in_filter(stat_file),
ffmpeg::escape_path_in_filter(&model),
threads
threads,
subsample,
)
} else {
format!(
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:n_threads={}",
"[distorted][ref]libvmaf=log_fmt='json':eof_action=endall:log_path={}:n_threads={}:n_subsample={}",
ffmpeg::escape_path_in_filter(stat_file),
threads
threads,
subsample,
)
};

Expand Down
5 changes: 5 additions & 0 deletions av1an/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ pub struct CliOpts {
#[clap(long, default_value_t = 1, help_heading = "Target Quality")]
pub probing_rate: u32,

/// Vmaf subsample to speedup VMAF calculation
#[clap(long, default_value_t = 1, help_heading = "Target Quality")]
pub vmaf_subsample: usize,

/// Use encoding settings for probes specified by --video-params rather than faster, less accurate settings
///
/// Note that this always performs encoding in one-pass mode, regardless of --passes.
Expand Down Expand Up @@ -572,6 +576,7 @@ impl CliOpts {
video_params: video_params.clone(),
probe_slow: self.probe_slow,
probing_rate: adapt_probing_rate(self.probing_rate as usize),
vmaf_subsample: self.vmaf_subsample,
}
})
}
Expand Down

0 comments on commit 5ec173c

Please sign in to comment.