Edgecase Functions

rvsfunc.edgecase.chunked_filter

Apply a filter to video in blocks of video smaller than the clip's surface.

rvsfunc.edgecase.questionable_rescale

Rescale function by Zastin for Doga Kobo, edited for reusability.

Edgecase functions that were generalized for if I ever need them again.

These functions should probably not be used in the general use case. They’re typically written for a very specific edgecase, but generalized for if I ever need them again. Currently only holds questionable_rescale() which I mangled from someone else’s code that had a very similar edgecase.

rvsfunc.edgecase.chunked_filter(clip, func, *, hchunks=3, vchunks=3)

Apply a filter to video in blocks of video smaller than the clip’s surface.

This is a utility function written for certain functions or filters don’t handle frames or clips over a certain size. It splits the clip into grid-based chunks to apply the filter to subsections of the clip. Chunks are then stacked into new clips that keep them in the same place as the corresponding chunk of the next frame to allow for temporal filters to work with the same area of the clip as if it was never split. Spatial filters might be impacted near the edges of chunks.

Parameters
  • clip (VideoNode) – The clip to chunk and filter.

  • filter – The filter to apply to the chunked clips. It’s recommended to supply either a function that takes the clip as its only argument, or to supply a partial to supply (kw)args to the filter.

  • hchunks (int) – The minimum amount of horizontal chunks to use.

  • vchunks (int) – The minimum amount of vertical chunks to use.

Return type

VideoNode

rvsfunc.edgecase.questionable_rescale(clip, height, b=1 / 3, c=1 / 3, descaler=core.descale.Debicubic, scaler=core.resize.Spline36, scale_kwargs={'height': None}, correct_shift=True, apply_mask=True, mask_thresh=0.05, ext_mask=None, depth_out=-1, return_mask=False)

Rescale function by Zastin for Doga Kobo, edited for reusability.

It’s originally written for Doga Kobo material, since they have some weird post-processing going on, making a normal descale impossible. It applies some Expression magic for fixing some common Doga Kobo issues. USE AT YOUR OWN RISK.

Parameters
  • clip (VideoNode) – YUV input clip, integer format. Will be dithered down if required.

  • height (int) – The height to descale to.

  • b (float) – b or filter_param_a arg for the descale.

  • c (float) – c or filter_param_b arg for the descale.

  • descaler (Callable[[VideoNode, int, int, Any, Any, Any], VideoNode]) – The descaler to use. Will use Debicubic by default.

  • scaler (Optional[Callable[[VideoNode, int, int, Any], VideoNode]]) – The scaler to use to scale the clip back to the original or provided output resolution. Pass it a function that returns the clip untouched to get the questionably descaled and then doubled clip. Pass None to prevent frame doubling. Default: Spline36. Called as scaler(clip, **scaler_kwargs).

  • scaler_kwargs – A kwargs dict for use with the upscaler. Defaults to an empty dict and sets output width and height to the same values as the input clip. Provide the values for the width and height keys to change the output resolution.

  • correct_shift (bool) – Same as in nnedi3_rpow2.

  • apply_mask (bool) – Whether or not to apply a detail mask.

  • mask_thresh (float) – Threshold for binarizing the default mask.

  • ext_mask (Optional[VideoNode]) – Supply your own mask instead of the default.

  • depth_out (int) – The output depth. Values below 0 will cause it to use the depth of the input clip, any other values will be passed to depth the way they are with no regards to what may be raised.

  • return_mask (bool) – Whether to return the mask used instead of the clip. This requires scaler to not be None.

Return type

VideoNode