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
impl Processor
Sourcepub fn new<P: AsRef<Path>>(device: P) -> Result<Self>
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.
Sourcepub fn open() -> Result<Self>
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.
Sourcepub fn with_display(display: Arc<Display>) -> Result<Self>
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.
Sourcepub fn display(&self) -> &Arc<Display> ⓘ
pub fn display(&self) -> &Arc<Display> ⓘ
Returns the display this processor runs on, to share with a decoder or an encoder.
Sourcepub fn import(&self, buffer: DmaBuf) -> Result<Surface<DmaBuf>>
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.
Sourcepub 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,
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).
Sourcepub fn process<D: SurfaceMemoryDescriptor>(
&self,
input: &Surface<D>,
fourcc: u32,
(width, height): (u32, u32),
input_color: Option<Color>,
output_color: Option<Color>,
) -> Result<Surface<()>>
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.
Sourcepub fn retile(&self, buffer: DmaBuf) -> Result<Surface<()>>
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.