Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th November 2002, 19:57   #1  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
new sharpen filter for avisynth 2.5 : asharp

Hi ^^
i'm too lazy to write, because i've already wrote a very complete readme :

Code:
	asharp beta 1 - adaptive sharpenning filter for Avisynth 2.5 - by MarcFD

1. intro

hi ^^
first, thanks for trying my first attempt of a sharpenning filter :)
basically, this filter is a very common unsharp mask, simply because unsharp 
mask is the most pleasant sharpenning technique for my eyes ^^
but i've added 3 simple ideas i had about sharpening :
- adaptive thresholding to avoid maskito noise enhancement
- block adaptive sharpenning to avoid DCT block edges enhancement
- block based sharpenning ( not implemented nor tested yet )

okay, i admit, i'm inspired by the RV9 codec post processing sharpenning ^_^

it's working in YV12 colorspace, and on luma only 
(chroma shapenning seems to only introduce artifacts)

2. syntax

okay, to the good stuff :

asharp(float "T", float "D", float "B", bool "large")

T : unsharp masking threshold. 0 will do nothing.
1 is like 32 in ffdsow/Vdub, it'll enhance contrast 1x
default is 2

D : adaptive sharpenning strength.
set to 0 to disable
if D>0, adaptive sharpenning is enabled.
the threshold is adapted for every pixel.
it's going to sharpen more around edges.
if adaptive sharpenning is enabled, T acts like a maximum.
default is 2

B : block adaptive sharpenning. (value clamped to [(disabled)..2])
set to a negative value to disable.
if B>=0, Block adaptive sharpenning is enabled.
it acts very simply, by lowering the threshold around DCT-blocks edges.
avoid any non mod8 cropping between decoding and this filter.
default is -1 (disabled)

3. examples

LoadPlugin(asharp.dll) # no autoloading in Avisynth 2.5 yet (too bad i loved it ^^)
asharp(2) # unsharp masking with a strength of 2x
asharp(2,2) # some adaptive sharpenning
asharp(4,6,1) # for DCT-based codec decoding (try without any PP)

4. tests

