Log in

View Full Version : AVISynth C API Now Available


Pages : 1 [2]

kevina
3rd January 2004, 01:53
I plan on eventually switching to the stdcall calling convention as stated in the readme. I do not have a timeframe for doing this. There are some issues I need to work out.

If you have Visual C++ you can change the C API to use stdcall by changing AVSC_CC to "__stdcall" in "avisynth_c.h" and adding "@4" to the string "avisynth_c_plugin_init" in the line = (AvisynthCPluginInitFunc)GetProcAddress(plugin, "avisynth_c_pl
ugin_init"); in "avisynth_c.cpp". You will then need to recompile. The stdcall version of the C API will NOT be binary compatible with the cdecl version. Furthermore it may cause some problems with the latest version of AviSynth since it included a cdecl version of the C API. So you might need to downgrade to AviSynth 2.5.2.

vion11
3rd January 2004, 17:03
If I have a C compiler I wouldn't ask for a VB
compatible API. And there might be a way to talk
to avisynth without your C API, when I'm determined
to a specific version.

I'd like to understand your intention to write a API,
when most spreaded development plattform can't use it.

Isn't it simply a job of find and replace to compile
a second VB compatible API, so avisynth can be integrated
in nearly every application running in the windows world?

albertgasset
8th January 2004, 00:25
Hi,

I've written a plugin in C to learn how to use the AviSynth C Interface. It's the C version of a filter I wrote some time ago in C++ (my first Avisynth filter). The C API is great, it seems to have no errors and the documentation is quite good, although beginners may need a few more examples. But rather than language-specific docs, I think more detailed information about how Avisynth works would be useful.

I used Dev-C++ 4.9.8.5 with Mingw compiler. Some functions are in assembly, in order to optimize the code. I found NASM to be very easy to use for that task.

This filter overlays two clips, it works in RGB32 and YUY2, and iits optimized for MMX. Some of the parameters are: alpha, colorkey, tolerance and fade in/out.

Download: http://www.fib.upc.es/~e7716401/Blend-1.1.zip

I really like the C interface, and its possibility to be used in any C/C++ compiler. I'm going to use it in all the Avisynth plugins I write in the future. Keep improving it and thanks!

kevina
8th January 2004, 04:46
albertgasset, thanks for the feedback. I am glad you like my C Interface.

vion11, I will release an experimental stdcall in a week or so for you to try out.

kevina
9th January 2004, 23:05
A experimental stdcall version is now available at http://kevin.atkinson.dhs.org/avisynth_c/avisynth_c-stdcall.zip .

This version IS NOT binary compatible with any other version and it might have problems with AviSynth 2.5.3 so you might need to downgrade to AviSynth 2.5.2.

vion11
9th January 2004, 23:26
Many thanks.
will include and try in the AVEditor now.
Expect feedback here....

vion11
11th January 2004, 13:34
I've started dealing with 2 functions:
-> avs_create_script_environment
-> avs_function_exists

avs_create_script_environment works and returns a value.
No more "Bad calling convention".

I pass the value back to avs_function_exists along
with a function name expecting a return code.
This forces windows to close the application.

I followed the translation rules for passing arguments
to a DLL found here (http://www.rdrop.com/~cary/program/mixed_language.html) and here (http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q187/9/12.asp&NoWebContent=1&NoWebContent=1).

What exactly is the return value from avs_create_script_environment?
Is it a pointer to the structure AVS_ScriptEnvironment
found in avisynth_c.cpp?

You can find source and binary to reproduce the error here (http://innerphase.de/Setup-ApiTest.exe).

Fizick
13th January 2004, 22:07
To Kevin:
What about Borland C (Free compiler tools)?
I try use it with AVISYNTH_C 0.14, but Borland use leading underscore with their library function names.

timecop
16th January 2004, 06:34
I don't want to sound like a troll here, but what exactly is everyone's beef with VC++?

So now instead of a single codebase of plugins all written in C++, using a high quality optimizing compiler, everyone and their mother can download a commie compiler/IDE like mingw/devc++ and write a crappy slow plugin?

I appreciate the effort of whoever spent time to write the C-interface for this, but after reading all 3 pages of this thread it just seems the entire purpose was to "stick the man" and "screw micro$oft".

You DO realize that avisynth runs on Windows and ONLY on Windows? There are plenty of qualified, skillful plugin writers for avisynth. Those that can't be bothered to either
a) purchase academic version of Visual C++
b) follow numerous guides explaining how to use (unoptimizing) C/C++
compiler inside .net framework package
should probably not be writing anything important that touches my video, either.

And seeing how this thread's been around for a few months, did anyone actually write anything more than a proof-of-concept plugin yet?

kevina
16th January 2004, 07:09
Dear timecop,

You, my friend are an asshole. I do not answer to assholes. That is all I am going to say.

To the moderators. If you delete my post you better delete his and ban his from this thread. If you delete (or modify) my post with out his you will probably never hear from me again.

timecop
16th January 2004, 07:38
Originally posted by kevina20723
Dear timecop,

You, my friend are an asshole. I do not answer to assholes. That is all I am going to say.

To the moderators. If you delete my post you better delete his and ban his from this thread. If you delete (or modify) my post with out his you will probably never hear from me again.

are we that touchy?
good grief.
I just stated my opinion and asked a serious question.
no need to get all bunched up over it.

kevina
16th January 2004, 07:46
You asked it in an extremely bias way:
... commie compiler/IDE like mingw/devc++ and write a crappy slow plugin?

...it just seems the entire purpose was to "stick the man" and "screw micro$oft".

timecop
16th January 2004, 07:52
Yeah.
Then (after your immediate "screw you" reply), I searched for your posts, and lo and behold, I was right.


Thread: Intent to get Avisynth working under Linux.


However, voicing my opinion about THAT particular thread will certainly get me banned from here AND start a totally offtopic discussion.

so unless you are going to (not that I'm forcing you or anything) answer the questions in my original post, consider this discussion dropped.

and to quote a message from your linux "port" thread,

Realisticly I don't think many of the current plugin writers would care enough to port them themselves, as there is no real gain by using the C-API, expect compiler independence.

I completely agree.

vion11
16th January 2004, 10:45
And seeing how this thread's been around for
a few months, did anyone actually write anything
more than a proof-of-concept plugin yet? The API is not only useful for writing plugins.
It enables better GUIs (http://forum.doom9.org/showthread.php?s=&threadid=68392) as well.

You'll see the impact when the experimental
stdcall version is ready to work.

sh0dan
16th January 2004, 10:47
@kevina20723: That was totally uncalled for! You might disagree with timecop, but if you cannot argue by other ways that flames - don't reply! You might have noticed a rule 4 strike - you are not new here, so there are no excuses. Followup to PM - not here!


@timecop: There are plenty of good reasons to have a compiler independent API. First and foremost is that people can write plugins in whatever compiler they prefer for whatever reason.

One reason is the price of the MS Dev. studio. Another reason is that it might also open open for infacing with other languages (VB, Delphi, etc). There are plenty of good reasons, and I see avisynth_c as a great advancement for AviSynth.

kevina
16th January 2004, 11:04
@sh0dan: His question was extremely leading and insulting to me. I don't particularly like online forms so I don't know if I will be posting any more to this forum.

kevina
16th January 2004, 11:46
Here is another stdcall version to try:

http://kevin.atkinson.dhs.org/avisynth_c/avisynth_c-stdcall-def.zip .

This one was compiled with a .def file. If this doesn't work I don't know what else to do. Someone with more experence on creating a proper DLL will need to play with it.

@sh0dan: You should eventually switch AviSynth over to using the stdcall version of the C API once it gets compiled into a proper DLL.

This may very well be my last version of the C API, and my last post. I far better things to do.

timecop
16th January 2004, 11:52
Originally posted by sh0dan
@timecop: There are plenty of good reasons to have a compiler independent API. First and foremost is that people can write plugins in whatever compiler they prefer for whatever reason.

One reason is the price of the MS Dev. studio. Another reason is that it might also open open for infacing with other languages (VB, Delphi, etc). There are plenty of good reasons, and I see avisynth_c as a great advancement for AviSynth.

about the first point, I suppose I don't care as long as the plugin's performance doesnt suffer from the fact that a less capable compiler was used to generate the code,

and about the second point, i believe education version of vc++ is ~$100, and even if that is too high, you can just compile your own versions with non-optimizing .net framework compilers (free) and release the source/makefiles so that others can compile it in vc++.

but yes, I see that it is indeed useful. I was more interested to know if anyone actually used this for anything other than testing/debugging, that's all. Didn't mean to start this whole mess.

Wilbert
16th January 2004, 12:16
@kevin,

Yes, timecop's post was a bit offensive and disrespectful. I hope he also noticed that.

This may very well be my last version of the C API, and my last post. I far better things to do.
Please, give it a night to think it over. We really do appreciate your work on this, and on the other filters you have made. I will be a pity if you leave this forum, just because someone posted an offensive reply.

RB
16th January 2004, 12:24
This may be a little OT, but just in case anyone cares: for a small shipping charge, you can order the Windows DDK (http://www.microsoft.com/whdc/ddk/ordernetddkcd.mspx) from MS. While the package is intended to be used for building Windows kernel drivers, it comes with their latest optimizing compiler (command line tools, no GUI) and you can happily build user mode stuff with this as well, you just need to figure out how to set up a SOURCES file and type BUILD to compile (the included docs explain everything). Or you just drop the new compiler executables into your MSVC++ (Standard ed.) directory in the appropriate places and it will automatically recognize them (optimization settings in project settings become available etc.) :D

sh0dan
16th January 2004, 13:04
Originally posted by kevina20723
This one was compiled with a .def file. If this doesn't work I don't know what else to do. Someone with more experence on creating a proper DLL will need to play with it.

Can I just use the source from the older binary to compile the dll, or is there some other changes?

kevina
16th January 2004, 13:11
Use the source in the new zip. There are some minor changes.

sh0dan
16th January 2004, 13:18
I was thinking about "avisynth_c.cpp". I'd rather not link to the library without having the source, as this would leave me with no chance of fixing any protential problems if they should arise. Having a primary API that I cannot support is not good IMO.

Edit: Ah - found the "avisynth_c-stdcall-def.zip" file - now all is good ! :)

Edit 2: The ".def"-file seems to help. The dll exports have quite nice names by now! No more @2 and @4 names.

vion11
16th January 2004, 14:34
Strike!

Got working so far:
- avs_create_script_environment
- avs_function_exists
- avs_get_cpu_flags
- avs_check_version

These declarations work:

Private Declare Function avs_create_script_environment_
Lib "AVISYNTH_CVB.DLL" (ByVal Version As Long) As Long
Private Declare Function avs_function_exists_
Lib "AVISYNTH_CVB.DLL" (ByVal pEnv As Long, ByVal sFunction As String) As Long
Private Declare Function avs_get_cpu_flags_
Lib "AVISYNTH_CVB.DLL" (ByVal pEnv As Long) As Long
Private Declare Function avs_check_version_
Lib "AVISYNTH_CVB.DLL" (ByVal pEnv As Long, nVersion As Long) As Long

I've renamed the DLL to avoid conflicts.

Ignus2
3rd December 2006, 13:05
First and foremost, I'd like to express my BIG THANKS to kevin, as my favourite compiler is GCC, and he made it possible for me to use it for writing my avisynth plugins :thanks:

Second, I'd like to request that the avisynth_c interface be updated in the 2.6 branch.

For example, I use the Y8 format between my filters, and avisynth_c.h doesn't yet define the necessary defines and functions for it (so I had to do it in my header file). I don't know if there is anything else missing.
Could someone take a look at it? It would be much appreciated.

--
Greets!