#[non_exhaustive]pub struct ConvertPolicy {Show 16 fields
pub depth: DepthPolicy,
pub alpha: AlphaPolicy,
pub gamut: GamutPolicy,
pub range: RangePolicy,
pub luma: LumaCoefficients,
pub luma_domain: LumaDomain,
pub diffuse_white: Option<DiffuseWhite>,
pub sdr_peak: Nits,
pub hlg_rendering: Option<HlgRendering>,
pub tone_mapper: Option<Arc<dyn ToneMapper>>,
pub cms: Option<Arc<dyn CmsBackend>>,
pub accelerators: Option<Accelerators>,
pub source_claims: SampleClaims,
pub tone_map_hdr_to_sdr: bool,
pub allow_icc_substitution: bool,
pub allow_approximate: bool,
}Expand description
Cohesive conversion policy controlling precision, alpha, gamut, signal range, HDR anchors, tone mapping, CMS fallback, and SIMD acceleration.
§Preset Defaults
| Field | lossless() / default() | working_linear() | permissive() | display_sdr(white, peak) |
|---|---|---|---|---|
depth | Forbid | Round | Round | Round |
alpha | Forbid | DiscardIfOpaque | DiscardUnchecked | CompositeOnto(BLACK) |
gamut | PreserveExtended | PreserveExtended | Clip | Clip |
range | Forbid | Convert | Convert | Convert |
diffuse_white | None | Some(BT2408) | None | Some(white) |
hlg_rendering | None | None | None | Some(REFERENCE_1000_NIT) |
tone_map_hdr_to_sdr | false | false | false | true |
allow_icc_substitution | false | true | true | true |
allow_approximate | false | false | false | false |
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.depth: DepthPolicyDepth/quantization behavior.
alpha: AlphaPolicyAlpha removal / compositing behavior.
gamut: GamutPolicyGamut narrowing / extended-range behavior.
range: RangePolicyExplicit Full ↔ Narrow range conversion policy.
luma: LumaCoefficientsRGB → Gray luma weights.
luma_domain: LumaDomainDomain in which RGB → Gray weights are evaluated (Encoded Y’ default vs LinearLight Y).
diffuse_white: Option<DiffuseWhite>Relative-linear 1.0 diffuse white anchor (required when crossing PQ ↔ relative light unless carried on ColorSpace).
sdr_peak: NitsTarget SDR peak luminance in cd/m² for HDR → SDR tone mapping (default 100.0 cd/m²).
hlg_rendering: Option<HlgRendering>Explicit HLG display rendering override when source/dest carries HlgMode::Scene.
tone_mapper: Option<Arc<dyn ToneMapper>>Optional custom HDR → SDR tone mapper (defaults to built-in Bt2446A when bt2446a feature is enabled).
cms: Option<Arc<dyn CmsBackend>>Optional CMS backend for arbitrary ColorSpace::Icc or ColorSpace::Cmyk transforms.
accelerators: Option<Accelerators>Optional hermetic accelerator table override (when None, consults the process registry / fast feature default).
source_claims: SampleClaimsCaller-asserted source sample facts (merged with buffer facts in ImagePlan).
tone_map_hdr_to_sdr: boolWhether to apply tone mapping when converting HDR → SDR (true in display_sdr(), false in lossless()/working_linear()).
allow_icc_substitution: boolWhether recognized matrix+TRC ICC profiles may substitute directly into native math (for non-absolute intents) instead of requiring a CMS backend.
Default is true in permissive()/working_linear()/display_sdr(), and false in lossless().
allow_approximate: boolWhether opt-in fast fixed-point approximations (max error <= 1 LSB vs exact float, e.g. Q13/Q14 integer LUT U8 sRGB-matrix fast path) may be selected.
Default is false (exact 0-bit parity with the float strip pipeline).
Implementations§
Source§impl ConvertPolicy
impl ConvertPolicy
Sourcepub fn lossless() -> Self
pub fn lossless() -> Self
Strict lossless-permission policy: forbids depth reduction, alpha loss, gamut clipping, RGB→Gray chroma loss (unless proven grayscale), and range scaling.
Allows lossless widening (U8 → U16 → F32), channel reordering (RGB ↔ BGR),
adding opaque alpha, and floating-point extended-gamut preservation. Note that
lossless() describes loss-permission settings rather than mathematical
invertibility of arbitrary floating-point color transforms.
Sourcepub fn working_linear() -> Self
pub fn working_linear() -> Self
Linear-light working-space policy: preserves extended values, defaults diffuse white
to ITU-R BT.2408 (203 cd/m², override via .with_diffuse_white(...)), and disables tone mapping.
Use ConvertPolicy::permissive or ConvertPolicy::lossless when unanchored
PQ ↔ relative routes must fail with ConvertError::MissingHdrAnchor
unless a diffuse white is explicitly provided.
Sourcepub fn display_sdr(white: DiffuseWhite, sdr_peak: Nits) -> Self
pub fn display_sdr(white: DiffuseWhite, sdr_peak: Nits) -> Self
Display-referred SDR output policy: enables HDR → SDR tone mapping, rounds depth, converts narrow range, and clips/compresses gamut.
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Permissive general-purpose policy (rounds depth, clips gamut, converts narrow range, discards alpha unchecked unless configured).
Sourcepub fn with_depth(self, depth: DepthPolicy) -> Self
pub fn with_depth(self, depth: DepthPolicy) -> Self
Set depth reduction policy (Forbid, Round, Truncate, OrderedDither).
Sourcepub fn with_alpha(self, alpha: AlphaPolicy) -> Self
pub fn with_alpha(self, alpha: AlphaPolicy) -> Self
Set alpha removal/compositing policy.
Sourcepub fn with_gamut(self, gamut: GamutPolicy) -> Self
pub fn with_gamut(self, gamut: GamutPolicy) -> Self
Set gamut narrowing / extended-range policy.
Sourcepub fn with_range(self, range: RangePolicy) -> Self
pub fn with_range(self, range: RangePolicy) -> Self
Set explicit Full ↔ Narrow signal range conversion policy.
Sourcepub fn with_luma(self, luma: LumaCoefficients) -> Self
pub fn with_luma(self, luma: LumaCoefficients) -> Self
Set RGB → Gray luminance weights.
Sourcepub fn with_luma_domain(self, domain: LumaDomain) -> Self
pub fn with_luma_domain(self, domain: LumaDomain) -> Self
Set RGB → Gray evaluation domain (LumaDomain::Encoded Y’ default vs LumaDomain::LinearLight Y).
Sourcepub fn with_diffuse_white(self, white: DiffuseWhite) -> Self
pub fn with_diffuse_white(self, white: DiffuseWhite) -> Self
Set relative-linear 1.0 diffuse white anchor (e.g. DiffuseWhite::BT2408 = 203 nits).
Sourcepub fn with_sdr_peak(self, peak: Nits) -> Self
pub fn with_sdr_peak(self, peak: Nits) -> Self
Set target SDR peak luminance in cd/m² for HDR → SDR tone mapping.
Sourcepub fn with_hlg_rendering(self, rendering: HlgRendering) -> Self
pub fn with_hlg_rendering(self, rendering: HlgRendering) -> Self
Set explicit BT.2100-3 HLG display rendering conditions.
Sourcepub fn with_tone_mapping(self, enable: bool) -> Self
pub fn with_tone_mapping(self, enable: bool) -> Self
Enable or disable HDR → SDR tone mapping.
Sourcepub fn with_tone_mapper(self, mapper: Arc<dyn ToneMapper>) -> Self
pub fn with_tone_mapper(self, mapper: Arc<dyn ToneMapper>) -> Self
Attach a custom ToneMapper and enable HDR → SDR tone mapping.
Sourcepub fn with_cms(self, cms: Arc<dyn CmsBackend>) -> Self
pub fn with_cms(self, cms: Arc<dyn CmsBackend>) -> Self
Attach a CmsBackend for arbitrary ICC profiles and CMYK conversions.
Sourcepub fn with_color_services(self, services: &ColorServices) -> Self
pub fn with_color_services(self, services: &ColorServices) -> Self
Apply a shared ColorServices bundle to this policy.
CmsChoice::Inherit: leavescmsandallow_icc_substitutionunchanged.CmsChoice::StrictNoIcc: clearscmsand setsallow_icc_substitution = false, permitting validated same-profile ICC carriage and known-space math while refusing both CMS evaluation and inferred matrix+TRC ICC substitution.CmsChoice::Use: installs the binding’sCmsBackend.services.tone_mapper: attaches the tone mapper if present without alteringtone_map_hdr_to_sdr.
Apply with_color_services last when composing a policy: subsequent calls to
with_cms or with_icc_substitution
overwrite the fields set here.
Sourcepub fn with_accelerators(self, accel: Accelerators) -> Self
pub fn with_accelerators(self, accel: Accelerators) -> Self
Override the SIMD accelerator table hermetically for plans built with this policy.
Sourcepub fn with_source_claims(self, facts: SampleClaims) -> Self
pub fn with_source_claims(self, facts: SampleClaims) -> Self
Supply proven source SampleClaims for row-level plans without buffer headers
(merged with runtime buffer facts in ImagePlan).
Sourcepub fn with_icc_substitution(self, allow: bool) -> Self
pub fn with_icc_substitution(self, allow: bool) -> Self
Control whether recognized matrix+TRC ICC profiles may substitute into native math.
Sourcepub fn with_approximate(self, allow: bool) -> Self
pub fn with_approximate(self, allow: bool) -> Self
Control whether fast fixed-point approximations (max error <= 1 LSB vs exact float)
may be used on supported U8 color-matrix routes (default false).
Trait Implementations§
Source§impl Clone for ConvertPolicy
impl Clone for ConvertPolicy
Source§fn clone(&self) -> ConvertPolicy
fn clone(&self) -> ConvertPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConvertPolicy
impl Debug for ConvertPolicy
Source§impl Default for ConvertPolicy
impl Default for ConvertPolicy
Source§fn default() -> Self
fn default() -> Self
Defaults to ConvertPolicy::lossless so callers never silently discard alpha,
narrow bit depth, clip gamut, or rescale signal range without opting in.
Use ConvertPolicy::permissive, ConvertPolicy::working_linear, or
ConvertPolicy::display_sdr when lossy conversion is desired.