i tried it on anime (as always ^^)
3 tests with asharp(4,6,1)
- a 350 kbps advanced profile XviD video (on my site, the "Slayers Next" trailer :)
asharp(2,2,1,true) looked cool. without any PP,
blocks not annoying, and heavy enhancement.
- a 1000 kbps simple profile CBR XviD video
asharp(4,6,1) was really adding something to this video.
it raised the sharpen level a lot, and blocks were almost invisible.
- a 6 mbps MPEG-2 (from a anime DVD)
XD it was way to slow to work in 720x567 :( 
i'll test again after optimisations.

5. coming 

block based sharpenning
A bit more complicated to code, but could improve quality against my basic
block adaptive sharpenning. so i'm gonna implement that first.

optimisation and SIMD
some C optmisation could be done (about +25%/50% speed boost)
SIMD optimisation is a child game (that's cool i'm a child. i hope +200% at least)

6. ffdshow

why did i wrote this filter ? why do it work in YV12 ? why am i gonna play 
with SIMD stuff ?

because i like ffdshow a lot, and current sharpen filters aren't pleasing to my eyes.
current ffdshow sharpen filters are :
- xsharpen : too destructive for my eyes
- unsharp mask : blocks & noise is too noticable after
- msharpen : unsharp mask is much pleasant for my eyes
- warpsharp : cool, but it's not really sharpening ^^

so when this thingie would be blind-fast (SIMDed) and stable, i'll give the
code to milan, and we would all enjoy RV9-like postprocessing 
(but better. opensource devellopement is always better ^__^)

MarcFD - 18.11.2002
(attached "asharp beta 1.zip")
Marc FD is offline   Reply With Quote
Old 19th November 2002, 17:33   #2  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
no feedback ?
if someone if convinced, and could make some demo screenshots, that would be great ^^.

BTW, i've tried block-based sharpenning, and it doesn't give what i expected. so i'll try some thresholding smoothing, and if it's good, do the SIMD stuff.
Marc FD is offline   Reply With Quote
Old 19th November 2002, 19:37   #3  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
oups forgot to explain the "large" parameter.
false => diameter 3 (faster)
true => diameter 5 (slower)

for both unsharp masking and adaptive thresholding. that's all ^__^
Marc FD is offline   Reply With Quote
Old 19th November 2002, 21:28   #4  |  Link
drebel
Registered User
 
Join Date: Nov 2002
Location: Athens,Hellas
Posts: 152
I had a crash last night which kept me from replying sooner...(Koepi's 11/18/2002.2),b-frames(5/200),GMC,Qpel and your filter:

Movie=Part2.crop(0,75,720,424).LumaFilter(-3,1).Undot().LanczosResize(672,272).asharp(2,6,1)

Right now i'm finishing 1st pass at ~7 fps(speed dropped 50%).Visual effect from small clips: perfect .My favourite sharpening filter so far was msharpen(9,45,true,false,false) on clean sources ,but asharp gives a more pleasant to the eye effect(i noticed it to from ffdshow a week before)

I just have to wait and see the effect on blocks in THE TIME MACHINE(pretty clear source though).From feeding Gnot with stats file is seems that all the gain in compressibility from the use of b-frames is "lost" in sharpening.Of course ,your deringing (cpu2=ooooxx) is also applied to avoid the usual(?) renging enhancement(to my eyes,anyway) of YV12.

regards,
george
drebel is offline   Reply With Quote
Old 19th November 2002, 21:35   #5  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
argh !! you shouldn't use sharpenning for encoding. and block filtering is meant for POST-processing !!!

in fact too use it instead of msharpen, something like asharp(1,3) would be more appropriate. i think it should lead to similar/better results than msharpen this way.
Marc FD is offline   Reply With Quote
Old 19th November 2002, 21:51   #6  |  Link
iago
retired
 
iago's Avatar
 
Join Date: Jun 2002
Location: hollywood
Posts: 1,013
Marc,

I'm considering to run some compressibility and visuals tests using asharp and some other sharpening filters tonight.

What would be your recommended settings as a starting point for clean real-life/normal movies?

regards,
iago
iago is offline   Reply With Quote
Old 19th November 2002, 22:01   #7  |  Link
drebel
Registered User
 
Join Date: Nov 2002
Location: Athens,Hellas
Posts: 152
I disagree with you on this..Seems my TV really needs this extra thing.So i don't mind "spending" 100 MB of a 2cd-encode for sharpening

About PP maybe i'm too dumb :could you please be more specific?Is the filter performing any?Which setting do you fird more appropriate(strength "2" suits me fine)

Thx in advance,
george
drebel is offline   Reply With Quote
Old 19th November 2002, 22:26   #8  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
>I'm considering to run some compressibility and visuals tests using
>asharp and some other sharpening filters tonight.

okay. asharp is not meant for encoding (i didn't encode everything with it) but adaptive thresholding may help to do very clean sharpenning.

because i decode everything with my PC (i've no hardware MPEG-4 decoder), my idea was to create the best post-sharpen filter, to sharpen as much as needed (and more ) clean XviD anime.

>What would be your recommended settings as a starting point for clean
>real-life/normal movies?

first, use adaptive thresdolding, because you're gonna encode, so it would be much better. and DON'T use block filtering. that's only for decoding post processing.

i think asharp(1,3) might be good.
raise T to a higher value if you want more maximum sharpening, and raise D if you want more aggressive edges.
example :
asharp(1,6) will sharpen more, but not too much.
asharp(2,3) will not sharpen much, but it'ld be very localised to edges.

you should try to tweak a bit. values are float (you can use asharp(1.4,4.7,-0.1) if you want.

>I disagree with you on this..Seems my TV really needs this extra
>thing.So i don't mind "spending" 100 MB of a 2cd-encode for sharpening

do you have a hardware MPEG-4 decoder ? try an avisynth script with sharpenning to decode you avis to your TV with asharp. may worth a try.

>About PP maybe i'm too dumb :could you please be more specific?Is the >filter performing any?

no debocking nor filtering. it's just some sharpenning strenght moderation around blocks edges, because normal sharpening filters would make them very noticable.

>Which setting do you fird more >appropriate(strength "2" suits me >fine)

noting, or -1 (disabled) for encoding. definitively.
it's for final playing only (on your TV for example)

the initial goal of this filter is to sharpen MPEG-4 video playback with outstanding quality. i dunno if you noticed, but the RV9 looks very sharp (look at doom9's codec comparison) because of his post processing. and this filter does it, and on anime, using asharp gived me huge sharpenning without additionnal blocking.
Marc FD is offline   Reply With Quote
Old 19th November 2002, 22:28   #9  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,169
This filter sounds really great marc! I wish I could try it out, but my monitor died so I can't use my PC
Zarxrax is offline   Reply With Quote
Old 20th November 2002, 14:59   #10  |  Link
drebel
Registered User
 
Join Date: Nov 2002
Location: Athens,Hellas
Posts: 152
First full encodind is finished.Results:
- Outstanding quality.Except for edging sharpening,no mosquito noise appeared in the screen ,no blocks enhanced,ever in dark areas with more than 50% Zoom and 70% brightness(monitor).
- You were right about strength.Value "1" is closer to msharpen(x,40),but in "Time Machine" i prefer 2 instead.
- I realize that the purpose of this filter is not encoding.But decoding b-frames,ac3 sound with milan's or nic's filter and asharp incorporated might be too heavy for some machines(mine,anyway-Duron 1GHZ here).I think i would prefer +1hr of encoding rather than possible choppy playback
- It "restores" some missing sharpness by the use of H.263 with b-frames-hope it will be fixed soon
- It 's not enhancing ringings preety common in YV12(you 're wright MaTTeR).With your deringing(cpu2....)the result is amazing.(another filter "grabbed" form PP-area).
- Enough said.I won't try to persuade you although the hope for optimizations dies last

regards,
george
drebel is offline   Reply With Quote
Old 20th November 2002, 15:16   #11  |  Link
milan
Registered User
 
Join Date: Apr 2002
Location: Slovakia
Posts: 220
I tested asharp yesterday and I was very satisfied with results. I'll include it to ffdshow immediatelly after the source code will be available.
__________________
ffdshow homepage: http://ffdshow.sourceforge.net/tikiwiki/
ffdshow download: http://sourceforge.net/projects/ffdshow/
milan is offline   Reply With Quote
Old 20th November 2002, 16:27   #12  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
i played around with asharp a bit, and it seems i was very inspired when i wrote it, because it seems the algorithm is almost perfect ^_^

i'm going to SIMD this afternoon.

>- I realize that the purpose of this filter is not encoding.But >decoding b-frames,ac3 sound with milan's or nic's filter and asharp >incorporated might be too heavy for some machines(mine,anyway-Duron >1GHZ here).I think i would prefer +1hr of encoding rather than >possible choppy playback

just wait for SIMD optimisations ^_^, i'll start with ISSE (my cpu target), maybe add MMX support later. i hope +200% speed at least.

>- It "restores" some missing sharpness by the use of H.263 with >b-frames-hope it will be fixed soon

fixed ? what ? H.263is just more low-frequency friendly. i recommend you too keep H.263, even with movie, because the quality is better in low frequency, and post-processing (with sharpenning ^^) will do the job better than MPEG stuff. MPEG is good for hardware decoding.

>- Enough said.I won't try to persuade you although the hope for >optimizations dies last

i'm going to do that ASAP ^_^

I tested asharp yesterday and I was very satisfied with results. I'll include it to ffdshow immediatelly after the source code will be available.

would i be possible to allow 3 scroll bars settings ? if it's helping you, i can merge 2 settings into one + checkbox. it may be more easy to make the interface this way.

BTW, since it's a post-processing filter, it may be a good idea to have QP acces (like PP) at decoding. maybe it would help to enhance quality a bit. would it be possible ?
Marc FD is offline   Reply With Quote
Old 20th November 2002, 17:26   #13  |  Link
milan
Registered User
 
Join Date: Apr 2002
Location: Slovakia
Posts: 220
I can add new slider if it would be needed. Access to quantizer array is possible too.
__________________
ffdshow homepage: http://ffdshow.sourceforge.net/tikiwiki/
ffdshow download: http://sourceforge.net/projects/ffdshow/
milan is offline   Reply With Quote
Old 20th November 2002, 21:37   #14  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
>I can add new slider if it would be needed.

the best would be 3 sliders : strenght / sensibility / block-filtering.

>Access to quantizer array is possible too.

i'ld play with that later ^^

okay, i've almost finished the SIMD stuff ^_^
i really like MMXing, it's so easy. i've just seen that masking and adaptive thresholding are independant, so i can interleave the code to get huge pairing.

my masking code is in word x4 and the adaptive thresholding is in byte x8, so it's monstruous fast ^_^.

BTW, i've added a new feature, where adaptive thresholding is block based, and it improves quality (less blocks).

maybe i wouldn't have time to release tonight. but i would tomorow anyway.

okay, back to code ^____^
Marc FD is offline   Reply With Quote
Old 21st November 2002, 05:30   #15  |  Link
Blight
Software Developer
 
Blight's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 994
Nice work Marc, I'm a true believer in post-processing where possible.
__________________
Yaron Gur
Zoom Player . Lead Developer
Blight is offline   Reply With Quote
Old 21st November 2002, 17:27   #16  |  Link
wing1
Registered User
 
Join Date: Feb 2002
Posts: 280
@Marc FD

nice filter! the sharpness level is just amazing. I use this filters at asharp(1.5,2,1,false) on movie instead of anime. edge enhancement is quite pleasant and compressibility are ok. If T > 2 then compressibility drop considerably.
wing1 is offline   Reply With Quote
Old 21st November 2002, 20:07   #17  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
thx ^^

okay, i've done 80% of the SIMD stuff. i'll add MMX support (there are some ISSE instructions)

the good news : MMX gives a nice speed boost : on a 512x384 clip, i have 40 fps in C and 100 in MMX ^_^, and there still something i can improve.

i'm taking a lot of time because i've cleaned the whole MMX stuff to avoid any errors. (overflow, ect..)

i tested a bit against msharpen thresh=20, strength=127 in ffdshow, vs asharp (via avisynth)

msharpen shows a lot of blocks (even with PP before), is slow (100% cpu load) and gives a bit sharper image.
asharp shows almost no blocs, is fast (50% cpu load) and gives a much sharper image.

@milan,

in fact my filter only calls the asharp code, who's a function with this kind of prototype :

asharp_run_xxx(ui8* planeptr, int stride, ui8* lineptr, int width, int height, int T, int D, int B, + some bools...)

with asharp_run_isse / asharp_run_c (for self-check) / asharp_run_mmx, ...

when you would add asharp in ffdshow, could you just add the asharp.cpp/asharp.h files, without changing the files at all, just do a function call in ffdshow's multi-sharpen filter ? i think it's much easier this way for you, and it'ld be easier for me to do updates of the code (because you'ld just have to change 2 files, and keep the ffdhow part as-is)

okay i'll finish the code and try to release something tonight.
Marc FD is offline   Reply With Quote
Old 22nd November 2002, 10:07   #18  |  Link
NoLogo
XviDer
 
NoLogo's Avatar
 
Join Date: Feb 2002
Location: France
Posts: 119
Hi all

Ok, my question may sound a little stupid, but how do you use that filter with decoding ?
I've tried many possibilities, none of them seem to work
__________________
"There's no honorable way to kill, no gentle way to destroy. There is nothing good in war. Except its ending." Abraham Lincoln
www.nion.us
NoLogo is offline   Reply With Quote
Old 22nd November 2002, 10:48   #19  |  Link
Blight
Software Developer
 
Blight's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 994
NoLogo:
You'll have to wait for it to be integrated into FFDShow for it to work as a proper post-processor.
__________________
Yaron Gur
Zoom Player . Lead Developer
Blight is offline   Reply With Quote
Old 22nd November 2002, 11:23   #20  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Quote:
Originally posted by Blight
NoLogo:
You'll have to wait for it to be integrated into FFDShow for it to work as a proper post-processor.
I have no problems using AviSynth (either 2.0 or 2.5) for postprocessing. Simply opening the avi using avisource, and then opening the AVS in Zoomplayer works like a charm. You might have to use "EnsureVBRMP3Sync" on some movies though.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump


All times are GMT +1. The time now is 22:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.