//  AddGrainC - Random noise film grain generator for Avisynth 2.5
//	Copyright (C) 2003 Tom Barry
//		trbarry@trbarry.com
//	modified by Foxyshadis
//		foxyshadis@jetemail.net
//	This program is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; either version 2 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program; if not, write to the Free Software
//	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also, this program is "Philanthropy-Ware".  That is, if you like it and feel
the need to reward or inspire the author then please feel free (but not obligated) 
to consider joining or donating to the Electronic Frontier Foundation. This will 
help keep cyber space free of barbed wire and bullsh*t.  

See their web page at www.eff.org

***************


AddGrain generates film like grain or other effects (like rain) by adding
random noise to a video clip.  This noise may optionally be horizontally 
or vertically correlated to cause streaking.


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


Requirements
==================

* Avisynth 2.5+
* YV12, YUY2, RGB
* SSE cpu (P3+, Athlon)


Parameters
==================

var (1.0), uvar (0.0)
	The standard deviation of the luma and chroma noise, 0 is disabled.
	uvar does nothing in RGB mode.

hcorr (0.0), vcorr (0.0)
	Horizontal and vertical correlation, which causes a nifty streaking effect.
	Range 0.0-1.0

seed (-1)
	Specifies a constant grain pattern for every frame. Set to at least 0 to use.


AddGrain alias is left to retain compatibility with existing scripts using it.

The correlation factors are actually just implemented as exponential smoothing
which give a weird side affect that I did not attempt to adjust.  But this means
that as you increase either corr factor you will have to also increase the stddev
(grain amount) in order to get the same visible amount of grain, since it is being 
smooth out a bit.

Increase both corr factors can somewhat give clumps, or larger grain size. 

And there is an interesting effect with, say, AddGrain(800,0,.9) or any huge amount 
of strongly vertical grain.  It can make a scene look like it is raining.


Version History
==================
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
