Skip to main content

SignalRange

Enum SignalRange 

Source
#[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:

depthluma / R’G’B’chroma (Cb/Cr)
8-bit16–23516–240
10-bit64–94064–960
12-bit256–3760256–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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source§

fn clone(&self) -> SignalRange

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SignalRange

Source§

impl Debug for SignalRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SignalRange

Source§

fn default() -> SignalRange

Returns the “default value” for a type. Read more
Source§

impl Display for SignalRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for SignalRange

Source§

impl Hash for SignalRange

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SignalRange

Source§

fn eq(&self, other: &SignalRange) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SignalRange

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.