The last big remaining piece of VapourSynth's puzzle is being able to create 
functions that manipulate frames directly in Nim.

Filter's in VapourSynth are created following [this 
structure](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c).
 Where 
[VapourSynthPluginInit](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L58)
 is used to register a plugin. It [registers a 
function](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L60)
 in a plugin.

During the function registration, filterCreate function is referenced. The 
function 
[filterCreate](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L42-L53)
 creates the filter calling createFilter. Three addiotional functions are 
referenced here:

  * 
[filterInit](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L15-L18):
 initialize some data
  * 
[filterGetFrame](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L20-L34):
 performs the frame manipulation
  * 
[filterFree](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/filter_skeleton.c#L36-L40):
 frees stuff



A proper filter example can be found 
[here](https://github.com/vapoursynth/vapoursynth/blob/master/sdk/invert_example.c).

I don't want to create plugins from Nim, but I need to keep most of these steps 
anyway.

I managed to do something that compiles: 
[function.nim](https://github.com/mantielero/VapourSynth.nim/blob/master/test/function.nim),
 but doesn't work (yes, I know there is plenty of rubbish in it). I think it 
has to do with something related with memory managment or nil pointers of stuff 
like that (I don't have the expertise).

I have reached a point where:

  * Despite I have created an 
[issue](https://github.com/vapoursynth/vapoursynth/issues/534) and they are 
being very supportive, now it is a very specific Nim's issue.
  * It is difficult to raise the issue here, because most people is not 
familiar with VapourSynth.
  * I don't have the knowledge (I don't know C and I have never done memory 
management before).



I need somebody's help who actually knows what is doing ;oP (not my case). When 
I execute function.nim I get the following runtime error:
    
    
    /home/jose/src/VapourSynth.nim/test/function.nim(327) cropAbsCreate1
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    Error: execution of an external program failed: 
'/home/jose/src/VapourSynth.nim/test/function '

which relates to [this 
line](https://github.com/mantielero/VapourSynth.nim/blob/master/test/function.nim#L327).

Any clue?

Reply via email to