Log in

View Full Version : NNEDI - intra-field deinterlacing filter


Pages : 1 2 3 [4] 5

Raere
5th April 2008, 02:33
This might have been answered in one form or another, but I couldn't get the exact syntax...

I'm trying to replace EEDI2 with NNEDI with megui's "TIVTC + TDeint(EDI)" because it says my source is hybrid film/interlaced - mostly film.

The code is


edeintted = AssumeTFF().SeparateFields().SelectEven().EEDI2(field=-1)
tdeintted = TDeint(edeint=edeintted,order=1)
tfm(order=1,clip2=tdeintted).tdecimate(hybrid=1)

I can't just replace EEDI2 with NNEDI because it complains about having a different resolution. I think I need to put PointResize in there somewhere, but I'm not sure.

TheRyuu
5th April 2008, 13:39
This might have been answered in one form or another, but I couldn't get the exact syntax...

I'm trying to replace EEDI2 with NNEDI with megui's "TIVTC + TDeint(EDI)" because it says my source is hybrid film/interlaced - mostly film.

The code is


edeintted = AssumeTFF().SeparateFields().SelectEven().EEDI2(field=-1)
tdeintted = TDeint(edeint=edeintted,order=1)
tfm(order=1,clip2=tdeintted).tdecimate(hybrid=1)

I can't just replace EEDI2 with NNEDI because it complains about having a different resolution. I think I need to put PointResize in there somewhere, but I'm not sure.

nnedi doesn't double the height like eedi2 did so leave out the separatefields and selecteven call.

Raere
5th April 2008, 13:43
nnedi doesn't double the height like eedi2 did so leave out the separatefields and selecteven call.

Thanks! That works.

g_aleph_r
11th April 2008, 13:41
I actually have a new version ready, I just need a free day to update the code.
I would like to test it to see if I can use nnedi to upscale to 1080p in realtime on 8800GT, and q6600
It would be veery nice

Leak
11th April 2008, 15:44
I would like to test it to see if I can use nnedi to upscale to 1080p in realtime on 8800GT, and q6600
It would be veery nice
Somehow I've got the feeling that you'd rather need a small miracle than the above hardware for that to happen...

np: The Orb - DDD (Dirty Disco Dub) (The Dream)

g_aleph_r
3rd May 2008, 07:42
Somehow I've got the feeling that you'd rather need a small miracle than the above hardware for that to happen...

np: The Orb - DDD (Dirty Disco Dub) (The Dream)
Always hope :D
BTW: CUDA is a miracle :cool:

Terka
3rd May 2008, 09:47
when new version will be ready?

g-force
5th May 2008, 15:48
tritical,

We can't wait for the update! Hoping it comes soon.

-G

Mug Funky
6th May 2008, 11:33
ssssh! don't you know it's not at all polite to ask someone how their thesis is going? :)

g-force
6th May 2008, 16:40
oops! sorry, tritical. Hope the thesis is going well!

-G

Adub
6th May 2008, 18:00
Congrats on the Netflix problem!

JP06
8th May 2008, 09:08
I can't seem to make NNEDI work with yadifmod. This is the code I'm using:


AviSource("Deint.avi")
loadplugin("D:\Video\AviSynth 2.5\plugins\nnedi.dll")
loadplugin("D:\Video\AviSynth 2.5\plugins\yadifmod.dll")
ConvertToYUY2()
AssumeBFF()
interp = nnedi()
yadifmod(edeint=interp)


It runs, but the output is the plain yadif output. When run alone, NNEDI works fine.

Terka
8th May 2008, 15:42
hi Tritical,
regarding deinterlace using nnedi:
is it possible to add to nnedi if statement like this:
if object with horizontal shape appers, new line is computed either from above,
either from below line(s).
b,w-known (different colors), ?-to be computed

bbb
???
bbb
???
www
???
www
---------------
bbb
???
bbb
bbb
www
???
www

OR

bbb
???
bbb
www
www
???
www

is it possible to decide the color from neibour frames?
this will avoid flickering after deinterlace. (instead of lines with width 1 pixel)

