Skip to content

Instantly share code, notes, and snippets.

@WolframRhodium
Last active December 16, 2018 05:20
Show Gist options
  • Save WolframRhodium/b4bfe39ba6890bef418361fbf4894e3f to your computer and use it in GitHub Desktop.
Save WolframRhodium/b4bfe39ba6890bef418361fbf4894e3f to your computer and use it in GitHub Desktop.
fmtconv vs zimg (resize)

Environment:

Intel Core i7-6700HQ @ 2.60GHz, 8 GB DDR4-2133 x2,

Windows 10 1809, VapourSynth R44 64bit, fmtconv r20(CRC: 6EEDD665)

Result:

Input dimensions Output dimensions Format Backend FPS
1920 x 1080 1280 x 720 GRAY8 zimg 920
1920 x 1080 1280 x 720 GRAY8 fmtconv 700
1920 x 1080 1280 x 720 GRAY16 zimg 865
1920 x 1080 1280 x 720 GRAY16 fmtconv 680
1920 x 1080 1280 x 720 GRAYS zimg 670
1920 x 1080 1280 x 720 GRAYS fmtconv 530
1280 x 720 1920 x 1080 GRAY8 zimg 920
1280 x 720 1920 x 1080 GRAY8 fmtconv 535
1280 x 720 1920 x 1080 GRAY16 zimg 920
1280 x 720 1920 x 1080 GRAY16 fmtconv 750
1280 x 720 1920 x 1080 GRAYS zimg 770
1280 x 720 1920 x 1080 GRAYS fmtconv 570
import vapoursynth as vs
core = vs.get_core(threads=8)
core.max_cache_size = 8000
# params
test_id = 5
length = 10000
use_zimg = False
param_list = [
dict(in_w=1920, in_h=1080, out_w=1280, out_h=720, format=vs.GRAY8),
dict(in_w=1920, in_h=1080, out_w=1280, out_h=720, format=vs.GRAY16),
dict(in_w=1920, in_h=1080, out_w=1280, out_h=720, format=vs.GRAYS),
dict(in_w=1280, in_h=720, out_w=1920, out_h=1080, format=vs.GRAY8),
dict(in_w=1280, in_h=720, out_w=1920, out_h=1080, format=vs.GRAY16),
dict(in_w=1280, in_h=720, out_w=1920, out_h=1080, format=vs.GRAYS)
]
if test_id >= len(param_list):
raise ValueError(f'"test_id" is {test_id}, while only {len(param_list)} params are given')
# process
src = core.std.BlankClip(width=param_list[test_id]['in_w'], height=param_list[test_id]['in_h'], format=param_list[test_id]['format'], length=length)
if use_zimg:
res = core.resize.Bicubic(src, param_list[test_id]['out_w'], param_list[test_id]['out_h'], filter_param_a=0, filter_param_b=0.5)
else:
res = core.fmtc.resample(src, param_list[test_id]['out_w'], param_list[test_id]['out_h'], kernel='bicubic', a1=0, a2=0.5)
if res.format.bits_per_sample != src.format.bits_per_sample:
res = core.fmtc.bitdepth(res, bits=src.format.bits_per_sample)
res.set_output()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment