Skip to main content

SimulationParams

Struct SimulationParams 

Source
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: f64

Scale factor to apply to the image (1.0 = no scaling).

§target_width: u32

Target width after scaling.

§target_height: u32

Target height after scaling.

§adjusted_ppd: f64

Adjusted PPD for metric thresholds.

In downsample-only mode, this may differ from effective_ppd() to compensate for skipped upscaling.

§requires_upscale: bool

Whether the simulation requires upscaling.

In downsample-only mode, this is always false.

§requires_downscale: bool

Whether the simulation requires downscaling.

Implementations§

Source§

impl SimulationParams

Source

pub fn requires_scaling(&self) -> bool

Check if any scaling is required.

Source

pub fn downscale_only_factor(&self) -> f64

Get the scale factor clamped to downscale-only (max 1.0).

Source

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);
Source

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 PPD
Source

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)
Source

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)
Source

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 value
  • base_threshold - Threshold at reference PPD
Source

pub fn butteraugli_acceptable( &self, butteraugli: f64, base_threshold: f64, ) -> bool

Check if a Butteraugli value is acceptable for this viewing condition.

Source

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

Source§

fn clone(&self) -> SimulationParams

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SimulationParams

Source§

impl Debug for SimulationParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SimulationParams

Source§

fn eq(&self, other: &SimulationParams) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SimulationParams

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.