Skip to content

Commit

Permalink
Fix FixInterlacedFades
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Jan 31, 2025
1 parent feec266 commit 192b94f
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions vsdeinterlace/funcs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

from typing import Any, cast
from typing import Any

from functools import partial

from stgpytools import CustomIntEnum
from vsdenoise import MVTools
from vsexprtools import ExprVars, complexpr_available, norm_expr
from vsexprtools import norm_expr
from vsrgtools import BlurMatrix, sbr
from vstools import (
ConvMode, CustomEnum, FormatsMismatchError, FuncExceptT, FunctionUtil, GenericVSFunction,
Expand All @@ -15,7 +15,7 @@

__all__ = [
'telop_resample',
'fix_interlaced_fades',
'FixInterlacedFades',
'vinverse'
]

Expand Down Expand Up @@ -173,9 +173,6 @@ def __call__(
"""
func = func or self.__class__

if not complexpr_available:
raise ExprVars._get_akarin_err()(func=func)

f = FunctionUtil(clip, func, planes, vs.YUV, 32)

fields = f.work_clip.std.Limiter().std.SeparateFields(tff=True)
Expand All @@ -191,24 +188,22 @@ def __call__(
}
)

expr_mode, expr_mode_chroma = (
('min', '<') if self == self.Darken else ('max', '>') if self == self.Brighten else ('+ 2 /', '+ 2 /')
)

expr_header = 'Y 2 % x.fbAvg{i} x.ftAvg{i} ? AVG! AVG@ 0 = x x {color} - '
expr_footer = ' AVG@ / * ? {color} +'

expr_mode, expr_mode_chroma = (
('min', '<') if self == self.Darken else ('max', '>') if self == self.Brighten else ('+ 2 /', '+ 2 /')
expr_luma = expr_header + 'x.ftAvg{i} x.fbAvg{i} {expr_mode}' + expr_footer
expr_chroma = expr_luma if self == self.Average else (
expr_header + 'x.ftAvg{i} abs x.fbAvg{i} abs {expr_mode} x.ftAvg{i} x.fbAvg{i} ?' + expr_footer
)

fix = norm_expr(
props_clip, (
# luma
expr_header + 'x.ftAvg{i} x.fbAvg{i} {expr_mode}' + expr_footer,
# chroma
expr_header + ('x.ftAvg{i} x.fbAvg{i} {expr_mode}' if (
self == self.Average
) else 'x.ftAvg{i} abs x.fbAvg{i} abs {expr_mode} x.ftAvg{i} x.fbAvg{i} ?') + expr_footer
),
planes, i=f.norm_planes, expr_mode=(expr_mode, expr_mode_chroma),
color=colors, force_akarin=func,
props_clip, (expr_luma, expr_chroma),
planes, i=f.norm_planes, color=colors,
expr_mode=(expr_mode, expr_mode_chroma)
)

return f.return_clip(fix)
Expand Down Expand Up @@ -266,6 +261,3 @@ def vinverse(
)

return func.return_clip(combed)


fix_interlaced_fades = cast(FixInterlacedFades, FixInterlacedFades.Average)

0 comments on commit 192b94f

Please sign in to comment.