View Full Version : TDeintMod : need some help
Pat357
19th March 2015, 21:03
I'm looking for a good deinterlacer that is faster and "lighter" than QTGMC.
I came to the ported TDeint called TDeintMod (https://github.com/HomeOfVapourSynthEvolution/VapourSynth-TDeintMod )
The example on this page :
import vapoursynth as vs
import functools
core = vs.get_core()
clip = Whatever
def conditionalDeint(n, f, orig, deint):
if f.props._Combed:
return deint
else:
return orig
deint = core.tdm.TDeintMod(clip, order=1, edeint=core.nnedi3.nnedi3(clip, field=1))
combProps = core.tdm.IsCombed(clip)
clip = core.std.FrameEval(clip, functools.partial(conditionalDeint, orig=clip, deint=deint), combProps)
clip.set_output()
Now what is this functools.partial in the FrameEval line ? Any more info about this would be nice.
What does this functools.partial exactly do ? I don't fully understand how this script works.
Can anyone explain this script to me ?
Like why does ConditionalDeint(n, f, orig, deint) need 4 arguments when we use only 3 of them ? (f, orig and Deint) , and "n" appears to be never used... ?
Has anyone a better or more comprehensive way to do this ?
This example should work for the same output rate as the input. How about double rate (bobbing) ?
Can this script be adapted for double rate output ?
Just letting NNEDI3 output double rate by setting "field=3" option won't obviously work, as the "edeint" clip will have double rate which doesn't match anymore.
captainadamo
20th March 2015, 03:55
Functools documentation (https://docs.python.org/3.4/library/functools.html):
functools.partial(func, *args, **keywords)
Return a new partial object which when called will behave like func called with the positional arguments args and keyword arguments keywords. If more arguments are supplied to the call, they are appended to args. If additional keyword arguments are supplied, they extend and override keywords. Roughly equivalent to:
def partial(func, *args, **keywords):
def newfunc(*fargs, **fkeywords):
newkeywords = keywords.copy()
newkeywords.update(fkeywords)
return func(*(args + fargs), **newkeywords)
newfunc.func = func
newfunc.args = args
newfunc.keywords = keywords
return newfunc
The partial() is used for partial function application which “freezes” some portion of a function’s arguments and/or keywords resulting in a new object with a simplified signature. For example, partial() can be used to create a callable that behaves like the int() function where the base argument defaults to two:
jackoneill
20th March 2015, 11:34
It may help to read the documentation for the FrameEval filter (http://www.vapoursynth.com/doc/functions/frameeval.html) too.
I'm not sure how helpful it is, but here's a picture:
http://i.imgur.com/0QTBo5W.png
For every frame n requested from FrameEval, it requests the corresponding frame from IsCombed (combProps), then passes said frame to the conditionalDeint() function, along with the frame number n, and the two arguments given to functools.partial(), orig and deint. IsCombed examines the frame and attaches the "_Combed" property, with the value of 0 or 1. The conditionalDeint() function then looks at that property and returns either orig or deint. FrameEval then takes the clip returned by conditionalDeint() and requests frame n from it, then returns that frame.
A better way to do this would be to make TDeintMod examine the "_Combed" property on its own, without involving Python and FrameEval. That's up to the author of TDeintMod, though.
Myrsloik
20th March 2015, 13:04
What is the source material? If it's truly interlaced you probably should process all of it and skip the FrameEval stuff.
TheFluff
20th March 2015, 13:35
Now what is this functools.partial in the FrameEval line ? Any more info about this would be nice.
It creates a partial function. :)
Let's say you have a function that takes two arguments, a and b:
def a_function(a, b):
do something with a and b
Now, if you figure that you want to call the function without explicitly specifying argument a. You create a partial function:
new_function = functools.partial(a_function, a_value_for_a)
Now you have a function called new_function, that, when called, will behave just as if you called a_function with the a argument being a_value_for_a. More importantly, new_function won't even have an a parameter, you can call it with only b.
In VS this is sometimes useful for passing a function as an argument to another function with extra parameters passed along.
jackoneill
20th March 2015, 16:58
Actually in the earlier releases, TDeintMod itself already contained the functionality of IsCombed, but got separated into another filter later on. The reason is, when users feed edeint with a clip that comes from a kinda slow upstream, like QTGMC for example, the frames from edeint are requested in arInitial state anyway, even though they are not used in the final arAllFramesReady state when the frames are detected as not combed, and the time is wasted.
That makes sense.
You could use fmUnordered and only request frames from edeint when they're needed:
if (activationReason == arInitial) {
// request n from IsCombed()
} else if (activationReason == arAllFramesReady) {
if ((intptr_t)(*frameData) == 1) {
// get n from edeint and return it
} else {
// get n from IsCombed()
if (!_Combed)
// return n
else
// request n from edeint
*frameData = (void *)1;
}
}
Pat357
20th March 2015, 18:58
Thanks for the for all your reactions !
After re-reading the things you all mentioned here, I think I now understands how it works.
I can't accept it for myself to use a script that I don't fully understand :-)
Thanks again to all !
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.