Log in

View Full Version : Speeding up Spline36Resize


Blue_MiSfit
12th March 2009, 02:47
Hey all,

So, I've noticed Spline36Resize is surprisingly slow!

Using very fast x264 settings, I get a 30fps increase (~60fps to ~90fps) by switching from Spline36 to Bilinear.

Obviously I love Spline36 and want to continue using it.

Using MT() doesn't seem like an option.

How can I go faster? :(

I'm trying to work up a very high speed transcoding workflow.

Thanks!

~MiSfit

*.mp4 guy
12th March 2009, 03:08
lanczos3
bicubic(b=0, c=0.5)

Blue_MiSfit
12th March 2009, 03:12
Well... I found the solution.

Using SetMTMode instead of MT worked much better :D

90fps for 1080p -> 480p with some decent x264 magic enabled is good enough for me!

~MiSfit

IanB
14th March 2009, 02:10
All the inbuilt resizers use the same code. The difference between them is the formula used to calculate the sample point weightings and the number of input sample points used.

For upsizing the number of samples used is just Taps*2 for downsizing it is Taps*2*In/Out.

The number of Taps for each resizer is :-

0 - Point (Minimum samples is 1)
1 - Bilinear
2 - Bicubic
2 - Spline16
3 - Lanczos or Taps=n value
3 - Spline36
4 - Blackman or Taps=n value
4 - Spline64
4 - Gauss

So Spline36 will use 3 times as many sample points as Bilinear, so the accumulation part of the code takes 3 times longer. Fortunately that part of the code is very highly optimised so the overall speed loss is nowhere near 3 times.

In your case going from 16ms per frame (60fps) to 11ms per frame (90fps) saving 5ms per frame. So each extra Tap will cost about 2.5ms per frame. i.e. Spline16 approx 72fps, Spline64 approx 52fps. These are very rough approximations, things like cache size and performance have a hugh bearing.

Also the resizers are separable, i.e. the H and V resizing are done as individual steps. The order is chosen to maximise quality by maximising the size of the intermediate image. If speed is primary over quality then you can script to minimise the intermediate image size. Also you could choose different resizer for H and V to adjust your speed/quality tradeoff. i.e.# 1920x1080 input
BilinearResize(640, 1080) # 3 times width reduction, soft
Spline16Resize(640, 480) # 2.25 times height reduction, sharp

BigDid
18th March 2009, 03:56
how do u use the SetMTMode setting? just add it to your script at the end?

Considering you know the how-to related to MT, setmtmode etc... should be:

Setmtmode (2,0) # _______ or Setmtmode (1,0) if working
spline36resize(1920,1080) # or whatever resolution needed

Setmtmode is included just before (not at the end) the resizer command BUT will affect all the followings ones; careful about the ones not compatible, the nightmare will begin :devil:
See: http://forum.doom9.org/showthread.php?t=145700

Did

Blue_MiSfit
18th March 2009, 09:05
It ended up not mattering :) I can do 2 encodes at once which are therefore not bottlenecked by AviSynth!

~MiSfit

Tuik
22nd September 2010, 13:45
It ended up not mattering :) I can do 2 encodes at once which are therefore not bottlenecked by AviSynth!

~MiSfit

How do you do that?