Struct cros_libva::Picture

source ·
pub struct Picture<S: PictureState, T> { /* private fields */ }
Expand description

A Surface that is being rendered into.

This struct abstracts the decoding flow using vaBeginPicture, vaRenderPicture, vaEndPicture and vaSyncSurface in a type-safe way.

The surface will have valid picture data after all the stages of decoding are called.

The T generic parameter must be Borrow<Surface<_>>, i.e. it can be Surface directly or some other type that contains one.

No constraint on T is specified in this declaration because specifying it here would force us to add the generic argument of Surface to this type as well, turning it into a type with 3 generics, one of which is redundant. To avoid that we leave T unconstrained and instead constrain the methods that require to act on it as a Surface.

Implementations§

source§

impl<T> Picture<PictureNew, T>

source

pub fn new<D: SurfaceMemoryDescriptor>( timestamp: u64, context: Rc<Context>, surface: T, ) -> Self
where T: Borrow<Surface<D>>,

Creates a new Picture with a given timestamp. surface is the underlying surface that libva will render to.

source

pub fn new_from_same_surface<S: PictureState>( timestamp: u64, picture: &Picture<S, T>, ) -> Self

Creates a new Picture with a given timestamp to identify it, reusing the Surface from picture. This is useful for interlaced decoding as one can render both fields to the same underlying surface.

source

pub fn add_buffer(&mut self, buffer: Buffer)

Add buffer to the picture.

source

pub fn begin<D: SurfaceMemoryDescriptor>( self, ) -> Result<Picture<PictureBegin, T>, VaError>
where T: Borrow<Surface<D>>,

Wrapper around vaBeginPicture.

source§

impl<T> Picture<PictureBegin, T>

source

pub fn render(self) -> Result<Picture<PictureRender, T>, VaError>

Wrapper around vaRenderPicture.

source§

impl<T> Picture<PictureRender, T>

source

pub fn end(self) -> Result<Picture<PictureEnd, T>, VaError>

Wrapper around vaEndPicture.

source§

impl<T> Picture<PictureEnd, T>

source

pub fn sync<D: SurfaceMemoryDescriptor>( self, ) -> Result<Picture<PictureSync, T>, (VaError, Self)>
where T: Borrow<Surface<D>>,

Syncs the picture, ensuring that all pending operations are complete when this call returns.

source§

impl<S: PictureState, T> Picture<S, T>

source

pub fn timestamp(&self) -> u64

Returns the timestamp of this picture.

source

pub fn surface<D: SurfaceMemoryDescriptor>(&self) -> &Surface<D>
where T: Borrow<Surface<D>>,

Returns a reference to the underlying Surface.

If you are interested in obtaining the container of the Surface, use as_ref() instead. This is a convenience method to avoid having to call borrow() every time the surface is needed.

source§

impl<S: PictureReclaimableSurface, T> Picture<S, T>

source

pub fn take_surface(self) -> Result<T, Self>

Reclaim ownership of the Surface this picture has been created from, consuming the picture in the process. Useful if the Surface is part of a pool.

This will fail and return the passed object if there are more than one reference to the underlying surface.

source

pub fn derive_image<'a, D: SurfaceMemoryDescriptor + 'a>( &'a self, visible_rect: (u32, u32), ) -> Result<Image<'_>, VaError>
where T: Borrow<Surface<D>>,

Create a new derived image from this Picture using vaDeriveImage.

Derived images are a direct view (i.e. without any copy) on the buffer content of the Picture. On the other hand, not all Pictures can be derived.

source

pub fn create_image<'a, D: SurfaceMemoryDescriptor + 'a>( &'a self, format: VAImageFormat, coded_resolution: (u32, u32), visible_rect: (u32, u32), ) -> Result<Image<'_>, VaError>
where T: Borrow<Surface<D>>,

Create new image from the Picture using vaCreateImage and vaGetImage.

The image will contain a copy of the Picture in the desired format and coded_resolution.

Trait Implementations§

source§

impl<S: PictureState, T> AsRef<T> for Picture<S, T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

§

impl<S, T> Freeze for Picture<S, T>

§

impl<S, T> RefUnwindSafe for Picture<S, T>

§

impl<S, T> !Send for Picture<S, T>

§

impl<S, T> !Sync for Picture<S, T>

§

impl<S, T> Unpin for Picture<S, T>
where S: Unpin,

§

impl<S, T> UnwindSafe for Picture<S, T>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.