pub struct Encoder { /* private fields */ }Expand description
Ultra HDR encoder.
Supports multiple input modes:
- HDR only: Automatically generates SDR via tone mapping
- HDR + SDR: Uses provided SDR image
- HDR + compressed SDR: Uses pre-encoded JPEG for base image
- HDR + SDR + existing gain map: Reuses pre-computed gain map (for lossless round-trips)
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn set_hdr_image(&mut self, image: RawImage) -> &mut Self
pub fn set_hdr_image(&mut self, image: RawImage) -> &mut Self
Set the HDR input image (required).
Sourcepub fn set_sdr_image(&mut self, image: RawImage) -> &mut Self
pub fn set_sdr_image(&mut self, image: RawImage) -> &mut Self
Set the SDR input image (optional).
If not provided, SDR will be generated via tone mapping.
Sourcepub fn set_compressed_sdr(&mut self, jpeg: Vec<u8>) -> &mut Self
pub fn set_compressed_sdr(&mut self, jpeg: Vec<u8>) -> &mut Self
Set a pre-compressed SDR JPEG (optional).
If provided, this JPEG will be used as the base image instead of compressing the SDR image.
Sourcepub fn set_existing_gainmap(
&mut self,
gainmap: GainMap,
metadata: GainMapMetadata,
) -> &mut Self
pub fn set_existing_gainmap( &mut self, gainmap: GainMap, metadata: GainMapMetadata, ) -> &mut Self
Set an existing gain map and metadata (optional).
If provided, this gain map will be used instead of computing a new one. This enables lossless UltraHDR round-trips (decode → process → encode) when the SDR dimensions haven’t changed.
Note: The caller is responsible for ensuring the gain map is appropriate for the SDR image. If the SDR dimensions have changed (e.g., after resize), the gain map should be invalidated and recomputed.
Sourcepub fn clear_existing_gainmap(&mut self) -> &mut Self
pub fn clear_existing_gainmap(&mut self) -> &mut Self
Clear any existing gain map, forcing recomputation.
Sourcepub fn set_existing_gainmap_jpeg(
&mut self,
jpeg: Vec<u8>,
metadata: GainMapMetadata,
) -> &mut Self
pub fn set_existing_gainmap_jpeg( &mut self, jpeg: Vec<u8>, metadata: GainMapMetadata, ) -> &mut Self
Set an existing gain map as raw JPEG bytes and metadata (optional).
This is an alternative to set_existing_gainmap that skips the
JPEG re-encoding step entirely. Useful when the original gain map
JPEG is available (e.g., from a decoded UltraHDR image).
When set, this takes precedence over existing_gainmap.
Sourcepub fn has_existing_gainmap(&self) -> bool
pub fn has_existing_gainmap(&self) -> bool
Check if an existing gain map is set.
Sourcepub fn set_quality(&mut self, base: u8, gainmap: u8) -> &mut Self
pub fn set_quality(&mut self, base: u8, gainmap: u8) -> &mut Self
Set JPEG quality for base and gain map images.
Quality ranges from 1-100. Default: base=90, gainmap=85.
Sourcepub fn set_gainmap_scale(&mut self, scale: u8) -> &mut Self
pub fn set_gainmap_scale(&mut self, scale: u8) -> &mut Self
Set gain map downscale factor.
The gain map is typically smaller than the base image. Factor of 4 means gain map is 1/4 the width and height. Default: 4. Range: 1-128.
Sourcepub fn set_target_display_peak(&mut self, nits: f32) -> &mut Self
pub fn set_target_display_peak(&mut self, nits: f32) -> &mut Self
Set target display peak brightness in nits.
Default: 10000.0 (HDR10 max).
Sourcepub fn set_min_content_boost(&mut self, boost: f32) -> &mut Self
pub fn set_min_content_boost(&mut self, boost: f32) -> &mut Self
Set minimum content boost.
Default: 1.0 (no boost at minimum).
Sourcepub fn set_use_iso_metadata(&mut self, use_iso: bool) -> &mut Self
pub fn set_use_iso_metadata(&mut self, use_iso: bool) -> &mut Self
Enable or disable ISO 21496-1 metadata.
Default: true (include both XMP and ISO metadata).