Skip to content

Commit

Permalink
based_aa: remove pmask
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Sep 9, 2024
1 parent 5c31176 commit ea289f5
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions vsaa/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
...
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit ea289f5

Please sign in to comment.