PDA

View Full Version : how to use LimitedSharpenFaster with interlaced BFF ?


hydra3333
27th January 2010, 04:30
I'm not sure how to use LimitedSharpenFaster with interlaced BFF material ...

The script below is what I have far ... should LimitedSharpenFaster be on the whole unseparated clip like it is now, or should it be done separately on each field (I guess within the function) ? The result is fed into HCenc. Also, comment on whether this is the right way to go about using AGC with interlaced material would be appreciated.

AviSource("canon-mv920-file.avi", audio=false)
AssumeFPS(25)
AssumeBFF()
MDegrain1i2(doAGC=TRUE).LimitedSharpenFaster(smode=4,strength=100)
AssumeBFF()

function AGCiEmbedded(clip srcclp) {
inpclp = srcclp
#inpclp=inpclp.HDRAGC(coef_gain=1.0, coef_sat=1.0) # default. +coef_gain=brighter decrease to limit. +coef_sat=more saturation
#inpclp=inpclp.HDRAGC(coef_gain=0.1, coef_sat=1.0) # default. +coef_gain=brighter decrease to limit. +coef_sat=more saturation
#inpclp=inpclp.HDRAGC(coef_gain=0.2, coef_sat=1.0, corrector=0.8, reducer=2.0) # default. +coef_gain=brighter decrease to limit. +coef_sat=more saturation
#inpclp=inpclp.HDRAGC(coef_gain=0.2, min_gain=0.1, max_gain=1.0, coef_sat=1.0, corrector=0.8, reducer=2.0) # default. +coef_gain=brighter decrease to limit. +coef_sat=more saturation
#inpclp=inpclp.HDRAGC(coef_gain=0.2, min_gain=0.1, max_gain=1.0, coef_sat=1.0, corrector=0.8, reducer=2.0, black_clip=0.5) # default. +coef_gain=brighter decrease to limit. +coef_sat=more saturation
inpclp=inpclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0)
#inpclp=inpclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=1.0, corrector=0.8, reducer=2.0, black_clip=1.0)
#inpclp=inpclp.HDRAGC(coef_gain=0.1, min_gain=0.2, max_gain=1.0, coef_sat=1.0, corrector=0.8, reducer=2.0, black_clip=1.0)
return inpclp
}
function AGCiEmbedded_EvenOdd(clip srcclp) {
# Assume SEPARATEFIELDS HAS ALREADY BEEN DONE BEFORE THE CALL TO THIS FUNCTION
e=srcclp.SelectEven().AGCiEmbedded()
o=srcclp.SelectOdd().AGCiEmbedded()
return Interleave(e,o)
}
function MDegrain1i2(clip srcclp, int "blksize", int "overlap", int "dct", bool "doAGC") {
doAGC=default(doAGC,TRUE)
# AssumexFF() must have been done prior to calling this function or funny things happen
blksize=default(blksize,8) # # 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
overlap=default(overlap,4) # overlap value (0 to 4 for blksize=8) Must be even and less than block size
dct=default(dct,0) # use dct=1 for clip with light flicker
fields=srcclp.SeparateFields() # separate by fields
super = fields.MSuper(pel=2, chroma=true, sharp=2) # half-pixel accuracy of the motion estimation
backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
fields=fields.MDegrain1(super, backward_vec2,forward_vec2,thSAD=400,plane=4)
doAGC ? fields.AGCiEmbedded_EvenOdd() : fields
Weave()
}
Converttoyv12(interlaced=true)
SetPlanarLegacyAlignment(True)

