# SimpleSlugUpscale v0.6 # # Simplifies the steps necessary to convert an interlaced, 4:3 DV-size clip (720x480 or 720x576) # to a variety of progressive and interlaced, SD and HD output frame sizes. Any questions or # comments, don't hesitate to contact me: robert.martens@gmail.com or get me on Twitter @ItEndsWithTens # # Requirements # # TempGaussMC_beta2 # MaskTools v2 # MVTools 2 # NNEDI2 # RemoveGrain & Repair 1.0 prerelease (mode 20, used by TGMCb2, only introduced in this version) # VerticalCleaner # # These can be found with a quick search online, or you can head to http://www.gyroshot.com/simpleslug.htm # to find copies I've hosted for the sake of convenience. Full source code is available for everything but # NNEDI2, which hasn't seen a public source release as of this writing. # # # croptop min 0, max (source height / 4), default (source height / 8) # # Sets the position of the top of the crop rectangle used as the base for 16:9 generation. Change to reframe # video on the Y axis; default grabs a vertically centered 16:9 area. Can be odd without issue since crop # follows deinterlace. # # drate true or false, default false # # For progressive output, gives 60p for NTSC, 50p for PAL. No effect on interlaced output. # # qual "low", "balance", or custom string, default "balance" # # Sets quality level by changing arguments passed into TGMC. Low quality isn't too bad for 480sq or 360sq # modes, and runs much faster than the others."Balance" is a compromise between speed and quality. A custom # string allows you to run TGMC with whatever arguments you see fit. The full gamut of options is too great # to cover here, but if you want custom settings you know what you're doing. Don't forget to use triple # quotes if you define a custom EdiMode! # # resizer default "BlackmanResize" # # Allows for change of scaling technique; argument must be name of resizer. Assuming a standard AviSynth # installation, possible values are listed in the AviSynth docs, at C:/Program Files/AviSynth 2.5/Docs/English/corefilters/resize.htm # # shtrfix true or false, default false # # No effect on progressive output with drate = true, or on interlaced output, but for same rate progressive # output false will simply select every other frame of the bobbed stream coming from TGMC, while true will # blend every pair of frames together. The end result being that false gives you output that's 30p with a # 1/60th shutter (NTSC) or 25p with a 1/50th shutter (PAL), and true simulates the look of 30p with a 1/30th # shutter (NTSC) or 25p with a 1/25th shutter (PAL). # # size default 720p # # Determines output size. 1080 modes are really pushing it with DV source, I don't recommend them unless # you're desperate. Possible values are: # # name size PAR interlaced? pillarbox # # 480sq 640x480 1:1 no none # 360sq 640x360 1:1 no none # 480iwide 720x480 40:33 bottom field first none # 480p 720x480 10:11 no none # 480pwide 720x480 40:33 no none # 576iwide 720x576 118:81 bottom field first none # 576p 720x576 59:54 no none # 576pwide 720x576 118:81 no none # 720p 1280x720 1:1 no none # 720pbox 1280x720 1:1 no black # 720pboxbg 1280x720 1:1 no motion # 1080isq 1920x1080 1:1 top field first none # 1080isqbox 1920x1080 1:1 top field first black # 1080isqboxbg 1920x1080 1:1 top field first motion # 1080psq 1920x1080 1:1 no none # 1080psqbox 1920x1080 1:1 no black # 1080psqboxbg 1920x1080 1:1 no motion # 1080iana 1440x1080 1.33:1 top field first none # 1080ianabox 1440x1080 1.33:1 top field first black # 1080ianaboxbg 1440x1080 1.33:1 top field first motion # 1080pana 1440x1080 1.33:1 no none # 1080panabox 1440x1080 1.33:1 no black # 1080panaboxbg 1440x1080 1.33:1 no motion # # Changes # # 0.6 - April 1, 2010 - Put 'croptop' and 'cropheight' in alphabetical order for input to SimpleSlugPillars, # allowed custom TGMC arguments, reintroduced "balance" qual option, eliminated "TGMCdefault", # changed cropheight calc to remove data type conversions. # # 0.5 - March 21, 2010 - Slightly simplified Assert for bad 'croptop' value, provided safer fallback for bad # 'qual', changed default() calls to use capital Ds (Avisynth isn't case sensitive, # but things like that still bother me), added 'resizer' var to allow for different # scaling, rejiggered "bobbed" variable and removed "balance" qual option, making it # the default. # # 0.4b - March 13, 2010 - Exposed croptop parameter to function interface (requested by mj.cj), recognized # unnecessarily complex equation for auto calculation of same, realized I don't # understand software version numbering, renamed last version. # # 0.4a - March 12, 2010 - Fixed crop dimensions to produce accurate aspect ratios, eliminated cropargs variable, # changed syntax of some lines to clean up script's presentation, changed quintuple # Blur to one GaussResize for "boxbg" pillar generation, added croptop and cropheight # variables, eliminated base variable, revised size table in comments, removed # interlacing checks from shtrclp variable, swapped default value of shtrfix, reworded # fallback subtitle for invalid 'size' setting. # # 0.3 - March 9, 2010 - Reworked background generation for "boxbg" modes, no more need for VariableBlur and # the associated FFTW3. # # 0.2 - March 4, 2010 - Added 1440 modes (thanks to Per Magne Handegård for the reminder), renamed existing # 1080 options to better reflect their output, cleaned up some unnecessary checks. # # 0.1 - March 1, 2010 - Initial release function SimpleSlugUpscale(clip original, int "croptop", bool "drate", string "qual", string "resizer", bool "shtrfix", string "size") { drate = Default(drate, false) qual = Default(qual, "balance") resizer = Default(resizer, "BlackmanResize") shtrfix = Default(shtrfix, false) size = Default(size, "720p") croptop = Default(croptop, (original.Height() / 8)) cropheight = (original.Height() / 4) * 3 Assert(!(drate==true && shtrfix==true), \ "SimpleSlugUpscale: No reason for drate and shtrfix to both be true! Please check your arguments.") Assert(original.Width()==720 && (original.Height()==480 || original.Height()==576), \ "SimpleSlugUpscale: Input must be DV size (720x480 or 720x576)!") Assert(croptop<=(original.Height() / 4), \ "SimpleSlugUpscale: 'croptop' cannot exceed source height / 4!") TGMCargs = qual=="low" ? \ """ 1,1,0,0,0,0,"bob",sharpness=0.0,Smode=0,SLmode=0,Sbb=0,SVthin=0.0 """ : \ qual=="balance" ? \ """ 1,1,3,0,0,0,EdiMode="NNEDI2",sharpness=1.0,Smode=1,SLmode=0,Sbb=0,SVthin=0.0 """ : \ qual bobbed = Eval("original.ConvertToYV12(interlaced=true).TempGaussMC_beta2(" + TGMCargs + ")") shtrclp = drate==true ? bobbed : \ (drate==false && shtrfix==true) ? Merge(bobbed.SelectEven(),bobbed.SelectOdd()) : \ bobbed.SelectEven() return size=="480sq" ? Eval("shtrclp." + resizer + "(640,480,8,0,704,original.Height())") : \ size=="360sq" ? Eval("shtrclp." + resizer + "(640,360,8,croptop,704,cropheight)") : \ size=="480iwide" ? Eval("bobbed." + resizer + "(720,240,0,croptop,720,cropheight)") \ .AssumeFieldBased().Weave() : \ size=="480p" ? Eval("shtrclp." + resizer + "(720,480)") : \ size=="480pwide" ? Eval("shtrclp." + resizer + "(720,480,0,croptop,720,cropheight)") : \ size=="576iwide" ? Eval("bobbed." + resizer + "(720,288,0,croptop,720,cropheight)") \ .AssumeFieldBased().Weave() : \ size=="576p" ? Eval("shtrclp." + resizer + "(720,576)") : \ size=="576pwide" ? Eval("shtrclp." + resizer + "(720,576,0,croptop,720,cropheight)") : \ size=="720p" ? Eval("shtrclp." + resizer + "(1280,720,8,croptop,704,cropheight)") : \ size=="720pbox" ? Eval("shtrclp." + resizer + "(960,720,8,0,704,original.Height())") \ .AddBorders(160,0,160,0) : \ size=="720pboxbg" ? shtrclp.SimpleSlugPillars(original,cropheight,croptop,720,resizer) : \ size=="1080isq" ? Eval("bobbed." + resizer + "(1920,540,8,croptop,704,cropheight)") \ .AssumeFieldBased().ComplementParity().Weave() : \ size=="1080isqbox" ? Eval("bobbed." + resizer + "(1440,540,8,0,704,original.Height())") \ .AddBorders(240,0,240,0).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080isqboxbg" ? Eval("bobbed.SimpleSlugPillars(original,cropheight,croptop,1080,resizer)." \ + resizer + "(1920,540)").AssumeFieldBased().ComplementParity().Weave() : \ size=="1080psq" ? Eval("shtrclp." + resizer + "(1920,1080,8,croptop,704,cropheight)") : \ size=="1080psqbox" ? Eval("shtrclp." + resizer + "(1440,1080,8,0,704,original.Height())") \ .AddBorders(240,0,240,0) : \ size=="1080psqboxbg" ? shtrclp.SimpleSlugPillars(original,cropheight,croptop,1080,resizer) : \ size=="1080iana" ? Eval("bobbed." + resizer + "(1440,540,8,croptop,704,cropheight)") \ .AssumeFieldBased().ComplementParity().Weave() : \ size=="1080ianabox" ? Eval("bobbed." + resizer + "(1080,540,8,0,704,original.Height())") \ .AddBorders(180,0,180,0).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080ianaboxbg" ? Eval("bobbed.SimpleSlugPillars(original,cropheight,croptop,1080,resizer)." \ + resizer + "(1440,540)").AssumeFieldBased().ComplementParity().Weave() : \ size=="1080pana" ? Eval("shtrclp." + resizer + "(1440,1080,8,croptop,704,cropheight)") : \ size=="1080panabox" ? Eval("shtrclp." + resizer + "(1080,1080,8,0,704,original.Height())") \ .AddBorders(180,0,180,0) : \ size=="1080panaboxbg" ? Eval("shtrclp.SimpleSlugPillars(original,cropheight,croptop,1080,resizer)." \ + resizer + "(1440,1080)") : \ original.Subtitle("SimpleSlugUpscale: Invalid 'size'!") } function SimpleSlugPillars(clip shtrclp, clip "original", int "cropheight", int "croptop", int "pheight", string "resizer") { pheight = default(pheight, 720) bg = pheight==1080 ? shtrclp.GaussResize(1920,1080,8,croptop,704,cropheight,p=1) : \ shtrclp.GaussResize(1280,720,8,croptop,704,cropheight,p=1) center = pheight==1080 ? Eval("shtrclp." + resizer + "(1440,1080,8,0,704,original.Height())") : \ Eval("shtrclp." + resizer + "(960,720,8,0,704,original.Height())") lpill = pheight==1080 ? bg.Crop(0,0,240,1080) : bg.Crop(0,0,160,720) rpill = pheight==1080 ? bg.Crop(1680,0,240,1080) : bg.Crop(1120,0,160,720) return StackHorizontal(lpill,center,rpill) }