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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st May 2006, 20:51   #1  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
AddGrainC (now with Chroma noise & YUY2, RGB)

As an experiment I made a version of Tom Barry's AddGrain with chroma noise, no more need for scripting workarounds.

AddGrain(var,hcorr,vcorr,uvar,seed)
AddGrainC(var,uvar,hcorr,vcorr,seed)

var, uvar:
luma and chroma variance.
chroma does nothing in rgb mode.

hcorr,vcorr:
horizontal & veritcal correlation.

seed:
int, to keep the same grain on every frame.

Unlike the original, these are all named and optional and default to 0.0 except var, which is 1.0.

It may be faster, it may also be SSE2 only (haven't run it on the Athlon yet). Thought it might be useful to others, I'll finish up the readme if there's any demand.

Download v1.7.1 here.

One name is meant to be backward compatible, one is meant to make more sense, I don't know which I prefer so I just left both.

Code:
Changelist:
1.0	2003/06/18   Tom Barry    Initial Release
1.1	2006/06/01   Foxyshadis   Chroma grain + constant seed
1.2	2006/06/06   Foxyshadis   Supports YUY2, RGB. Fix cache mess.
1.3	2006/06/10   Foxyshadis   Crashfix, noisegen optimization
1.4	2006/08/11   Foxyshadis   Constant replaces seed, seed repeatable
1.5	2010/05/07   Foxyshadis   Limit the initial seed generation to fix memory issues.
1.5.1   2010/05/13   Firesledge   The source code compiles on Visual C++ versions older than 2008
1.5.2   2011/10/26   Firesledge   Removed the SSE2 requirement.
1.5.3   2011/10/26   Firesledge   Fixed coloring and bluring in RGB24 mode.
1.5.4   2011/10/27   Firesledge   Fixed bad pixels on the last line in YV12 mode when constant=true,
                                  fixed potential problems with frame width > 4096 pixels
                                  and fixed several other minor things.
1.6.0   2011/10/28   LaTo INV.    Added SSE2 code (50% faster than MMX).
1.6.1   2011/10/29   LaTo INV.    Automatic switch to MMX if SSE2 is not supported by the CPU.
1.7.0   2012/08/16   Firesledge   Supports Y8, YV16, YV24 and YV411 colorspaces.
1.7.1   2013/11/25   Firesledge   64-bit version.

Last edited by foxyshadis; 15th May 2014 at 01:21. Reason: new v1.7.1
foxyshadis is offline   Reply With Quote
Old 31st May 2006, 21:38   #2  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416
404 on the link good buddy, over.
Backwoods is offline   Reply With Quote
Old 1st June 2006, 00:29   #3  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Ah, foxyshadis is entering plugin land ... /me rubs hands

Nice extension to AddGrain. Less juggling-around with separating & merging color planes.

BTW: It seems there's a long standing issue with AddGrain. Somehow, if during processing a AddGrain'ed clip is duplicated, used otherwise, and later on combined again with the original AddGrain'ed clip, then the noise pattern is no more the same. Seems like the filter starts with a different seed for processing the child frame, instead of using the seed from the mother frame.
At times, this is highly unpropitious. The usual workaround is to not apply AddGrain directly to a clip, but to apply it to a neutral grey clip instead, and subtracting this one from the clip you want to process. This way mother and child keep having the same pattern.
Sorry for I've no example at hand right now (and can't make one, since I'm already sleeping )

From the sourcecode I can tell nothing (no clue about how these things are handled). Perhaps someone in the knowings can see where it's going wrong.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 1st June 2006, 02:30   #4  |  Link
BigDid
Actually in reserve
 
Join Date: Oct 2004
Posts: 1,605
Quote:
Originally Posted by Didée
...(and can't make one, since I'm already sleeping )...
You can type and sleep, wonderful

To stay on the subject: same 404 error when trying to download

Did
__________________
Having a problem with AutoGK? Read & use the FAQ & MORE FAQ first
Want to exchange on AutoGK? try doom10.org
In reserve (inactive) for an undefined period of time.
BigDid is offline   Reply With Quote
Old 1st June 2006, 03:05   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Heh, I forgot that I always put stuff in the /random folder... ^^;; Sorry.

I've been doing plugins for a while, it's just that they usually don't pan out so there's no point in releasing.

What I suspect is happening there is the cache gets blown, so that even though both paths lead back to the same addgrain'd clip, it gets done twice - but I might be entirely wrong. I'll take a look.
foxyshadis is offline   Reply With Quote
Old 1st June 2006, 21:47   #6  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416
http://foxyshadis.slightlydark.com/random/AddGrainC.zip
Backwoods is offline   Reply With Quote
Old 2nd June 2006, 02:30   #7  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
hey, cool. i just made a scripty workaround the other day.

would it also be possible to keep the same seed for each frame? this could be useful for avoiding banding when using addgrain for dither (perhaps it could even be added into gradfun2db?)
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 2nd June 2006 at 02:36.
Mug Funky is offline   Reply With Quote
Old 2nd June 2006, 02:41   #8  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
Sounds like it would make a great addition to BlockTerminator . One thing though: I assume the chroma noise won't look like rainbows or color bands, what would it look like?
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 2nd June 2006, 03:25   #9  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
It will look like chroma noise. The output should be identical to this:
Code:
function AddChromaGrain(clip c, int "grain") {
	grainu=c.utoy().addgrain(grain,0,0)
	grainv=c.vtoy().addgrain(grain,0,0)
	return ytouv(grainu,grainv).mergeluma(c)
}
I need to organize my invented script functions better, they're all over several hard drives...

Here, I'll put up a screenshot.

Go easy on chroma noise; heavy luma noise can look artsy, but heavy chroma noise just looks like a horrible capture. (That was uvariance 100, btw.)

I was thinking about having a single starting seed, but a constant seed actually sounds useful. Btw, I made modifications of blockbuster as well, so that its arguments are more useful. I have other ideas for it, when I remember to pick it back up.

Edit: Okay, I updated, fixing a bug with the luma/chroma noise interaction (maybe I only broke it today ), and adding a seed parameter for Mug. Use anything >= 0 to enable.

Actually it appears to be using std. dev., not variance, the variable names lied. =p So maybe I'll change var and uvar to dev and udev.

Edit 2 jun: updated readme in archive as well.

Last edited by foxyshadis; 2nd June 2006 at 20:11.
foxyshadis is offline   Reply With Quote
Old 2nd June 2006, 19:29   #10  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
Thanks for update!
IMHO, first parameter of AddGrain is variance, or squared deviation (sigma*sigma), and is not standard deviation.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 3rd June 2006, 08:12   #11  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
And feature request: YUY2 support.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 3rd June 2006, 14:01   #12  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
I'll look into it, I've only used YV12 before but I have a Plan that might let me use the existing mmx writeover code. I'm sure there's some function I could use in RemoveGrain, but ouch that code hurts my brain, or Tritical's filters; if I can't figure it out then Interleaved2Planar/Planar2Interleaved or straight C will work.

Didée, IanB explained the problem as coming from playing fast and loose with the cache, and offered a quick workaround I'll insert.
foxyshadis is offline   Reply With Quote
Old 5th June 2006, 19:17   #13  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
Probaly it may be implemented as interleaved, not planar.
At last with equal luma and chroma noise it is trivial
Fizick is offline   Reply With Quote
Old 6th June 2006, 11:31   #14  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Quote:
Originally Posted by Fizick
And feature request: YUY2 support.
Done.

RGB24/32 as well, but luma only. (How would you make gaussian noise across 3 color channels?)

Quote:
Originally Posted by Didée
Somehow, if during processing a AddGrain'ed clip is duplicated, used otherwise, and later on combined again with the original AddGrain'ed clip, then the noise pattern is no more the same.
Fixed. Or at least covered up, I'm not quite sure which.

Enjoy. It was a lot of fun to do, really, even if I had to recode much of it. Hope it isn't horrifying to you real plugin devs. Threw comments and a new readme in. Now I just have to learn SSE and figure out how to parallelize the inner update loop. ;D

Last edited by foxyshadis; 6th June 2006 at 11:34.
foxyshadis is offline   Reply With Quote
Old 6th June 2006, 16:41   #15  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
thanks, i will try use it.
I often used AddGrain for denoise filter development.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 6th June 2006, 19:43   #16  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
I tried it.
"Evaluate: System exception. Illegal instruction."

I have AthlonXP.
Need in SSE2?
But when I compile your source myself (VCToolkit2003), DLL works fine for me.
Wrong source?
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 6th June 2006, 20:26   #17  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
No, I just compiled it with SSE2 for testing and didn't turn it off. I uploaded the normal SSE one.

Maybe I'll do what Kassandro does. (But seriously, thanks for reminding me to turn that option off for a final release, it doesn't change the speed anyway.)

[edit] It seems to have some bug that causes crashes on reload with mid-to-large res. I'll fix soon.

Last edited by foxyshadis; 7th June 2006 at 12:10.
foxyshadis is offline   Reply With Quote
Old 10th June 2006, 21:35   #18  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Quote:
Originally Posted by foxyshadis
[edit] It seems to have some bug that causes crashes on reload with mid-to-large res. I'll fix soon.
Fixed. I also partly optimized the random generation, which you'd only notice if you use it many times in a script, like me. >.>
foxyshadis is offline   Reply With Quote
Old 14th September 2006, 23:31   #19  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
So, to use AddGrain(x,0,0) on luma and AddGrain(y,0,0) on chroma, what would be the corresponding AddGrainC call?
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 14th September 2006, 23:44   #20  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
AddGrainC(x,y)

That's it.
foxyshadis 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 11:09.


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