Log in

View Full Version : SetMTmode, tdeint, ffd3dfilter and derainbow causes a crash


MadRat
1st July 2010, 09:22
Now that I have a processor with 6 cores and threads, I've starting trying to use MT, the multi-threading plug-in and version of avisynth. My usual script template looks something like this but without the SetMTMode line:


SetMTmode(2,0)
MPEG2Source("E:\MyVideos\300.d2v")

# Inverse Telecine
interp = nnedi2(field=-2)
tdeint(mode=2,edeint=interp)
TDecimate()

# Restore the color pallet, resize & crop
ColorMatrix(mode="Rec.709->Rec.601")
BilinearResize(704,480,24,2,-4,-6)

# Denoise
#~ vf=last.mvanalyse(pel=2,blksize=8,isb=false,idx=1,overlap=4,sharp=2,truemotion=true)
#~ vb=last.mvanalyse(pel=2,blksize=8,isb=true,idx=1,overlap=4,sharp=2,truemotion=true)
#~ vf2=last.mvanalyse(pel=2,blksize=8,isb=false,idx=1,delta=2,overlap=4,sharp=2,truemotion=true)
#~ interleave(\
#~ mvcompensate(last,vf2,idx=1,thSCD1=600)\
#~ , mvcompensate(last,vf,idx=1,thSCD1=600)\
#~ , last\
#~ , mvcompensate(last,vb,idx=1,thSCD1=600))
#~ FFT3DFilter(sigma=1.7, bt=5, bw=8, bh=8, ow=4, oh=4, sharpen=1.0)
#~ selectevery(4,2)

# Derainbow
strength = 1 # <-- 1 through 10
FFT3DFilter(plane=3, bt=3, sigma=3, sigma2=3, sigma3=strength, sigma4=3)
mergechroma(AddBorders(4, 0, 4, 0).awarpsharp(depth=20.0, thresh=0.75, blurlevel=2, cm=1).Crop(4,0,-4,0))

# Sharpen
LSFmod()

# Dehalo & remove edge noise
dehalo_alpha(darkstr=0)
EdgeCleaner(64)

# Deband
gradfunkmirror()


I use it on Hauphauge WinTV-PVR 150 TV captures (which are supposed to be directly compatible with DVD) because I get lots of noise, rainbowing and color bleeds. As it is above, it works. If I uncomment the denoise section I get a crash. If I comment out the inverse telecine and derainbow, then I can uncomment denoise and it's fine.

Why doesn't it work? Is there a way to get it all to work all at the same time? I've already tried taking out the fft3dfilter type of derainbow and using tcomb right after mpeg2source but that crashed. I've tried other setMTmode settings (2,3,4 and 5) and it still crashed. I tried using fft3dfilter denoise without motion compensation but that crashed too. I'm open to using other filters and any suggestions on how this script could be improved, speed and/or quality wise would also be appreciated.
:thanks:

um3k
1st July 2010, 14:25
Try commenting out LSFmod and see what happens. I seem to vaguely recall it having some kind of issue with SetMTMode.

MadRat
1st July 2010, 17:56
Thanks um3k, but it still crashes.

johnmeyer
2nd July 2010, 20:55
Try changing this:SetMTmode(2,0)
MPEG2Source("E:\MyVideos\300.d2v")

to this:SetMTmode(5)
MPEG2Source("E:\MyVideos\300.d2v").killaudio()
SetMTmode(2,0)

I have been told by several senior members on the board that the killaudio() command will not solve the problem and that using it is urban legend. However, try it. The other thing in the above code is to not go to multiple cores until after you have fetched the clip.

MadRat
3rd July 2010, 07:40
As a temporary work-around I commented out all lines other than the first two, the inverse telecine, color adjustment and resize. After that, I saved to a lossless AVI file using Lagarith. I then replaced MPEG2Source with AVISource and reversed the commented lines so that denoise, derainbow, sharpen, dehalo, edge cleaner and debanding were active and uncommented, everything else was commented out. It crashed. I read your message and put in killaudio and... it worked. Therefore the myth is...

Plausible

However, when adding killaudio to the original script and uncommenting everything it crashed.

Now when you say:


The other thing in the above code is to not go to multiple cores until after you have fetched the clip.

What do you mean? Could you explain further?

johnmeyer
3rd July 2010, 08:16
What do you mean? Could you explain further? I am referring to the SetMTMode(5) and SetMTMode(2,0) lines. You turn off multi-threading to start with (SetMTMode(5)), then get your clip (AVISource, or whatever), and then enable one of the multi-threaded modes, in your script that is mode 2, with maximum number of cores (which is set by using "0" as the second parameter).

Blue_MiSfit
3rd July 2010, 08:17
DGDecode/MPEG2Source is not a thread-safe decoder.

In other words, if you try to multithread it, it's liable to break.

SO, by beginning the script with SetMTMode(5), we tell avisynth "don't use multiple threads yet".

After loading the source, we can SetMTMode(2), since we're assuming filters AFTER MPEG2Source are (more) thread-safe, and are demanding enough to benefit from multiple threads.

Derek

Gavino
3rd July 2010, 10:30
SetMTmode(5)
MPEG2Source("E:\MyVideos\300.d2v").killaudio()
SetMTmode(2,0)

I have been told by several senior members on the board that the killaudio() command will not solve the problem and that using it is urban legend.
Especially in the case of MPEG2Source, which doesn't even have audio to start with. :)

It's interesting that MadRat found it helped with AVISource, although in fact the source clip used (since produced from the earlier script) did not have audio either. I continue to believe it's not 'killaudio' as such that helps, it's just that random crashes will often come and go when you make random changes to the script.

On the other hand, there are sound technical reasons to use SetMTMode(5) for source filters.