Skip to content

Instantly share code, notes, and snippets.

@acuozzo
Last active June 25, 2020 04:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save acuozzo/940869257cc79016215600a2392b33eb to your computer and use it in GitHub Desktop.
This Avisynth function deemphasizes ringing common to SD video signals resulting from a playback device in the transfer chain poorly compensating for pre-emphasis baked into the source signal.
function Deemphasize(clip c, int "strength", bool "interlaced", bool "tff")
{
strength = default(strength, 95)
strength = strength < 0 ? -strength : strength
strength = strength >= 100 ? 0 : 100-strength
tff = default(tff, false)
interlaced = default(interlaced, false)
c = interlaced ? (tff ? c.AssumeTFF().SeparateFields() : c.AssumeBFF().SeparateFields()) : c
mask = c.mt_edge("1 0 -1 2 0 -2 1 0 -1", 0, 255, 0, 255)
mask = mask.mt_inpand(mode="vertical")\
.mt_inpand(mode="vertical")\
.mt_inpand(mode="vertical")\
.mt_expand(mode="vertical")\
.mt_expand(mode="vertical")\
.mt_expand(mode="vertical")
blurred = c.GaussResize(c.width-2, c.height, p=strength).Spline64Resize(c.width, c.height)
output = mt_merge(blurred, c, mask)
return interlaced ? output.Weave() : output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment