AviSynth C Interface API Reference

Here is the complete ABI for the AviSynth C Interface.

The ABI closely mirrors the native Visual C++ ABI. It should provide all the functionally of the C++. The main differences from the C++ ABI are:

  1. In the way a new filter is created since virtual functions can't be used
  2. Error handling since exceptions can't be used
  3. Memory management since smart pointers can't be used.

Be sure to also check out the Illustrated Example and the orignal AviSynth development documentation.

Basic Info

Everything is defined in "avisynth_c.h". Link with "avisynth_c.lib".

The macro "AVSC_CC" should always be used after the return type when defining call back functions. This macro stands for AviSynth C calling convention. Right now it expands to "__cdecl" but it is likely to change to "__stdcall" in a future version for better compatibility with languages such as Visual Basic.

Constants

Audio Sample information:   Colorspace properties: Specific colorformats: Imagetype properties:   Subtypes:   Constants for avs_get_cpu_flags. (These are backwards-compatible with those in VirtualDub.)  

AVS_VideoInfo

typedef struct AVS_VideoInfo {
  int width, height;    // width=0 means no video
  unsigned fps_numerator, fps_denominator;
  int num_frames;

  int pixel_type;
  
  int audio_samples_per_second;   // 0 means no audio
  int sample_type;
  INT64 num_audio_samples;
  int nchannels;

  // Imagetype properties

  int image_type;
} AVS_VideoInfo;
Helper functions: Useful mutator:

AVS_VideoFrame

The "_p" suffex stands for planar.

AVS_Value

Treat AVS_Value as a fat pointer. That is use avs_copy_value and avs_release_value appropiaty as you would if AVS_Value was a pointer.

It is defined in the header file but to maintain source code compatibility with future versions of the avisynth_c API don't use the AVS_Value directly.

AVS_Value should be initilized with "avs_void". Should also set to avs_void after the value is released with avs_copy_value. Consider it the equalvent of setting a pointer to NULL

AVS_Clip

Functions for accessing an existing clip.

AVS_ScriptEnvironment

Callbacks

In order to create a new filter avs_add_function must be used to register a call back function of type AVS_ApplyFunc.
typedef struct AVS_FilterInfo
{
  // these members should not be modified outside of the AVS_ApplyFunc callback
  AVS_Clip * child;
  AVS_VideoInfo vi;
  AVS_ScriptEnvironment * env;
  AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
  int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
  int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, 
				  INT64 start, INT64 count);
  int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, 
					int frame_range);
  void (AVSC_CC * free_filter)(AVS_FilterInfo *);
  
  // Should be set when ever there is an error to report.
  // It is cleared before any of the above methods are called
  const char * error;
  // this is to store whatever and may be modified at will
  void * user_data;
} AVS_FilterInfo;
This is the structure that containts the essence of a filter. The AVS_ApplyFunc callback must manipulate it appropriately. avs_new_c_filter creates a new filter. It should be called inside the AVS_ApplyFunc call back. "fi" is set to point to the AVS_FilterInfo so that you can modify it once it is initilized. "store_child" should generally be set to true. If it is not set than ALL methods (the function pointers) must be defined. If it is set than you do not need to worry about freeing the child clip.  

"avisynth_c_plugin_init" is the entry point for the plugin and must be defined.


Copyright © 2004 Kevin Atkinson under the GPL GNU General Public License as published by the Free Software Foundation version 2.0.
Last Modified January 1, 2004.
Avisynth can be found at www.avisynth.org. The latest version of the C interface can be found at kevin.atkinson.dhs.org/avisynth_c/.