AVS Forum


Google™ Search AVS:

Go Back   AVS Forum > Video Components > Home Theater Computers



Reply
Forum Jump
 
Thread Tools
Old 11-13-04, 04:20 PM   #1   |  Link


Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Using Avisynth LimitedSharpen pre-processing with ffdshow for DVD playback!

I was perusing the Avisynth forum and read a post about a LimitedSharpen script for Avisynth that produces superior sharpening. Here is a blurb from that thread from Didée the LimitedSharpen author:

Quote:
LimitedSharpen() can be used like a traditional sharpener, but producing much less artefacts. It can be used as a replacement for the common "resize(x4)-XSharpen-resize(x1)" combo, with very similar results (perhaps even better) - but at least 2 times faster, since it requires much less oversampling. And by chaining several instances, it can even be used for something like a "[very] poor man's deconvolution" - but only if one knows how to battle the noise

What's the problem with "normal" sharpening?

Traditional sharpeners like sharpen() or UnsharpMask() compare each pixel against the average of its neighborhood, and emphasize the difference between them. The results (something like "per-pixel contrast enhancement") are good as long as the strength is kept low enough. But artefacts will arise very soon.
XSharpen, being a non-linear sharpener, replaces each pixel with either its darkest or brightest neighbor, depending on which is nearer in range. By the nature of the method, XSharpen produces edges with maximal possible aliasing (jaggyness). So one has either to reduce the percentage, thereby weakening the overall effect, or to work with big supersampling, which makes it both extremely slow and less effective.
After seeing some of the results some were getting using it in pre-processing I decided to see if it could be use in post processing via ffdshow for DVD playback. This is a powerful sharpening script but I found if you set its parameters low it could be used on the fly with one draw back at least for me and that is re-sizing. If I try to resize it becomes to slow and stutters so the before and after pics are original size.

Last edited by Socio; 11-13-04 at 04:41 PM..
Socio is offline   Reply With Quote
Old 11-13-04, 04:21 PM   #2   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
I found that using LimitedSharpen with Denoise3d and applying the Denoise prior to LimitedSharpen gives me the best results with between 53% &56% processor usage.

Here are some of my results so far what do you think?:

Empire Strikes BackNormal



Empire Strikes BackNormal with LimitedSharpen and Denoise3d



Episode 1 Normal



Episode 1 with LimitedSharpen and Denoise3d



Normal LOTR



LOTR with LimitedSharpen and Denoise3d


Last edited by Socio; 11-13-04 at 04:37 PM..
Socio is offline   Reply With Quote
Old 11-13-04, 06:07 PM   #3   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Here is a another before and after :


Pirates of the Caribbean Normal



Pirates of the Caribbean with limitedSharpen + denoise3dl



Open Range Normal



Open Range with limitedSharpen + denoise3dl



Open Range with limitedSharpen + denoise3dl with modified hue & saturation tweak See 5 posts down for explanation.


Last edited by Socio; 11-13-04 at 09:22 PM..
Socio is offline   Reply With Quote
Old 11-13-04, 06:50 PM   #4   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
Um how does this work? using a avisynth code in ffdshow? I knew you could proccess avs scripts using ffdshow.
Nightanole is offline   Reply With Quote
Old 11-13-04, 07:33 PM   #5   |  Link
imf4
Member
 
Join Date: Sep 2003
Location: Pittsburgh, PA
Posts: 174
I don't know if I like the effect. It seems to wash out the colors a little. None the less it is an interesting way of doing it.
imf4 is offline   Reply With Quote
Old 11-13-04, 07:54 PM   #6   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Quote:
Originally posted by Nightanole
Um how does this work? using a avisynth code in ffdshow? I knew you could proccess avs scripts using ffdshow.
Ok this will take a little work for you;

Assuming you already have ffdshow you will need to download Avisynth 2.55 and install it.

Next you will ned to download the pluginWarpsharp and the Masktools 1.5.4 if you have AMD or other non P4 processor or the Masktools for P4 dll for P4 users and install both the Warpsharp and masktool dll files in avisynth's plugin folder.

