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: _VAImageThe VAImage returned by libva.
data: &'a mut [u8]The mapped surface data.
derived: boolWhether the image was derived using the vaDeriveImage API or created using the
vaCreateImage API.
dirty: boolTracks 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
sourceimpl<'a> Image<'a>
impl<'a> Image<'a>
sourcepub fn new(
picture: &'a mut Picture<PictureSync>,
format: VAImageFormat,
width: u32,
height: u32,
derive: bool
) -> Result<Self>
pub fn new(
picture: &'a mut Picture<PictureSync>,
format: VAImageFormat,
width: u32,
height: u32,
derive: bool
) -> Result<Self>
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- ThePicturethat owns the Surface this image will be created from.format- AVAImageFormatreturned bycrate::Display::query_image_formats.width- The image’s desired width.height- The image’s desired height.derive- Whether to try deriving the image frompicture, 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.
sourcefn create_image(
picture: &'a mut Picture<PictureSync>,
image: &mut _VAImage,
format: &mut VAImageFormat,
width: u32,
height: u32
) -> Result<()>
fn create_image(
picture: &'a mut Picture<PictureSync>,
image: &mut _VAImage,
format: &mut VAImageFormat,
width: u32,
height: u32
) -> Result<()>
Creates image from picture using vaCreateImage and vaGetImage in order to copy the
surface data into the image buffer.
sourcefn derive_image(
picture: &'a mut Picture<PictureSync>,
image: &mut _VAImage
) -> Result<bool>
fn derive_image(
picture: &'a mut Picture<PictureSync>,
image: &mut _VAImage
) -> Result<bool>
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.