# SimpleSlugUpscale v0.4b # # 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 TGMCdefault, default balance # # Sets quality level by changing arguments passed into TGMC. Low isn't too bad for # 480sq or 360sq modes, and runs much faster than the others. # # 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.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", bool "shtrfix", string "size") { drate = default(drate, false) qual = default(qual, "balance") shtrfix = default(shtrfix, false) size = default(size, "720p") croptop = default(croptop, (original.Height() / 8)) cropheight = Int(Float(original.Height()) * 0.75) 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!") bobbed = qual=="low" ? original.ConvertToYV12(interlaced=true).TempGaussMC_beta2(1,1,0,0,0,0,"bob",sharpness=0.0,Smode=0,SLmode=0,Sbb=0,SVthin=0.0) : \ qual=="balance" ? original.ConvertToYV12(interlaced=true).TempGaussMC_beta2(1,1,3,0,0,0,EdiMode="NNEDI2",sharpness=1.0,Smode=1,SLmode=0,Sbb=0,SVthin=0.0) : \ qual=="TGMCdefault" ? original.ConvertToYV12(interlaced=true).TempGaussMC_beta2(EdiMode="NNEDI2") : \ original.Bob(0.0,1.0) shtrclp = drate==true ? bobbed : (drate==false && shtrfix==true) ? Merge(bobbed.SelectEven(),bobbed.SelectOdd()) : bobbed.SelectEven() return size=="480sq" ? shtrclp.BlackmanResize(640,480,8,0,704,original.Height()) : \ size=="360sq" ? shtrclp.BlackmanResize(640,360,8,croptop,704,cropheight) : \ size=="480iwide" ? bobbed.BlackmanResize(720,240,0,croptop,720,cropheight).AssumeFieldBased().Weave() : \ size=="480p" ? shtrclp.BlackmanResize(720,480) : \ size=="480pwide" ? shtrclp.BlackmanResize(720,480,0,croptop,720,cropheight) : \ size=="576iwide" ? bobbed.BlackmanResize(720,288,0,croptop,720,cropheight).AssumeFieldBased().Weave() : \ size=="576p" ? shtrclp.BlackmanResize(720,576) : \ size=="576pwide" ? shtrclp.BlackmanResize(720,576,0,croptop,720,cropheight) : \ size=="720p" ? shtrclp.BlackmanResize(1280,720,8,croptop,704,cropheight) : \ size=="720pbox" ? shtrclp.BlackmanResize(960,720,8,0,704,original.Height()).AddBorders(160,0,160,0) : \ size=="720pboxbg" ? shtrclp.SimpleSlugPillars(original,croptop,cropheight,720) : \ size=="1080isq" ? bobbed.BlackmanResize(1920,540,8,croptop,704,cropheight).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080isqbox" ? bobbed.BlackmanResize(1440,540,8,0,704,original.Height()).AddBorders(240,0,240,0).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080isqboxbg" ? bobbed.SimpleSlugPillars(original,croptop,cropheight,1080).BlackmanResize(1920,540).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080psq" ? shtrclp.BlackmanResize(1920,1080,8,croptop,704,cropheight) : \ size=="1080psqbox" ? shtrclp.BlackmanResize(1440,1080,8,0,704,original.Height()).AddBorders(240,0,240,0) : \ size=="1080psqboxbg" ? shtrclp.SimpleSlugPillars(original,croptop,cropheight,1080) : \ size=="1080iana" ? bobbed.BlackmanResize(1440,540,8,croptop,704,cropheight).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080ianabox" ? bobbed.BlackmanResize(1080,540,8,0,704,original.Height()).AddBorders(180,0,180,0).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080ianaboxbg" ? bobbed.SimpleSlugPillars(original,croptop,cropheight,1080).BlackmanResize(1440,540).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080pana" ? shtrclp.BlackmanResize(1440,1080,8,croptop,704,cropheight) : \ size=="1080panabox" ? shtrclp.BlackmanResize(1080,1080,8,0,704,original.Height()).AddBorders(180,0,180,0) : \ size=="1080panaboxbg" ? shtrclp.SimpleSlugPillars(original,croptop,cropheight,1080).BlackmanResize(1440,1080) : \ original.Subtitle("SimpleSlugUpscale: Invalid 'size' parameter!") } function SimpleSlugPillars(clip shtrclp, clip "original", int "croptop", int "cropheight", int "pheight") { 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 ? shtrclp.BlackmanResize(1440,1080,8,0,704,original.Height()) : shtrclp.BlackmanResize(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) }