Now go to this
thread go to Didée's second post and copy the script starting at "# LimitedSharpen()"
Copy it to notepad then save it to your avisynth plugin folder and call it LimitedSharpen.avs and close notepad.

Open your ffdshow config and click on avisynth, in the text box enter these two lines:

Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)


Put a check in the avisynth box and you are set!

Oh and enable denoise3d and adjust to taste for best results!

NOTE: If you installed Avisynth some place other than C:\program files you will need to change the first line accordingly.

You can change the ss_x and ss_y parameters up to 2.0 but it will slow it down to a crawl, the smode choices are 1, 2, or 3 and strength can be set from 0 to 100. The way it is now is what I use.


NOTE: This works with the latest non-SSE SSE2 version of ffdshow it will give you a script error if you try it in the SSE-SSE2 versions.

Last edited by Socio; 11-13-04 at 08:33 PM..
Socio is offline   Reply With Quote
Old 11-13-04, 08:00 PM   #7   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Quote:
Originally posted by imf4
I don't know if I like the effect. It seems to wash out the colors a little. None the less it is an interesting way of doing it.
Yes, but you only really notice it in still captures watching it live I don't even notice it at all even looking for it, it's pretty subtle.

I have not tried it yet but you could probably adjust hue and saturation to compensate if it bothers you to much, I might experiment with that tomorrow if I have time.

Last edited by Socio; 11-13-04 at 08:34 PM..
Socio is offline   Reply With Quote
Old 11-13-04, 09:36 PM   #8   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
*Hue & Saturation tweak

As imf4 pointed out this uber sharping seems to wash out a bit of the color and the easiest way I could find to fix it was in ffdshow by enabling the "Picture Properties" and adjusting the Hue and Saturation to taste. Once fine tuned you should not need to adjust it again while using the Avisynth LimitedSharpening because it seems to remove the exact same amount of color no matter the source.

I did a quick experiment I bumped the Saturation from 64 to 78 and the hue from O to 2 and got the sharpened Open Range pic (see a few posts up) pretty close to the color in the original Open Range normal pic. It's not perfect, I will have to adjust a little more but once done it should be set for everything.
Socio is offline   Reply With Quote
Old 11-14-04, 11:02 AM   #9   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Update!

No Hue-Saturation tweak needed!

Re-Sizing in 100% doable!


First, I found that the color fading was due to using VMR9 as renderer in Zoomplayer I switched to Overlay as renderer and get zero color fade with a pristine image. So unless you insist on VMR9 NO tweaking of the Hue & Saturation is needed.


Second, Re-sizing is doable!

I have found the best way to re-size while using this sharpening method is to do it from within Avisynth and keep as much of the image processing as you can in one procedure. Because this Limitedsharpen takes some processing power it is better to resize after it has processed the image. You can add either of these lines after the LimitedSharpen call and change the size according to your needs;

BicubicResize(1280,720)
LanczosResize(1280,720)
Lanczos4Resize(1280,720)

All do a nice job with Lanczos4 giving you the best quality but taking the most processing power.

You can also try this resizing method during the sharpening process by including dest_x= and dest_y= in the LimitedSharpen call.

For example here is 1280x720 resize:

LimitedSharpen(ss_x=1.0,ss_y=1.0,dest_x=1280,dest_y=720,Smod e=3,strength=40)

Another thing you can to save some processing power is to crop before the LimitSharpen call by entering this line

crop(0,0,-0,-0,)
or
crop(0,0,-0,-0,true) The true parameter is supposed to make it a little faster I think?


Here is what I am using now with Avisynth in ffdshow for trimming the black borders and resizing to 1280x720 and it looks awesome!

Quote:
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

crop(8,8,-8,-8,true)
LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)
Lanczos4Resize(1280,720)

Last edited by Socio; 11-14-04 at 11:17 AM..
Socio is offline   Reply With Quote
Old 11-14-04, 01:13 PM   #10   |  Link
chenzhaoyi
Member
 
Join Date: Jun 2004
Posts: 78
why it always shows error:import:couldn't open C:\Program Files\AviSynth 2.5\plugins\avsfilter.vdf.avs
__________________
chen
chenzhaoyi is offline   Reply With Quote
Old 11-14-04, 01:45 PM   #11   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Quote:
Originally posted by chenzhaoyi
why it always shows error:import:couldn't open C:\Program Files\AviSynth 2.5\plugins\avsfilter.vdf.avs
What settings are you using?
What are you trying to import?

