Skip to main content

Processor

Struct Processor 

Source
pub struct Processor { /* private fields */ }
Expand description

A video post-processor on one device.

Holds the display, the VPP configuration, and one processing context per destination size, which are what cost something to build. A caller converting every frame of a stream, or of a few renditions, pays for each context once.

Implementations§

Source§

impl Processor

Source

pub fn new<P: AsRef<Path>>(device: P) -> Result<Self>

Opens device and configures it for video post-processing.

device is a DRM render node, e.g. /dev/dri/renderD128. Pick the one matching the device that will consume the result: the blit only stays on the GPU when both ends are the same device.

Source

pub fn open() -> Result<Self>

Opens the first device whose driver can post-process, if any.

Mirrors Display::open, and is what a caller with no opinion about which GPU should use. A machine with more than one wants Processor::new or Processor::with_display instead.

Source

pub fn with_display(display: Arc<Display>) -> Result<Self>

Configures an already open display for video post-processing.

Sharing the display with a decoder or an encoder is what lets a surface move between them: a surface belongs to the display that created it.

§Errors

Fails when the device has no VAEntrypointVideoProc, which is how a caller finds out before the first frame rather than during it.

Source

pub fn display(&self) -> &Arc<Display> ⓘ

Returns the display this processor runs on, to share with a decoder or an encoder.

Source

pub fn import(&self, buffer: DmaBuf) -> Result<Surface<DmaBuf>>

Imports an exported DMA-BUF as a surface on this processor’s display, without copying it.

The returned surface owns buffer, so the descriptor stays open exactly as long as the surface referring to it.

§Errors

See DmaBuf::import.

Source

pub fn blit<D, E>( &self, input: &Surface<D>, output: &Surface<E>, input_color: Option<Color>, output_color: Option<Color>, ) -> Result<()>

Blits input into output, scaling to the size of output and converting to its format.

input_color and output_color name the YUV space on each side. Leave the input side None for an RGB input, which has no matrix; set the output side to the space a YUV destination should be written in. A side left None is up to the driver, which is right for a blit that only re-tiles, and for a scale that names neither side. Returns once the destination holds the result.

§Errors

Fails when either surface belongs to another display, and when the driver refuses the blit (a format pair or scale it cannot do).

Source

pub fn process<D: SurfaceMemoryDescriptor>( &self, input: &Surface<D>, fourcc: u32, (width, height): (u32, u32), input_color: Option<Color>, output_color: Option<Color>, ) -> Result<Surface<()>>

Blits input into a new driver-allocated surface of fourcc, width and height.

The destination is hinted as post-processing output that will be exported, so Surface::export_prime works on it. See blit for the colors.

§Errors

Fails for a format with no render target mapping, when the destination cannot be allocated, and as blit does.

Source

pub fn retile(&self, buffer: DmaBuf) -> Result<Surface<()>>

Imports buffer and blits it into a driver-allocated surface of the same format and size.

This is the whole re-tile. Export the result with Surface::export_prime and read the modifier off the object to see what the driver chose. Destroying the returned surface does not invalidate an export taken from it, since the exported descriptor holds its own reference on the underlying buffer.

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.