puddy
8th May 2008, 22:08
I'm working with NTSC 29.97 camcorder interlaced video captured at 720x480 compressed YUY2 huffy. I'm seeing my encoding speed drop to less than a quarter of what it was before using NNEDI.

Here's my original yadif only AVS (CCE SP2 Speed = .20):
Setmemorymax(768)
Load_Stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")

AviSource("G:\VideoCapture\cam1.avi")
Trim(14,19527)+Trim(19534,20380)+Trim(20523,27914)+Trim(28672,110689)

assumetff()
Crop(0,8,-16,-8,True)

yadif(mode=1, order=1)
HDRAGC(coef_gain=.5,max_gain=1,min_gain=0,black_clip=.1,reducer=2,max_sat=1.3)
FFT3DGPU(sigma=4, bt=3, bw=32, bh=32, ow=16, oh=16, sharpen=1.5, interlaced=false)

assumetff()
separatefields().selectevery(4,0,3).weave()

AddBorders(8, 8, 8, 8, $000000)

FadeOut2(55)
FadeIn2(55)


Here's my yadifmod+nnedi AVS (CCE SP2 Speed = .04):
Setmemorymax(768)

AviSource("G:\VideoCapture\cam1.avi")
Trim(14,19527)+Trim(19534,20380)+Trim(20523,27914)+Trim(28672,110689)

assumetff()
Crop(0,8,-16,-8,True)

yadifmod(mode=1, order=1, edeint=nnedi(field=-2))
HDRAGC(coef_gain=.5,max_gain=1,min_gain=0,black_clip=.1,reducer=2,max_sat=1.3)
FFT3DGPU(sigma=4, bt=3, bw=32, bh=32, ow=16, oh=16, sharpen=1.5, interlaced=false)

assumetff()
separatefields().selectevery(4,0,3).weave()

AddBorders(8, 8, 8, 8, $000000)

FadeOut2(55)
FadeIn2(55)

Notice my sig, I have an HT processor. Using default nnedit settings it starts two threads on my machine. If I force it to use just one thread and make sure it is using SSE I don't see any change in speed:

yadifmod(mode=1, order=1, edeint=nnedi(field=-2, threads=1, opt=2))

I've also tried 2 Threads + SSE = same

Am I missing something because other have eluded that using nnedi was at least as fast if not faster.

I've been at this for several years now but still feel like a newbie sometimes...

Thanks so much!

Leak
8th May 2008, 22:45
Am I missing something because other have eluded that using nnedi was at least as fast if not faster.
Using NNEDI was as fast as what?

Tar? Molasses? Glacial migration?

Sorry, NNEDI is just about the definition of slow. It's got the quality to justify it, though...