I have no such error and no such file in my Avisynth plugin folder.
Socio is offline   Reply With Quote
Old 11-14-04, 03:24 PM   #12   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
I get instant death and ie resets. Running 20041012 non sse ffdshow. the screen shows up and then the program crashes. I have the odd LimitedSharpen.avs copied to my avs plugin dir and the dlls and all the other junk that went with them.
Nightanole is offline   Reply With Quote
Old 11-14-04, 03:29 PM   #13   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
there is no function named " DEdgemask"

line 47


line47 =


edge = logic( tmp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=2)
\ ,tmp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=2)
\ ,"max").levels(0,0.86,128,0,255,false)
Nightanole is offline   Reply With Quote
Old 11-14-04, 03:38 PM   #14   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
tryed to add:

LoadPlugin("C:\Program Files\Avisynth 2.5\plugins\MaskTools.dll")
LoadPlugin("C:\Program Files\Avisynth 2.5\plugins\warpsharp.dll")


to the avs script and it just pitched a fit. either says unable to load or aception.
Nightanole is offline   Reply With Quote
Old 11-14-04, 04:34 PM   #15   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
First , all you need are the MaskTools.dll, warpsharp.dll, and the LimitedSharpen.avs, added to your plugin folder not the other stuff that came with the dll files you downloaded. They also have to be in the first folder not a sub folder.

What processor do you have P4? AMD? The Masktool dll will cause Zoomplayer to crash if you are using the wrong version.

Also, using Avisynth in ffdshow you do not have to load plugins it will load them automatically for you.
Socio is offline   Reply With Quote
Old 11-14-04, 04:48 PM   #16   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Update #2

VMR9 fix

Here is the fix for using VMR9 as your renderer and not having washed out color!

Just download the ColorMatrix Avisynth plugin and install just the Colormatrix.dll in the Avisynth plugin folder then add this parameter to your setting in Avisynth in ffdshow "ColorMatrix()".

This is what mine looks like now:

Quote:
[Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

crop(8,8,-8,-8,true)
LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)
ColorMatrix()
Lanczos4Resize(1280,720)
Here are a couple of non-resized pics using VRM9:

Normal




Using above settings except resize with VMR9 renderer


Last edited by Socio; 11-14-04 at 06:16 PM..
Socio is offline   Reply With Quote
Old 11-14-04, 04:52 PM   #17   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
Im running a dual xeon setup. Im not using the sse versions of ffdshow like you said. Im also runing avisynth 2.5.5. I have both dlls in the root plugins folder. For some reason they dont want to load.
Nightanole is offline   Reply With Quote
Old 11-14-04, 05:05 PM   #18   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Try this Masktools.dll I have a P4 and it works for me. Just make sure you delete the old one in your plugin folder.

I only have 7 files in my Avisynth plugin folder they are and should be all you need:

DirectShowSource.dll
LimitedSharpen.avs
TCPDeliver.dll
warpsharp.dll
ffavisynth.dll
MaskTools-p4-5.dll
ColorMatrix.dll

If you have any thing besides those remove them to a backup folder or delete them. You don't want ffdshow to try to load any thing oddball that could make it crash.
Socio is offline   Reply With Quote
Old 11-14-04, 05:30 PM   #19   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
That did it. thanks. Now i just have to figure out what its doing. it looks better, but i dont know why. Its not harshing the edges like unsharp mask used to do, but its also improving something else. Like its smoother or something, less edginess. Hell i cant tell anything from freeze frames. Its like explaining how dvi looks better then component, freeze frames look the same but dvi runs alot smoother.
Nightanole is offline   Reply With Quote
Old 11-14-04, 05:56 PM   #20   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Thumbs up

Awesome!

Love to see some pics!

You are alo right, the pics are good but seeing it live it is even a hole lot lbetter!

Remember to try Denoise3d with it but low settings or it will wash out some detail and see what you think.

Mine is set to: L:0 C:0.78 T:3.98 with HQ enabled.

