util ¶
Type Aliases:
-
NoScaleLike–Type alias for anything that can resolve to a NoScale scaler.
Classes:
-
BaseMixedScaler–An abstract base class to provide mixed or chained scaling for BaseScaler-like classes.
-
BaseScalerSpecializer–An abstract base class to provide specialization logic for BaseScaler-like classes.
-
LinearLight–Utility class for processing a clip in linear format.
-
MixedScalerProcess–An abstract class for chained scaling with an additional processing step.
-
NoScale–A utility scaler class that performs no scaling on the input clip.
-
ScalerSpecializer–An abstract base class to provide specialization logic for Scaler-like classes.
Functions:
-
is_complex_descaler_like–Returns true if obj is a ComplexDescalerLike.
-
is_complex_kernel_like–Returns true if obj is a ComplexKernelLike.
-
is_complex_scaler_like–Returns true if obj is a ComplexScalerLike.
-
is_custom_complex_kernel_like–Returns true if obj is a CustomComplexKernelLike.
-
is_descaler_like–Returns true if obj is a DescalerLike.
-
is_kernel_like–Returns true if obj is a KernelLike.
-
is_noscale_like–Returns true if obj is a NoScaleLike.
-
is_resampler_like–Returns true if obj is a ResamplerLike.
-
is_scaler_like–Returns true if obj is a ScalerLike.
-
resample_to–
NoScaleLike ¶
BaseMixedScaler ¶
Bases: BaseScalerSpecializer[DefaultScalerT]
An abstract base class to provide mixed or chained scaling for BaseScaler-like classes.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
default_scaler–Retrieve the default scaler type associated with this class.
-
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).
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
is_abstract–Return True if this class can't be instantiated.
-
kernel_radius–Return the effective kernel radius for the scaler.
Attributes:
-
kwargs–Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
specializer(type[DefaultScalerT]) –Returns the effective specializer.
Source code in vskernels/util.py
125 126 127 128 129 130 131 132 | |
kwargs instance-attribute ¶
kwargs = kwargs
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
default_scaler classmethod ¶
default_scaler() -> type[DefaultScalerT]
Retrieve the default scaler type associated with this class.
This method looks up the type parameter that matches cls.__scaler_type_param_name__ in the class's type parameters (__type_params__) or, if not found, in the MRO.
If no default scaler type is defined, an error is raised.
Raises:
-
CustomRuntimeError–If neither the class nor any of its bases define a type parameter matching
__scaler_type_param_name__. -
CustomRuntimeError–If the type parameter exists but does not specify a default scaler type.
Returns:
-
type[DefaultScalerT]–The default scaler type defined for the class.
Source code in vskernels/util.py
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 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
468 469 470 471 472 473 474 475 476 477 478 479 | |
is_abstract classmethod ¶
is_abstract() -> bool
Return True if this class can't be instantiated.
Source code in vskernels/abstract/base.py
462 463 464 465 466 | |
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 in vskernels/abstract/base.py
425 426 427 428 429 430 431 432 433 434 435 436 | |
BaseMixedScalerMeta ¶
Bases: BaseScalerSpecializerMeta
Meta class for BaseMixedScaler to handle mixed scaling logic.
Classes:
-
cachedproperty–Read only version of jetpytools.cachedproperty.
Attributes:
cachedproperty ¶
cachedproperty(func: Callable[Concatenate[BaseScalerT, P], R])
Bases: cachedproperty[R]
Read only version of jetpytools.cachedproperty.
Methods:
-
clear_cache–Clear cached properties of an object instance.
-
deleter– -
getter– -
setter– -
update_cache–Update cached property of an object instance.
Attributes:
Source code in vskernels/abstract/base.py
218 219 220 | |
clear_cache classmethod ¶
Clear cached properties of an object instance.
Parameters:
-
(obj¶object) –The object whose cache should be cleared.
-
(names¶str | Iterable[str] | None, default:None) –Specific property names to clear. If None, all cached properties are cleared.
Source code in jetpytools/types/utils.py
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
deleter ¶
deleter(fdel: Callable[..., None]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
762 | |
getter ¶
getter(fget: Callable[..., _R_co]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
758 | |
setter ¶
setter(fset: Callable[[Any, _T_Any], None]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
760 | |
update_cache classmethod ¶
Update cached property of an object instance.
Parameters:
-
(obj¶object) –The object whose cache should be updated.
-
(name¶str) –Property name to update.
-
(value¶Any) –The value to assign.
Source code in jetpytools/types/utils.py
829 830 831 832 833 834 835 836 837 838 839 | |
BaseScalerSpecializer ¶
Bases: BaseScaler
An abstract base class to provide specialization logic for BaseScaler-like classes.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
default_scaler–Retrieve the default scaler type associated with this class.
-
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).
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
is_abstract–Return True if this class can't be instantiated.
-
kernel_radius–Return the effective kernel radius for the scaler.
Attributes:
-
kwargs–Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
specializer(type[DefaultScalerT]) –Returns the effective specializer.
Source code in vskernels/util.py
125 126 127 128 129 130 131 132 | |
kwargs instance-attribute ¶
kwargs = kwargs
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
default_scaler classmethod ¶
default_scaler() -> type[DefaultScalerT]
Retrieve the default scaler type associated with this class.
This method looks up the type parameter that matches cls.__scaler_type_param_name__ in the class's type parameters (__type_params__) or, if not found, in the MRO.
If no default scaler type is defined, an error is raised.
Raises:
-
CustomRuntimeError–If neither the class nor any of its bases define a type parameter matching
__scaler_type_param_name__. -
CustomRuntimeError–If the type parameter exists but does not specify a default scaler type.
Returns:
-
type[DefaultScalerT]–The default scaler type defined for the class.
Source code in vskernels/util.py
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 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
468 469 470 471 472 473 474 475 476 477 478 479 | |
is_abstract classmethod ¶
is_abstract() -> bool
Return True if this class can't be instantiated.
Source code in vskernels/abstract/base.py
462 463 464 465 466 | |
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 in vskernels/abstract/base.py
425 426 427 428 429 430 431 432 433 434 435 436 | |
BaseScalerSpecializerMeta ¶
Bases: BaseScalerMeta
Meta class for BaseScalerSpecializer to handle specialization logic.
Classes:
-
cachedproperty–Read only version of jetpytools.cachedproperty.
Attributes:
cachedproperty ¶
cachedproperty(func: Callable[Concatenate[BaseScalerT, P], R])
Bases: cachedproperty[R]
Read only version of jetpytools.cachedproperty.
Methods:
-
clear_cache–Clear cached properties of an object instance.
-
deleter– -
getter– -
setter– -
update_cache–Update cached property of an object instance.
Attributes:
Source code in vskernels/abstract/base.py
218 219 220 | |
clear_cache classmethod ¶
Clear cached properties of an object instance.
Parameters:
-
(obj¶object) –The object whose cache should be cleared.
-
(names¶str | Iterable[str] | None, default:None) –Specific property names to clear. If None, all cached properties are cleared.
Source code in jetpytools/types/utils.py
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
deleter ¶
deleter(fdel: Callable[..., None]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
762 | |
getter ¶
getter(fget: Callable[..., _R_co]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
758 | |
setter ¶
setter(fset: Callable[[Any, _T_Any], None]) -> cachedproperty[_R_co, _T_Any]
Source code in jetpytools/types/utils.py
760 | |
update_cache classmethod ¶
Update cached property of an object instance.
Parameters:
-
(obj¶object) –The object whose cache should be updated.
-
(name¶str) –Property name to update.
-
(value¶Any) –The value to assign.
Source code in jetpytools/types/utils.py
829 830 831 832 833 834 835 836 837 838 839 | |
LinearLight dataclass ¶
LinearLight(
clip: VideoNode,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatLike | HoldsVideoFormat | None = None,
)
Bases: VSObjectABC, AbstractContextManager[LinearLightProcessing]
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 | VideoFormatLike | HoldsVideoFormat | 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 | VideoFormatLike | HoldsVideoFormat | 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 | VideoFormatLike | HoldsVideoFormat | None = None,
) -> Callable[Concatenate[VideoNode, P], VideoNode]
from_func(
*,
sigmoid: bool | tuple[Slope, Center] = False,
resampler: ResamplerLike = Catrom,
out_fmt: int | VideoFormatLike | HoldsVideoFormat | 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 | VideoFormatLike | HoldsVideoFormat | None = None,
) -> (
Callable[Concatenate[VideoNode, P], VideoNode]
| Callable[
[Callable[Concatenate[VideoNode, P], VideoNode]],
Callable[Concatenate[VideoNode, P], VideoNode],
]
)
Decorator version of LinearLight.
Source code in vskernels/util.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
LinearLightProcessing dataclass ¶
LinearLightProcessing(ll: LinearLight)
Bases: VSObject
Methods:
-
get_linear–Getter for
linearcached property. -
out– -
set_linear–Setter for
linearcached property.
Attributes:
-
linear–Cached property to use for linear light processing.
-
ll(LinearLight) –
linear class-attribute instance-attribute ¶
linear = cachedproperty[vs.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 in vskernels/util.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
out ¶
out() -> VideoNode
Source code in vskernels/util.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
set_linear ¶
set_linear(processed: VideoNode) -> None
Setter for linear cached property.
Source code in vskernels/util.py
426 427 428 429 430 431 432 433 434 | |
MixedScalerProcess ¶
MixedScalerProcess(*, function: VSFunctionNoArgs, **kwargs: Any)
Bases: BaseMixedScaler[DefaultScalerT, *BaseScalerTs], Scaler
An abstract class for chained scaling with an additional processing step.
Initialize the MixedScalerProcess.
Parameters:
-
(function¶VSFunctionNoArgs) –A function to apply on the scaling pipeline.
-
(**kwargs¶Any, default:{}) –Keyword arguments that configure the internal scaling behavior.
Methods:
-
default_scaler–Retrieve the default scaler type associated with this class.
-
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).
-
get_scale_args–Generate the keyword arguments used for scaling.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
is_abstract–Return True if this class can't be instantiated.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
scale–Scale a clip to a specified resolution.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
function– -
kwargs–Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
-
specializer(type[DefaultScalerT]) –Returns the effective specializer.
Source code in vskernels/util.py
377 378 379 380 381 382 383 384 385 386 387 | |
kwargs instance-attribute ¶
kwargs = kwargs
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
scale_function instance-attribute ¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
default_scaler classmethod ¶
default_scaler() -> type[DefaultScalerT]
Retrieve the default scaler type associated with this class.
This method looks up the type parameter that matches cls.__scaler_type_param_name__ in the class's type parameters (__type_params__) or, if not found, in the MRO.
If no default scaler type is defined, an error is raised.
Raises:
-
CustomRuntimeError–If neither the class nor any of its bases define a type parameter matching
__scaler_type_param_name__. -
CustomRuntimeError–If the type parameter exists but does not specify a default scaler type.
Returns:
-
type[DefaultScalerT]–The default scaler type defined for the class.
Source code in vskernels/util.py
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 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
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 in vskernels/abstract/base.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
468 469 470 471 472 473 474 475 476 477 478 479 | |
is_abstract classmethod ¶
is_abstract() -> bool
Return True if this class can't be instantiated.
Source code in vskernels/abstract/base.py
462 463 464 465 466 | |
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 in vskernels/abstract/base.py
425 426 427 428 429 430 431 432 433 434 435 436 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
Scale a clip to a specified resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(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:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –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:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
NoScale ¶
Bases: ScalerSpecializer[DefaultScalerT]
A utility scaler class that performs no scaling on the input clip.
If used without a specified scaler, it defaults to inheriting from Catrom.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
default_scaler–Retrieve the default scaler type associated with this class.
-
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.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
is_abstract–Return True if this class can't be instantiated.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
scale–Return the input clip unscaled, validating that the dimensions are consistent.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs–Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
-
specializer(type[DefaultScalerT]) –Returns the effective specializer.
Source code in vskernels/util.py
125 126 127 128 129 130 131 132 | |
kwargs instance-attribute ¶
kwargs = kwargs
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
scale_function instance-attribute ¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
default_scaler classmethod ¶
default_scaler() -> type[DefaultScalerT]
Retrieve the default scaler type associated with this class.
This method looks up the type parameter that matches cls.__scaler_type_param_name__ in the class's type parameters (__type_params__) or, if not found, in the MRO.
If no default scaler type is defined, an error is raised.
Raises:
-
CustomRuntimeError–If neither the class nor any of its bases define a type parameter matching
__scaler_type_param_name__. -
CustomRuntimeError–If the type parameter exists but does not specify a default scaler type.
Returns:
-
type[DefaultScalerT]–The default scaler type defined for the class.
Source code in vskernels/util.py
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 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
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 in vskernels/util.py
265 266 267 268 269 270 271 272 273 274 275 276 | |
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 in vskernels/abstract/base.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
468 469 470 471 472 473 474 475 476 477 478 479 | |
is_abstract classmethod ¶
is_abstract() -> bool
Return True if this class can't be instantiated.
Source code in vskernels/abstract/base.py
462 463 464 465 466 | |
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 in vskernels/abstract/base.py
425 426 427 428 429 430 431 432 433 434 435 436 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
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
widthorheightdiffer from the clip's dimensions.
Source code in vskernels/util.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –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:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
ScalerSpecializer ¶
Bases: BaseScalerSpecializer[DefaultScalerT], Scaler
An abstract base class to provide specialization logic for Scaler-like classes.
Initialize the scaler with optional keyword arguments.
These keyword arguments are automatically forwarded to the implemented_funcs methods but only if the method explicitly accepts them as named parameters. If the same keyword is passed to both __init__ and one of the implemented_funcs, the one passed to func takes precedence.
Parameters:
Methods:
-
default_scaler–Retrieve the default scaler type associated with this class.
-
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).
-
get_scale_args–Generate the keyword arguments used for scaling.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
is_abstract–Return True if this class can't be instantiated.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
scale–Scale a clip to a specified resolution.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
kwargs–Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
-
specializer(type[DefaultScalerT]) –Returns the effective specializer.
Source code in vskernels/util.py
125 126 127 128 129 130 131 132 | |
kwargs instance-attribute ¶
kwargs = kwargs
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
scale_function instance-attribute ¶
scale_function: Callable[..., VideoNode]
Scale function called internally when performing scaling operations.
default_scaler classmethod ¶
default_scaler() -> type[DefaultScalerT]
Retrieve the default scaler type associated with this class.
This method looks up the type parameter that matches cls.__scaler_type_param_name__ in the class's type parameters (__type_params__) or, if not found, in the MRO.
If no default scaler type is defined, an error is raised.
Raises:
-
CustomRuntimeError–If neither the class nor any of its bases define a type parameter matching
__scaler_type_param_name__. -
CustomRuntimeError–If the type parameter exists but does not specify a default scaler type.
Returns:
-
type[DefaultScalerT]–The default scaler type defined for the class.
Source code in vskernels/util.py
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 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | 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¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
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 in vskernels/abstract/base.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
468 469 470 471 472 473 474 475 476 477 478 479 | |
is_abstract classmethod ¶
is_abstract() -> bool
Return True if this class can't be instantiated.
Source code in vskernels/abstract/base.py
462 463 464 465 466 | |
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 in vskernels/abstract/base.py
425 426 427 428 429 430 431 432 433 434 435 436 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
Scale a clip to a specified resolution.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(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:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/base.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any,
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –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:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
is_bobber_like ¶
is_bobber_like(obj: Any) -> TypeIs[BobberLike]
Returns true if obj is a BobberLike.
Source code in vskernels/util.py
658 659 660 | |
is_complex_descaler_like ¶
is_complex_descaler_like(obj: Any) -> TypeIs[ComplexDescalerLike]
Returns true if obj is a ComplexDescalerLike.
Source code in vskernels/util.py
668 669 670 | |
is_complex_kernel_like ¶
is_complex_kernel_like(obj: Any) -> TypeIs[ComplexKernelLike]
Returns true if obj is a ComplexKernelLike.
Source code in vskernels/util.py
673 674 675 | |
is_complex_scaler_like ¶
is_complex_scaler_like(obj: Any) -> TypeIs[ComplexScalerLike]
Returns true if obj is a ComplexScalerLike.
Source code in vskernels/util.py
663 664 665 | |
is_custom_complex_kernel_like ¶
is_custom_complex_kernel_like(obj: Any) -> TypeIs[CustomComplexKernelLike]
Returns true if obj is a CustomComplexKernelLike.
Source code in vskernels/util.py
678 679 680 | |
is_descaler_like ¶
is_descaler_like(obj: Any) -> TypeIs[DescalerLike]
Returns true if obj is a DescalerLike.
Source code in vskernels/util.py
643 644 645 | |
is_kernel_like ¶
is_kernel_like(obj: Any) -> TypeIs[KernelLike]
Returns true if obj is a KernelLike.
Source code in vskernels/util.py
653 654 655 | |
is_noscale_like ¶
is_noscale_like(
obj: Any, specializer: type[ScalerT] = Scaler
) -> TypeIs[NoScaleLike[ScalerT]]
Returns true if obj is a NoScaleLike.
Source code in vskernels/util.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
is_resampler_like ¶
is_resampler_like(obj: Any) -> TypeIs[ResamplerLike]
Returns true if obj is a ResamplerLike.
Source code in vskernels/util.py
648 649 650 | |
is_scaler_like ¶
is_scaler_like(obj: Any) -> TypeIs[ScalerLike]
Returns true if obj is a ScalerLike.
Source code in vskernels/util.py
638 639 640 | |
resample_to ¶
resample_to(
clip: VideoNode,
out_fmt: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
resampler: ResamplerLike = Catrom,
) -> VideoNode
Source code in vskernels/util.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |