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. |
![]() |
#1 | Link |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
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 |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,402
|
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!) |
![]() |
![]() |
![]() |
#4 | Link | |
Actually in reserve
Join Date: Oct 2004
Posts: 1,605
|
Quote:
![]() ![]() 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. |
|
![]() |
![]() |
![]() |
#5 | Link |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
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. |
![]() |
![]() |
![]() |
#7 | Link |
interlace this!
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. |
![]() |
![]() |
![]() |
#8 | Link |
Huh?
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
|
Sounds like it would make a great addition to BlockTerminator
![]()
__________________
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. |
![]() |
![]() |
![]() |
#9 | Link |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
It will look like chroma noise.
![]() 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) } 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 ![]() 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. |
![]() |
![]() |
![]() |
#10 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,182
|
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. |
![]() |
![]() |
![]() |
#11 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,182
|
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. |
![]() |
![]() |
![]() |
#12 | Link |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
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. |
![]() |
![]() |
![]() |
#14 | Link | ||
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
Quote:
RGB24/32 as well, but luma only. (How would you make gaussian noise across 3 color channels?) Quote:
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. |
||
![]() |
![]() |
![]() |
#15 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,182
|
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. |
![]() |
![]() |
![]() |
#16 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,182
|
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. |
![]() |
![]() |
![]() |
#17 | Link |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
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. ![]() [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. |
![]() |
![]() |
![]() |
#18 | Link | |
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
Quote:
|
|
![]() |
![]() |
![]() |
#19 | Link |
Huh?
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. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|