You can also try these settings seems to be a bit more cleaner.

LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=2,strength=60)
Socio is offline   Reply With Quote
Old 11-14-04, 06:30 PM   #21   |  Link
Nightanole
Senior Member
 
Join Date: Aug 2001
Location: akron,ohio,usa
Posts: 399
SNiff sniff it doesnt work on dvds. Im not fast enough. I have to turn off denoise to get it to full speed. i have dual 2.6ghz, but its not smp compatible. Avi's work great though. Maybe ill try it with another decoder other then sonic.
Nightanole is offline   Reply With Quote
Old 11-14-04, 07:38 PM   #22   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
You can try Tom Barry's UnDot Avisynth plugin. Just instal it in to your plugin folder and add the UnDot() parameter to start of your settings should look like this, make sure to include the period;

UnDot().LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40 )

This is very light so it should not slow you down at all!
Socio is offline   Reply With Quote
Old 11-14-04, 08:40 PM   #23   |  Link
chenzhaoyi
Member
 
Join Date: Jun 2004
Posts: 78
Quote:
Originally posted by Socio
What settings are you using?
What are you trying to import?

I have no such error and no such file in my Avisynth plugin folder.

I had the odd LimitedSharpen.avs copied to my avs plugin dir and the dlls and all the other junk that went with them. now I delete all junk,it works,but the cpu
loaded 95% and i just use blurr and limitedsharpen,no resize! LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)
why?
__________________
chen
chenzhaoyi is offline   Reply With Quote
Old 11-14-04, 09:23 PM   #24   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Not sure,

Try not using the blur and use the Undot plugin in above post it takes much less procesing power, or just try it with out either and see what is does.

Make sure you are using nothing in ffdshow but avisynth and double check your settings, if ss_x=1.0,ss_y=1.0 are set to anything above 1.0 it will slow you down to a crawl.

What processor are you using?

One other thing to try, set your ffdshow blur before Avisynth in ffdshow. One thing I noticed on my setup was if I did any thing other than re-size after LimitedSharpen it would slow me down big time. Besides that doing any denoise after the sharpen would just degrade the sharpening anyway.

Last edited by Socio; 11-14-04 at 09:47 PM..
Socio is offline   Reply With Quote
Old 11-14-04, 09:44 PM   #25   |  Link
jpooton
Member
 
Join Date: Jun 2003
Location: Flathead Valley, Montana
Posts: 137
Very cool...

This really is an excellent sharpening technique. Very happy with the results I'm getting here. I've been playing with the settings so see how this all works. So far my favorite results have been using this combo:

TT2 w/ NV 4 codecs
NVPP (Film mode)
FFDSHOW (July 9th SSE AndyIEG version):
1) AVISYNTH:
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")
crop(0,0,-0,-0,true)
LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)
2) Resize: 1280x720 Lanczos4 w/ .6 chroma

For some reason doing the resize afterward in FFDshow is faster for me then in AVISYNTH. I'm am using this with the July 9th *SSE2 optimized* version of FFDshow from Andy. So maybe his optimizations are just that much better for the resize.

