Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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