Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # make aWarpSharp2 work on other planar, for avs 2.6
- # mod to make it faster with last aWarpSharp2 and add aWarp4, v1.38
- function aWarpSharp4xx (clip osrc, int "thresh", int "blur", int "type", int "depth", int "chroma", int "cdepth", string "cplace", bool "bic", int "cblur", bool "useaWarp4", clip "y_mask", bool "lsb")
- {
- lsb = default(lsb, false)
- src = lsb ? osrc.DitherPost(mode=-1) : osrc
- depth = default(depth, 16)
- type = default(type , 0)
- blur = default(blur , type==0 ? 2 : 3)
- chroma = default(chroma, 4)
- cplace = default(cplace, "MPEG2")
- cdepth = default(cdepth, IsYV24(src) ? depth : depth/2)
- cblur = default(cblur, IsYV24(src) ? blur : (blur+1)/2)
- bic = default(bic, true)
- useaW4 = default(useaWarp4, false)
- Assert(IsPlanar(src) && isyuv(src), "aWarpSharp4xx: input clip must be planar YUV")
- assert(0 <= chroma <= 6, "aWarpSharp4xx: argument chroma must be an integer between 0 and 6.")
- assert(cplace == "MPEG2" || cplace == "MPEG1", "aWarpSharp4xx: chroma siting must be MPEG2 or MPEG1")
- Assert(Defined(y_mask) ? isy8(y_mask) : true, "aWarpSharp4xx: y_mask clip must be Y8")
- !Defined(y_mask) || !useaW4 || (IsY8(src) || (IsYV12(src) && (chroma == 0 || chroma == 1 || chroma == 2))) ? \
- Eval("""
- output = src.aWarpSharp2(thresh=thresh, blur=blur, type=type, depth=depth, chroma=chroma, depthC=cdepth, cplace=cplace)
- """) : \
- Eval("""
- chrgu = chroma == 4 || chroma == 6
- y = chroma > 2 && !(chroma > 4 && Defined(y_mask)) ? ConvertToY8(src) : src
- u = chroma > 2 ? UtoY8(src) : nop()
- v = chroma > 2 ? VtoY8(src) : nop()
- y_mask = Defined(y_mask) ? y_mask : useaW4 || chrgu ? aSobel(y, thresh=thresh).aBlur(blur=blur, type=type) : nop()
- cshift = chrgu ? IsYV411(src) ? -1.5 : (cplace == "MPEG1" && IsYV12(src)) ? 0 : -0.5 : nop()
- uv_mask = chrgu ? IsYV24(src) ? y_mask : bic ? y_mask.BicubicResize(u.width(), v.height(), src_left=cshift) : y_mask.BilinearResize(u.width(), v.height(), src_left=cshift) : nop()
- u_mask = chrgu ? uv_mask : chroma > 2 ? aSobel(u, thresh=thresh).aBlur(blur=cblur, type=type) : nop()
- v_mask = chrgu ? uv_mask : chroma > 2 ? aSobel(v, thresh=thresh).aBlur(blur=cblur, type=type) : nop()
- y = chroma < 5 ? useaW4 ? y.nnedi3_rpow2(rfactor=2).nnedi3_rpow2(rfactor=2) : y : y
- u = chroma > 2 ? useaW4 ? U.nnedi3_rpow2(rfactor=2).nnedi3_rpow2(rfactor=2) : u : nop()
- v = chroma > 2 ? useaW4 ? V.nnedi3_rpow2(rfactor=2).nnedi3_rpow2(rfactor=2) : v : nop()
- # warp each channel independently
- y_warp = chroma < 5 ? useaW4 ? aWarp4(y, y_mask, depth=depth, chroma=chroma, cplace=cplace) : aWarpSharp2(y, thresh=thresh, blur=blur, type=type, depth=depth, chroma=chroma, cplace=cplace) : y
- u_warp = chroma > 2 ? useaW4 ? aWarp4(u, u_mask, depth=cdepth ) : aWarp(u, u_mask, depth=cdepth ) : nop()
- v_warp = chroma > 2 ? useaW4 ? aWarp4(v, v_mask, depth=cdepth ) : aWarp(v, v_mask, depth=cdepth ) : nop()
- # luma/chroma processing
- output = chroma > 2 ? YtoUV( u_warp , v_warp , y_warp ) : \
- y_warp
- """)
- output8_16 = lsb==true ? output.Dither_convert_8_to_16() : output
- y_ld = chroma < 5 ? 3 : 2
- uv_ld = Min(chroma, 3)
- Return(lsb==true ? Dither_limit_dif16(osrc, output8_16, thr=1.0, elast=1.5, y=y_ld, u=uv_ld, v=uv_ld) : output8_16)
- }
Add Comment
Please, Sign In to add comment