Skip to main content

Escr

Struct Escr 

Source
pub struct Escr {
    pub base: u64,
    pub extension: u16,
}
Expand description

Elementary Stream Clock Reference: 33-bit base (90 kHz) + 9-bit extension (27 MHz) — ISO/IEC 13818-1 §2.4.3.7, Table 2-21.

Wire layout (6 bytes, 48 bits): 2×reserved(1) | ESCR_base[32:30](3) | marker(1) | ESCR_base[29:15](15) | marker(1) | ESCR_base[14:0](15) | marker(1) | ESCR_ext(9) | marker(1).

Fields§

§base: u64

33-bit base (90 kHz units).

§extension: u16

9-bit extension (27 MHz units, 0..=299).

Implementations§

Source§

impl Escr

Source

pub fn as_27mhz(self) -> u64

Full ESCR value on the 27 MHz clock: base * 300 + extension.

Source

pub fn from_27mhz(ticks: u64) -> Self

Construct from an absolute 27 MHz clock value.

Source

pub fn from_field_bytes(b: &[u8; 6]) -> Result<Self>

Decode from the 6-byte ESCR field.

Bit layout (ISO/IEC 13818-1 §2.4.3.7, Table 2-21): B0[7:6]=reserved, B0[5:3]=base[32:30], B0[2]=marker, B0[1:0]=base[29:28], B1[7:0]=base[27:20], B2[7:3]=base[19:15], B2[2]=marker, B2[1:0]=base[14:13], B3[7:0]=base[12:5], B4[7:3]=base[4:0], B4[2]=marker, B4[1:0]=ext[8:7], B5[7:1]=ext[6:0], B5[0]=marker.

Source

pub fn to_field_bytes(self) -> [u8; 6]

Encode as the 6-byte ESCR field.

Reserved bits are set to 1 per the spec convention. Exact inverse of from_field_bytes.

Trait Implementations§

Source§

impl Clone for Escr

Source§

fn clone(&self) -> Escr

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 Escr

Source§

impl Debug for Escr

Source§

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

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

impl Eq for Escr

Source§

impl PartialEq for Escr

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Escr

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Escr

Auto Trait Implementations§

§

impl Freeze for Escr

§

impl RefUnwindSafe for Escr

§

impl Send for Escr

§

impl Sync for Escr

§

impl Unpin for Escr

§

impl UnsafeUnpin for Escr

§

impl UnwindSafe for Escr

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, 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.