View Full Version : VirtualDub's internal sharpen
TCmullet
23rd May 2024, 02:25
I've done searches any way I can think of but cannot find any documentation on VirtualDub's internal sharpen filter. I'd like to see an Avisynth filter created that EXACTLY matches Vdub's sharpen. Reason: I've been very pleased with Vdub's sharpen, especially at high settings, and would like to see the exact algorithm (including the possible values of the input parameter) implemented in Avisynth. I haven't found any Avisynth sharpening filter that even claims "this does exactly what the Vdub internal sharpener does". (If I've missed it, please forgive me and direct me there.)
Guest
23rd May 2024, 07:05
I've done searches any way I can think of but cannot find any documentation on VirtualDub's internal sharpen filter. I'd like to see an Avisynth filter created that EXACTLY matches Vdub's sharpen. Reason: I've been very pleased with Vdub's sharpen, especially at high settings, and would like to see the exact algorithm (including the possible values of the input parameter) implemented in Avisynth. I haven't found any Avisynth sharpening filter that even claims "this does exactly what the Vdub internal sharpener does". (If I've missed it, please forgive me and direct me there.)
Hi TC, it's me again.
I did a quick search and found this info (but it's SO old)
https://virtualdub.org/virtualdub_filters.html
http://avisynth.nl/index.php/WarpSharp
WarpSharp
Sharpening filter like VirtualDub's WarpSharp.
https://forum.doom9.org/showthread.php?t=31775
https://rationalqm.us/board/search.php?keywords=warpsharp
There's probably some good options with Dogways SMDegrain, too.
PS:- You still haven't sent me that VHS sample :(
TCmullet
23rd June 2024, 03:41
Hi TC, it's me again.
I did a quick search and found this info (but it's SO old)
Thanks for trying (by giving links to info about Warpsharp), but the sharpener in Vdub is NOT Warpsharp. If it was, I'd be able to make Warpsharp work just like the Vdub sharpener.
As it's been a month and NO ONE here appears to know the answer, I guess I may have to track down the Vdub 2 author and ask HIM. If the Vdub sharpener is the equivalent of some existing Avisynth filter, I'd REALLY like to know. I haven't found it yet myself.
wonkey_monkey
23rd June 2024, 15:00
Looks like it's applies a 3x3 convolution:
-v -v -v
-v 256+8v -v / 256
-v -v -v
where v is the input parameter (0-64).
Try:
function VDSharpen(clip c, int v) {
minus_v = String(-v) + " "
center = String(256+8*v) + " "
conv = minus_v + minus_v + minus_v + minus_v + center + minus_v + minus_v + minus_v + minus_v
return c.GeneralConvolution(0, conv)
}
after converting to an RGB colourspace.
TCmullet
28th June 2024, 22:31
Thanks, Wonkey. I will try this. How did you find out that this was the algorithm in Vdub?
I was hoping to figure out how it works, but the link to what "general convolution" is, is dead.
And do you think this will be close to just as fast as the Vdub built-in?
Also, why can't I have the clip in YV12 (or something other than RGB)?
Reel.Deel
29th June 2024, 01:20
...but the link to what "general convolution" is, is dead.
archived: https://web.archive.org/web/20120802031716/https://jeanbruenn.info/2011/03/13/avisynths-convolution-stuff-explained/ - check the the updated docs page https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/convolution.html
poisondeathray
29th June 2024, 01:38
And do you think this will be close to just as fast as the Vdub built-in?
vdub's built in sharpen is single threaded . If you use multithreading in avs+ (prefetch(some value)) it will be faster if you have the HW resources. A quick test for me was about 3-4x faster on a 4c/8t using vdub's video analysis pass. But if you have other bottlenecks in your workflow (e.g other slow filters, slow encoding settings) the difference might be smaller
Also, why can't I have the clip in YV12 (or something other than RGB)?
vdub's internal sharpen filter works in RGB . If you checkmark "show image formats" in the filter dialog box, vdub will show you the pixel format used between filters
You can also check the vdub code from sourceforge in the VFSharpen.cpp file
TCmullet
29th June 2024, 01:56
vdub's internal sharpen filter works in RGB . If you checkmark "show image formats" in the filter dialog box, vdub will show you the pixel format used between filters
You can also check the vdub code from sourceforge in the VFSharpen.cpp file
The image formats does make "RGB32" pop up. But I won't be using Vdub's. I'll be using the Avisynth function Wonkey created. What would happen if I didn't convert the clip to RGB before calling it (then converting it back to the clip's native colorspace)? Simply not work? Blow up? Turn the image to garbage? Scramble the colors? I don't see in the convolution function any reference to colorspace restriction.
Edit: OH, I see the original doc DOES say "RGB32" only. However the updated docs say "all color formats supported". So, I DON'T need to convert to RGB?
"What would happen if I didn't convert the clip to RGB before calling it (then converting it back to the clip's native colorspace)? Simply not work? Blow up? Turn the image to garbage? Scramble the colors?"
Digital convolution is relative to sampling frequency.
If you apply same convolution to YV12 3 channels (4:2:0) you will got somehow thicker/oversharpened chroma (also with ugly lossy 4:2:0 format it will increase distoritions). 3x3 kernel is applied to high enough frequencies only (fine details). But UV in 4:2:0 is half-banded so fine-chroma processing mean 2x size of fine luma details and 2x bigger.
Possible solutions with YUV 4:2:0:
1. Apply sharpening to Y plane only (will not increase chroma noise also).
2. Adjust kernel param between Y and UV planes to make oversharpening of UV planes lower.
3. Design different kernel for UV planes and apply with different param. 3x3 expected to be not fine and 5x5 or 7x7 may act better.
Perfect matching between RGB and subsampled YUV sharpening looks like not possible. Also because of design defects of sub-sampled chroma formats.
Also I not sure if applying sharpness to RGB and YUV spaces even in 4:4:4 is equal by design at all. (require testing in AVS).
"Looks like it's applies a 3x3 convolution:"
GeneralConvolution() is possible to be used as sharpener but not very easy. Also I found some changes in the AVS kernel processing between 201x years and 202x years AVS+ releases so my old adjusted kernels for GeneralConvolution() stop working as expected. User may need to play with 'auto' param too. See https://github.com/AviSynth/AviSynthPlus/issues/343 .
" I'd like to see an Avisynth filter created that EXACTLY matches Vdub's sharpen. "
Because GeneralConvolution approach may be unstable (in param adjustments range also) - best solution is simply make a plugin for RGB processing using virtualdub function.
wonkey_monkey
29th June 2024, 16:20
Thanks, Wonkey. I will try this. How did you find out that this was the algorithm in Vdub?
I had a look in the VirtualDub source code and found what looked like the 3x3 convolution table it uses.
I would convert to 32-bit Planar RGB, apply the filter, and then convert back again. You could also try YUV444.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.