View Full Version : AVISynth C API Now Available
kevina
4th August 2003, 08:13
I have just released a compiler neutral C Interface to AviSynth in the forum of a plugin. You can find it at http://kevin.atkinson.dhs.org/avisynth_c/. The current version is 0.14.
I would really appreate it if some AVISynth developers could look it over and give me some feedback. I am hoping that eventually it can become part of AVISynth.
It currently is designed for AVISynth 2.5.
Enjoy.
sh0dan
4th August 2003, 08:30
First impression is good - I'll have a closer look ASAP.
sh0dan
5th August 2003, 14:28
I took a few minutes and made an attempt at integrating it into the core. I tried to implement it, so it would work seamless, and results look promising.
avisynth_c.dll seems to be required for other plugins to load - no problem - it can be included in the installation package. It does however not have to be loaded as a plugin when it is part of the core.
LoadPlugin automatically remaps C-plugins to "LoadCPlugin", if a C-plugin is detected.
I get a bunch of errors like "D:\dev\avisynth2\avisynth\avisynth_c.cpp(58) : warning C4273: 'avs_release_video_frame' : inconsistent dll linkage. dllexport assumed."
Are you interested in having C-plugins put into the core?? It seems to work very nicely!
kevina
5th August 2003, 15:15
Yes I am interested in integrating it into the core. It has not been tested very well, so for right now I rather have it as a plugin since it makes updating it easier....
I am not sure why you are getting those errors. You might need to define AVISYNTH_C_EXPORTS.
If it is integrated in the core avisynth_c.dll should not be needed. However a .lib file will be needed to compile plugins since, unlike with the VC++ API, plugins need to use several symbols from avisynth_c.dll.
I hope I am making sence to you.
sh0dan
5th August 2003, 15:23
Not much ;)
But I assume it would only be a lib for avisynth_c. Shouldn't be much of a problem. I'm committing my temp work now - I'll get back with binary, libraries, etc.
Edit: Do you have CVS access??
sh0dan
6th August 2003, 13:10
New CVS binary up, with C-plugin support.
Kurosu
6th August 2003, 16:34
I didn't take time to explore this, but if it means C-only code can be used to generate plugins and/or other compilers than MS VC++ can be used without much hassle, then that's definetely a good thing, which should be put forward even further (once it's stable, I guess).
kevina
6th August 2003, 16:52
Kurosu, that is exactly what it does. C only code, or C++ code other than VC++.
sh0dan
6th August 2003, 17:18
For now I guess it can only be tested with the example plugin in the archive above.
Kurosu
6th August 2003, 17:22
Great!
Though, I'm so much used to current Avisynth framework I would take an awful time to switch to another one (even for the better, be it 3.0 or C-code - arhg, and asm syntax would change if I use another compiler :mad: ). But not having to compile with VC++ is a big step forward into the direction of "free software".
kevina
12th August 2003, 23:24
Version 0.11 is now available at http://kevin.atkinson.dhs.org/avisynth_c/.
Minor API Changes, Bug Fixes, and enhanced examples to work with YV12.
kevina
23rd August 2003, 02:21
Version 0.12 is now available at http://kevin.atkinson.dhs.org/avisynth_c/ .
Added some missing function to the API.
Si
24th August 2003, 21:59
Kevin,
I was wondering if you'd consider doing a LoadCPlugin conversion of SimpleSample (just a conversion of SimpleSample13a would do :) )
I believe your plugin could entice more people (hopefully with good ideas) into writing Avisynth filters.
regards
Simon
kevina
24th August 2003, 22:10
I guess I could. I do provide some examples however.
If someone else cares to test out my API they could attempt to convert it. Would also give me some feedback on my design.....
Sigmatador
25th August 2003, 02:21
what about speed, do the same plugin done with vcc/icl and Cplugin have the same speed ?
kevina
25th August 2003, 02:55
There is a little bit of overhead due to a extra function call for each API method used. However, since data is retrived on a per-frame bases
the overhead should be negligible.
stickboy
25th August 2003, 04:10
Just to make sure your stance on the GPL is clear: must any plug-in that uses the Avisynth C API also be GPL'd?
kevina
25th August 2003, 04:59
It is under the same copyright of Avisynth itself. So filters must not be GPL. I will try update the copyright for the next version.
Si
25th August 2003, 15:32
@stickboy
Can I ask why you raised the question?
@kevin
COuld you explain your answer So filters must not be GPL
(Have I missed something somewhere :confused: )
regards
Simon
kevina
25th August 2003, 15:37
My mistake. Filters do not have to be GPL.
Si
25th August 2003, 15:56
@Kevin
Ta- makes sense now :)
Simon
stickboy
25th August 2003, 17:02
Originally posted by siwalters
Can I ask why you raised the question?Why not?
It isn't clear what the answer is, the answer can affect adoption of the API, and it's better to get it figured out sooner rather than later.
Si
25th August 2003, 19:31
Why not?
Thank you for concise and informative answer.:rolleyes:
And to return the favour
It isn't clear what the answer is
.. it is to me. :)
regards
Simon
stickboy
25th August 2003, 20:23
Originally posted by siwalters
Thank you for concise and informative answer.I don't see the harm in asking a simple, legit question. I have no hidden agenda or ulterior motives if that's what you're wondering. I am not trying to troll.
.. it is [clear] to me.Without kevina20723's response, no, it's not clear. The FSF's stance is that programs that use GPL'd (not LGPL'd) dynamically-linked libraries also be released under the GPL or a GPL-compatible license. However, their opinion is not necessarily binding, and AFAIK the use of GPL'd DLLs is debatable and subject to some interpretation.
I'm not against the GPL, but I just wanted to make sure that whatever licensing issues there are with the Avisynth C API are clear in advance. You don't want a situation where people who want to write good, closed-source plug-ins are discouraged unnecessarily, and you also don't want a situation where people think that closed-source plugins are okay and then discover later that they're not.
Si
25th August 2003, 21:31
There's no harm in asking a simple legit question .. I think'll you'll find we both did :)
Thank you for replying to mine. :)
I understand Kevin's position because of his answers to your question.
regards
Simon
deXtoRious
26th August 2003, 14:37
I'm a non-expercienced Delphi programmer and I wanted to know if anyone has written a unit for using AviSynth... The prospect of writing all these functions myself isn't a very appealing one...
deXtoRious
9th September 2003, 14:49
Could anybody please give any links to the syntax of invoking the AviSynth dll, any examples, docs, anything???
MfA
9th September 2003, 19:28
It is not entirely clear wether using header files constitutes copying. TO be safe GPL projects which want to allow use through dynamic linking by non GPL programs should just dual license the header files IMO ... BSD and GPL, then there is no problem. You would not be using GPL'd source in your plugins, so as long as you dont distribute your plugins with Avisynth you wont be bound by the GPL (the moment you distribute them together you are though).
libs are less of an issue since the information can just be extracted from the DLL itself, using them doesnt represent copying IMO.
Guest
9th September 2003, 21:07
Originally posted by deXtoRious
I'm a non-expercienced Delphi programmer and I wanted to know if anyone has written a unit for using AviSynth... The prospect of writing all these functions myself isn't a very appealing one... http://aquaplaning.20m.com/ might be of interest, depending on what your goals are.
kevina
10th September 2003, 05:24
I am now up to version 0.14. Get it at http://kevin.atkinson.dhs.org/avisynth_c/ .
I would really appreciate it if some people will start trying it out so I can get some feedback on the interface.
Si
10th September 2003, 08:16
I'm just repeating my suggestion to produce a "conversion" (with lots of comments unfortunately :( ) of one of the SimpleSamples.
Or 2nd'ly - lots of comments in your examples.c - but 1st suggestion would be better(for me at least ;) )
Then everyone could see the sort of changes needed to use your interface.
Obviously, the experts can already but I imagine they have super douper MS VC++ programming enviroments with lots of tools and a heavy learning investment.
Us camp followers don't but we need leading :)
And your main possible "customers" will be newbies with little/no C/C++ programming skills/complier but a strong wish to implement their brilliant idea for an Avisynth filter :)
regards
Simon
sh0dan
12th September 2003, 08:29
I added v0.14 to the new CVS binary.
kevina
12th September 2003, 08:39
Thanks did you make any changes?
Also do you really want to keep my interface in a seperate DLL?
In order to use the exported symbol GetEnvironment (or something like that), avisynth.lib is required. In order to get it I had to recompile avisynth. That lib should be made easilly available. Avisynth_c.lib is required for my interface, so why not just combine them all into avisynth.lib and avoid the extra DLL avisynth_c.dll? I hope this is making sense to you.
sh0dan
12th September 2003, 09:05
I think keeping it separate until the API is more "final" is a good idea - it's easier to maintain.
Only change is "return !!res;" instead of "return res;" somewhere. I'm a bit concerned about "D:\dev\avisynth2\avisynth\avisynth_c.cpp(301) : warning C4700: local variable 'val' used without having been initialized" in "AVSValue __cdecl create_c_video_filter".
I get unload crashes, when placing "Smartdecimate" in the plugin directory. "examples.dll" work fine, when autoloaded as a plugin. Loading smartdecimate using "Loadplugin" works fine though.
kevina
12th September 2003, 09:13
Ok thats fine. Don't know what why SmartDecimate is crashing on unload. Are you using version 0.21 or better?
sh0dan
12th September 2003, 09:17
I'm using 0.22.
It crahes in ~AtExiter(), calling the shutdownfunc.
PS. I might have edited the post above while you were ansering ;)
kevina
12th September 2003, 09:25
Ok I will look into it.
deXtoRious
12th September 2003, 22:39
neuron2 and MfA
Thanks, that really helped!
all
Any chance of a Delphi/Pascal API appearing? Not all people no C very well, you know :(
kevina
12th September 2003, 22:51
Originally posted by sh0dan
I'm a bit concerned about "D:\dev\avisynth2\avisynth\avisynth_c.cpp(301) : warning C4700: local variable 'val' used without having been initialized" in "AVSValue __cdecl create_c_video_filter".
I am 99.9% sure that VC++ is getting confused and there is nothing wrong with the code. If there was something wrong with create_c_video_filter I would of noticed by now as every filter uses that function.
If you can figure out how to get VC++ to shut up please let me know.
Bidoche
13th September 2003, 10:36
Well you can use that :
#pragma warning (disable:4700)
But that's not really curing the problem, and besides sometimes you are happy to see those warnings.
Bidoche
13th September 2003, 10:53
Try that :
AVSValue val = *reinterpret_cast<AVSValue*>(&rev);
Maybe he will like it better.
MSCV is known to report an problem different to the real one, maybe he rejects the cast and then val is truly uniitialised...
stickboy
13th September 2003, 20:10
Originally posted by kevina20723
I would really appreciate it if some people will start trying it out so I can get some feedback on the interface.I'm planning to take a crack at writing a few filters once I figure out how to set up a working build environment. (This seems perfect for me, since I have a lot of experience with C but not with C++.)
However, I'm new to using gcc with Windows. What do you use or recommend? cygwin? MinGW?
kevina
13th September 2003, 21:14
If you are use to using gcc with unix then I recommend MinGW with MSYS. If you are use to emacs you might want to install Xemacs for windows.
You can also try Visual-MinGW (http://visual-mingw.sourceforge.net/) if you want a nice GUI.
kevina
13th September 2003, 23:43
Originally posted by Bidoche
Try that :
AVSValue val = *reinterpret_cast<AVSValue*>(&rev);
Nope. This did:
AVSValue val;
val = (*(const AVSValue *)&res);
stickboy
14th September 2003, 07:55
Okay, I used your C API to write my first AviSynth plug-in (SelectByString (http://www.avisynth.org/~stickboy/SelectByString.zip); it's really simple, since it doesn't do anything with video).
Anyhow, here are my impressions so far:
a brief tutorial would be nice; otherwise people need to read the C++ tutorials and flip back-and-forth between those and avisynth_c.h
examples.c needs way more comments
if some of the structures should not be accessed directly , why not make them opaque? (It's not possible with all of them, but I think you can do it with AVS_VideoFrameBuffer and AVS_VideoFrame.)
if we're supposed to treat AVS_Value structures as opaque, why does examples.c use args.d.array[0] instead of avs_array_elt?
it's not clear how I'm supposed to manage memory. For example, can I pass a heap-allocated C string to avs_new_value_string or avs_new_value_error? Will that memory be freed for me?
kevina
14th September 2003, 08:15
Thanks for the feedback.
I agree that more documentation is needed.
>if we're supposed to treat AVS_Value structures as opaque, why does examples.c use args.d.array[0] instead of avs_array_elt?
Bad Kevin. Yes you are suppose to. But I don't always follow my own rules. I will fix it.
>if some of the structures should not be accessed directly , why not make them opaque?
If I make AVS_VideoFrameBuffer and AVS_VideoFrame opaque I would have to eleminate the inline functions. Some of them may look large but since the plane paramter is often given explistly they can be greatly simplified by the compiler.
stickboy
14th September 2003, 11:39
Originally posted by kevina20723
If I make AVS_VideoFrameBuffer and AVS_VideoFrame opaque I would have to eleminate the inline functions.Oh, duh. I somehow didn't notice they were inlined.
(Did you see my last question about memory management? I edited my post while you were replying.)
Also, when specifying the parameter types, it seems that * allows zero arguments only when applied to the first parameter. (I'm not sure if this is a problem with the C interface or with AviSynth.) Here's some sample code (http://www.csua.berkeley.edu/~jameslin/tmp/AsteriskTest.zip).
kevina
14th September 2003, 11:54
(Did you see my last question about memory management? I edited my post while you were replying.)
Please don't edit posts unless it is minor. Very Annoying.
AVS_Value will NOT free stings for you. You have to make sure it gets deleted somehow.
Also, when specifying the parameter types, it seems that * allows zero arguments only when applied to the first parameter.
That is an AVISynth problem.
kevina
2nd January 2004, 03:43
Version 0.15 is now available.
As always you can find it at http://kevin.atkinson.dhs.org/avisynth_c/
This version contains various bug fixes. I also wrote some basic documentation, including an API reference and an illustrated example.
Enjoy.
vion11
2nd January 2004, 13:51
I appreciate a robust and flexible API to avisynth.
It is a valuable path to give avisynth a gui
so more users will work with.
As far I can see the current API gives developers
complete access to all aspects of avisynth.
Loading, changing and playing of graphs/scripts
is possible.
There is also a way to create line based script
debuggers with visual control for a better handling
of complex scripts.
Unfortunately Visual Basic developper are barred,
the API still uses __cdecl instead of __stdcall
calling convention.
Quite remarkable since avisynth itself uses
the more compatible __stdcall calling convention
to export functions.
What are the next steps and how long does it will
take to get a VB compatible version of the API?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.