pub struct TemporalSmoother { /* private fields */ }Expand description
Temporal smoother for rolling shutter motion vectors.
Applies an exponentially weighted moving average (EWMA) across consecutive frames to suppress frame-to-frame jitter in the per-scanline motion estimates. This is critical for preventing flickering artifacts that occur when raw per-frame motion vectors vary erratically.
§Algorithm
For each block index i, the smoother maintains a running estimate:
mv_smoothed[i] = alpha * mv_new[i] + (1 - alpha) * mv_prev[i]A lower alpha produces more temporal smoothing (more lag), while a higher
alpha responds faster to genuine motion changes.
Implementations§
Source§impl TemporalSmoother
impl TemporalSmoother
Sourcepub fn new(alpha: f64) -> Self
pub fn new(alpha: f64) -> Self
Create a new temporal smoother.
alpha is clamped to [0.01, 1.0].
Sourcepub fn smooth(&mut self, motion_vectors: &[MotionVector]) -> Vec<MotionVector>
pub fn smooth(&mut self, motion_vectors: &[MotionVector]) -> Vec<MotionVector>
Smooth a new frame’s motion vectors against the running average.
On the first call the input is returned as-is (there is no history). Subsequent calls blend the new vectors with the accumulated state.
If the number of blocks changes between calls (e.g. resolution change) the state is reset.
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Number of blocks tracked.
Auto Trait Implementations§
impl Freeze for TemporalSmoother
impl RefUnwindSafe for TemporalSmoother
impl Send for TemporalSmoother
impl Sync for TemporalSmoother
impl Unpin for TemporalSmoother
impl UnsafeUnpin for TemporalSmoother
impl UnwindSafe for TemporalSmoother
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.