(The "NN" in NNEDI stands for neural networks, if you didn't know - running those chews a lot of CPU...)

np: Kettel - Peeksje 1994 (My Dogan)

R3Z
9th May 2008, 03:05
Using NNEDI was as fast as what?

Tar? Molasses? Glacial migration?



:D I had a chuckle.

Adub
9th May 2008, 05:37
It's not THAT slow. I can get almost realtime usage out of it. I have seen a lot worse.

Leak
9th May 2008, 11:17
It's not THAT slow. I can get almost realtime usage out of it. I have seen a lot worse.
Whoa... so what supercomputer did you use to accomplish that feat, if I may ask?

np: DJ Koze - Brutalga Square (Speicher CD2)

thetoof
9th May 2008, 15:19
I can "accomplish that feat" too (almost realtime) and I've got a q6600, 2x 2GB DDR2 RAM and 8800 GTS.

jeffy
9th May 2008, 15:53
I can "accomplish that feat" too (almost realtime) and I've got a q6600, 2x 2GB DDR2 RAM and 8800 GTS.
Could you please tell us what's in the script that runs almost realtime? The source is in MPEG-2 or MPEG-4 format, SD or HD?
Does it really mean (cough) almost 30 fps? Does it use MT?
What exact NNEDI setting is used?
Thank you.

Terka
9th May 2008, 21:46
Tritical, is it possible to modify nnedi be temporal too?

Adub
10th May 2008, 07:49
Yep, I am running an E6600 with 3gb ram. It runs fine. Note: this is with SD sources.

thetoof
12th May 2008, 03:09
MPEG-2 720x480 source, nnedi alone, default parameters, 90-100% cpu usage (multithreading is used even without MT() or SetMTMode()), 165MB RAM, 175 MB virtual memory, 20-30 fps

Undead Sega
2nd June 2008, 21:18
how is running NNEDI on a GPU going? i would really want to see that happen very soon :D

especially MCBob, i need to use that filter for a 7mins 100fps video! :(

g_aleph_r
15th June 2008, 13:37
how is running NNEDI on a GPU going? i would really want to see that happen very soon :D
Me too!!:thanks:

pitch.fr
12th July 2008, 14:14
(The next topic could be: "How to implement the zoom filter used in the CSI TV-series?")

that's something I would also like to know :)

this script looks really good, but I don't succeed to get the same results on very ugly videos than with this PS script(to be used in MPC) :


// +deinterlace (blend).txt=ps_3_0
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);

#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])

#define PI acos(-1)

float4 main(float2 tex : TEXCOORD0) : COLOR
{

float2 h = float2(0, one_over_height);
float4 c1 = tex2D(s0, tex-h);
float4 c2 = tex2D(s0, tex+h);
float4 c0 = (c1+c2)/2;

return c0;
}

on videos full of combing artefacts, this script does miracles :eek:

any idea how to get the same results with AVS ?

thanks,

Leak
12th July 2008, 19:39
any idea how to get the same results with AVS ?
Bob().ConvertFPS(last.framerate)
You might probably want to replace Bob with something more advanced like LeakKernelBob (okay, I'm biased... :p) or something.

But why not simply apply bobbing on playback? That gives you the full temporal resolution instead of the above blended mess at half the temporal resolution...

(ffdshow will happily apply a KernelBob on playback - for best results set your monitor's refresh rate to an integer multiple of the produced framerate, i.e. 48, 50 or 60 Hz according to your source...)

np: Underworld & Gabriel Yared - Happy Toast (Breaking & Entering OST)

pitch.fr
12th July 2008, 23:35
thanks for the tip, but I've already tried all the ffdshow deinterlacers(including yours), and none of them appealed to me.

I'm talking about "artefacts" due to poorly or non-interlaced heavily interlaced videos.

these combing effects have no pattern, they are just erratic.

the MPC PS script I posted above literally does miracles on such poorly encoded AVI's or MPEG files :eek:

just looking for something just as powerful at this point.......and I can't find something that does miracles like this in ffdshow or AVS :(

Didée
13th July 2008, 00:35
I'm not used to read such pixelshader code, but it seems it's simply replacing each pixel with the average of its top & bottom neighbor?

Blur(0,1)

Ah, the miracle.

Leak
13th July 2008, 00:41
I'm talking about "artefacts" due to poorly or non-interlaced heavily interlaced videos.
"non-interlaced heavily interlaced videos" :confused:

If you mean interlaced videos that have been resized without proper handling so the interlaced frames got smeared together - do yourself a favour and throw them into the recycle bin; they're well beyond repair...

If that's not what you meant - could you perhaps post a sample?

np: The Cinematic Orchestra - Child Song (Live At The Royal Albert Hall)

pitch.fr
13th July 2008, 00:59
yes I mean interlaced video that were resized w/o deinterlace in the first place(quite common on old avi's).

they look ugly....they really do :)

but this PS script can almost fix them up perfectly..........it looks a lot less blurry than the ffdshow "linear blending" filter.

I've tried the nnedi AVS script that was posted on 1st page, it can prolly be improved by messing around with the parameters ?!

thanks for your help anyway ;)

pitch.fr
13th July 2008, 01:00
I'm not used to read such pixelshader code, but it seems it's simply replacing each pixel with the average of its top & bottom neighbor?

Blur(0,1)

Ah, the miracle.

thanks, I've tried that......didn't look too good

pitch.fr
13th July 2008, 20:03
actually I've been told by a PS coder that "GeneralConvolution ( 0, "0 1 0 0 0 0 0 1 0" )" would do the same as my script.

too bad this only works in RGB32, and converting in RGB32 is not multi-threaded and very slow in AVS......besides it's got "Chroma upsampling" problems, as shown here :
http://forum.doom9.org/showpost.php?p=1158550&postcount=9

any idea how to achieve this in YV12 ? :D

Didée
13th July 2008, 20:18
That can be done with MaskTools, it's a one-liner:

mt_luts(last,last,mode="average",pixels="0 -1 0 1",expr="y",Y=3,U=3,V=3)

However, you must be aware that this is NOT a general solution for progressively resized interlaced content. The exact appearance of such mistreated footage depends on the ratio OldHeight/NewHeight, and on the used resampling algorithm. The result of such mistreatment may be anywhere from something that looks almost like "correct" interlacing (i.e. still very thin miceteeth) - this is where this filtering might work okay - up to horrible, very very thick vertical bands, where this kind of filtering will have ZERO positive effect.

It's not a "magic" solution. It's a primitve filter that sometimes happens to do something useful, if you're lucky enough that the destruction is not all too severe.


Edit: corrected the pixel map in mt_luts(), there was an error in it.


Example for a case where this doesn't work out:

http://img166.imageshack.us/img166/7283/itaintworkbk6.jpg (http://imageshack.us)
(left - progressively resized interlaced content -- right: your "solution")

pitch.fr
13th July 2008, 20:33
oh my.....Didée you really are a life saver :)

I'm already totally sold on LSF in ffdshow in realtime, it makes the picture so much sharper....without any visible artefacts :)

this is too slow for realtime use and MT("mt_luts(last,last,mode="average",pixels="0 -1 0 0 0 1",expr="y",Y=3,U=3,V=3)",2) is giving an error msg that it's missing some "" ?!

and for interlaced WMV's with remaining combing artefacts, what would be a more suitable formula then ?

thanks again,

Didée
13th July 2008, 20:44
Note I edited my post above.

And, for the problem you're dealing with,

there is NO general solution.

("Generally", it is *impossible* to repair such defects.)

pitch.fr
13th July 2008, 20:57
well I still get an error msg that it's missing "" on :
MT("mt_luts(last,last,mode="average",pixels="0 -1 0 1",expr="y",Y=3,U=3,V=3)",2)

actually I've got some interlaced WMV's that are supposed to be deinterlaced by the WMV decoder, but it does a pretty poor job.

what would be a good AVS solution for this kind of regular combing ?

Didée
13th July 2008, 21:04
You probably need to put triple quotes: MT("""mt_luts(....)""",2)

pitch.fr
13th July 2008, 21:13
great thanks! I didn't know you could need so many """ :D

well that seems to work pretty well, but it's too slow for realtime use in ffdshow...

oh well I'll stick to EVR with this PS script I guess ;)

Didée
13th July 2008, 23:03
Just for the record, in this case here one can use the faster mt_edge() instead of mt_luts() :

mt_edge("0 1 0 0 0 0 0 1 0",0,255,0,255,Y=3,U=3,V=3)

(mt_edge is limited to a 3x3 kernel, which is sufficient here. For 3x3, it can be used like general_convolution.)

pitch.fr
14th July 2008, 00:10
ahhh, still too slow for realtime use in ffdshow.

it's already a miracle that the spline36 version of LSF works in realtime in ffdshow, AVS was really not meant for realtime use in the first place :(

and anyway what I find amazing in LSF is that it sharpens the motion blur, this is really impressive...especially when running Reclock :D

IanB
14th July 2008, 02:02
If you want fast, try this
Merge(Crop(0, 2, 0, 0), Crop(0, 0, 0, -2))Sure it loses a line top and bottom, but...

pitch.fr
14th July 2008, 10:04
thanks for the tip IanB, but this requires "splitvertical=true" in MT, and then it ruins the AR....I'll stick to the PS script I think :D

IanB
14th July 2008, 14:36
@pitch.fr,

You are wasting your time with MT on any filter that has the speed near that of a frame BitBlt operation, Merge(0.5) is almost as fast as a BitBlt. MT does a BitBlt operations to assemble all the final results pieces, so you get a net loss here. MT at best runs (Time(bitblt)+Time(filter)/Nprocessors) so to win Time(filter) > N/(N-1)*Time(bitblt)

If the loss of the top and bottom line is so catastrophic you could adjust this method:-T=StackVertical(Crop(0, 0, 0, 2), Last)
B=StackVertical(Last, Crop(0, Height()-2, 0, 0))
Merge(T, B)
Crop(0, 2, 0, 0)There are many variation on the theme.

And note the AR had not changed, you had just lost the top and bottom lines. There are lots of ways to compensate for or replace them.

pitch.fr
14th July 2008, 14:59
wow cool, you're right....MT actually slows things down in that case :eek:

it's very usable in realtime now, and I'd rather avoid missing horizontal lines because HR gives ghost lines when its built-in scaler is being used on ATi cards..

while I'm at it, do you know a way to run ConvertToRGB32() a bit faster ? like I dunno, multithreaded or only on Core0(considering Core1 is always busy decoding video)....or any other fast plugin to do that job ?

ffdshow is way faster than AVS to do YV12>RGB32 conversion.

thanks again!

IanB
14th July 2008, 15:19
Internally YV12>RGB32 is actually YV12>YUY2>RGB32 but there is no Cache between the 2 steps so if you are using SetMTMode you might get a small gain by explicitly doing the 2 steps so there is a cache between the 2 parts....
ConvertToYUY2(Interlaced=...)
ConvertToRGB32(Matrix=...)

pitch.fr
14th July 2008, 15:30
actually I was getting a script error until I did like Didee showed me :

MT("""ConvertToRGB32(matrix="rec709")""",2)

why so many quotes anyway ? :D

oh right, so I could let ffdshow convert to YUY2 and only convert to RGB32 in AVS....now we're getting somewhere :)

OTOH, I've saved this as SimpleDeinterlace.avsi :

function SimpleDeinterlace()
{
T=StackVertical(Crop(0, 0, 0, 2), Last)
B=StackVertical(Last, Crop(0, Height()-2, 0, 0))
Merge(T, B)
Crop(0, 2, 0, 0)
}

but when I do SimpleDeinterlace() in ffdshow, it says "invalid arguments to function Crop"....any idea please ?

sorry for the noobish questions :rolleyes:

Gavino
14th July 2008, 16:42
when I do SimpleDeinterlace() in ffdshow, it says "invalid arguments to function Crop"....any idea please ?
You need to do this:
function SimpleDeinterlace(clip c) {
c # sets 'last'
T=StackVertical(Crop(0, 0, 0, 2), Last)
...

Triple quotes are needed when a string literal is to include a quote character.

I suggest you spend some time studying the language basics (http://avisynth.org/mediawiki/Main_Page#AviSynth_Syntax).

Oh, and please use CODE, not QUOTE for code fragments here.

pitch.fr
14th July 2008, 17:21
ok will do, sorry! and thanks for the link and the fix :)

one last question if you don't mind.

LSF is doing some YV12 transformation in Avisynth, but it's mod4 in 2.57

latest AVS 2.58 RC2 is mod2 on YV12, but there's not MT modified version yet.

is there some trick to add black borders to always be mod4 before feeding LSF ?

TIA,

Underground78
14th July 2008, 17:55
Width (clip) : Returns the width of the clip in pixels (type: int).
Height (clip) : Returns the height of the clip in pixels (type: int).
Modulo operator : %

Here a silly example, AddBorders(width % 4, height % 4, 0, 0, color=color_pink) makes the last clip mod4 adding if necessary pink borders on the left and/or the top of the frame ... It's an example, you can surely do something really better (and you should) ... :p