Sorry the YUY2 version of the YtoUV() code is broken. See
post 132 above by Stainless.
The planar version works so you could use an intermediate YV16 and then convert that to YUY2 at the end.
Also a better workflow in 2.6 would be RGB -> YV24 -> nnedi3 -> YV16 -> YUY2, which would save doubling the chroma width.
Code:
ImageSource("TSW Charger V4.4.jpg", end=0) # RGB Format
ConvertToYV24() # No chroma subsampling
nnediresize_YUY2()
function nnediresize2x(clip c, bool pY, bool pU, bool pV)
{
v = c.nnedi3(dh=true,Y=pY,U=pU,V=pV,field=0).turnleft()
v = v.nnedi3(dh=true,Y=pY,U=pU,V=pV,field=0).turnright()
return v
}
function nnediresize_YUY2(clip c)
{
cy = c.ConvertToY8().ConvertToYV12() # Fast extract Y, blank chroma
cu = c.UtoY8().ConvertToYV12() # Fast extract U to Y, blank chroma
cv = c.VtoY8().ConvertToYV12() # Fast extract V to Y, blank chroma
cy = nnediresize2x(cy,true,false,false) # Double height and double width
cu = nnedi3(dh=true,Y=True,U=False,V=False,field=0) # Double height only
cv = nnedi3(dh=true,Y=True,U=False,V=False,field=0) # Double height only
YtoUV(cu,cv,cy) # YV16 output
return ConvertToYUY2() # Lossless conversion to YUY2
}
The *toY8() are all zero cost (pointer flip only) for planar. The Y8 to YV12 costs a plane blit + 2 memfills. A normal YV24 to YV12 would cost a resize of the chroma but as we don't want them here we can save a lot. As nnedi3() is a 2.5 filter it must have YV12.