diff --git a/vskernels/kernels/abstract.py b/vskernels/kernels/abstract.py index 4b788be..6e6de08 100644 --- a/vskernels/kernels/abstract.py +++ b/vskernels/kernels/abstract.py @@ -5,8 +5,8 @@ from vstools import ( CustomIndexError, CustomValueError, FieldBased, FuncExceptT, GenericVSFunction, HoldsVideoFormatT, Matrix, MatrixT, - T, VideoFormatT, check_correct_subsampling, check_variable_resolution, core, get_subclasses, get_video_format, - inject_self, vs, vs_object + T, VideoFormatT, check_correct_subsampling, check_variable_resolution, core, depth, expect_bits, get_subclasses, + get_video_format, inject_self, vs, vs_object ) from ..exceptions import UnknownDescalerError, UnknownKernelError, UnknownScalerError @@ -130,12 +130,14 @@ def descale( # type: ignore[override] field_based = FieldBased.from_video(clip) + clip, bits = expect_bits(clip, 32) + + de_kwargs = self.get_descale_args(clip, shift, width, height // (1 + field_based.is_inter), **kwargs) + if field_based.is_inter: if height % 2: raise CustomIndexError('You can\'t descale to odd resolution when crossconverted!', self.descale) - de_kwargs = self.get_descale_args(clip, shift, width, height // 2, **kwargs) - top_shift, field_shift = de_kwargs.get('src_top'), 0.125 * height / clip.height fields = clip.std.SeparateFields(field_based.is_tff) @@ -145,9 +147,11 @@ def descale( # type: ignore[override] for offset, mult in [(0, 1), (1, -1)] ]) - return interleaved.std.DoubleWeave(field_based.is_tff)[::2] + descaled = interleaved.std.DoubleWeave(field_based.is_tff)[::2] + else: + descaled = self.descale_function(clip, **de_kwargs) - return self.descale_function(clip, **self.get_descale_args(clip, shift, width, height, **kwargs)) + return depth(descaled, bits) @classmethod def from_param( diff --git a/vskernels/kernels/docs.py b/vskernels/kernels/docs.py index eec7c65..2316798 100644 --- a/vskernels/kernels/docs.py +++ b/vskernels/kernels/docs.py @@ -2,7 +2,7 @@ from typing import Any, overload -from vstools import HoldsVideoFormatT, MatrixT, VideoFormatT, core, get_video_format, inject_self, vs +from vstools import HoldsVideoFormatT, MatrixT, VideoFormatT, core, depth, get_video_format, inject_self, vs from .abstract import Kernel @@ -54,9 +54,9 @@ def descale( # type: ignore[override] :rtype: ``VideoNode`` """ - return core.descale.Debicubic( - clip, width, height, b=self.b, c=self.c, src_top=shift[0], src_left=shift[1], **kwargs - ) + return depth(core.descale.Debicubic( + depth(clip, 32), width, height, b=self.b, c=self.c, src_top=shift[0], src_left=shift[1], **kwargs + ), clip) @inject_self.cached def resample( # type: ignore[override]