It has improved a bit. Regarding the Nim filter:
* 308fps by tuning seq[seq[int]], into array[9,int32]
* 442fps by changing the bound checks into min( max(val, 0), max_val)
Still slow but getting better.
import ../vapoursynth
import math
template clamp(val:int,
This is the source of your slowness
let kernel = @[@[1, 2, 1],
@[2, 4, 2],
@[1, 2, 1] ]
Run
Instead you should use
let kernel = [[1, 2, 1],
[2, 4, 2],
[1, 2, 1]]
Run
**Working with C filters**
When I work with C filters (like Convolution) I works fine with refc GC. In
that case, I don't know why I get 2640fps vs 3740fps on the python version.
They should be roughly the same. When I call a filter within an existing plugin
I just call one function:
> At this stage I can only recommend NOT to use VapourSynth.nim. It is too slow
Please note that your first task would be to make it work with default refc GC
and with arc GC.
\--gc:none was only suggested for tests, as you reported that it crash with
refc GC.|
---|---
For performance
At this stage I can only recommend NOT to use VapourSynth.nim. It is too slow
(not because of nim, but I cannot find out why).
Testing the convolution filter in Python:
import vapoursynth as vs
core = vs.get_core()
core.std.SetMaxCPU('none')
clip =
I would prefer UncheckedArray, since it's integrated directly into Nim and also
because I personally it's semantics.
If you want to expose an API in a safer way UncheckedArrays also have the
advantage that they can be
Let me try asking less general questions:
What is preferred, using UncheckedArray, using [these
templates](https://forum.nim-lang.org/t/1188#7366)? I guess all this is better
than performing a memcopy into a Nim structure.
My filters are unsurprisingly slow (because of the "My" variable, of course).
Now I would like to learn how to avoid that. I have implemented a Gauss filter
just to compare it with a C++ version . The results are 80fps (for me) against
about 2400fps for a C++ wrapper and 11748fps for a pure C
Just for the record the C++ version is
[here](https://github.com/IFeelBloated/vsFilterScript/blob/master/GaussBlur.hxx#L23)
using templates.
And this is by using the [low level
API](https://github.com/IFeelBloated/test_c_filters/blob/master/GaussBlur.cxx#L26).