util ¶
Classes:
-
BaseScalerSpecializer
–An abstract base class to provide specialization logic for Scaler-like classes.
-
LinearLight
–Utility class for processing a clip in linear format.
-
NoScale
–A utility scaler class that performs no scaling on the input clip.
Functions:
BaseScalerSpecializer ¶
BaseScalerSpecializer(**kwargs: Any)
Bases: BaseScaler
, Generic[_BaseScalerT]
An abstract base class to provide specialization logic for Scaler-like classes.
Methods:
-
ensure_obj
–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param
–Resolve and return a scaler type from a given input (string, type, or instance).
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
pretty_string
–Cached property returning a user-friendly string representation.
Attributes:
-
kwargs
–
Source code
85 86 87 88 89 90 91 92 |
|
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
scaler
¶str | type[Self] | Self | None
, default:None
) –Scaler identifier (string, class, or instance).
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
scaler
¶str | type[Self] | Self | None
, default:None
) –Scaler identifier (string, class, or instance).
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Returns:
-
int
–Kernel radius.
Source code
393 394 395 396 397 398 399 400 401 402 403 404 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
420 421 422 423 424 425 426 427 428 |
|
BaseScalerSpecializerMeta ¶
Bases: BaseScalerMeta
Meta class for BaseScalerSpecializer to handle specialization logic.
Classes:
-
cached_property
–Read only version of functools.cached_property.
cached_property ¶
cached_property(func: Callable[Concatenate[_BaseScalerT, P], T_co])
Bases: cached_property[T_co]
Read only version of functools.cached_property.
Source code
206 |
|
LinearLight dataclass
¶
LinearLight(
clip: VideoNode,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatT | HoldsVideoFormatT | None = None,
)
Bases: AbstractContextManager[LinearLightProcessing]
, vs_object
Utility class for processing a clip in linear format.
Usage
with LinearLight(clip, ...) as ll:
ll.linear = function(ll.linear, ...)
out = ll.out
Methods:
-
from_func
–Decorator version of LinearLight.
Attributes:
-
clip
(VideoNode
) –Input clip.
-
out_fmt
(int | VideoFormatT | HoldsVideoFormatT | None
) –Optional output format.
-
resampler
(ResamplerLike
) –Resampler for converting to linear format and converting back to input clip format.
-
sigmoid
(bool | tuple[Slope, Center]
) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
out_fmt class-attribute
instance-attribute
¶
out_fmt: int | VideoFormatT | HoldsVideoFormatT | None = None
Optional output format.
resampler class-attribute
instance-attribute
¶
resampler: ResamplerLike = Catrom
Resampler for converting to linear format and converting back to input clip format.
sigmoid class-attribute
instance-attribute
¶
Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center). True
applies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0. (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive).
from_func classmethod
¶
from_func(
func: Callable[Concatenate[VideoNode, P], VideoNode],
/,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatT | HoldsVideoFormatT | None = None,
) -> Callable[Concatenate[VideoNode, P], VideoNode]
from_func(
*,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatT | HoldsVideoFormatT | None = None
) -> Callable[
[Callable[Concatenate[VideoNode, P], VideoNode]],
Callable[Concatenate[VideoNode, P], VideoNode],
]
from_func(
func: Callable[Concatenate[VideoNode, P], VideoNode] | None = None,
/,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatT | HoldsVideoFormatT | None = None,
) -> Union[
Callable[Concatenate[VideoNode, P], VideoNode],
Callable[
[Callable[Concatenate[VideoNode, P], VideoNode]],
Callable[Concatenate[VideoNode, P], VideoNode],
],
]
Decorator version of LinearLight.
Source code
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
LinearLightProcessing dataclass
¶
LinearLightProcessing(ll: LinearLight)
Bases: baseclass
, vs_object
Methods:
-
get_linear
–Getter for
linear
cached property. -
out
– -
set_linear
–Setter for
linear
cached property.
Attributes:
-
linear
–Cached property to use for linear light processing.
-
ll
(LinearLight
) –
linear class-attribute
instance-attribute
¶
linear = cachedproperty[[Self], VideoNode, Self, VideoNode, ...](
get_linear, set_linear
)
Cached property to use for linear light processing.
get_linear ¶
get_linear() -> VideoNode
Getter for linear
cached property.
Source code
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
out ¶
out() -> VideoNode
Source code
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 |
|
set_linear ¶
set_linear(processed: VideoNode) -> None
Setter for linear
cached property.
Source code
204 205 206 207 208 209 210 211 212 |
|
NoScale ¶
NoScale(**kwargs: Any)
Bases: BaseScalerSpecializer[_ScalerT]
, Scaler
A utility scaler class that performs no scaling on the input clip.
If used without a specified scaler, it defaults to inheriting from Catrom
.
Methods:
-
ensure_obj
–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param
–Resolve and return a scaler type from a given input (string, type, or instance).
-
from_scaler
–Create a specialized NoScale class using a specific scaler.
-
get_scale_args
–Generate the keyword arguments used for scaling.
-
kernel_radius
–Return the effective kernel radius for the scaler.
-
multi
–Deprecated alias for
supersample
. -
pretty_string
–Cached property returning a user-friendly string representation.
-
scale
–Return the input clip unscaled, validating that the dimensions are consistent.
-
supersample
–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs
– -
scale_function
(Callable[..., VideoNode]
) –Scale function called internally when performing scaling operations.
Source code
85 86 87 88 89 90 91 92 |
|
scale_function instance-attribute
¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
ensure_obj classmethod
¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
scaler
¶str | type[Self] | Self | None
, default:None
) –Scaler identifier (string, class, or instance).
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
Self
–Scaler instance.
Source code
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
from_param classmethod
¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExceptT | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
scaler
¶str | type[Self] | Self | None
, default:None
) –Scaler identifier (string, class, or instance).
-
func_except
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling.
Returns:
-
type[Self]
–Resolved scaler type.
Source code
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
from_scaler classmethod
¶
from_scaler(scaler: ScalerLike) -> type[NoScale[Scaler]]
Create a specialized NoScale class using a specific scaler.
Parameters:
-
scaler
¶ScalerLike
) –A Scaler instance, type or string used as a base for specialization.
Returns:
Source code
161 162 163 164 165 166 167 168 169 170 171 172 |
|
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for scaling.
Parameters:
-
clip
¶VideoNode
) –The source clip.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left).
-
width
¶int | None
, default:None
) –Target width.
-
height
¶int | None
, default:None
) –Target height.
-
**kwargs
¶Any
, default:{}
) –Extra parameters to merge.
Returns:
Source code
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError
–If no kernel radius is defined.
Returns:
-
int
–Kernel radius.
Source code
393 394 395 396 397 398 399 400 401 402 403 404 |
|
multi ¶
multi(
clip: VideoNodeT,
multi: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Deprecated alias for supersample
.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
multi
¶float
, default:2.0
) –Supersampling factor.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left) applied during scaling.
-
**kwargs
¶Any
, default:{}
) –Additional arguments forwarded to the scale function.
Returns:
-
VideoNodeT
–The supersampled clip.
Source code
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
|
pretty_string ¶
pretty_string() -> str
Cached property returning a user-friendly string representation.
Returns:
-
str
–Pretty-printed string with arguments.
Source code
420 421 422 423 424 425 426 427 428 |
|
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Return the input clip unscaled, validating that the dimensions are consistent.
Parameters:
-
clip
¶VideoNode
) –The source clip.
-
width
¶int | None
, default:None
) –Optional width to validate against the clip's width.
-
height
¶int | None
, default:None
) –Optional height to validate against the clip's height.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left).
-
**kwargs
¶Any
, default:{}
) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError
–If
width
orheight
differ from the clip's dimensions.
Source code
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 |
|
supersample ¶
supersample(
clip: VideoNodeT,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNodeT
Supersample a clip by a given scaling factor.
Parameters:
-
clip
¶VideoNodeT
) –The source clip.
-
rfactor
¶float
, default:2.0
) –Scaling factor for supersampling.
-
shift
¶tuple[TopShift, LeftShift]
, default:(0, 0)
) –Subpixel shift (top, left) applied during scaling.
-
**kwargs
¶Any
, default:{}
) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError
–If resulting resolution is non-positive.
Returns:
-
VideoNodeT
–The supersampled clip.
Source code
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
resample_to ¶
resample_to(
clip: VideoNode,
out_fmt: int | VideoFormatT | HoldsVideoFormatT,
matrix: MatrixT | None = None,
resampler: ResamplerLike = Catrom,
) -> VideoNode
Source code
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|