Anime Upscale Script

This was a basic script created to upscale and filter anime footage for use with AMV editing.  There are three strengths to the filter and it is recommend that you use Strength=2.  Strength controls the spatial smoothing and also effects some of the other default values. Only extremely old grainy anime should need a Strength=3 setting.  Another important setting is widesreen, which is set to either true or false, the default is true.  The FullHD setting, which is true by default, controls whether the output is 1080p (when set to true) or 720p (when set to false).  There is also an option built in that will use daa() before the upscale which is used to help with combing artifacts.  There is also the ability to run the maa() anti-aliasing filter for edge smoothing after the upscale when the Edge setting is set to true.  There is also the ability to crop through this script; cropSD crops at the original resolution, and cropHD crops at the new upscaled resolution.  This filter will run very slow as the backbone of it is MDegrain2(), which you can disable with the Degrain setting, however that is not recommended.

Strength               (Default = 2)
-Use strength=1 for basic upscaling.
-Use strength=2 for videos with mild grain or noise.
-Use strength=3 for videos with lots of gain or noise.
Degrain                (Default = 1)
(NOTE: Default is 3 for Strength=3)
-Use Degrain=0 to disable MDegrain2.
-Use Degrain=1 for standard degrain.
-Use Degrain=2 for double pass standard degrain.
-Use Degrain=3 for heavy degrain.
-Use Degrain=4 for double pass heavy degrain.
FixComb              (Default = false)
Edge (Edge Smoothing)  (Default = false)
FullHD                 (Default = true) Use false for 720p.
Widescreen          (Default = true) Use false for fullscreen videos.
CropSD                (Default = "0,0,0,0") Ex. "2,2,-2,-2"
CropHD                (Default = "0,0,0,0") Ex. "2,2,-2,-2"
ResizeMethod       (Default = "lanczos4resize")
Classic                 (Default = false)
-Use eDeen for smoothing instead of Deathray.

Widescreen Examples:

Fullscreen Example:

Example for fixing combing artifacts:

HELPFUL TIP:  AviSynth uses the Rec.601 color matrix for YV12 footage by default, which is the default color matrix for SD footage.  This is not the same color matrix that is used for storing and decoding HD footage, therefore it is recommended that you convert the footage to RGB [ConvertToRGB(matrix="Rec601")] for use with editing software so that the colors will not get decoded improperly.  It is also important to remember than when preparing the footage for the final HD encode that you specify the correct color matrix when converting to YV12 [ConvertToYV12(matrix="Rec709")]. 

NOTE: If you are having more stability issues than with previous versions you can use the classic setting to use eDeen for spatial smoothing instead of Deathray.

MT Mask Tools
Repair (part of RemoveGrain)

Known Issues
 - Filter will error if you are using VirtualDub version 1.10 or higher.
 - The new filter Deathray may be incompatible with some GPUs.
 - Using AnimeUpscale multiple times in a script can cause visual artifacts due to Deathray.
 - The Edge setting, which enables MAA, can cause it to run out of memory.

Release Notes
Version 3.32 (10-26-2013)
 - Fixed classic mode sharpening.

Version 3.31 (10-17-2013)
 - Adjusted the filter order so that sharpening happens after spatial smoothing.

Version 3.3 (10-15-2013)
 - Fixed issues where spatial smoothing did not run when FullHD = false.
 - Strength 3 changed to use Dehalo Alpha.
 - Strength 3 runs the sharpening filter after smoothing filters are run.

Version 3.2 (9-22-2013)
 - Edge disabled by default for all settings.
 - AA setting renamed to FixComb.

Version 3.1 (9-20-2013)
 - eDeen replaced by Deathray for spatial smoothing.
 - eDeen still usable by setting classic to true.

Version 3.0 (6-1-2013)
 - Complete rewrite that changed the entire way this script functions.
 - Strength now only controls the eDeen settings, but does affect other default values.
 - Added the ability to control the degrain strength.
 - Degrain default is 1, but when strength is set to 3 the default changes to 2.
 - MAA is now optional via the Edge setting.
 - Edge is on by default for FullHD when Strength is greater than 1.

Version 2.2 (5-12-2013)

 - Added cropSD() and cropHD() for internal cropping of the video.
 - Optimized filters for 720p upscales.

Version 2.1 (5-8-2013)
 - Added FullHD option that outputs 720p when set to false, the default is true.
 - Fixed error in the script for strength level 1.

Version 2.0 (5-3-2013)
 - Renamed internal function l33tdegrain() to mdegrain2default()
 - Added mdegrain2strong() which runs MDegrain2 with overlapped blocks (blksize=4, overlap=2) and subpixel precision.
 - Added 3 strength levels.
 - Strength levels 2, 3, & 4 are now 3, 4, & 6 respectively.
 - Strength levels 2, 5, & 7 use mdegrain2strong() for more aggressive noise reduction.
 - Added parameter that enables anti-aliasing using DAA()

Version 1.0 (8-23-2012)
 - First public release of animeupscale()
 - Internal function l33tdegrain() runs MDegrain2 with overlapped blocks (blksize=8, overlap=4) and subpixel precision.
 - MDegrain2 is used one all strength levels for grain removal and noise reduction.
 - Gradfun2db() is used on all strength levels to reduce banding after noise reduction.
 - aWarpSharp() is used on all strength levels to smooth out edges and lines.
 - Strength levels 2, 3, & 4 use eDeen for aggressive spatial smoothing.
 - Strength levels 3 & 4 use MAA() for additional smoothing on edges.