Struct PgsDisplaySet

Source
pub struct PgsDisplaySet {
    pub pcs: Option<Rc<PgsPcsSegment>>,
    pub wds: Option<Rc<PgsWdsSegment>>,
    pub pds: Option<Rc<PgsPdsSegment>>,
    pub ods: Option<Rc<PgsOdsSegment>>,
}
Expand description

Struct representing a collection of PGS segments required for rendering a single subtitle frame. The segments include:

  • pcs: Presentation Composition Segment.
  • wds: Window Definition Segment.
  • pds: Palette Definition Segment.
  • ods: Object Definition Segment.

Fields§

§pcs: Option<Rc<PgsPcsSegment>>§wds: Option<Rc<PgsWdsSegment>>§pds: Option<Rc<PgsPdsSegment>>§ods: Option<Rc<PgsOdsSegment>>

Implementations§

Source§

impl PgsDisplaySet

Source

pub fn new() -> Self

Creates a new, empty PgsDisplaySet with no segments.

§Returns

A new PgsDisplaySet instance with all segment options set to None.

Source

pub fn state(&self) -> PgsDisplaySetState

Determines the current state of the display set.

  • If PCS and WDS are present, but PDS and ODS are not, the state is EmptyFrame.
  • If all segments (PCS, WDS, PDS, ODS) are present, the state is Complete.
  • Otherwise, the state is Incomplete.
§Returns

The current state of the PgsDisplaySet.

Source

pub fn get_rle_image(&self) -> Result<&Vec<u8>>

Returns a reference to the RLE (Run-Length Encoded) image data contained in the ODS segment.

§Errors

Returns Error::IncompleteDisplaySet if the display set is not in the Complete state.

§Returns

A reference to the raw RLE image data.

Source

pub fn get_decoded_image(&self, gray: bool) -> Result<Vec<Vec<u32>>>

Decodes the RLE image data and returns the image as a 2D array of pixels.

This function decodes the image contained in the ODS segment using the palette from the PDS segment. It can return the image in either grayscale or color depending on the gray parameter.

§Parameters
  • gray: A boolean flag indicating whether to decode the image in grayscale (true) or color (false).
§Errors

Returns Error::IncompleteDisplaySet if the display set is not in the Complete state.

§Returns

A 2D vector containing the decoded pixels, where each pixel is represented as a 32-bit color value.

Trait Implementations§

Source§

impl Clone for PgsDisplaySet

Source§

fn clone(&self) -> PgsDisplaySet

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PgsDisplaySet

Source§

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

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

impl Default for PgsDisplaySet

Source§

fn default() -> PgsDisplaySet

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

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