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, 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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
descale(kernel, width, height, base_height=None, base_width=None, shift=(0, 0), field_based=None, mode='hw')
Performs descale and rescale (with the same kernel).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
KernelT
|
Kernel to descale with |
required |
height
|
int | float
|
Height to descale to |
required |
width
|
int | float
|
Width to descale to |
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
|
FieldBasedT | None
|
To descale a cross-converted/interlaced clip. Will try to take the prop from the clip if |
None
|
Source code in vodesfunc/rescale.py
double(upscaler=None)
Upscales the descaled clip by 2x
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upscaler
|
Doubler | ScalerT | None
|
Any kind of vsscale scaler. Defaults to Waifu2x. |
None
|
Source code in vodesfunc/rescale.py
downscale(downscaler=None)
Downscales the clip back the size of the original input clip and applies the masks, if any.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
downscaler
|
ScalerT | None
|
Any vsscale scaler to use. Defaults to Linear Hermite. |
None
|
Source code in vodesfunc/rescale.py
errormask(mask=0.05, maximum_iter=2, inflate_iter=3, expand=0)
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(ranges, mask=0.05, maximum_iter=2, inflate_iter=3, expand=0)
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
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. |
Source code in vodesfunc/rescale.py
linemask(mask=None, downscaler=None, maximum_iter=0, inflate_iter=0, expand=0, kernel_window=None, **kwargs)
A function to apply a linemask to the final output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
VideoNode | EdgeDetectT | None
|
This can be a masking function like |
None
|
downscaler
|
ScalerT | 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
|
**kwargs
|
Any other params to pass to the edgemask creation. For example |
{}
|
Source code in vodesfunc/rescale.py
post_descale(func)
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
|
GenericVSFunction
|
This can be any function that takes a videonode input and returns a videonode. You are responsible for keeping the format the same. |
required |
Source code in vodesfunc/rescale.py
post_double(func)
A function to apply any arbitrary function on the doubled clip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
GenericVSFunction
|
This can be any function that takes a videonode input and returns a videonode. You are responsible for keeping the format the same. |
required |