基于一些速度测试,希望加入zresize和zmartrix函数。
fuchanghao opened this issue · comments
测试结论基于:
vapoursynth r1856
zimg r700
fmtc r20
mvsfunc r47
1.比起zdepth而言,如果建立zresize和zmartrix能有效提高速度。
例如对于420P16输入:
res = core.resize.Bicubic(res, format=vs.YUV444P16, matrix_in_s="709")
res = core.fmtc.resample (res, css="444")
或是YUV444P16输入:
res = core.resize.Point(res, format=vs.RGB48, matrix_in_s="709")
res = core.fmtc.matrix(res, mat="709", col_fam=vs.RGB)
实际对于RGB48/RGBS/YUV444PS测试结果也显示,core的表现优于fmtc。
相反zdepth相关测试:无论是升bitdepth
如
res = core.resize.Point(res, format=vs.YUV420P16) 150-180fps,换成res = core.std.Expr(res,["x 256 *"],vs.YUV420P16)也是如此。
res = core.fmtc.bitdepth(res,bits=16) 200-250fps接近视频解码速度300fps。
还是降bitdepth
如
res = core.resize.Point(res, format=vs.RGB24,dither_type="error_diffusion")
res = core.fmtc.bitdepth(res, bits=8)
速度都是fmtc更胜一筹。
2.还有就是有如下优化空间:滤镜同样效果下,能一次性搞定千万不要分多次搞定。
例如8bit input:
res = core.fmtc.bitdepth(res,bits=16)
res = core.fmtc.resample(res, css="444")
如果这样写就会比
res = core.fmtc.resample(res, css="444")
同样是16bit输出,前者慢至少30%。
同理诸如:
res = core.resize.Point(res, format=vs.YUV420P16)
res = core.resize.Bicubic(res, format=vs.YUV444P16, matrix_in_s="709")
res = core.resize.Point(res, format=vs.RGB48, matrix_in_s="709")
就比
res = core.resize.Bicubic(res, format=vs.RGB48, matrix_in_s="709")
慢了一倍不止,而且内存占用更大。
res = core.fmtc.resample(res, css="444")
所以如果能生成诸如:
res = core.resize.Bicubic(res, format=vs.RGB48, matrix_in_s="709")
就会比如下计算
res = core.fmtc.resample(res, css="444")
res = core.fmtc.matrix(res, mat="709", col_fam=vs.RGB)
要优质的多。
- mvf.ToYUV和mvf.ToRGB本来就是基于fmtconv的wrapper,而core.resize自身已经是wrapper(而且是在滤镜内部,效率更高),没有再去编写的必要,需要的话直接用。
- mvf.Depth之所以提供zimg的支持,是因为zimg支持的bit depth更多。以前版本的fmtconv对full range的定义是错误的,所以用zimg代替,但现在已经修正,所以再无必要。
- fmtconv的bitdepth支持的dither类型更多,而且error diffusion的优化比zimg好。resample、matrix也都有更多支持的功能,所以塞进同一个wrapper里只会让它变得更难用更难理解。
- 需要用fmtc.resample时mvsfunc里已经避免了先过一次Depth转换。
大致了解了。
感谢mawen大大的解答。