Expand description
ISO 21496-1 / UltraHDR dual-layer gain-map reconstruction, resampling, orientation, and extraction.
Subsumes pure ISO 21496-1 pixel math in no_std + alloc, #![forbid(unsafe_code)]
with 0-bit Accelerators::ALL == Accelerators::SCALAR parity and
O(width) streaming memory:
- Direction-complete ISO 21496-1: exact
i128rational headroom ordering supports both Forward (SDR base → HDR alternate,H_alt > H_base) and Reverse (HDR base → SDR alternate,H_base > H_alt) with signed weight, exactGainMapTarget::AlternateRendition/GainMapTarget::BaseRenditionendpoints, and zero-weight identity bypass. - Multiple orientation models:
- O(1) EXIF passthrough metadata compose via
DualLayerHdrBuf::compose_orientation/DualLayerHdrView::compose_orientation(zero pixel rebake, both layers kept aligned). - Whole-image apply policy
GainMapOrientation(Baketo upright display pixels,Passthroughreturning(PixelBuf, Orientation)with zero transpose viaapply_gain_map_oriented, orRequireIdentity). - Coordinated pixel-level dual-layer baking via
bake_dual_layer_orientationandbake_dual_layer_orientation_afterkeepingbaseandgain_mapstrictly registered.
- O(1) EXIF passthrough metadata compose via
- Separable resampling (
zenresizecenter-sited math):GainMapResample::Bilinear,GainMapResample::Bicubic,GainMapResample::Mitchell, andGainMapResample::Nearest, with cached horizontally-upsampled gain rows and 8-element padded scratch rows so SIMD kernels execute pure SIMD-only loops with zero scalar tails. - Streaming row workers & extraction:
GainMapApplierfor pull/streaming decode with fallible row providers,GainMapRowExtractorfor fused row-level encode, andextract_gain_map_onlysupportingBox/Bilinear/Pointdownsampling, 2-passcontent_fit, 1-ch/3-ch, U8/U16/10-bit/12-bit maps, and optionalhow_far::Pulse.
Structs§
- Gain
MapApplier - Reusable, O(width)-memory, row-streaming ISO 21496-1 gain-map reconstructor.
- Gain
MapApply Config - Configuration for ISO 21496-1 gain-map reconstruction via
GainMapApplier,apply_gain_map_oriented, orapply_gain_map_with. - Gain
MapExtract Config - Configuration for ISO 21496-1 gain-map extraction (
extract_gain_map_only,GainMapRowExtractor). - Gain
MapLayer - Layer format and stored pixel dimensions passed to
GainMapApplier::new. - Gain
MapRow Extractor - Row-streaming linear-f32 ISO 21496-1 gain-map encoder.
Enums§
- Gain
MapDownsample - Downsampling filter used during gain-map extraction when
scale_factor > 1. - Gain
MapOrientation - Policy controlling how pending EXIF
Orientationon aDualLayerHdrBuf/DualLayerHdrViewis handled during whole-image gain-map reconstruction. - Gain
MapResample - Resampling filter used when the gain map resolution differs from the base image.
- Gain
MapTarget - Target display headroom or explicit rendition endpoint for ISO 21496-1 reconstruction.
- Linear
Input Channels - Interleaved channel layout for linear
f32row buffers passed toGainMapRowExtractor::encode_row_linear_f32.
Constants§
- CONTENT_
FIT_ MIN_ SPAN_ STOPS - Minimum log₂ span (
1/16stop) enforced by content-fitted extraction grids so uniform images never degenerate to a zero-width quantization range.
Functions§
- apply_
gain_ map_ oriented - Reconstruct a
PixelBufand its resulting pendingOrientationfrom a zero-copyDualLayerHdrViewaccording toconfig.orientation, with optional cooperative cancellation and progress viapulse(passNonewhen not needed): - apply_
gain_ map_ with - Reconstruct a
PixelBuffrom a zero-copyDualLayerHdrViewwith full control over target headroom/rendition (GainMapApplyConfig::from_headroom_stopsorGainMapApplyConfig::from_display_boost_linear), resampling kernel, orientation policy, conversion policy, optional targetPixelFormat, and optional cooperativePulsecancellation/progress (passNonewhen not needed). - bake_
dual_ layer_ orientation - Physically bake
dual.orientation()into bothbaseandgain_map, returning an owned alignedDualLayerHdrBufwithOrientation::Identity. - bake_
dual_ layer_ orientation_ after - Physically bake
dual.orientation().then(delta)into bothbaseandgain_map, keeping both layers strictly registered and returning an ownedDualLayerHdrBufwithOrientation::Identity. - bake_
dual_ layer_ orientation_ after_ with_ pulse - Physically bake
dual.orientation().then(delta)into bothbaseandgain_mapwith optional cooperative cancellation and progress viapulse(passNonewhen not needed). - bake_
dual_ layer_ orientation_ with_ pulse - Physically bake
dual.orientation()into bothbaseandgain_mapwith optional cooperative cancellation and progress viapulse(passNonewhen not needed). - display_
boost_ to_ headroom_ stops - Convert a linear display boost ratio (e.g.
1.0= SDR,4.0= 4× HDR) into ISO 21496-1 log₂ headroom stops (0.0for<= 1.0or non-finite). - extract_
gain_ map - Extract an ISO 21496-1
DualLayerHdrBufat 1:1 resolution frombase_srcandalternate_srcusing exact caller-suppliedmetadataverbatim. - extract_
gain_ map_ only - Extract only the numeric gain-map
PixelBufand exactGainMapMetadatafrom borrowedbase_srcandalternate_srcviews without duplicating the base raster, observing optional cooperative cancellation and progress viapulse(passNonewhen not needed). - extract_
gain_ map_ with_ pulse - Extract an ISO 21496-1
DualLayerHdrBufat 1:1 resolution with optional cooperative cancellation and progress viapulse(passNonewhen not needed). - full_
reconstruction_ headroom_ stops - Full-reconstruction display headroom in log₂ stops (
metadata.alternate_hdr_headroom()). - signed_
weight - Compute the ISO 21496-1 signed application weight for
display_headroom_stopsusing exacti128rational cross-products (never divides by zero or yieldsNaNon close valid rationals): - signed_
weight_ for_ target - Compute a target’s signed application weight. See
GainMapTarget::signed_weight.