Log in

View Full Version : Recommended Sharpening Filter for YUY2 Video Source


Incast
19th July 2012, 00:22
Having done some searching tonight, I've found a great deal of information on avisynth sharpening filters. However, it is all very focused on anime sources in the YV12 colour space.

I am looking at some sports video broadcast footage from just over 10 years ago (576i MPEG2). The image itself is quite soft, but there is a fair amount of MPEG2 pixellation.

I am looking for a filter which:
1. Will Sharpen the image to a high standard with a minimal effect on the MPEG2 artifacts
2. Work in the YUY2 Colour Space (as I am using DGDecode's UpConv=1 I do not have the option to use the YV12 space)

Interlaced support would be beneficial but is not essential as I am separating the fields in the current processing steps before weaving at the end.

Can anyone offer any recommendations?

yup
19th July 2012, 08:05
Hi Incast!
Unsharp mask approach. I use for my VHS capture
ColorYUV(autogain=true, autowhite=true)
unsharp(varY=150,varC=150,strength=0.3)# tritical variableblur revision
tune strengtn and var.
last variableblur
http://bengal.missouri.edu/~kes25c/variableblur.zip
and last fftw
yup.

TheSkiller
19th July 2012, 10:55
Interlaced support would be beneficial but is not essential as I am separating the fields in the current processing steps before weaving at the end.Simply separating the fields, sharpening them and then weaving it back together is not too recommendable since like that the sharpener works on fields only. This will amplify ugly vertical contouring and give a generally poor sharpening result in the vertical direction. But it might be OK, it depends.

Better, but of course slower, is doing a bob-deinterlace (25i to 50p) so that the filters have a proper picture to work on and then, if needed, reinterlace it back to 25i.


For Deblocking see this thread (http://forum.doom9.org/showthread.php?t=165297). Deblock_QED should be used right after the source filter (which then should do no deblocking at all obviously, i.e. if you use MPEG2Source then make sure cpu=0).
And since your video is interlaced make sure you wrap Deblock_QED as seen in post #4 in the linked thread.


Edit: If you convert your YV12 source to YUY2 within the source filter then Deblock_QED won't work as it needs YV12.
However, there is no benefit from converting to YUY2 right at the start because your source already is YV12 anyway. If you really need YUY2 then add ConvertToYUY2() at the very end of the script.

Incast
19th July 2012, 19:43
:thanks: Many thanks for both of your suggestions, as a result of this I have:
1. Delayed YUY2 conversion until the end.
2. Installed variableblur to experiment with - the initial results look very impressive.

The content I have requires me to remain with interlacing.

Very much appreciate your help!

06_taro
20th July 2012, 01:56
In most cases you won't need to sharpen chroma (and actually most good sharpeners don't sharpen chroma), so it is simple to:
1. convert your YUY2 source to YV12
2. do the sharpening
3. convert it back to YUY2
4. merge chroma from the source clip
And there's no loss in chroma planes

E.g.,
src = ANY_SOURCE_FILTER() # YUY2
tmp = src.ConvertToYV12
tmp = tmp.ANY_SHARPENER() # sharpen Y plane

tmp.ConvertToYUY2
\ .MergeChroma(src)

TheSkiller
20th July 2012, 11:30
Yes but his source surely is YV12 as he says it's an MPEG2 broadcast.


The content I have requires me to remain with interlacing.Yes but I think you misunderstood me. Whenever people hear the "deinterlacing" part in the word "bob-deinterlacing" they think it's not adequate if they want to keep their video interlaced.

But the thing is, if you give your sharpener only fields and not full height frames it won't give very good results in the vertical direction.
To overcome this one can give something better to the sharpener/other filters to chew on by creating an intermediate progressive video inside your script and at the end you throw away the additional pixels the bob-deinterlacer has created to make it interlaced again, like the source, without deinterlacing losses. This is possible because bob-deinterlacing, unlike regular "single rate" deinterlacing, does not throw away anything the source originally had.

So you might want to try if something like this gives you better results:

YadifMod(mode=1, edeint=nnedi3(field=-2))

#[sharpener and other filters here...]

SeparateFields().SelectEvery(4,0,3).Weave()

Requires YadifMod and nnedi3 (http://forum.doom9.org/showthread.php?t=147695).

Incast
21st July 2012, 02:28
TheSkiller, you are absolutely correct - I didn't consider this as an option.

I've just downloaded those filters and put those into my script and I can see an immediate improvement previewing in Virtualdub. This is a truly fantastic suggestion - enormous thanks!

TheSkiller
22nd July 2012, 11:04
That's good to hear. :)

By the way, here's an advice regarding YUY2: if you need YUY2 then put ConvertToYUY2() right before the re-interlacing line (SeparateFields...).

If you put it after that, you would need to add interlaced=true because at that point the video is interlaced again. And as a consequence this would give less accurate YUY2 chroma. And without interlaced=true the chroma would get messed up and show ghosting because it's smeared between fields. The mean thing is, this is not easily noticed in VirtualDub's preview while looking at the interlaced video.