Skip to main content

PlanarDenoiser

Struct PlanarDenoiser 

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

Wraps the luma and chroma Denoiser instances needed for one subsampled YUV source.

The caller pushes planar frames in and gets planar frames out. The luma and chroma split is invisible from the outside.

Implementations§

Source§

impl PlanarDenoiser

Source

pub fn create( opts: &PlaneOptions, layout: FrameLayout, ) -> Result<PlanarDenoiser, Error>

Source

pub fn temporal_radius(&self) -> u32

The temporal radius the underlying denoisers run at.

Source

pub fn push(&mut self, planes: &Planes) -> Result<(), DenoiserError>

Pushes one planar frame.

On QueueFull the caller should receive one frame and then retry the whole call. Any other error is passed on unchanged.

The denoiser push runs before either passthrough queue is touched, so a retry replays the whole frame cleanly instead of queueing the disabled side’s plane twice.

§Why a retry cannot duplicate a frame

In LumaChroma mode luma and chroma are both real Denoisers with their own queues. A retry pushes again into whichever half already succeeded, which would duplicate that half’s frame if the two could ever sit at different fill levels.

They cannot. Both are built from the same opts.mode, so they share a temporal radius and a MAX_PENDING ceiling. Every successful push or receive moves both on by exactly one frame, and a failed push moves neither, because the QueueFull check runs before anything changes.

So the two halves always enter this function with the same frame count and the same pending depth, and the QueueFull check inside push_frame answers the same way for each. If the luma push succeeds then the chroma push succeeds too, which makes the duplicate unreachable.

Source

pub fn recv(&mut self) -> Result<Option<Planes>, Error>

Blocks until each enabled half emits one frame, then reassembles them into a planar frame.

Returns Ok(None) if neither half had pending output.

Source

pub fn flush(&mut self, sink: impl FnMut(Planes)) -> Result<(), Error>

Drains the temporal tail of both halves.

sink is called once per emitted planar frame.

Source

pub fn window_span(&self) -> WindowSpan

The number of frames behind and ahead of a target frame a Self::reseed window must supply, for whichever algorithm this PlanarDenoiser runs.

Every owned Denoiser was built from the same algorithm, so any one of them answers for all of them.

Source

pub fn reseed(&mut self, window: &[Planes]) -> Result<Planes, Error>

Denoises the target frame of an explicit window, sized and shaped exactly as Self::window_span reports for whichever algorithm this PlanarDenoiser runs.

This abandons whatever stream was running and starts a new one from the window, keeping every GPU allocation. When it returns, the stream sits exactly where it would be had the window been pushed frame by frame, so the caller can carry on with Self::push and Self::recv for the frame after the target.

Callers clamp the window’s indices at the clip’s ends, matching how the streaming path repeats the first and last frames.

§Why the window is wider than 2r+1 for some algorithms

The two NLM algorithms produce one output per submit once their own 2r+1-frame window is full, so a symmetric window centred on the target frame is enough.

nl4d scatters every pass’s contribution across the 2r+1 frames that pass reaches, and a target frame’s own region only starts collecting contributions once the earliest pass able to reach it, the one centred r frames behind the target, has actually run, which itself needs the front end’s own window full at that earlier centre. Both of those requirements push the target’s own r-wide neighbourhood back by another r, on both sides, which is exactly what Self::window_span reports through nl4d’s doubled behind and ahead. This is bit-exact with the streaming path because every frame the window supplies is real, distinct content, run through the same sequence of passes streaming would have run to reach the target frame.

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

Source§

fn downcast(&self) -> &T

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

Source§

fn comptime(self) -> Self

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, <T as TryFrom<U>>::Error>

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

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

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