Skip to content

Commit

Permalink
Eedi3: Allow VideoNode to be passed to sclip_aa
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Sep 30, 2024
1 parent d014df9 commit ad1cb82
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions vsaa/antialiasers/eedi3.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ class EEDI3(_Antialiaser):
opencl: bool = dc_field(default=False, kw_only=True)

mclip: vs.VideoNode | None = None
sclip_aa: type[Antialiaser] | Antialiaser | Literal[True] | None = dc_field(
sclip_aa: type[Antialiaser] | Antialiaser | Literal[True] | vs.VideoNode | None = dc_field(
default_factory=lambda: nnedi3.Nnedi3
)

def __post_init__(self) -> None:
super().__post_init__()

self._sclip_aa: Antialiaser | Literal[True] | None
self._sclip_aa: Antialiaser | Literal[True] | vs.VideoNode | None

if self.sclip_aa and self.sclip_aa is not True and not isinstance(self.sclip_aa, Antialiaser):
self._sclip_aa = self.sclip_aa()
if self.sclip_aa and self.sclip_aa is not True and not isinstance(self.sclip_aa, (Antialiaser, vs.VideoNode)):
self._sclip_aa = self.sclip_aa() # type: ignore[operator]
else:
self._sclip_aa = self.sclip_aa # type: ignore[assignment]

Expand All @@ -69,9 +69,22 @@ def interpolate(self, clip: vs.VideoNode, double_y: bool, **kwargs: Any) -> vs.V
aa_kwargs = self.get_aa_args(clip, **kwargs)

if self._sclip_aa and ((('sclip' in kwargs) and not kwargs['sclip']) or 'sclip' not in kwargs):
if self._sclip_aa is True:
if self._sclip_aa is True or isinstance(self._sclip_aa, vs.VideoNode):
if double_y:
raise CustomValueError("You can't pass sclip_aa=True when supersampling!", self.__class__)
if self._sclip_aa is True:
raise CustomValueError("You can't pass sclip_aa=True when supersampling!", self.__class__)

expected_dimensions = (clip.width * 2, clip.height * 2)
actual_dimensions = (clip.width, clip.height)

if expected_dimensions != actual_dimensions:
raise CustomValueError(
f"The dimensions of sclip_aa ({actual_dimensions[0]}x{actual_dimensions[1]}) "
f"don't match the expected dimensions for supersampling "
f"({expected_dimensions[0]}x{expected_dimensions[1]})!",
self.__class__
)

aa_kwargs.update(sclip=clip)
else:
sclip_args = self._sclip_aa.get_aa_args(clip, **(dict(mclip=kwargs.get('mclip', None))))
Expand Down

0 comments on commit ad1cb82

Please sign in to comment.