The filter does take some serious CPU power though. I would love to let it have at a 1280x720 input but that seems quite out of reach at this point w/ my 3.52 (OC'd) P4. Still messing with everything though. THANKS for the find...

-James

Last edited by jpooton; 11-14-04 at 10:16 PM..
jpooton is offline   Reply With Quote
Old 11-14-04, 10:00 PM   #26   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Re: Very cool...

Quote:
Originally posted by jpooton
I'm am using this with the July 9th *SSE2 optimized* version of FFDshow from Andy. So maybe his optimizations are just that much better for the resize.

The filter does take some serious CPU power though. I would love to let it have at a 1280x720 input but that seems quite out of reach at this point w/ my 3.52 (OC'd) P4. Still messing with everything though. THANKS for the find...

-James
You got the SSE2 version of ffdshow to work? I have tried it and all it would do is give me Avisynth script errors! I will have to give it a shot again.

I am running a P4 3.06 and can do 1280x720 nicely I am also using the latest reclock and it sems to help. I will post some re-size pics in a while I am still fine tuning my settings.

Glad you like it, It does need some processing power but the results live are remarkable.
Socio is offline   Reply With Quote
Old 11-14-04, 10:15 PM   #27   |  Link
jpooton
Member
 
Join Date: Jun 2003
Location: Flathead Valley, Montana
Posts: 137
Re: Re: Very cool...

Quote:
Originally posted by Socio
You got the SSE2 version of ffdshow to work? I have tried it and all it would do is give me Avisynth script errors! I will have to give it a shot again.
Yep... the July 9th version seems to work fine for me (that is what I already had in installed). BTW the "newer" 1012 SSE version did give me script errors you are talking about on another machine. Personally I get better results with Andy's version anyway, so that's what is on my htpc.

Quote:
Originally posted by Socio
I am running a P4 3.06 and can do 1280x720 nicely I am also using the latest reclock and it sems to help. I will post some re-size pics in a while I am still fine tuning my settings.
I should have been more clear above. I can (and am) resizing to 1280x720 after the AVISYNTH routines. I'd just love to see limited sharpen work on a 1280x720 input Reclock I haven't tried at this point. Things are smooth for me, just a somewhat heavy cpu load. It's there to be used though.

Quote:
Originally posted by Socio
Glad you like it, It does need some processing power but the results live are remarkable.
No doubt, it's a keeper!
jpooton is offline   Reply With Quote
Old 11-14-04, 11:42 PM   #28   |  Link
chenzhaoyi
Member
 
Join Date: Jun 2004
Posts: 78
Quote:
Originally posted by Socio
Not sure,

Try not using the blur and use the Undot plugin in above post it takes much less procesing power, or just try it with out either and see what is does.

Make sure you are using nothing in ffdshow but avisynth and double check your settings, if ss_x=1.0,ss_y=1.0 are set to anything above 1.0 it will slow you down to a crawl.

What processor are you using?

One other thing to try, set your ffdshow blur before Avisynth in ffdshow. One thing I noticed on my setup was if I did any thing other than re-size after LimitedSharpen it would slow me down big time. Besides that doing any denoise after the sharpen would just degrade the sharpening anyway.
AMD barton 2500+ oc 3200+,nvidia Ti 4200, I am using nothing in ffdshow but
avisynth,cpu still loaded 75%. ffdshow version 20041012 non sse.dscaler 5 decoder in zplayer,colourspace yv12.
__________________
chen
chenzhaoyi is offline   Reply With Quote
Old 11-15-04, 08:47 AM   #29   |  Link
MHoefler
Member
 
Join Date: Sep 2002
Location: Vienna, AUSTRIA
Posts: 154
I just get

Evaluate: Unrecognized exception!
(ffdshow_filter_avisynth_scipt. line 1)

What does this mean? I tried everything, followed the instructions carefully, toggled Hyperthreading, made sure I had the P4 dll, etc. but no matter what I do I get this message.

Can somebody help?

Thanks, Martin.
MHoefler is offline   Reply With Quote
Old 11-15-04, 08:59 AM   #30   |  Link
Socio
AVS Special Member
 
Join Date: May 2002
Posts: 1,996
Quote:
Originally posted by chenzhaoyi
AMD barton 2500+ oc 3200+,nvidia Ti 4200, I am using nothing in ffdshow but
avisynth,cpu still loaded 75%. ffdshow version 20041012 non sse.dscaler 5 decoder in zplayer,colourspace yv12.
Still not sure, looks like you have plenty of power to do it, perhaps OCing is interfering with processing.

I am not completely familiar with all the AMD processors but if yours is has SSE you can try the July 9th version of ffdshow with SSE/SSE2 and see if that improves performance and as jpooton pointed out it no Avisynth script errors with this one.

What version of Masktools plugin are you using?
Socio is offline   Reply With Quote
Reply

Forum Jump

AVS Forum > Video Components > Home Theater Computers



Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -5. The time now is 11:11 AM.


Load Balanced and Protected By
 

Hosting Services Powered By

Page generated in 0.84524107 seconds (100.00% PHP - 0% MySQL) with 10 queries

Copyright ©1995 - 2009 AVS Forum.com, Inc. - All Rights Reserved. No information may be posted elsewhere without written permission.