#[non_exhaustive]#[repr(u8)]pub enum SignalRange {
Full = 0,
Narrow = 1,
}Expand description
Signal (quantization) range of the encoded channel values.
Narrow is the single ITU convention variously called limited, video,
studio swing, MPEG, or TV range (BT.601 / BT.709 / BT.2100 — the
aliases do not differ in meaning). Its anchor values scale with bit depth
as anchor × 2^(N−8) — a bit shift, not a full-scale stretch:
| depth | luma / R’G’B’ | chroma (Cb/Cr) |
|---|---|---|
| 8-bit | 16–235 | 16–240 |
| 10-bit | 64–940 | 64–960 |
| 12-bit | 256–3760 | 256–3840 |
For the RGB and gray layouts this crate describes, narrow means studio-swing R’G’B’ / Y′: the luma span applies to every channel. The wider chroma span would matter only for YCbCr layouts (none exist here).
Values outside the anchors are legal in a narrow signal — sub-blacks (1–15·2^(N−8)), super-whites (236–254·2^(N−8)), and xvYCC’s deliberate gamut excursions. Any future expand-to-full conversion must choose clamp-vs-preserve for them explicitly.
Maps 1:1 to CICP’s video_full_range_flag and AV1’s color_range
(Full = full-range flag set, Narrow =
limited).
There are no Narrow↔Full conversion kernels yet. zenpixels-convert
refuses range-crossing conversions rather than relabeling (relabeling
without rescaling lifts or crushes blacks); narrow data must be preserved
verbatim end-to-end. Caveat while that holds: cross-depth conversion of
narrow data uses full-scale rescaling (×(2^M−1)/(2^N−1)), which maps ITU
anchors only approximately (8-bit 235 widens to 60 395 where the ITU
16-bit anchor is 235·256 = 60 160, ≈0.36 % of full scale); exact anchor
remapping is the future range kernels’ job.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Full = 0
Full range: 0 – 2^N−1 (0–255 for 8-bit, 0–65535 for 16-bit).
Narrow = 1
Narrow (limited/studio) range: 16–235 luma applied to all RGB/gray channels, scaled by 2^(N−8) at higher depths — see the type-level docs for the full table, excursion semantics, and conversion rules.
Trait Implementations§
Source§impl Clone for SignalRange
impl Clone for SignalRange
Source§fn clone(&self) -> SignalRange
fn clone(&self) -> SignalRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SignalRange
Source§impl Debug for SignalRange
impl Debug for SignalRange
Source§impl Default for SignalRange
impl Default for SignalRange
Source§fn default() -> SignalRange
fn default() -> SignalRange
Source§impl Display for SignalRange
impl Display for SignalRange
impl Eq for SignalRange
Source§impl Hash for SignalRange
impl Hash for SignalRange
Source§impl PartialEq for SignalRange
impl PartialEq for SignalRange
Source§fn eq(&self, other: &SignalRange) -> bool
fn eq(&self, other: &SignalRange) -> bool
self and other values to be equal, and is used by ==.