Crestore function by MOmonster


---------------
basic
---------------
	Use import("Crestore.avs") in your script and load the filters of this package to be 
	able using this functions.

	required:	- mt_masktools

	version number:	- Crestore 1.0

	changes from v0.9:	- different handling with clip2 parameter
				- needs filters to run (masktools)
				- new important parameters (mode, nomo, rate...)
				- new detection modes -> better detection, better speed
				- rate instead of two versions (+Cdeint)

----------------
Crestore
----------------
	If you want to restore telecined fieldblended material, Crestore is your function.
	It is created as an alternative for restore24.
	
	--------
	Usage
	--------
	code:	progressive (bobbed) source

		Crestore(mode=3, bthresh=130, rate=25)

		------
		or:

		ord = last.getparity() ? 1 : 0

		a = tdeint(mode=1)

		c = leakkernelbob(order=ord).crop(8,8,-8,-8).BilinearResize(480,288)	

		Crestore(a, clip2=c, mode=-4)


	parameters:
		mode:	Same as dmode in Cdeblend -> set the detection mode. Its an integer and
			values between -10 and 10 can be useful, depends on the source. 
			There are three different detection algorythm you can choose:
			mode < 0	-> the fastest blenddetection. Works good with clean
					   sources with many motion (bthresh<80 more useful)
			mode > 0	-> the new high quality mode. Its a bit slower, but still
					   fast and will give you good results.
			mode = 0	-> same as mode > 0, but without the motioninfluence. Its
					   sometimes the best choice for natural sources.
			That higher the absolut value of mode (abs(mode)) is setted, that higher
			is the motioninfluence.	For fluid natural sources 1 or 2 (-1,-2) are good values, 
			for bad motion and animes values till 4 or 5 are useful.
			Default: 0

		rate:	Here you can set the outputframerate, normally for pal sources 23.976 and for ntsc
			sources 25 fps, but 24fps is also sometimes so right framerate. Crestore has no
			decimating Code, only a pattern detection. So a strange pattern are wrong rate will
			result in bad motion. Default: 23.976

		bthresh:From 0 to 99 its the basic blendthresholding (85-99 is not recommed). Higher 
			values means a stronger detection. Values over 99 call a simple special handling.
			If the current frame has a higher blend possibility than the next and the previous
			and the clearfactor difference is higher than thresh/100-1 (for 150->0.5) its
			detected as a blend. Default: 120
		
		dl:	Detectionlimiting. Its only used for mode >= 0. If a pixeldifference is not higher
			than this integer, it isnt used for the blenddetection. For animes higher values
			(2-4) are useful and for really good sources zero can be used.	Default: 1

		clip2:	Same as bclip from the previous version, except that it isnt necessary anymore
			to set a clip. But of course it is still useful.
			Use a bobber with low threshold for the detection. If the source is noisy or
			you want to speed up things, you can also soften and resize the clip. A smaller
			detection clip can give a small speed up and bilinear resizing soften the artefacts.
			You should general crop a bobbed clip before.

		momo:	The point of no motion. Blended pixel differences will be subtracted from this value
			and clear pixel differences will be added. Because the range is 255, 128 is a good value.
			For the simple blendthresholding (thresh 0-99) and for really blocky sources high 
			values arent so good, here you	should set floats between 4-48. Default: 128
			
		mthresh:Its used for simple motion thresholding. For framedifferences smaller than mthresh there 
			will be no blends detected (it just follows the current pattern). This is useful because
			mode < 0 dont work so good for really small differences. Also it has its usage for the decimating.
			Default: 0.16