Skip to content

Commit

Permalink
FunctionUtil: Accept bitdepths above max accepted bitdepth
Browse files Browse the repository at this point in the history
Fix the removal of range.stop causing the highest bitdepth to be messed up.

Closes #155
  • Loading branch information
LightArrowsEXE committed Oct 15, 2024
1 parent 733ebcc commit 5334d1f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vstools/functions/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
InvalidColorFamilyError.check(clip, color_family, func)

if isinstance(bitdepth, tuple):
bitdepth = range(*bitdepth)
bitdepth = range(bitdepth[0], bitdepth[1] + 1)

self.clip = clip
self.planes = planes
Expand All @@ -114,7 +114,10 @@ def norm_clip(self) -> ConstantFormatVideoNode:
from .. import get_depth

if isinstance(self.bitdepth, (range, set)) and self.clip.format.bits_per_sample not in self.bitdepth:
clip = depth(self.clip, min(bits for bits in self.bitdepth if bits >= get_depth(self.clip)))
src_depth = get_depth(self.clip)
target_depth = next((bits for bits in self.bitdepth if bits >= src_depth), max(self.bitdepth))

clip = depth(self.clip, target_depth)
elif isinstance(self.bitdepth, int):
clip = depth(self.clip, self.bitdepth)
else:
Expand Down

0 comments on commit 5334d1f

Please sign in to comment.