Skip to content

Commit

Permalink
Don't use gaussian weights for grain temporal averaging and fix avera…
Browse files Browse the repository at this point in the history
…ging on clip boundaries (#101)

* Don't use gaussian weights for grain temporal averaging

* remove unused import

* fix clip bounds with temporal averaging
  • Loading branch information
emotion3459 authored Oct 7, 2024
1 parent 8550361 commit 4280717
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions vsdeband/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from vsexprtools import complexpr_available, norm_expr
from vskernels import BicubicAuto, Bilinear, Catrom, Kernel, KernelT, Lanczos, LinearLight, Scaler, ScalerT
from vsmasktools import adg_mask
from vsrgtools import BlurMatrix
from vstools import (
CustomIndexError, CustomOverflowError, CustomValueError, InvalidColorFamilyError, KwargsT, Matrix, MatrixT, PlanesT,
check_variable, core, depth, fallback, get_neutral_values, get_peak_value, get_sample_type, get_y, inject_self,
Expand Down Expand Up @@ -224,14 +223,6 @@ def _try_grain(src: vs.VideoNode, stre: tuple[float, float] = strength, **args:

grained = _try_grain(base_clip)

if clip.num_frames != grained.num_frames:
if grained.num_frames == 1:
grained = grained.std.Loop(clip.num_frames)
elif grained.num_frames > clip.num_frames:
grained = grained[:clip.num_frames]
else:
grained = grained + grained[-1].std.Loop(clip.num_frames - grained.num_frames)

if input_dep and neutral_out:
grained = clip.std.MakeDiff(grained)

Expand Down Expand Up @@ -261,7 +252,7 @@ def _try_grain(src: vs.VideoNode, stre: tuple[float, float] = strength, **args:
grained = _wrap_implementation(clip, True)

if do_taverage:
average = grained.std.AverageFrames(BlurMatrix.GAUSS.from_radius(self.temporal_radius))
average = grained.std.AverageFrames([1] * (self.temporal_radius * 2 + 1))
grained = grained.std.Merge(average, self.temporal_average)
grained = grained[self.temporal_radius:-self.temporal_radius]

Expand Down

0 comments on commit 4280717

Please sign in to comment.