vodesfunc.rescale
RescaleBuilder
Bases: RescBuildFB, RescBuildNonFB, RescBuildMixed
The fancy new rescale wrapper to make life easier. Now 99% less buggy and should handle everything.
Example usage:
builder, rescaled = (
RescaleBuilder(clip)
.descale(Bilinear, 1500, 843.75, base_height=846)
.double()
.errormask(0.0975)
.linemask()
.post_double(lambda x: aa_dehalo(x)) # Or a function like post_double(aa_dehalo)
.downscale(Hermite(linear=True))
.final()
)
Source code in
vodesfunc/rescale.py
descale
descale(kernel: KernelLike, width: int | float, height: int | float, base_height: int | None = None, base_width: int | None = None, shift: tuple[float, float] = (0, 0), field_based: FieldBasedLike | None = None, ignore_mask: bool | VideoNode | Ignore_Mask_Func = False, sample_grid_model: SampleGridModel | int = SampleGridModel.MATCH_EDGES, mode: str = 'hw') -> Self
Performs descale and rescale (with the same kernel) using the "traditional" getfnative approach with base_width/height for fractional descales.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
KernelLike
|
Kernel to descale with |
required |
height
|
int | float
|
Height to descale to |
required |
width
|
int | float
|
Width to descale to. Please be absolutely certain of what you're doing if you're using get_w for this. |
required |
base_height
|
int | None
|
Padded height used in a "fractional" descale |
None
|
base_width
|
int | None
|
Padded width used in a "fractional" descale Both of these are technically optional but highly recommended to have set for float width/height. |
None
|
shift
|
tuple[float, float]
|
A custom shift to be applied |
(0, 0)
|
mode
|
str
|
Whether to descale only height, only width, or both. "h" or "w" respectively for the former two. |
'hw'
|
field_based
|
FieldBasedLike | None
|
To descale a cross-converted/interlaced clip.
Will try to take the prop from the clip if |
None
|
ignore_mask
|
bool | VideoNode | Ignore_Mask_Func
|
Manual mask of areas to ignore in the descale process. This is most commonly used to avoid clipping.
You can also pass your own function to generate a mask using all arguments and for both steps. See the aforementioned function for how this works. |
False
|
sample_grid_model
|
SampleGridModel | int
|
See the vs-jetpack docs for this. This param will only be used as a fallback if the kernel doesn't have one passed to it. Do note that this will always show up as |
MATCH_EDGES
|
Source code in
vodesfunc/rescale.py
descale_raw
descale_raw(kernel: KernelLike, width: int, height: int, src_left: float | None = None, src_top: float | None = None, src_width: float | None = None, src_height: float | None = None, mode: str = 'hw', ignore_mask: bool | VideoNode | Ignore_Mask_Func = False) -> Self
Performs descale and rescale (with the same kernel) using raw src_* values directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
KernelLike
|
Kernel to descale with. If you want |
required |
height
|
int
|
Height to descale to |
required |
width
|
int
|
Width to descale to. Please be absolutely certain of what you're doing if you're using get_w for this. |
required |
src_left
|
float | None
|
Used to select the source region of the input to use. Can also be used to shift the image. Defaults to the whole image. |
None
|
src_top
|
float | None
|
See above. |
None
|
src_width
|
float | None
|
See above. |
None
|
src_height
|
float | None
|
See above. |
None
|
mode
|
str
|
Whether to descale only height, only width, or both. "h" or "w" respectively for the former two. |
'hw'
|
ignore_mask
|
bool | VideoNode | Ignore_Mask_Func
|
Manual mask of areas to ignore in the descale process. This is most commonly used to avoid clipping.
You can also pass your own function to generate a mask using all arguments and for both steps. See the aforementioned function for how this works. |
False
|
Source code in
vodesfunc/rescale.py
post_descale
A function to apply any arbitrary function on the descaled clip.
I can't think of a good usecase/example for this but I was asked to add this before.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
VSFunctionNoArgs | list[VSFunctionNoArgs]
|
This can be any function or list of functions that take a videonode input and returns a videonode. You are responsible for keeping the format the same. |
required |
Source code in
vodesfunc/rescale.py
linemask
linemask(mask: VideoNode | EdgeDetectLike | None = None, downscaler: ScalerLike | None = None, maximum_iter: int = 0, inflate_iter: int = 0, expand: int | tuple[int, int | None] = 0, kernel_window: int | None = None, prefilter: bool | VSFunctionNoArgs = False, **kwargs) -> Self
A function to apply a linemask to the final output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
VideoNode | EdgeDetectLike | None
|
This can be a masking function like |
None
|
downscaler
|
ScalerLike | None
|
Downscaler to use if creating a linemask on the doubled clip. Defaults to |
None
|
maximum_iter
|
int
|
Apply std.Maximum x amount of times |
0
|
inflate_iter
|
int
|
Apply std.inflate x amount of times |
0
|
expand
|
int | tuple[int, int | None]
|
Apply an ellipse morpho expand with the passed amount. Can be a tuple of (horizontal, vertical) or a single value for both. |
0
|
kernel_window
|
int | None
|
To override kernel radius used in case of border_handling being used. |
None
|
prefilter
|
bool | VSFunctionNoArgs
|
Prefilter the input clip for the mask function.
|
False
|
**kwargs
|
Any other params to pass to the edgemask creation. For example |
{}
|
Source code in
vodesfunc/rescale.py
errormask
errormask(mask: VideoNode | float = 0.05, maximum_iter: int = 2, inflate_iter: int = 3, expand: int | tuple[int, int | None] = 0) -> Self
A function to apply a basic error mask to the final output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
VideoNode | float
|
With a float, and by default, will be created internally. Could also pass a clip. |
0.05
|
maximum_iter
|
int
|
Apply std.Maximum x amount of times |
2
|
inflate_iter
|
int
|
Apply std.inflate x amount of times |
3
|
expand
|
int | tuple[int, int | None]
|
Apply an ellipse morpho expand with the passed amount. Can be a tuple of (horizontal, vertical) or a single value for both. |
0
|
Source code in
vodesfunc/rescale.py
errormask_zoned
errormask_zoned(ranges: FrameRangesN, mask: VideoNode | float = 0.05, maximum_iter: int = 2, inflate_iter: int = 3, expand: int | tuple[int, int | None] = 0) -> Self
A function to apply a basic error mask to the final output.
But with this rfs'd to certain ranges.
Source code in
vodesfunc/rescale.py
double
Upscales the descaled clip by 2x
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upscaler
|
ScalerLike
|
Any kind of vsscale scaler. Defaults to ArtCNN.R8F64. |
R8F64
|
Source code in
vodesfunc/rescale.py
post_double
A function to apply any arbitrary function on the doubled clip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
VSFunctionNoArgs | list[VSFunctionNoArgs]
|
This can be any function or list of functions that take a videonode input and returns a videonode. You are responsible for keeping the format the same. |
required |
Source code in
vodesfunc/rescale.py
downscale
Downscales the clip back the size of the original input clip and applies the masks, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
downscaler
|
ScalerLike | None
|
Any vsscale scaler to use. Defaults to Linear Hermite. |
None
|
Source code in
vodesfunc/rescale.py
final
This is the last function in the chain that also returns the final clip.
It internally calls downscale if you haven't done so before and then merges the resulting clip with the input chroma, if any.
Returns:
| Type | Description |
|---|---|
tuple[Self, VideoNode]
|
A tuple of this class and the resulting final rescale. |