diff --git a/vsaa/funcs.py b/vsaa/funcs.py index 16734c9..b603149 100644 --- a/vsaa/funcs.py +++ b/vsaa/funcs.py @@ -4,14 +4,14 @@ from pathlib import Path from typing import TYPE_CHECKING, Any, Literal -from vsexprtools import ExprOp, complexpr_available, norm_expr +from vsexprtools import complexpr_available, norm_expr from vskernels import Catrom, NoScale, Scaler, ScalerT, Bilinear -from vsmasktools import EdgeDetect, EdgeDetectT, Morpho, Prewitt, ScharrTCanny +from vsmasktools import EdgeDetect, EdgeDetectT, Prewitt, ScharrTCanny from vsrgtools import RepairMode, box_blur, contrasharpening_median, median_clips, repair, unsharp_masked from vstools import ( - MISSING, CustomOverflowError, CustomRuntimeError, CustomValueError, FunctionUtil, MissingT, PlanesT, VSFunction, + MISSING, CustomOverflowError, CustomRuntimeError, FunctionUtil, MissingT, PlanesT, VSFunction, check_ref_clip, get_h, get_peak_value, get_w, get_y, join, normalize_planes, plane, scale_8bit, scale_value, split, - vs, padder + vs ) from .abstract import Antialiaser, SingleRater @@ -322,7 +322,7 @@ def based_aa( downscaler: ScalerT = Catrom, supersampler: ScalerT | FSRCNNXShaderT | ShaderFile | Path | Literal[False] = ArtCNN.C16F64, antialiaser: Antialiaser = Eedi3(0.125, 0.25, vthresh0=12, vthresh1=24, field=1, sclip_aa=None), - prefilter: Prefilter | vs.VideoNode = Prefilter.NONE, show_mask: bool | int = False, planes: PlanesT = 0, + prefilter: Prefilter | vs.VideoNode = Prefilter.NONE, show_mask: bool = False, planes: PlanesT = 0, **kwargs: Any ) -> vs.VideoNode: ... @@ -333,7 +333,7 @@ def based_aa( downscaler: ScalerT = Catrom, supersampler: ScalerT | FSRCNNXShaderT | ShaderFile | Path | Literal[False] | MissingT = MISSING, antialiaser: Antialiaser = Eedi3(0.125, 0.25, vthresh0=12, vthresh1=24, field=1, sclip_aa=None), - prefilter: Prefilter | vs.VideoNode | MissingT = MISSING, show_mask: bool | int = False, planes: PlanesT = 0, + prefilter: Prefilter | vs.VideoNode | MissingT = MISSING, show_mask: bool = False, planes: PlanesT = 0, **kwargs: Any ) -> vs.VideoNode: try: @@ -396,7 +396,7 @@ def based_aa( if not func.luma_only: lmask = Catrom.resample(join(lmask, lmask, lmask), work_clip) - if show_mask == 1: + if show_mask: return lmask supersampler = Scaler.ensure_obj(supersampler, based_aa) @@ -410,24 +410,10 @@ def based_aa( aa = antialiaser.interpolate(ss, False, sclip=ss, mclip=mclip_up).std.Transpose() aa = antialiaser.interpolate(aa, False, sclip=aa, mclip=mclip_up.std.Transpose()).std.Transpose() - pmask = norm_expr([ss, aa], 'x y = 0 range_size ?') - pmask = padder.COLOR(pmask.std.Crop(2, 2, 2, 2), 2, 2, 2, 2) - pmask = resize_aa_mask(pmask, work_clip.width, work_clip.height) - pmask = Morpho.maximum(norm_expr(pmask, 'x range_size 0 ?'), iterations=3) - - lpmask = ExprOp.MIN(lmask, pmask) - - if show_mask == 2: - return pmask - elif show_mask == 3: - return lpmask - elif show_mask: - raise CustomValueError('Wrong show_mask value! It can be one of 1 (True), 2, 3', based_aa) - aa = downscaler.scale(aa, work_clip.width, work_clip.height) no_aa = downscaler.scale(ss, work_clip.width, work_clip.height) aa_merge = norm_expr([work_clip, aa, no_aa], "y z = x y ?") - aa_merge = work_clip.std.MaskedMerge(aa_merge, lpmask) + aa_merge = work_clip.std.MaskedMerge(aa_merge, lmask) return func.return_clip(aa_merge)