This is a cheap approach in YUV.
Code:
function GreyWorld(clip a) {
rgb = isRGB(a)
isy = isy(a)
px = PixelType(a)
bi = BitsPerComponent(a)
fs = propNumElements (a,"_ColorRange") > 0 ? \
propGetInt (a,"_ColorRange") == 0 : rgb
ScriptClip(a,function[bi,fs,px] () {
U = PlaneMinMaxStats(0, 0, 1, false)
V = PlaneMinMaxStats(0, 0, 2, false)
H = ex_bs(128, 8, bi, true, float=true)
U = H - U[4]
V = H - V[4]
Expr(last,SwapUV(),"",Format("x {U} +"),Format("x {V} +"), Format=px)
} ) }