pub struct SimulationParams {
pub scale_factor: f64,
pub target_width: u32,
pub target_height: u32,
pub adjusted_ppd: f64,
pub requires_upscale: bool,
pub requires_downscale: bool,
}Expand description
Parameters for viewing simulation.
Describes how to transform an image and adjust metrics for a viewing condition.
Fields§
§scale_factor: f64Scale factor to apply to the image (1.0 = no scaling).
target_width: u32Target width after scaling.
target_height: u32Target height after scaling.
adjusted_ppd: f64Adjusted PPD for metric thresholds.
In downsample-only mode, this may differ from effective_ppd() to compensate for skipped upscaling.
requires_upscale: boolWhether the simulation requires upscaling.
In downsample-only mode, this is always false.
requires_downscale: boolWhether the simulation requires downscaling.
Implementations§
Source§impl SimulationParams
impl SimulationParams
Sourcepub fn requires_scaling(&self) -> bool
pub fn requires_scaling(&self) -> bool
Check if any scaling is required.
Sourcepub fn downscale_only_factor(&self) -> f64
pub fn downscale_only_factor(&self) -> f64
Get the scale factor clamped to downscale-only (max 1.0).
Sourcepub fn threshold_multiplier(&self) -> f64
pub fn threshold_multiplier(&self) -> f64
Compute threshold multiplier for metric values.
This accounts for how viewing conditions affect artifact visibility. Higher PPD = smaller angular size = artifacts less visible = more lenient thresholds.
The multiplier is relative to REFERENCE_PPD (40, desktop viewing).
§Returns
- 1.0 at reference PPD (40)
-
1.0 for higher PPD (more lenient, e.g., 1.75 at 70 PPD)
- < 1.0 for lower PPD (stricter, e.g., 0.5 at 20 PPD)
§Example
use codec_eval::viewing::{ViewingCondition, SimulationMode, REFERENCE_PPD};
// Desktop at reference PPD
let condition = ViewingCondition::new(40.0);
let params = condition.simulation_params(1000, 800, SimulationMode::Accurate);
assert!((params.threshold_multiplier() - 1.0).abs() < 0.01);
// Laptop at 70 PPD - more lenient
let condition = ViewingCondition::new(70.0);
let params = condition.simulation_params(1000, 800, SimulationMode::Accurate);
assert!(params.threshold_multiplier() > 1.5);Sourcepub fn adjust_dssim_threshold(&self, base_threshold: f64) -> f64
pub fn adjust_dssim_threshold(&self, base_threshold: f64) -> f64
Adjust a DSSIM threshold for this viewing condition.
Higher PPD allows higher DSSIM values (artifacts less visible).
§Arguments
base_threshold- Threshold at reference PPD (e.g., 0.0003 for imperceptible)
§Example
use codec_eval::viewing::{ViewingCondition, SimulationMode};
let condition = ViewingCondition::new(70.0); // laptop
let params = condition.simulation_params(1000, 800, SimulationMode::Accurate);
// Imperceptible threshold at reference is 0.0003
let adjusted = params.adjust_dssim_threshold(0.0003);
assert!(adjusted > 0.0003); // More lenient at higher PPDSourcepub fn adjust_butteraugli_threshold(&self, base_threshold: f64) -> f64
pub fn adjust_butteraugli_threshold(&self, base_threshold: f64) -> f64
Adjust a Butteraugli threshold for this viewing condition.
Higher PPD allows higher Butteraugli values (artifacts less visible).
§Arguments
base_threshold- Threshold at reference PPD (e.g., 1.0 for imperceptible)
Sourcepub fn adjust_ssimulacra2_threshold(&self, base_threshold: f64) -> f64
pub fn adjust_ssimulacra2_threshold(&self, base_threshold: f64) -> f64
Adjust a SSIMULACRA2 threshold for this viewing condition.
Higher PPD allows lower SSIMULACRA2 scores (artifacts less visible). Note: SSIMULACRA2 is inverted (higher = better), so we divide.
§Arguments
base_threshold- Threshold at reference PPD (e.g., 90.0 for imperceptible)
Sourcepub fn dssim_acceptable(&self, dssim: f64, base_threshold: f64) -> bool
pub fn dssim_acceptable(&self, dssim: f64, base_threshold: f64) -> bool
Check if a DSSIM value is acceptable for this viewing condition.
§Arguments
dssim- Measured DSSIM valuebase_threshold- Threshold at reference PPD
Sourcepub fn butteraugli_acceptable(
&self,
butteraugli: f64,
base_threshold: f64,
) -> bool
pub fn butteraugli_acceptable( &self, butteraugli: f64, base_threshold: f64, ) -> bool
Check if a Butteraugli value is acceptable for this viewing condition.
Sourcepub fn ssimulacra2_acceptable(
&self,
ssimulacra2: f64,
base_threshold: f64,
) -> bool
pub fn ssimulacra2_acceptable( &self, ssimulacra2: f64, base_threshold: f64, ) -> bool
Check if a SSIMULACRA2 value is acceptable for this viewing condition.
Trait Implementations§
Source§impl Clone for SimulationParams
impl Clone for SimulationParams
Source§fn clone(&self) -> SimulationParams
fn clone(&self) -> SimulationParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SimulationParams
impl Debug for SimulationParams
Source§impl PartialEq for SimulationParams
impl PartialEq for SimulationParams
impl Copy for SimulationParams
impl StructuralPartialEq for SimulationParams
Auto Trait Implementations§
impl Freeze for SimulationParams
impl RefUnwindSafe for SimulationParams
impl Send for SimulationParams
impl Sync for SimulationParams
impl Unpin for SimulationParams
impl UnwindSafe for SimulationParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more