Skip to main content

check_native_hdr_roundtrip

Function check_native_hdr_roundtrip 

Source
pub fn check_native_hdr_roundtrip<E, D>(enc: E, dec: D) -> Conformance
where E: EncoderConfig, D: DecoderConfig, <E::Job as EncodeJob>::Enc: Encoder<Error = E::Error>,
Expand description

Native HDR survives a round trip: for BT.2100 PQ and HLG, the CICP, the HDR envelope (content light level + mastering display), the pixels, and the decoded buffer’s HDR labelling all come back from a PreserveExact encode → decode.

Skipped (Ok) unless both ends declare hdr. For each transfer:

  • encodes Cicp::BT2100_PQ / Cicp::BT2100_HLG with ContentLightLevel(1000, 400) and MasteringDisplay::HDR10_REFERENCE, using a 16-bit RGB gradient when both ends declare native_16bit (the 8-bit RGB gradient otherwise — the signaling path is exercised either way);
  • the decoded pixels must equal the input byte-for-byte;
  • the decoded descriptor must carry the HDR transfer (Pq / Hlg) — a PQ decode labelled sRGB is exactly the mislabel the descriptor exists to prevent — and on the 16-bit path must equal RGB16_BT2100_PQ / _HLG;
  • when both ends declare the cicp channel, Metadata.cicp must equal the input;
  • content_light_level must survive exactly and mastering_display within container fixed-point precision (2e-5 on xy, 1e-5 relative on luminance). hdr on both ends means the envelope reaches the encoder and comes back — silently dropping it is the “gain-map → native-HDR transcode loses the envelope” hazard in docs/correctness-model.md.

This is Phase 0 of the gain-map / HDR delivery scope (docs/gainmap-pipeline-scope-2026-06-08.md): prove native HDR works with zero new API before any gain-map encode surface is added. Part of check_all.