function aWarpSharp4xx (clip src, int "thresh", int "blur", int "type", int "depth", int "depthC", int "chroma", bool "lsb", string "cplace")
{
depth  = default(depth, 16)
depthC = default(depthC, src.IsYV24 ? depth : depth/2) #depth/3 is claimed to work better
chroma = default(chroma, 4)
lsb    = default(lsb, false)
cplace = default(cplace, "MPEG2")

Assert(IsPlanar(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")

src8 = lsb ? src.DitherPost(mode=-1) : src

IsY8(src) || IsYV12(src) && (chroma != 4 && chroma != 6) ? \
Eval("""
warp   = ConvertToYV12(src8).aWarpSharp2(thresh=thresh, blur=blur, type=type, depth=depth, chroma=IsY8(src) ? 1 : chroma)
output = IsY8(src) ? ConvertToY8(warp) : warp
""") : \
Eval("""
y = ConvertToY8(src8).ConvertToYV12()
u = UtoY(src8).ConvertToYV12()
v = VtoY(src8).ConvertToYV12()

# warp each channel independently
y_warp = aWarpSharp2(y, thresh=thresh, blur=blur, type=type, depth=depth,  chroma=1)
u_warp = aWarpSharp2(u, thresh=thresh, blur=blur, type=type, depth=depthC, chroma=1)
v_warp = aWarpSharp2(v, thresh=thresh, blur=blur, type=type, depth=depthC, chroma=1)

# warp chroma by guiding it with the luma edge mask
cshift = cplace == "MPEG2" && !src.IsYV24 ? -0.5 : 0
y_mask  = aSobel(y, thresh=thresh).aBlur(blur=blur, type=type).BilinearResize(u.width(), v.height(), src_left=cshift)
u_warp2 = aWarp(u, y_mask, depth=depthC, chroma=1)
v_warp2 = aWarp(v, y_mask, depth=depthC, chroma=1)

# "fill with zeroes"
blank = BlankClip(u, pixel_type="Y8", color_yuv=$808080)

# luma/chroma processing
output = chroma==0 ||                                      \
         chroma==1 ? YtoUV( blank   , blank   , y_warp ) : \
         chroma==2 ? YtoUV( u       , v       , y_warp ) : \
         chroma==3 ? YtoUV( u_warp  , v_warp  , y_warp ) : \
         chroma==4 ? YtoUV( u_warp2 , v_warp2 , y_warp ) : \
         chroma==5 ? YtoUV( u_warp  , v_warp  , y      ) : \
         chroma==6 ? YtoUV( u_warp2 , v_warp2 , y      ) : \
         src8
""")
output8_16 = lsb==true ? output.Dither_convert_8_to_16() : output
y_ld  = chroma < 5 ? 3 : 2
uv_ld = Min(chroma, 3)
output16 = Dither_limit_dif16(src, output8_16, thr=1.0, elast=1.5, y=y_ld, u=uv_ld, v=uv_ld)
Return(lsb==true ? output16 : output8_16)
}