pub struct Image<'a> {
    picture: &'a Picture<PictureSync>,
    image: _VAImage,
    data: &'a mut [u8],
    derived: bool,
    dirty: bool,
}
Expand description

Wrapper around VAImage that is tied to the lifetime of a given Picture.

An image is used to either get the surface data to client memory, or to copy image data in client memory to a surface.

Fields

picture: &'a Picture<PictureSync>

The picture whose Surface we use as the source of pixel data.

image: _VAImage

The VAImage returned by libva.

data: &'a mut [u8]

The mapped surface data.

derived: bool

Whether the image was derived using the vaDeriveImage API or created using the vaCreateImage API.

dirty: bool

Tracks whether the underlying data has possibly been written to, i.e. an encoder will create an image and map its buffer in order to write to it, so we must writeback later.

Implementations

Creates a new Image either by calling vaCreateImage or vaDeriveImage. Creating an Image depends on acquiring a ready Surface from an underlying Picture. Note that Image has a borrowed Picture, so it will be dropped before the underlying Surface is dropped, as mandated by VAAPI.

Arguments
  • picture - The Picture that owns the Surface this image will be created from.
  • format - A VAImageFormat returned by crate::Display::query_image_formats.
  • width - The image’s desired width.
  • height - The image’s desired height.
  • derive - Whether to try deriving the image from picture, which allows zero-copy access to the surface data. Deriving may fail, in which case vaCreateImage will be used instead, incurring an extra data copy.

Creates image from picture using vaCreateImage and vaGetImage in order to copy the surface data into the image buffer.

Tries to derive image from picture to access the raw surface data without copy.

Returns Ok(true) if the image has been successfully derived, Ok(false) if deriving is not possible and create_image should be used as a fallback, or an error if an error occurred.

Get a reference to the underlying VAImage that describes this image.

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.