I'm guessing that if LSF needs to be applied separately to fields, the right way would be to change the function header to
function MDegrain1i2(clip srcclp, int "blksize", int "overlap", int "dct", bool "doAGC", bool "doLSF") {
doAGC=default(doAGC,TRUE)
doLSF=default(doLSF,TRUE)

and add another line after the "doAGC ?" line like
doLSF ? fields.LSF_EvenOdd(smode=4,strength=100) : fields
and add another function

function LSF_EvenOdd(clip srcclp) {
# Assume SEPARATEFIELDS HAS ALREADY BEEN DONE BEFORE THE CALL TO THIS FUNCTION
e=srcclp.SelectEven().LimitedSharpenFaster(smode=4,strength=100)
o=srcclp.SelectOdd().LimitedSharpenFaster(smode=4,strength=100)
return Interleave(e,o)
}

yup
27th January 2010, 07:16
Hi hydra3333!
Use bober, I prefer nnedi2, use sharpener and after reinterlace. also I make denoise on bobed frame, You spent more time, but result little better.
yup.

hydra3333
27th January 2010, 07:49
Let's see, does that mean deinterlace the BFF interlaced clip to double-framerate progressive so as not to lose anything, denoise etc, then re-interlace back to original framerate and BFF ?

If you have one, I'd value an example of nnedi2 to do that and also re-interlacing the double-framerate back to the BFF interlaced.

It's a mate's trip to Switzerland, on a number of 4:3 Canon DV tapes. I suppose I should look over on the DV sub-forum too.

hydra3333
27th January 2010, 10:32
Hi yup, I read in other threads that this may be a way but I don't know how to use nnedi2 in it or even if that'd be a good thing to do ...

AssumeBFF()
# deinterlace to double framerate
edi=separatefields().eedi2(field=-2) # field=-2 alternates each frame, uses avisynth's internal parity value to start # eedi2 from http://bengal.missouri.edu/~kes25c/
YADIFmod(order=-1,mode=1,field=-1,edeint=edi) # YADIFmod from http://bengal.missouri.edu/~kes25c/

#do denoising and AGC and stuff here
blksize=8 # 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
overlap=4 # overlap value (0 to 4 for blksize=8) Must be even and less than block size
dct=0 # use dct=1 for clip with light flicker
super = MSuper(pel=2, chroma=true, sharp=2) # half-pixel accuracy of the motion estimation
backward_vec2 = super.MAnalyse(isb = true, delta = 1, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
forward_vec2 = super.MAnalyse(isb = false, delta = 1, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
MDegrain1(super, backward_vec2,forward_vec2,thSAD=400,plane=4)
HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0)
LimitedSharpenFaster(smode=4,strength=100)

# re-interlace back to BFF
SeparateFields().SelectEvery(4, 0, 3).Weave().AssumeBFF()
Any suggestions ?

I gather that if none of the denoising etc is performed, then after re-interlacing you have exactly what you started with.

davidhorman
27th January 2010, 11:46
Isn't it overkill to nnedi before denoising if you're only going to go back to interlaced afterwards? You're doubling the number of pixels that have to be processed, then deleting all the interpolated ones anyway - and the fact that they are interpolated means it's not "real" information, so you're better off just using the real pixels in the plain separated fields.

I'm under the impression that the way to do this, if you're doing any kind of temporal processing, is to separate to two clips - one of the even fields, and one of the odd fields, process them separately and then re-interleave and weave.

David

Didée
27th January 2010, 12:13
Speaking as generally as possible, sharpening is an invalid operation for interlaced content. Sharpening relies on a pixel's neighbors, and in interlaced content you have only 2 valid neighbors, where 6 neighbors are missing. The immediate neighborhood is missing, and the actually present (vertical) neighbors in fact are the over-next neighbors, which on their own are not reliable enough.

Take some progressive footage, and make a close comparison between "sharpen(1)" and "separatefields().sharpen(1).weave()". Then you'll see why sharpening interlaced content is evil.

yup
27th January 2010, 12:16
If Your target DVD? Yes!
I use folowing script for denoising and bobing
DirectShowSource("tape4ed.avi")
source=AssumeTFF()
noise=source.nnedi2(field=-2, threads=1)
supernoise = MSuper(noise)
backward_vec1=supernoise.MAnalyse(isb = true, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec1=supernoise.MAnalyse(isb = false, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec2=supernoise.MAnalyse(isb = true, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec2=supernoise.MAnalyse(isb = false, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec3=supernoise.MAnalyse(isb = true, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec3=supernoise.MAnalyse(isb = false, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
noise.MDegrain3(supernoise,backward_vec3,backward_vec2,backward_vec1,forward_vec1,forward_vec2,forward_vec3,thSAD=400,thSADc=400,plane=4)

Output 50 Hz bobed
And for sharpening
ConvertToYV12()
LSFmod(defaults="slow")
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
Weave()

Change AssumeTFF() to AssumeBFF() and use cedocida codec fo DV footage. for me this give little better than denoising and sharpening on fields.
yup

davidhorman
27th January 2010, 15:30
Take some progressive footage, and make a close comparison between "sharpen(1)" and "separatefields().sharpen(1).weave()". Then you'll see why sharpening interlaced content is evil.

Ah, right, I wasn't thinking of sharpening. For denoising purporses, though, shouldn't it be done on two separate streams of separated Then a later nnedi2 would have less noise to deal with when bobbing.

David

hydra3333
28th January 2010, 07:49
For denoising purporses, though, shouldn't it be done on two separate streams of separated Then a later nnedi2 would have less noise to deal with when bobbing.
Ah, do it in 2 steps then ?
i) denoise individual fields like in the 1st post
ii) deinterlace and sharpen
then re-interlace

What about the AGC ? Is it valid to do it on separated fields or must I do it on a deinterlaced clip ?

Alex_ander
28th January 2010, 10:00
Ah, right, I wasn't thinking of sharpening. For denoising purporses, though, shouldn't it be done on two separate streams of separated Then a later nnedi2 would have less noise to deal with when bobbing.


As for nnedi (and other single-field based bobbers), yes there is such a problem (making grain larger in vertical direction + specific artifacts in case the image itself is too sharp). I'd use another bobber (like LeakKernel) before processing but still wouldn't do it on separate fields.
Any spacial frequency filter (for sharpening, smoothing or noise suppression) has finite (non-zero) transient response. This means that some picture elements after correct filtering (like on progressive) will either move in vertical direction or modify vertically-adjascent pixels. If the same filtering is performed on separated fields, those moving parts (or influences) will a) modify pixels in wrong, more distant line (since adjascent line is missing) and b) this modification will most likely be based on data derived from wrong line(s). As a result, splitting of horizontal edges may occur (similar to resizing separated fields vertically). So bobbing before either sharpening or noise filtering is more safe. I always do so (after having compared the results) even with slow filters like NeatVideo, despite double processing time.

2Bdecided
28th January 2010, 11:23
I can't imagine that you'd get something from a DV camcorder that needs sharpening.

It may be soft looking, but I bet it's already got halos. Extra sharpening will likely make it worse, though LSF is least bad I suppose. You might have some nice footage, so I could be wrong.


When the content is interlaced, you can always sharpen horizontally without worrying about the interlacing. The built-in Sharpen() lets you do this. Not sure LSF can do this though.

Cheers,
David.

hydra3333
28th January 2010, 12:22
Ah. Will try it without sharpening then ...
i) deinterlace
ii) denoise
iii) agc
iv) re-interlace
and use setMTmode with 4 threads to make it seem less glacial. Hopefully SetMTmode(mode=2,threads=4) won't "interfere" with anything.

Does
AssumeBFF()
nnedi2(field=-2, threads=1)
yield more appealing results in some way than this ? Or is quicker or something ?
AssumeBFF()
edi=separatefields().eedi2(field=-2)
YADIFmod(order=-1,mode=1,field=-1,edeint=edi)