pub struct GainMapMetadata {
pub is_multichannel: bool,
pub use_base_colour_space: bool,
pub backward_direction: bool,
pub base_hdr_headroom_n: u32,
pub base_hdr_headroom_d: u32,
pub alternate_hdr_headroom_n: u32,
pub alternate_hdr_headroom_d: u32,
pub channels: [GainMapChannel; 3],
}Expand description
Gain map metadata from a ToneMapImage (tmap) derived image item.
Describes how to apply a gain map to convert between SDR and HDR renditions. The gain map is a separate AV1-encoded image that, combined with this metadata, allows reconstructing an HDR image from the SDR base.
See ISO 21496-1:2025 for the full specification.
Fields§
§is_multichannel: boolIf true, each RGB channel has independent gain map parameters.
If false, channels[0] applies to all three channels.
use_base_colour_space: boolIf true, the gain map is encoded in the base image’s colour space. If false, it’s in the alternate image’s colour space.
backward_direction: boolISO 21496-1 backward direction flag (bit 2 of flags byte). When true, the base image is HDR and the alternate is SDR. Default false = base is SDR, alternate is HDR.
base_hdr_headroom_n: u32Base HDR headroom (numerator).
base_hdr_headroom_d: u32Base HDR headroom (denominator).
alternate_hdr_headroom_n: u32Alternate HDR headroom (numerator).
alternate_hdr_headroom_d: u32Alternate HDR headroom (denominator).
channels: [GainMapChannel; 3]Per-channel parameters. For single-channel mode, only index 0 is meaningful (indices 1 and 2 are copies of index 0).
Implementations§
Source§impl GainMapMetadata
impl GainMapMetadata
Sourcepub fn parse_tmap_bytes(data: &[u8]) -> Result<Self>
pub fn parse_tmap_bytes(data: &[u8]) -> Result<Self>
Parse an ISO 21496-1 AVIF tmap item payload into a GainMapMetadata.
This is the public mirror of the internal parser. Useful for testing and for consumers who hold raw tmap payload bytes.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize this metadata to the ISO 21496-1 AVIF tmap item payload format.
This is the inverse of the internal parse_tone_map_image function and
produces the exact byte sequence expected in an AVIF tmap item. The
output can be passed to zenavif_serialize::Aviffy::set_gain_map or
used for byte-level roundtrip testing.
The writer is always written as version 0 / minimum_version 0.
Trait Implementations§
Source§impl Clone for GainMapMetadata
impl Clone for GainMapMetadata
Source§fn clone(&self) -> GainMapMetadata
fn clone(&self) -> GainMapMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GainMapMetadata
impl Debug for GainMapMetadata
Source§impl From<&GainMapMetadata> for GainMapParams
Available on crate feature zencodec only.
impl From<&GainMapMetadata> for GainMapParams
zencodec only.Source§fn from(md: &GainMapMetadata) -> Self
fn from(md: &GainMapMetadata) -> Self
Source§impl From<&GainMapParams> for GainMapMetadata
Available on crate feature zencodec only.
impl From<&GainMapParams> for GainMapMetadata
zencodec only.