avisynth_c.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. // Avisynth C Interface Version 0.20
  2. // Copyright 2003 Kevin Atkinson
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 2 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. // MA 02110-1301 USA, or visit
  17. // http://www.gnu.org/copyleft/gpl.html .
  18. //
  19. // As a special exception, I give you permission to link to the
  20. // Avisynth C interface with independent modules that communicate with
  21. // the Avisynth C interface solely through the interfaces defined in
  22. // avisynth_c.h, regardless of the license terms of these independent
  23. // modules, and to copy and distribute the resulting combined work
  24. // under terms of your choice, provided that every copy of the
  25. // combined work is accompanied by a complete copy of the source code
  26. // of the Avisynth C interface and Avisynth itself (with the version
  27. // used to produce the combined work), being distributed under the
  28. // terms of the GNU General Public License plus this exception. An
  29. // independent module is a module which is not derived from or based
  30. // on Avisynth C Interface, such as 3rd-party filters, import and
  31. // export plugins, or graphical user interfaces.
  32. // NOTE: this is a partial update of the Avisynth C interface to recognize
  33. // new color spaces added in Avisynth 2.60. By no means is this document
  34. // completely Avisynth 2.60 compliant.
  35. #ifndef __AVISYNTH_C__
  36. #define __AVISYNTH_C__
  37. #include "avs/config.h"
  38. #include "avs/capi.h"
  39. #include "avs/types.h"
  40. /////////////////////////////////////////////////////////////////////
  41. //
  42. // Constants
  43. //
  44. #ifndef __AVISYNTH_6_H__
  45. enum { AVISYNTH_INTERFACE_VERSION = 6 };
  46. #endif
  47. enum {AVS_SAMPLE_INT8 = 1<<0,
  48. AVS_SAMPLE_INT16 = 1<<1,
  49. AVS_SAMPLE_INT24 = 1<<2,
  50. AVS_SAMPLE_INT32 = 1<<3,
  51. AVS_SAMPLE_FLOAT = 1<<4};
  52. enum {AVS_PLANAR_Y=1<<0,
  53. AVS_PLANAR_U=1<<1,
  54. AVS_PLANAR_V=1<<2,
  55. AVS_PLANAR_ALIGNED=1<<3,
  56. AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED,
  57. AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED,
  58. AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED,
  59. AVS_PLANAR_A=1<<4,
  60. AVS_PLANAR_R=1<<5,
  61. AVS_PLANAR_G=1<<6,
  62. AVS_PLANAR_B=1<<7,
  63. AVS_PLANAR_A_ALIGNED=AVS_PLANAR_A|AVS_PLANAR_ALIGNED,
  64. AVS_PLANAR_R_ALIGNED=AVS_PLANAR_R|AVS_PLANAR_ALIGNED,
  65. AVS_PLANAR_G_ALIGNED=AVS_PLANAR_G|AVS_PLANAR_ALIGNED,
  66. AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED};
  67. // Colorspace properties.
  68. enum {AVS_CS_BGR = 1<<28,
  69. AVS_CS_YUV = 1<<29,
  70. AVS_CS_INTERLEAVED = 1<<30,
  71. AVS_CS_PLANAR = 1<<31,
  72. AVS_CS_SHIFT_SUB_WIDTH = 0,
  73. AVS_CS_SHIFT_SUB_HEIGHT = 8,
  74. AVS_CS_SHIFT_SAMPLE_BITS = 16,
  75. AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
  76. AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
  77. AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
  78. AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
  79. AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
  80. AVS_CS_UPLANEFIRST = 1 << 4, // I420
  81. AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
  82. AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
  83. AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
  84. AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
  85. AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
  86. AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
  87. AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
  88. AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
  89. AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK,
  90. AVS_CS_PLANAR_FILTER = ~( AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST )};
  91. // Specific colorformats
  92. enum {
  93. AVS_CS_UNKNOWN = 0,
  94. AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
  95. AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
  96. AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
  97. // AVS_CS_YV12 = 1<<3 Reserved
  98. // AVS_CS_I420 = 1<<4 Reserved
  99. AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED,
  100. AVS_CS_YV24 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // YVU 4:4:4 planar
  101. AVS_CS_YV16 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:2 planar
  102. AVS_CS_YV12 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:0 planar
  103. AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar
  104. AVS_CS_IYUV = AVS_CS_I420,
  105. AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:1 planar
  106. AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:0 planar
  107. AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar
  108. };
  109. enum {
  110. AVS_IT_BFF = 1<<0,
  111. AVS_IT_TFF = 1<<1,
  112. AVS_IT_FIELDBASED = 1<<2};
  113. enum {
  114. AVS_FILTER_TYPE=1,
  115. AVS_FILTER_INPUT_COLORSPACE=2,
  116. AVS_FILTER_OUTPUT_TYPE=9,
  117. AVS_FILTER_NAME=4,
  118. AVS_FILTER_AUTHOR=5,
  119. AVS_FILTER_VERSION=6,
  120. AVS_FILTER_ARGS=7,
  121. AVS_FILTER_ARGS_INFO=8,
  122. AVS_FILTER_ARGS_DESCRIPTION=10,
  123. AVS_FILTER_DESCRIPTION=11};
  124. enum { //SUBTYPES
  125. AVS_FILTER_TYPE_AUDIO=1,
  126. AVS_FILTER_TYPE_VIDEO=2,
  127. AVS_FILTER_OUTPUT_TYPE_SAME=3,
  128. AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4};
  129. enum {
  130. // New 2.6 explicitly defined cache hints.
  131. AVS_CACHE_NOTHING=10, // Do not cache video.
  132. AVS_CACHE_WINDOW=11, // Hard protect upto X frames within a range of X from the current frame N.
  133. AVS_CACHE_GENERIC=12, // LRU cache upto X frames.
  134. AVS_CACHE_FORCE_GENERIC=13, // LRU cache upto X frames, override any previous CACHE_WINDOW.
  135. AVS_CACHE_GET_POLICY=30, // Get the current policy.
  136. AVS_CACHE_GET_WINDOW=31, // Get the current window h_span.
  137. AVS_CACHE_GET_RANGE=32, // Get the current generic frame range.
  138. AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache.
  139. AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio.
  140. AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte intial cache.
  141. AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte intial cache.
  142. AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy.
  143. AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size.
  144. AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N.
  145. AVS_CACHE_PREFETCH_GO=101, // Action video prefetches.
  146. AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section).
  147. AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start.
  148. AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start.
  149. AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length.
  150. AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section).
  151. AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches.
  152. AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode.
  153. AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size.
  154. AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode.
  155. AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size.
  156. AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost.
  157. AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only).
  158. AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit).
  159. AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast)
  160. AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time)
  161. AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow)
  162. AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safetyness.
  163. AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default!
  164. AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default!
  165. AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance.
  166. AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded.
  167. AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern.
  168. AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic.
  169. AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost)
  170. AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost)
  171. };
  172. #ifdef BUILDING_AVSCORE
  173. struct AVS_ScriptEnvironment {
  174. IScriptEnvironment * env;
  175. const char * error;
  176. AVS_ScriptEnvironment(IScriptEnvironment * e = 0)
  177. : env(e), error(0) {}
  178. };
  179. #endif
  180. typedef struct AVS_Clip AVS_Clip;
  181. typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;
  182. /////////////////////////////////////////////////////////////////////
  183. //
  184. // AVS_VideoInfo
  185. //
  186. // AVS_VideoInfo is layed out identicly to VideoInfo
  187. typedef struct AVS_VideoInfo {
  188. int width, height; // width=0 means no video
  189. unsigned fps_numerator, fps_denominator;
  190. int num_frames;
  191. int pixel_type;
  192. int audio_samples_per_second; // 0 means no audio
  193. int sample_type;
  194. INT64 num_audio_samples;
  195. int nchannels;
  196. // Imagetype properties
  197. int image_type;
  198. } AVS_VideoInfo;
  199. // useful functions of the above
  200. AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)
  201. { return (p->width!=0); }
  202. AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)
  203. { return (p->audio_samples_per_second!=0); }
  204. AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
  205. { return !!(p->pixel_type&AVS_CS_BGR); }
  206. AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
  207. { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties
  208. AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)
  209. { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; }
  210. AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
  211. { return !!(p->pixel_type&AVS_CS_YUV ); }
  212. AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)
  213. { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
  214. AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p);
  215. AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p);
  216. AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ;
  217. AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);
  218. AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p);
  219. AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
  220. { return ((p->image_type & property)==property ); }
  221. AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)
  222. { return !!(p->pixel_type & AVS_CS_PLANAR); }
  223. AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space);
  224. AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)
  225. { return !!(p->image_type & AVS_IT_FIELDBASED); }
  226. AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)
  227. { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); }
  228. AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)
  229. { return !!(p->image_type & AVS_IT_BFF); }
  230. AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)
  231. { return !!(p->image_type & AVS_IT_TFF); }
  232. AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);
  233. AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);
  234. AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);
  235. AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels);
  236. AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);
  237. AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);
  238. AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)
  239. { return p->audio_samples_per_second; }
  240. AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)
  241. {
  242. switch (p->sample_type) {
  243. case AVS_SAMPLE_INT8: return sizeof(signed char);
  244. case AVS_SAMPLE_INT16: return sizeof(signed short);
  245. case AVS_SAMPLE_INT24: return 3;
  246. case AVS_SAMPLE_INT32: return sizeof(signed int);
  247. case AVS_SAMPLE_FLOAT: return sizeof(float);
  248. default: return 0;
  249. }
  250. }
  251. AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)
  252. { return p->nchannels*avs_bytes_per_channel_sample(p);}
  253. AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames)
  254. { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
  255. AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
  256. { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); }
  257. AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes)
  258. { return bytes / avs_bytes_per_audio_sample(p); }
  259. AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
  260. { return samples * avs_bytes_per_audio_sample(p); }
  261. AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)
  262. { return p->nchannels; }
  263. AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)
  264. { return p->sample_type;}
  265. // useful mutator
  266. AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)
  267. { p->image_type|=property; }
  268. AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)
  269. { p->image_type&=~property; }
  270. AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
  271. { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
  272. AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
  273. {
  274. unsigned x=numerator, y=denominator;
  275. while (y) { // find gcd
  276. unsigned t = x%y; x = y; y = t;
  277. }
  278. p->fps_numerator = numerator/x;
  279. p->fps_denominator = denominator/x;
  280. }
  281. #ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR
  282. AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)
  283. {
  284. return (x->pixel_type == y->pixel_type)
  285. || (avs_is_yv12(x) && avs_is_yv12(y));
  286. }
  287. #endif
  288. /////////////////////////////////////////////////////////////////////
  289. //
  290. // AVS_VideoFrame
  291. //
  292. // VideoFrameBuffer holds information about a memory block which is used
  293. // for video data. For efficiency, instances of this class are not deleted
  294. // when the refcount reaches zero; instead they're stored in a linked list
  295. // to be reused. The instances are deleted when the corresponding AVS
  296. // file is closed.
  297. // AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer
  298. // DO NOT USE THIS STRUCTURE DIRECTLY
  299. typedef struct AVS_VideoFrameBuffer {
  300. BYTE * data;
  301. int data_size;
  302. // sequence_number is incremented every time the buffer is changed, so
  303. // that stale views can tell they're no longer valid.
  304. volatile long sequence_number;
  305. volatile long refcount;
  306. } AVS_VideoFrameBuffer;
  307. // VideoFrame holds a "window" into a VideoFrameBuffer.
  308. // AVS_VideoFrame is layed out identicly to IVideoFrame
  309. // DO NOT USE THIS STRUCTURE DIRECTLY
  310. typedef struct AVS_VideoFrame {
  311. volatile long refcount;
  312. AVS_VideoFrameBuffer * vfb;
  313. int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture.
  314. int row_sizeUV, heightUV;
  315. } AVS_VideoFrame;
  316. // Access functions for AVS_VideoFrame
  317. AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);
  318. #ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR
  319. AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) {
  320. return avs_get_pitch_p(p, 0);}
  321. #endif
  322. AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);
  323. AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) {
  324. return p->row_size; }
  325. AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);
  326. AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) {
  327. return p->height;}
  328. AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);
  329. #ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR
  330. AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) {
  331. return avs_get_read_ptr_p(p, 0);}
  332. #endif
  333. AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);
  334. AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane);
  335. #ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR
  336. AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) {
  337. return avs_get_write_ptr_p(p, 0);}
  338. #endif
  339. AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
  340. // makes a shallow copy of a video frame
  341. AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
  342. #ifndef AVSC_NO_DECLSPEC
  343. AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f)
  344. {avs_release_video_frame(f);}
  345. AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f)
  346. {return avs_copy_video_frame(f);}
  347. #endif
  348. /////////////////////////////////////////////////////////////////////
  349. //
  350. // AVS_Value
  351. //
  352. // Treat AVS_Value as a fat pointer. That is use avs_copy_value
  353. // and avs_release_value appropiaty as you would if AVS_Value was
  354. // a pointer.
  355. // To maintain source code compatibility with future versions of the
  356. // avisynth_c API don't use the AVS_Value directly. Use the helper
  357. // functions below.
  358. // AVS_Value is layed out identicly to AVSValue
  359. typedef struct AVS_Value AVS_Value;
  360. struct AVS_Value {
  361. short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
  362. // for some function e'rror
  363. short array_size;
  364. union {
  365. void * clip; // do not use directly, use avs_take_clip
  366. char boolean;
  367. int integer;
  368. float floating_pt;
  369. const char * string;
  370. const AVS_Value * array;
  371. } d;
  372. };
  373. // AVS_Value should be initilized with avs_void.
  374. // Should also set to avs_void after the value is released
  375. // with avs_copy_value. Consider it the equalvent of setting
  376. // a pointer to NULL
  377. static const AVS_Value avs_void = {'v'};
  378. AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
  379. AVSC_API(void, avs_release_value)(AVS_Value);
  380. AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
  381. AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
  382. AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
  383. AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }
  384. AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }
  385. AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
  386. AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
  387. AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
  388. AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
  389. AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
  390. AVSC_INLINE int avs_as_bool(AVS_Value v)
  391. { return v.d.boolean; }
  392. AVSC_INLINE int avs_as_int(AVS_Value v)
  393. { return v.d.integer; }
  394. AVSC_INLINE const char * avs_as_string(AVS_Value v)
  395. { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
  396. AVSC_INLINE double avs_as_float(AVS_Value v)
  397. { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }
  398. AVSC_INLINE const char * avs_as_error(AVS_Value v)
  399. { return avs_is_error(v) ? v.d.string : 0; }
  400. AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
  401. { return v.d.array; }
  402. AVSC_INLINE int avs_array_size(AVS_Value v)
  403. { return avs_is_array(v) ? v.array_size : 1; }
  404. AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
  405. { return avs_is_array(v) ? v.d.array[index] : v; }
  406. // only use these functions on an AVS_Value that does not already have
  407. // an active value. Remember, treat AVS_Value as a fat pointer.
  408. AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
  409. { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
  410. AVSC_INLINE AVS_Value avs_new_value_int(int v0)
  411. { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }
  412. AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
  413. { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
  414. AVSC_INLINE AVS_Value avs_new_value_float(float v0)
  415. { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
  416. AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
  417. { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }
  418. #ifndef AVSC_NO_DECLSPEC
  419. AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)
  420. { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
  421. #endif
  422. AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
  423. { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
  424. /////////////////////////////////////////////////////////////////////
  425. //
  426. // AVS_Clip
  427. //
  428. AVSC_API(void, avs_release_clip)(AVS_Clip *);
  429. AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
  430. AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
  431. AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
  432. AVSC_API(int, avs_get_version)(AVS_Clip *);
  433. AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
  434. // The returned video frame must be released with avs_release_video_frame
  435. AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
  436. // return field parity if field_based, else parity of first field in frame
  437. AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
  438. INT64 start, INT64 count);
  439. // start and count are in samples
  440. AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
  441. int cachehints, int frame_range);
  442. // This is the callback type used by avs_add_function
  443. typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
  444. (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);
  445. typedef struct AVS_FilterInfo AVS_FilterInfo;
  446. struct AVS_FilterInfo
  447. {
  448. // these members should not be modified outside of the AVS_ApplyFunc callback
  449. AVS_Clip * child;
  450. AVS_VideoInfo vi;
  451. AVS_ScriptEnvironment * env;
  452. AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
  453. int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
  454. int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
  455. INT64 start, INT64 count);
  456. int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
  457. int frame_range);
  458. void (AVSC_CC * free_filter)(AVS_FilterInfo *);
  459. // Should be set when ever there is an error to report.
  460. // It is cleared before any of the above methods are called
  461. const char * error;
  462. // this is to store whatever and may be modified at will
  463. void * user_data;
  464. };
  465. // Create a new filter
  466. // fi is set to point to the AVS_FilterInfo so that you can
  467. // modify it once it is initilized.
  468. // store_child should generally be set to true. If it is not
  469. // set than ALL methods (the function pointers) must be defined
  470. // If it is set than you do not need to worry about freeing the child
  471. // clip.
  472. AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
  473. AVS_FilterInfo * * fi,
  474. AVS_Value child, int store_child);
  475. /////////////////////////////////////////////////////////////////////
  476. //
  477. // AVS_ScriptEnvironment
  478. //
  479. // For GetCPUFlags. These are backwards-compatible with those in VirtualDub.
  480. enum {
  481. /* slowest CPU to support extension */
  482. AVS_CPU_FORCE = 0x01, // N/A
  483. AVS_CPU_FPU = 0x02, // 386/486DX
  484. AVS_CPU_MMX = 0x04, // P55C, K6, PII
  485. AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
  486. AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
  487. AVS_CPU_SSE2 = 0x20, // PIV, Hammer
  488. AVS_CPU_3DNOW = 0x40, // K6-2
  489. AVS_CPU_3DNOW_EXT = 0x80, // Athlon
  490. AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
  491. // which only Hammer will have anyway)
  492. AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice
  493. AVS_CPUF_SSSE3 = 0x200, // Core 2
  494. AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield
  495. AVS_CPUF_SSE4_1 = 0x400,
  496. //AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer
  497. AVS_CPUF_SSE4_2 = 0x1000, // Nehalem
  498. //AVS_CPUF_AVX2 = 0x2000, // Haswell
  499. //AVS_CPUF_AVX512 = 0x4000, // Knights Landing
  500. };
  501. AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
  502. AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
  503. AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
  504. AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
  505. AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
  506. AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val);
  507. // note: val is really a va_list; I hope everyone typedefs va_list to a pointer
  508. AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
  509. const char * name, const char * params,
  510. AVS_ApplyFunc apply, void * user_data);
  511. AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
  512. AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
  513. AVS_Value args, const char** arg_names);
  514. // The returned value must be be released with avs_release_value
  515. AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
  516. // The returned value must be be released with avs_release_value
  517. AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
  518. AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
  519. //void avs_push_context(AVS_ScriptEnvironment *, int level=0);
  520. //void avs_pop_context(AVS_ScriptEnvironment *);
  521. AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
  522. const AVS_VideoInfo * vi, int align);
  523. // align should be at least 16
  524. #ifndef AVSC_NO_DECLSPEC
  525. AVSC_INLINE
  526. AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,
  527. const AVS_VideoInfo * vi)
  528. {return avs_new_video_frame_a(env,vi,FRAME_ALIGN);}
  529. AVSC_INLINE
  530. AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,
  531. const AVS_VideoInfo * vi)
  532. {return avs_new_video_frame_a(env,vi,FRAME_ALIGN);}
  533. #endif
  534. AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
  535. AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);
  536. typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);
  537. AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
  538. AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
  539. // The returned video frame must be be released
  540. AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
  541. AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
  542. // avisynth.dll exports this; it's a way to use it as a library, without
  543. // writing an AVS script or without going through AVIFile.
  544. AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
  545. // this symbol is the entry point for the plugin and must
  546. // be defined
  547. AVSC_EXPORT
  548. const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);
  549. AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
  550. AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV);
  551. // The returned video frame must be be released
  552. #ifdef AVSC_NO_DECLSPEC
  553. // use LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)
  554. /*
  555. The following functions needs to have been declared, probably from windows.h
  556. void* malloc(size_t)
  557. void free(void*);
  558. HMODULE LoadLibrary(const char*);
  559. void* GetProcAddress(HMODULE, const char*);
  560. FreeLibrary(HMODULE);
  561. */
  562. typedef struct AVS_Library AVS_Library;
  563. #define AVSC_DECLARE_FUNC(name) name##_func name
  564. struct AVS_Library {
  565. HMODULE handle;
  566. AVSC_DECLARE_FUNC(avs_add_function);
  567. AVSC_DECLARE_FUNC(avs_at_exit);
  568. AVSC_DECLARE_FUNC(avs_bit_blt);
  569. AVSC_DECLARE_FUNC(avs_check_version);
  570. AVSC_DECLARE_FUNC(avs_clip_get_error);
  571. AVSC_DECLARE_FUNC(avs_copy_clip);
  572. AVSC_DECLARE_FUNC(avs_copy_value);
  573. AVSC_DECLARE_FUNC(avs_copy_video_frame);
  574. AVSC_DECLARE_FUNC(avs_create_script_environment);
  575. AVSC_DECLARE_FUNC(avs_delete_script_environment);
  576. AVSC_DECLARE_FUNC(avs_function_exists);
  577. AVSC_DECLARE_FUNC(avs_get_audio);
  578. AVSC_DECLARE_FUNC(avs_get_cpu_flags);
  579. AVSC_DECLARE_FUNC(avs_get_frame);
  580. AVSC_DECLARE_FUNC(avs_get_parity);
  581. AVSC_DECLARE_FUNC(avs_get_var);
  582. AVSC_DECLARE_FUNC(avs_get_version);
  583. AVSC_DECLARE_FUNC(avs_get_video_info);
  584. AVSC_DECLARE_FUNC(avs_invoke);
  585. AVSC_DECLARE_FUNC(avs_make_writable);
  586. AVSC_DECLARE_FUNC(avs_new_c_filter);
  587. AVSC_DECLARE_FUNC(avs_new_video_frame_a);
  588. AVSC_DECLARE_FUNC(avs_release_clip);
  589. AVSC_DECLARE_FUNC(avs_release_value);
  590. AVSC_DECLARE_FUNC(avs_release_video_frame);
  591. AVSC_DECLARE_FUNC(avs_save_string);
  592. AVSC_DECLARE_FUNC(avs_set_cache_hints);
  593. AVSC_DECLARE_FUNC(avs_set_global_var);
  594. AVSC_DECLARE_FUNC(avs_set_memory_max);
  595. AVSC_DECLARE_FUNC(avs_set_to_clip);
  596. AVSC_DECLARE_FUNC(avs_set_var);
  597. AVSC_DECLARE_FUNC(avs_set_working_dir);
  598. AVSC_DECLARE_FUNC(avs_sprintf);
  599. AVSC_DECLARE_FUNC(avs_subframe);
  600. AVSC_DECLARE_FUNC(avs_subframe_planar);
  601. AVSC_DECLARE_FUNC(avs_take_clip);
  602. AVSC_DECLARE_FUNC(avs_vsprintf);
  603. AVSC_DECLARE_FUNC(avs_get_error);
  604. AVSC_DECLARE_FUNC(avs_is_yv24);
  605. AVSC_DECLARE_FUNC(avs_is_yv16);
  606. AVSC_DECLARE_FUNC(avs_is_yv12);
  607. AVSC_DECLARE_FUNC(avs_is_yv411);
  608. AVSC_DECLARE_FUNC(avs_is_y8);
  609. AVSC_DECLARE_FUNC(avs_is_color_space);
  610. AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);
  611. AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);
  612. AVSC_DECLARE_FUNC(avs_bits_per_pixel);
  613. AVSC_DECLARE_FUNC(avs_bytes_from_pixels);
  614. AVSC_DECLARE_FUNC(avs_row_size);
  615. AVSC_DECLARE_FUNC(avs_bmp_size);
  616. AVSC_DECLARE_FUNC(avs_get_pitch_p);
  617. AVSC_DECLARE_FUNC(avs_get_row_size_p);
  618. AVSC_DECLARE_FUNC(avs_get_height_p);
  619. AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
  620. AVSC_DECLARE_FUNC(avs_is_writable);
  621. AVSC_DECLARE_FUNC(avs_get_write_ptr_p);
  622. };
  623. #undef AVSC_DECLARE_FUNC
  624. AVSC_INLINE AVS_Library * avs_load_library() {
  625. AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));
  626. if (library == NULL)
  627. return NULL;
  628. library->handle = LoadLibrary("avisynth");
  629. if (library->handle == NULL)
  630. goto fail;
  631. #define __AVSC_STRINGIFY(x) #x
  632. #define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)
  633. #define AVSC_LOAD_FUNC(name) {\
  634. library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
  635. if (library->name == NULL)\
  636. goto fail;\
  637. }
  638. AVSC_LOAD_FUNC(avs_add_function);
  639. AVSC_LOAD_FUNC(avs_at_exit);
  640. AVSC_LOAD_FUNC(avs_bit_blt);
  641. AVSC_LOAD_FUNC(avs_check_version);
  642. AVSC_LOAD_FUNC(avs_clip_get_error);
  643. AVSC_LOAD_FUNC(avs_copy_clip);
  644. AVSC_LOAD_FUNC(avs_copy_value);
  645. AVSC_LOAD_FUNC(avs_copy_video_frame);
  646. AVSC_LOAD_FUNC(avs_create_script_environment);
  647. AVSC_LOAD_FUNC(avs_delete_script_environment);
  648. AVSC_LOAD_FUNC(avs_function_exists);
  649. AVSC_LOAD_FUNC(avs_get_audio);
  650. AVSC_LOAD_FUNC(avs_get_cpu_flags);
  651. AVSC_LOAD_FUNC(avs_get_frame);
  652. AVSC_LOAD_FUNC(avs_get_parity);
  653. AVSC_LOAD_FUNC(avs_get_var);
  654. AVSC_LOAD_FUNC(avs_get_version);
  655. AVSC_LOAD_FUNC(avs_get_video_info);
  656. AVSC_LOAD_FUNC(avs_invoke);
  657. AVSC_LOAD_FUNC(avs_make_writable);
  658. AVSC_LOAD_FUNC(avs_new_c_filter);
  659. AVSC_LOAD_FUNC(avs_new_video_frame_a);
  660. AVSC_LOAD_FUNC(avs_release_clip);
  661. AVSC_LOAD_FUNC(avs_release_value);
  662. AVSC_LOAD_FUNC(avs_release_video_frame);
  663. AVSC_LOAD_FUNC(avs_save_string);
  664. AVSC_LOAD_FUNC(avs_set_cache_hints);
  665. AVSC_LOAD_FUNC(avs_set_global_var);
  666. AVSC_LOAD_FUNC(avs_set_memory_max);
  667. AVSC_LOAD_FUNC(avs_set_to_clip);
  668. AVSC_LOAD_FUNC(avs_set_var);
  669. AVSC_LOAD_FUNC(avs_set_working_dir);
  670. AVSC_LOAD_FUNC(avs_sprintf);
  671. AVSC_LOAD_FUNC(avs_subframe);
  672. AVSC_LOAD_FUNC(avs_subframe_planar);
  673. AVSC_LOAD_FUNC(avs_take_clip);
  674. AVSC_LOAD_FUNC(avs_vsprintf);
  675. AVSC_LOAD_FUNC(avs_get_error);
  676. AVSC_LOAD_FUNC(avs_is_yv24);
  677. AVSC_LOAD_FUNC(avs_is_yv16);
  678. AVSC_LOAD_FUNC(avs_is_yv12);
  679. AVSC_LOAD_FUNC(avs_is_yv411);
  680. AVSC_LOAD_FUNC(avs_is_y8);
  681. AVSC_LOAD_FUNC(avs_is_color_space);
  682. AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);
  683. AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);
  684. AVSC_LOAD_FUNC(avs_bits_per_pixel);
  685. AVSC_LOAD_FUNC(avs_bytes_from_pixels);
  686. AVSC_LOAD_FUNC(avs_row_size);
  687. AVSC_LOAD_FUNC(avs_bmp_size);
  688. AVSC_LOAD_FUNC(avs_get_pitch_p);
  689. AVSC_LOAD_FUNC(avs_get_row_size_p);
  690. AVSC_LOAD_FUNC(avs_get_height_p);
  691. AVSC_LOAD_FUNC(avs_get_read_ptr_p);
  692. AVSC_LOAD_FUNC(avs_is_writable);
  693. AVSC_LOAD_FUNC(avs_get_write_ptr_p);
  694. #undef __AVSC_STRINGIFY
  695. #undef AVSC_STRINGIFY
  696. #undef AVSC_LOAD_FUNC
  697. return library;
  698. fail:
  699. free(library);
  700. return NULL;
  701. }
  702. AVSC_INLINE void avs_free_library(AVS_Library *library) {
  703. if (library == NULL)
  704. return;
  705. FreeLibrary(library->handle);
  706. free(library);
  707. }
  708. #endif
  709. #endif