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 per destination size a processing context and the surfaces resize writes into, which are what cost something to build. A caller converting every frame of a stream, or of a few renditions, pays for each 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<()>
where D: SurfaceMemoryDescriptor, E: SurfaceMemoryDescriptor,

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 resize<D: SurfaceMemoryDescriptor>( &self, input: &Surface<D>, size: (u32, u32), input_color: Option<Color>, output_color: Option<Color>, ) -> Result<ExportedFrame>

Scales input to width by height and converts it to NV12, returning the result exported.

The output comes from a pool per size, so a stream of frames costs no allocation per frame: once the returned frame drops, its surface is the next one written at that size. A frame still held is never written over; the next resize allocates another surface instead. At most one free surface is kept per size, and any returned past that is destroyed. See blit for the colors.

The frame’s timestamp is zero, for the caller to set.

§Errors

Fails when the destination cannot be allocated or exported, 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§

§

impl !Freeze for Processor

§

impl !RefUnwindSafe for Processor

§

impl !Send for Processor

§

impl !Sync for Processor

§

impl Forget for Processor

§

impl Move for Processor

§

impl Unpin for Processor
where Arc<Display>: Unpin, *const u8 is !null: Unpin, InternalBitFlags: Unpin, Arc<FreeList>: Unpin, Rc<Context>: Unpin,

§

impl UnsafeUnpin for Processor
where *const ArcInner<Display> is !null: UnsafeUnpin, PhantomData<ArcInner<Display>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<((u32, u32), SurfacePool)>: UnsafeUnpin, PhantomData<((u32, u32), Rc<Context>)>: UnsafeUnpin,

§

impl UnwindSafe for Processor
where Arc<Display>: UnwindSafe, HashMap<(u32, u32), SurfacePool>: UnwindSafe, HashMap<(u32, u32), Rc<Context>>: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more