Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # NNEDI chroma upsubsampling v0.6 by A.SONY
- FUNCTION nnchromaupsubsampling(clip srco, bool "interlaced", bool "inv420") {
- interlaced = default(interlaced, false)
- inv420 = default(inv420 , false)
- ssispmt = Findstr(VersionString(), "AviSynth+") != 0 && Findstr(VersionString(), "r1576") == 0
- sislumaonly = ssispmt ? srco.isy() : srco.isy8()
- sis420 = ssispmt ? srco.is420() : srco.isyv12()
- sisfullchroma = ssispmt ? srco.is444() : srco.isyv24()
- Assert(IsPlanar(srco) && isyuv(srco), "nnchromaupsubsampling: input clip must be planar YUV")
- Assert(!(Isyv12(srco) && !interlaced), "nnchromaupsubsampling: YV12/420 must be interlaced PAL DV")
- Assert(!(sisfullchroma || sislumaonly), "nnchromaupsubsampling: this function for subsampling sources")
- src = interlaced ? srco.SeparateFields().AssumeFrameBased() : srco
- chromay8 = ssispmt ? Interleave(src.ExtractU(),src.ExtractV()) : Interleave(src.UToY8(),src.VToY8())
- chromaturn = !sis420 ? Eval("try { fTurnLeft(ssispmt ? nop() : chromay8) } catch(error_msg) { TurnLeft(chromay8) }").Padding(2,2,2,2).nnedi3(field=0,dh=true).crop(2,4,-2,-4,true) : nop()
- chromaupturn = !sis420 ? Eval("try { fTurnRight(ssispmt ? nop() : chromaturn) } catch(error_msg) { TurnRight(chromaturn) }") : nop()
- chromaup = sis420 ? ssispmt ? YToUV(chromaupturn.SelectEven().Padding(2,2,2,2).nnedi3(field=inv420 ? 1 : 0,dh=true).crop(2,4,-2,-4,true),chromaupturn.SelectOdd().Padding(2,2,2,2).nnedi3(field=inv420 ? 0 : 1,dh=true).crop(2,4,-2,-4,true),src.ConvertToY()) : \
- YToUV(chromay8.SelectEven().Padding(2,2,2,2).nnedi3(field=inv420 ? 1 : 0,dh=true).crop(2,4,-2,-4,true),chromay8.SelectOdd().Padding(2,2,2,2).nnedi3(field=inv420 ? 0 : 1,dh=true).crop(2,4,-2,-4,true),src.ConvertToY8()) : \
- ssispmt ? YToUV(chromaupturn.SelectEven(),chromaupturn.SelectOdd(),src.ConvertToY()) : \
- YToUV(chromaupturn.SelectEven(),chromaupturn.SelectOdd(),src.ConvertToY8())
- return interlaced ? GetParity(srco) ? chromaup.AssumeFieldBased().AssumeTFF().Weave() : chromaup.AssumeFieldBased().AssumeBFF().Weave() : chromaup
- }
- # NNEDI chroma upsubsampling v0.4 by A.SONY (Inverse for testing purposes)
- FUNCTION Innchromaupsubsampling(clip srco, bool "interlaced") {
- srco
- nnchromaupsubsampling(interlaced,true)
- }
- # NNEDI yv12 point subsampling fix v0.5 by A.SONY
- # the output will be yv12 in mode 2 and yv16 in mode 1 and yv24 in mode 3, convert it back to yv12 by the method you like, the default setting work with Konjiki no Gash Bell!! S1 R2J DVD
- FUNCTION yv12pointsamplingnnfix(clip srco, bool "interlaced", bool "top", bool "left", int "mode", bool "leftshift", int "qual", int "nns", int "nsize", int "etype", int "pscrn", bool "eed", int "vcheck", float "vthresh0", float "vthresh1", float "vthresh2", int "nrad", int "mdis", float "alpha", float "beta", float "gamma", bool "nnrep" ) {
- interlaced = default(interlaced, false)
- eed = default(eed, false)
- top = default(top, true)
- left = default(left, true)
- mode = default(mode, 1)
- leftshift = default(leftshift, left)
- nnrep = Default(nnrep, false)
- Assert(Isyv12(srco), "yv12pointsamplingnnfix: input must be YV12")
- src = interlaced ? srco.SeparateFields().AssumeFrameBased() : srco
- chromay8 = mode==3 || mode==1 ? Interleave(src.UToY8(),src.VToY8()) : nop()
- chromay8n = mode==3 || mode==1 ? chromay8.Padding(2,2,2,2) : chromay8
- chromay8n = mode==3 || mode==1 ? chromay8n.nnedi3(field=top ? 1 : 0,dh=true, qual=qual, nns=nns, nsize=nsize, etype=etype, pscrn=pscrn ).crop(2,4,-2,-4,true) : chromay8n
- chromay8e = (mode==3 || mode==1) && eed ? chromay8.EEdi3(field=top ? 1 : 0,dh=true,sclip=chromay8n,u=false,v=false,vcheck=vcheck, nrad=nrad, mdis=mdis, alpha=alpha, beta=beta, gamma=gamma, vthresh0=vthresh0, vthresh1=vthresh1, vthresh2=vthresh2) : chromay8n
- chromay8 = (mode==3 || mode==1) && eed && nnrep ? chromay8e.Repair(chromay8n,9) : chromay8e
- chromay8 = mode==2 || mode==3 ? Eval("try { fTurnRight(mode==3 ? chromay8 : Interleave(src.UToY8(),src.VToY8())) } catch(error_msg) { TurnRight(mode==3 ? chromay8 : Interleave(src.UToY8(),src.VToY8())) }") : chromay8
- chromay8n = mode==2 || mode==3 ? chromay8.Padding(2,2,2,2) : chromay8
- chromay8n = mode==2 || mode==3 ? chromay8n.nnedi3(field=left ? 1 : 0,dh=true, qual=qual, nns=nns, nsize=nsize, etype=etype, pscrn=pscrn ).crop(2,4,-2,-4,true) : chromay8n
- chromay8e = (mode==2 || mode==3) && eed ? chromay8.EEdi3(field=left ? 1 : 0,dh=true,sclip=chromay8n,u=false,v=false,vcheck=vcheck, nrad=nrad, mdis=mdis, alpha=alpha, beta=beta, gamma=gamma, vthresh0=vthresh0, vthresh1=vthresh1, vthresh2=vthresh2) : chromay8n
- chromay8 = (mode==2 || mode==3) && eed && nnrep ? chromay8e.Repair(chromay8n,9) : chromay8e
- chromay8 = mode==2 || mode==3 ? Eval("try { fTurnLeft(chromay8) } catch(error_msg) { TurnLeft(chromay8) }") : chromay8
- chromay8 = mode==2 ? chromay8.BilinearResize(width(chromay8)/2,height(chromay8),src_left=leftshift ? -0.5 : 0.5) : chromay8
- chromaup = YToUV(chromay8.SelectEven(),chromay8.SelectOdd(),src.ConvertToY8())
- return interlaced ? GetParity(srco) ? chromaup.AssumeFieldBased().AssumeTFF().Weave() : chromaup.AssumeFieldBased().AssumeBFF().Weave() : chromaup
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement