# SimpleSlugUpscale v0.1 # # 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) # VariableBlur # 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. # # # 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 true # # 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: # # 480sq 640x480, 1:1 PAR # 360sq 640x360, 1:1 PAR # 480iwide 720x480, 40:33 PAR (DV NTSC wide), interlaced bottom field first # 480p 720x480, 10:11 PAR (DV NTSC) # 480pwide 720x480, 40:33 PAR (DV NTSC wide) # 576iwide 720x576, 118:81 PAR (DV PAL wide), interlaced bottom field first # 576p 720x576, 59:54 PAR (DV PAL) # 576pwide 720x576, 118:81 PAR (DV PAL wide) # 720p 1280x720, 1:1 PAR # 720pbox 1280x720 frame, 960x720 video, black pillarbox # 720pboxbg 1280x720 frame, 960x720 video, motion pillarbox # 1080i 1920x1080, 1:1 PAR, interlaced top field first # 1080ibox 1920x1080 frame, 1440x1080 video, black pillarbox, interlaced top field first # 1080iboxbg 1920x1080 frame, 1440x1080 video, motion pillarbox, interlaced top field first # 1080p 1920x1080, 1:1 PAR # 1080pbox 1920x1080 frame, 1440x1080 video, black pillarbox # 1080pboxbg 1920x1080 frame, 1440x1080 video, motion pillarbox # # Changes # # 0.1 - March 1, 2010 - Initial release function SimpleSlugUpscale(clip original, bool "drate", string "qual", bool "shtrfix", string "size") { drate = default(drate, false) qual = default(qual, "balance") shtrfix = default(shtrfix, true) size = default(size, "720p") 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)!") base = original.IsYV12() ? original : original.ConvertToYV12(interlaced=true) cropargs = original.Height()==576 ? "0,72,720,432" : \ original.Height()==480 ? "0,60,720,360" : \ original.Subtitle("Input must be NTSC or PAL DV dimensions!") bobbed = qual=="low" ? base.TempGaussMC_beta2(1,1,0,0,0,0,"bob",sharpness=0.0,Smode=0,SLmode=0,Sbb=0,SVthin=0.0) : \ qual=="balance" ? base.TempGaussMC_beta2(1,1,3,0,0,0,EdiMode="NNEDI2",sharpness=1.0,Smode=1,SLmode=0,Sbb=0,SVthin=0.0) : \ qual=="TGMCdefault" ? base.TempGaussMC_beta2(EdiMode="NNEDI2") : \ base shtrclp = size=="480iwide" || size=="576iwide" || size=="1080i" || size=="1080ibox" || size=="1080iboxbg" || drate==true ? bobbed : \ (drate==false && shtrfix==true) ? Merge(bobbed.SelectEven(),bobbed.SelectOdd()) : \ bobbed.SelectEven() output = size=="480sq" ? shtrclp.BlackmanResize(640,480) : \ size=="360sq" ? Eval("shtrclp.BlackmanResize(640,360," + cropargs + ")" ) : \ size=="480iwide" ? Eval("shtrclp.BlackmanResize(720,240," + cropargs + ")").AssumeFieldBased().Weave() : \ size=="480p" ? shtrclp.BlackmanResize(720,480) : \ size=="480pwide" ? Eval("shtrclp.BlackmanResize(720,480," + cropargs + ")") : \ size=="576iwide" ? Eval("shtrclp.BlackmanResize(720,288," + cropargs + ")").AssumeFieldBased().Weave() : \ size=="576p" ? shtrclp.BlackmanResize(720,576) : \ size=="576pwide" ? Eval("shtrclp.BlackmanResize(720,576," + cropargs + ")") : \ size=="720p" ? Eval("shtrclp.BlackmanResize(1280,720," + cropargs + ")") : \ size=="720pbox" ? shtrclp.BlackmanResize(960,720).AddBorders(160,0,160,0) : \ size=="720pboxbg" ? SimpleSlugPillars(shtrclp,cropargs,720) : \ size=="1080i" ? Eval("bobbed.BlackmanResize(1920,540," + cropargs + ")").AssumeFieldBased().ComplementParity().Weave() : \ size=="1080ibox" ? shtrclp.BlackmanResize(1440,540).AddBorders(240,0,240,0).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080iboxbg" ? SimpleSlugPillars(shtrclp,cropargs,1080).BlackmanResize(1920,540).AssumeFieldBased().ComplementParity().Weave() : \ size=="1080p" ? Eval("shtrclp.BlackmanResize(1920,1080," + cropargs + ")") : \ size=="1080pbox" ? shtrclp.BlackmanResize(1440,1080).AddBorders(240,0,240,0) : \ size=="1080pboxbg" ? SimpleSlugPillars(shtrclp,cropargs,1080) : \ original.Subtitle("Invalid 'size' parameter!") return output } function SimpleSlugPillars(clip shtrclp, string "cropargs", int "pheight") { pheight = default(pheight, 720) bg = pheight==1080 ? Eval("shtrclp.binomialBlur(varY=100,varC=100,Y=3,U=3,V=3).BilinearResize(1920,1080," + cropargs + ")") : \ Eval("shtrclp.binomialBlur(varY=100,varC=100,Y=3,U=3,V=3).BilinearResize(1280,720," + cropargs + ")") center = pheight==1080 ? shtrclp.BlackmanResize(1440,1080) : shtrclp.BlackmanResize(960,720) 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) }