You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1265 lines
52KB

  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. // 170103: added new CPU constants (FMA4, AVX512xx)
  36. // 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64.
  37. // 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access
  38. // 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access
  39. // 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init
  40. // 180524: avs_is_same_colorspace VideoInfo parameters to const
  41. // 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff
  42. // 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions
  43. // 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define)
  44. // 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN
  45. // 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference)
  46. // 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions:
  47. // if they are not loadable, they will work in a classic Avisynth compatible mode
  48. // Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead
  49. // Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel)
  50. // Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL
  51. #ifndef __AVISYNTH_C__
  52. #define __AVISYNTH_C__
  53. #include "avs/config.h"
  54. #include "avs/capi.h"
  55. #include "avs/types.h"
  56. #define AVS_FRAME_ALIGN FRAME_ALIGN
  57. /////////////////////////////////////////////////////////////////////
  58. //
  59. // Constants
  60. //
  61. #ifndef __AVISYNTH_6_H__
  62. enum { AVISYNTH_INTERFACE_VERSION = 6 };
  63. #endif
  64. enum {AVS_SAMPLE_INT8 = 1<<0,
  65. AVS_SAMPLE_INT16 = 1<<1,
  66. AVS_SAMPLE_INT24 = 1<<2,
  67. AVS_SAMPLE_INT32 = 1<<3,
  68. AVS_SAMPLE_FLOAT = 1<<4};
  69. enum {AVS_PLANAR_Y=1<<0,
  70. AVS_PLANAR_U=1<<1,
  71. AVS_PLANAR_V=1<<2,
  72. AVS_PLANAR_ALIGNED=1<<3,
  73. AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED,
  74. AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED,
  75. AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED,
  76. AVS_PLANAR_A=1<<4,
  77. AVS_PLANAR_R=1<<5,
  78. AVS_PLANAR_G=1<<6,
  79. AVS_PLANAR_B=1<<7,
  80. AVS_PLANAR_A_ALIGNED=AVS_PLANAR_A|AVS_PLANAR_ALIGNED,
  81. AVS_PLANAR_R_ALIGNED=AVS_PLANAR_R|AVS_PLANAR_ALIGNED,
  82. AVS_PLANAR_G_ALIGNED=AVS_PLANAR_G|AVS_PLANAR_ALIGNED,
  83. AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED};
  84. // Colorspace properties.
  85. enum {
  86. AVS_CS_YUVA = 1 << 27,
  87. AVS_CS_BGR = 1 << 28,
  88. AVS_CS_YUV = 1 << 29,
  89. AVS_CS_INTERLEAVED = 1 << 30,
  90. AVS_CS_PLANAR = 1 << 31,
  91. AVS_CS_SHIFT_SUB_WIDTH = 0,
  92. AVS_CS_SHIFT_SUB_HEIGHT = 8,
  93. AVS_CS_SHIFT_SAMPLE_BITS = 16,
  94. AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
  95. AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
  96. AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
  97. AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
  98. AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
  99. AVS_CS_UPLANEFIRST = 1 << 4, // I420
  100. AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
  101. AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
  102. AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
  103. AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
  104. AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
  105. AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
  106. AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS,
  107. AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS,
  108. AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
  109. AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
  110. AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
  111. AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK,
  112. AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST),
  113. AVS_CS_RGB_TYPE = 1 << 0,
  114. AVS_CS_RGBA_TYPE = 1 << 1,
  115. AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0 planar
  116. AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2 planar
  117. AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // 4:4:4 planar
  118. AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0)
  119. AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB
  120. AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA
  121. AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0:A planar
  122. AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2:A planar
  123. AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1 }; // 4:4:4:A planar
  124. // Specific color formats
  125. enum {
  126. AVS_CS_UNKNOWN = 0,
  127. AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
  128. AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
  129. AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
  130. // AVS_CS_YV12 = 1<<3 Reserved
  131. // AVS_CS_I420 = 1<<4 Reserved
  132. AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED,
  133. AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YUV 4:4:4 planar
  134. AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:2 planar
  135. AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:0 planar
  136. 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
  137. AVS_CS_IYUV = AVS_CS_I420,
  138. 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, // YUV 4:1:1 planar
  139. 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, // YUV 4:1:0 planar
  140. AVS_CS_Y8 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar
  141. //-------------------------
  142. // AVS16: new planar constants go live! Experimental PF 160613
  143. // 10-12-14-16 bit + planar RGB + BGR48/64 160725
  144. AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples
  145. AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples
  146. AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples
  147. AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples
  148. AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples
  149. AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples
  150. AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples
  151. AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples
  152. AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples
  153. AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples
  154. AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples
  155. AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples
  156. AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples
  157. AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples
  158. AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples
  159. AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples
  160. // 32 bit samples (float)
  161. AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples
  162. AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples
  163. AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples
  164. AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples
  165. // RGB packed
  166. AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit
  167. AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit
  168. // no packed 32 bit (float) support for these legacy types
  169. // RGB planar
  170. AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples
  171. AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples
  172. AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples
  173. AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples
  174. AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples
  175. AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples
  176. // RGBA planar
  177. AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples
  178. AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples
  179. AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples
  180. AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples
  181. AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples
  182. AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples
  183. // Planar YUVA
  184. AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples
  185. AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples
  186. AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples
  187. AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples
  188. AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples
  189. AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples
  190. AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples
  191. AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples
  192. AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples
  193. AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples
  194. AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples
  195. AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples
  196. AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples
  197. AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples
  198. AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples
  199. AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples
  200. AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples
  201. AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples
  202. };
  203. enum {
  204. AVS_IT_BFF = 1<<0,
  205. AVS_IT_TFF = 1<<1,
  206. AVS_IT_FIELDBASED = 1<<2};
  207. enum {
  208. AVS_FILTER_TYPE=1,
  209. AVS_FILTER_INPUT_COLORSPACE=2,
  210. AVS_FILTER_OUTPUT_TYPE=9,
  211. AVS_FILTER_NAME=4,
  212. AVS_FILTER_AUTHOR=5,
  213. AVS_FILTER_VERSION=6,
  214. AVS_FILTER_ARGS=7,
  215. AVS_FILTER_ARGS_INFO=8,
  216. AVS_FILTER_ARGS_DESCRIPTION=10,
  217. AVS_FILTER_DESCRIPTION=11};
  218. enum { //SUBTYPES
  219. AVS_FILTER_TYPE_AUDIO=1,
  220. AVS_FILTER_TYPE_VIDEO=2,
  221. AVS_FILTER_OUTPUT_TYPE_SAME=3,
  222. AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4};
  223. enum {
  224. // New 2.6 explicitly defined cache hints.
  225. AVS_CACHE_NOTHING=10, // Do not cache video.
  226. AVS_CACHE_WINDOW=11, // Hard protect up to X frames within a range of X from the current frame N.
  227. AVS_CACHE_GENERIC=12, // LRU cache up to X frames.
  228. AVS_CACHE_FORCE_GENERIC=13, // LRU cache up to X frames, override any previous CACHE_WINDOW.
  229. AVS_CACHE_GET_POLICY=30, // Get the current policy.
  230. AVS_CACHE_GET_WINDOW=31, // Get the current window h_span.
  231. AVS_CACHE_GET_RANGE=32, // Get the current generic frame range.
  232. AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache.
  233. AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio.
  234. AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte initial cache.
  235. AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte initial cache.
  236. AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy.
  237. AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size.
  238. AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N.
  239. AVS_CACHE_PREFETCH_GO=101, // Action video prefetches.
  240. AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section).
  241. AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start.
  242. AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start.
  243. AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length.
  244. AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section).
  245. AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches.
  246. AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode.
  247. AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size.
  248. AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode.
  249. AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size.
  250. AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost.
  251. AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only).
  252. AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit).
  253. AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast)
  254. AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time)
  255. AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow)
  256. AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safety.
  257. AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default!
  258. AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default!
  259. AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance.
  260. AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded.
  261. AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern.
  262. AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic.
  263. AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost)
  264. AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost)
  265. };
  266. #ifdef BUILDING_AVSCORE
  267. AVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0);
  268. struct AVS_ScriptEnvironment {
  269. IScriptEnvironment * env;
  270. const char * error;
  271. AVS_ScriptEnvironment(IScriptEnvironment * e = 0)
  272. : env(e), error(0) {}
  273. };
  274. #endif
  275. typedef struct AVS_Clip AVS_Clip;
  276. typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;
  277. /////////////////////////////////////////////////////////////////////
  278. //
  279. // AVS_VideoInfo
  280. //
  281. // AVS_VideoInfo is laid out identically to VideoInfo
  282. typedef struct AVS_VideoInfo {
  283. int width, height; // width=0 means no video
  284. unsigned fps_numerator, fps_denominator;
  285. int num_frames;
  286. int pixel_type;
  287. int audio_samples_per_second; // 0 means no audio
  288. int sample_type;
  289. INT64 num_audio_samples;
  290. int nchannels;
  291. // Image type properties
  292. int image_type;
  293. } AVS_VideoInfo;
  294. // useful functions of the above
  295. AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)
  296. { return (p->width!=0); }
  297. AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)
  298. { return (p->audio_samples_per_second!=0); }
  299. AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
  300. { return !!(p->pixel_type&AVS_CS_BGR); }
  301. AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
  302. { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }
  303. AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)
  304. { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }
  305. AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
  306. { return !!(p->pixel_type&AVS_CS_YUV ); }
  307. AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)
  308. { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
  309. AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444
  310. AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422
  311. AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420
  312. AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);
  313. AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y
  314. AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);
  315. AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);
  316. AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);
  317. AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels);
  318. AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);
  319. AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);
  320. AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space);
  321. // no API for these, inline helper functions
  322. AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
  323. {
  324. return ((p->image_type & property) == property);
  325. }
  326. AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)
  327. {
  328. return !!(p->pixel_type & AVS_CS_PLANAR);
  329. }
  330. AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)
  331. {
  332. return !!(p->image_type & AVS_IT_FIELDBASED);
  333. }
  334. AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)
  335. {
  336. return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF)));
  337. }
  338. AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)
  339. {
  340. return !!(p->image_type & AVS_IT_BFF);
  341. }
  342. AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)
  343. {
  344. return !!(p->image_type & AVS_IT_TFF);
  345. }
  346. AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)
  347. { return p->audio_samples_per_second; }
  348. AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)
  349. {
  350. switch (p->sample_type) {
  351. case AVS_SAMPLE_INT8: return sizeof(signed char);
  352. case AVS_SAMPLE_INT16: return sizeof(signed short);
  353. case AVS_SAMPLE_INT24: return 3;
  354. case AVS_SAMPLE_INT32: return sizeof(signed int);
  355. case AVS_SAMPLE_FLOAT: return sizeof(float);
  356. default: return 0;
  357. }
  358. }
  359. AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)
  360. { return p->nchannels*avs_bytes_per_channel_sample(p);}
  361. AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames)
  362. { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
  363. AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
  364. { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); }
  365. AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes)
  366. { return bytes / avs_bytes_per_audio_sample(p); }
  367. AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
  368. { return samples * avs_bytes_per_audio_sample(p); }
  369. AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)
  370. { return p->nchannels; }
  371. AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)
  372. { return p->sample_type;}
  373. // useful mutator
  374. AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)
  375. { p->image_type|=property; }
  376. AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)
  377. { p->image_type&=~property; }
  378. AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
  379. { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
  380. AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
  381. {
  382. unsigned x=numerator, y=denominator;
  383. while (y) { // find gcd
  384. unsigned t = x%y; x = y; y = t;
  385. }
  386. p->fps_numerator = numerator/x;
  387. p->fps_denominator = denominator/x;
  388. }
  389. #ifndef AVSC_NO_DECLSPEC
  390. // this inline function is calling an API function
  391. AVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y)
  392. {
  393. return (x->pixel_type == y->pixel_type)
  394. || (avs_is_yv12(x) && avs_is_yv12(y));
  395. }
  396. #endif
  397. // Avisynth+ extensions
  398. AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);
  399. AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);
  400. AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444
  401. AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422
  402. AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420
  403. AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // obsolete, use avs_is_y
  404. AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444
  405. AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422
  406. AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420
  407. AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // obsolete, use avs_is_y
  408. AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);
  409. AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);
  410. AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);
  411. AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);
  412. AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);
  413. AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);
  414. AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);
  415. AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);
  416. AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);
  417. AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);
  418. // end of Avisynth+ specific
  419. /////////////////////////////////////////////////////////////////////
  420. //
  421. // AVS_VideoFrame
  422. //
  423. // VideoFrameBuffer holds information about a memory block which is used
  424. // for video data. For efficiency, instances of this class are not deleted
  425. // when the refcount reaches zero; instead they're stored in a linked list
  426. // to be reused. The instances are deleted when the corresponding AVS
  427. // file is closed.
  428. // AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer
  429. // DO NOT USE THIS STRUCTURE DIRECTLY
  430. typedef struct AVS_VideoFrameBuffer {
  431. BYTE * data;
  432. #ifdef SIZETMOD
  433. size_t data_size;
  434. #else
  435. int data_size;
  436. #endif
  437. // sequence_number is incremented every time the buffer is changed, so
  438. // that stale views can tell they're no longer valid.
  439. volatile long sequence_number;
  440. volatile long refcount;
  441. } AVS_VideoFrameBuffer;
  442. // VideoFrame holds a "window" into a VideoFrameBuffer.
  443. // AVS_VideoFrame is laid out identically to IVideoFrame
  444. // DO NOT USE THIS STRUCTURE DIRECTLY
  445. typedef struct AVS_VideoFrame {
  446. volatile long refcount;
  447. AVS_VideoFrameBuffer * vfb;
  448. #ifdef SIZETMOD
  449. size_t offset;
  450. #else
  451. int offset;
  452. #endif
  453. int pitch, row_size, height;
  454. #ifdef SIZETMOD
  455. size_t offsetU, offsetV;
  456. #else
  457. int offsetU, offsetV;
  458. #endif
  459. int pitchUV; // U&V offsets are from top of picture.
  460. int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.
  461. // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)
  462. // the decision on existence of UV is checked by zero pitch
  463. // AVS+ extension, avisynth.h: class does not break plugins if appended here
  464. #ifdef SIZETMOD
  465. size_t offsetA;
  466. #else
  467. int offsetA;
  468. #endif
  469. int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none
  470. } AVS_VideoFrame;
  471. // Access functions for AVS_VideoFrame
  472. AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);
  473. AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);
  474. AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);
  475. AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);
  476. AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);
  477. AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane);
  478. AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
  479. // makes a shallow copy of a video frame
  480. AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
  481. // no API for these, inline helper functions
  482. #ifndef AVSC_NO_DECLSPEC
  483. // this inline function is calling an API function
  484. AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) {
  485. return avs_get_pitch_p(p, 0);
  486. }
  487. #endif
  488. #ifndef AVSC_NO_DECLSPEC
  489. // this inline function is calling an API function
  490. AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) {
  491. return avs_get_row_size_p(p, 0); }
  492. #endif
  493. #ifndef AVSC_NO_DECLSPEC
  494. // this inline function is calling an API function
  495. AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) {
  496. return avs_get_height_p(p, 0);
  497. }
  498. #endif
  499. #ifndef AVSC_NO_DECLSPEC
  500. // this inline function is calling an API function
  501. AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) {
  502. return avs_get_read_ptr_p(p, 0);}
  503. #endif
  504. #ifndef AVSC_NO_DECLSPEC
  505. // this inline function is calling an API function
  506. AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) {
  507. return avs_get_write_ptr_p(p, 0);}
  508. #endif
  509. #ifndef AVSC_NO_DECLSPEC
  510. // this inline function is calling an API function
  511. AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f)
  512. {avs_release_video_frame(f);}
  513. #endif
  514. #ifndef AVSC_NO_DECLSPEC
  515. // this inline function is calling an API function
  516. AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f)
  517. {return avs_copy_video_frame(f);}
  518. #endif
  519. /////////////////////////////////////////////////////////////////////
  520. //
  521. // AVS_Value
  522. //
  523. // Treat AVS_Value as a fat pointer. That is use avs_copy_value
  524. // and avs_release_value appropriately as you would if AVS_Value was
  525. // a pointer.
  526. // To maintain source code compatibility with future versions of the
  527. // avisynth_c API don't use the AVS_Value directly. Use the helper
  528. // functions below.
  529. // AVS_Value is laid out identically to AVSValue
  530. typedef struct AVS_Value AVS_Value;
  531. struct AVS_Value {
  532. short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
  533. // for some function e'rror
  534. short array_size;
  535. union {
  536. void * clip; // do not use directly, use avs_take_clip
  537. char boolean;
  538. int integer;
  539. float floating_pt;
  540. const char * string;
  541. const AVS_Value * array;
  542. } d;
  543. };
  544. // AVS_Value should be initialized with avs_void.
  545. // Should also set to avs_void after the value is released
  546. // with avs_copy_value. Consider it the equivalent of setting
  547. // a pointer to NULL
  548. static const AVS_Value avs_void = {'v'};
  549. AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
  550. AVSC_API(void, avs_release_value)(AVS_Value);
  551. AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
  552. AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
  553. // no API for these, inline helper functions
  554. AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
  555. AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
  556. AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
  557. AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }
  558. AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }
  559. AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
  560. AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
  561. AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
  562. AVSC_INLINE int avs_as_bool(AVS_Value v)
  563. { return v.d.boolean; }
  564. AVSC_INLINE int avs_as_int(AVS_Value v)
  565. { return v.d.integer; }
  566. AVSC_INLINE const char * avs_as_string(AVS_Value v)
  567. { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
  568. AVSC_INLINE double avs_as_float(AVS_Value v)
  569. { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }
  570. AVSC_INLINE const char * avs_as_error(AVS_Value v)
  571. { return avs_is_error(v) ? v.d.string : 0; }
  572. AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
  573. { return v.d.array; }
  574. AVSC_INLINE int avs_array_size(AVS_Value v)
  575. { return avs_is_array(v) ? v.array_size : 1; }
  576. AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
  577. { return avs_is_array(v) ? v.d.array[index] : v; }
  578. // only use these functions on an AVS_Value that does not already have
  579. // an active value. Remember, treat AVS_Value as a fat pointer.
  580. AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
  581. { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
  582. AVSC_INLINE AVS_Value avs_new_value_int(int v0)
  583. { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }
  584. AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
  585. { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
  586. AVSC_INLINE AVS_Value avs_new_value_float(float v0)
  587. { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
  588. AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
  589. { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }
  590. #ifndef AVSC_NO_DECLSPEC
  591. // this inline function is calling an API function
  592. AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)
  593. { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
  594. #endif
  595. AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
  596. { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; }
  597. // end of inline helper functions
  598. /////////////////////////////////////////////////////////////////////
  599. //
  600. // AVS_Clip
  601. //
  602. AVSC_API(void, avs_release_clip)(AVS_Clip *);
  603. AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
  604. AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
  605. AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
  606. AVSC_API(int, avs_get_version)(AVS_Clip *);
  607. AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
  608. // The returned video frame must be released with avs_release_video_frame
  609. AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
  610. // return field parity if field_based, else parity of first field in frame
  611. AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
  612. INT64 start, INT64 count);
  613. // start and count are in samples
  614. AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
  615. int cachehints, int frame_range);
  616. // This is the callback type used by avs_add_function
  617. typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
  618. (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);
  619. typedef struct AVS_FilterInfo AVS_FilterInfo;
  620. struct AVS_FilterInfo
  621. {
  622. // these members should not be modified outside of the AVS_ApplyFunc callback
  623. AVS_Clip * child;
  624. AVS_VideoInfo vi;
  625. AVS_ScriptEnvironment * env;
  626. AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
  627. int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
  628. int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
  629. INT64 start, INT64 count);
  630. int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
  631. int frame_range);
  632. void (AVSC_CC * free_filter)(AVS_FilterInfo *);
  633. // Should be set when ever there is an error to report.
  634. // It is cleared before any of the above methods are called
  635. const char * error;
  636. // this is to store whatever and may be modified at will
  637. void * user_data;
  638. };
  639. // Create a new filter
  640. // fi is set to point to the AVS_FilterInfo so that you can
  641. // modify it once it is initialized.
  642. // store_child should generally be set to true. If it is not
  643. // set than ALL methods (the function pointers) must be defined
  644. // If it is set than you do not need to worry about freeing the child
  645. // clip.
  646. AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
  647. AVS_FilterInfo * * fi,
  648. AVS_Value child, int store_child);
  649. /////////////////////////////////////////////////////////////////////
  650. //
  651. // AVS_ScriptEnvironment
  652. //
  653. // For GetCPUFlags. These are backwards-compatible with those in VirtualDub.
  654. enum {
  655. /* slowest CPU to support extension */
  656. AVS_CPU_FORCE = 0x01, // N/A
  657. AVS_CPU_FPU = 0x02, // 386/486DX
  658. AVS_CPU_MMX = 0x04, // P55C, K6, PII
  659. AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
  660. AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
  661. AVS_CPU_SSE2 = 0x20, // PIV, Hammer
  662. AVS_CPU_3DNOW = 0x40, // K6-2
  663. AVS_CPU_3DNOW_EXT = 0x80, // Athlon
  664. AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
  665. // which only Hammer will have anyway)
  666. AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice
  667. AVS_CPUF_SSSE3 = 0x200, // Core 2
  668. AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield
  669. AVS_CPUF_SSE4_1 = 0x400,
  670. AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer
  671. AVS_CPUF_SSE4_2 = 0x1000, // Nehalem
  672. // AVS+
  673. AVS_CPUF_AVX2 = 0x2000, // Haswell
  674. AVS_CPUF_FMA3 = 0x4000,
  675. AVS_CPUF_F16C = 0x8000,
  676. AVS_CPUF_MOVBE = 0x10000, // Big Endian Move
  677. AVS_CPUF_POPCNT = 0x20000,
  678. AVS_CPUF_AES = 0x40000,
  679. AVS_CPUF_FMA4 = 0x80000,
  680. AVS_CPUF_AVX512F = 0x100000, // AVX-512 Foundation.
  681. AVS_CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions
  682. AVS_CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch
  683. AVS_CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal
  684. AVS_CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection
  685. AVS_CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions
  686. AVS_CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions
  687. AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit
  688. AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI
  689. };
  690. AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
  691. AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
  692. AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
  693. AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
  694. AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
  695. AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val);
  696. // note: val is really a va_list; I hope everyone typedefs va_list to a pointer
  697. AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
  698. const char * name, const char * params,
  699. AVS_ApplyFunc apply, void * user_data);
  700. AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
  701. AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
  702. AVS_Value args, const char** arg_names);
  703. // The returned value must be be released with avs_release_value
  704. AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
  705. // The returned value must be be released with avs_release_value
  706. AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
  707. AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
  708. //void avs_push_context(AVS_ScriptEnvironment *, int level=0);
  709. //void avs_pop_context(AVS_ScriptEnvironment *);
  710. AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
  711. const AVS_VideoInfo * vi, int align);
  712. // align should be at least 16 for classic Avisynth
  713. // Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided
  714. // no API for these, inline helper functions
  715. #ifndef AVSC_NO_DECLSPEC
  716. // this inline function is calling an API function
  717. AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,
  718. const AVS_VideoInfo * vi)
  719. {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
  720. // an older compatibility alias
  721. // this inline function is calling an API function
  722. AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,
  723. const AVS_VideoInfo * vi)
  724. {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
  725. #endif
  726. // end of inline helper functions
  727. AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
  728. AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);
  729. typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);
  730. AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
  731. AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
  732. // The returned video frame must be be released
  733. AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
  734. AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
  735. // avisynth.dll exports this; it's a way to use it as a library, without
  736. // writing an AVS script or without going through AVIFile.
  737. AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
  738. // this symbol is the entry point for the plugin and must
  739. // be defined
  740. AVSC_EXPORT
  741. const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);
  742. AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
  743. 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);
  744. // The returned video frame must be be released
  745. #ifdef AVSC_NO_DECLSPEC
  746. // This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)
  747. // When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct
  748. // AVSC_INLINE functions which call onto an API functions should be treated specially (todo)
  749. /*
  750. The following functions needs to have been declared, probably from windows.h
  751. void* malloc(size_t)
  752. void free(void*);
  753. HMODULE LoadLibrary(const char*);
  754. void* GetProcAddress(HMODULE, const char*);
  755. FreeLibrary(HMODULE);
  756. */
  757. typedef struct AVS_Library AVS_Library;
  758. #define AVSC_DECLARE_FUNC(name) name##_func name
  759. // AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx
  760. // e.g. "AVSC_DECLARE_FUNC(avs_add_function);"
  761. // is a shortcut for "avs_add_function_func avs_add_function;"
  762. // Note: AVSC_INLINE functions which call into API,
  763. // are guarded by #ifndef AVSC_NO_DECLSPEC
  764. // They should call the appropriate library-> API entry
  765. struct AVS_Library {
  766. HMODULE handle;
  767. AVSC_DECLARE_FUNC(avs_add_function);
  768. AVSC_DECLARE_FUNC(avs_at_exit);
  769. AVSC_DECLARE_FUNC(avs_bit_blt);
  770. AVSC_DECLARE_FUNC(avs_check_version);
  771. AVSC_DECLARE_FUNC(avs_clip_get_error);
  772. AVSC_DECLARE_FUNC(avs_copy_clip);
  773. AVSC_DECLARE_FUNC(avs_copy_value);
  774. AVSC_DECLARE_FUNC(avs_copy_video_frame);
  775. AVSC_DECLARE_FUNC(avs_create_script_environment);
  776. AVSC_DECLARE_FUNC(avs_delete_script_environment);
  777. AVSC_DECLARE_FUNC(avs_function_exists);
  778. AVSC_DECLARE_FUNC(avs_get_audio);
  779. AVSC_DECLARE_FUNC(avs_get_cpu_flags);
  780. AVSC_DECLARE_FUNC(avs_get_frame);
  781. AVSC_DECLARE_FUNC(avs_get_parity);
  782. AVSC_DECLARE_FUNC(avs_get_var);
  783. AVSC_DECLARE_FUNC(avs_get_version);
  784. AVSC_DECLARE_FUNC(avs_get_video_info);
  785. AVSC_DECLARE_FUNC(avs_invoke);
  786. AVSC_DECLARE_FUNC(avs_make_writable);
  787. AVSC_DECLARE_FUNC(avs_new_c_filter);
  788. AVSC_DECLARE_FUNC(avs_new_video_frame_a);
  789. AVSC_DECLARE_FUNC(avs_release_clip);
  790. AVSC_DECLARE_FUNC(avs_release_value);
  791. AVSC_DECLARE_FUNC(avs_release_video_frame);
  792. AVSC_DECLARE_FUNC(avs_save_string);
  793. AVSC_DECLARE_FUNC(avs_set_cache_hints);
  794. AVSC_DECLARE_FUNC(avs_set_global_var);
  795. AVSC_DECLARE_FUNC(avs_set_memory_max);
  796. AVSC_DECLARE_FUNC(avs_set_to_clip);
  797. AVSC_DECLARE_FUNC(avs_set_var);
  798. AVSC_DECLARE_FUNC(avs_set_working_dir);
  799. AVSC_DECLARE_FUNC(avs_sprintf);
  800. AVSC_DECLARE_FUNC(avs_subframe);
  801. AVSC_DECLARE_FUNC(avs_subframe_planar);
  802. AVSC_DECLARE_FUNC(avs_take_clip);
  803. AVSC_DECLARE_FUNC(avs_vsprintf);
  804. AVSC_DECLARE_FUNC(avs_get_error);
  805. AVSC_DECLARE_FUNC(avs_is_yv24);
  806. AVSC_DECLARE_FUNC(avs_is_yv16);
  807. AVSC_DECLARE_FUNC(avs_is_yv12);
  808. AVSC_DECLARE_FUNC(avs_is_yv411);
  809. AVSC_DECLARE_FUNC(avs_is_y8);
  810. AVSC_DECLARE_FUNC(avs_is_color_space);
  811. AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);
  812. AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);
  813. AVSC_DECLARE_FUNC(avs_bits_per_pixel);
  814. AVSC_DECLARE_FUNC(avs_bytes_from_pixels);
  815. AVSC_DECLARE_FUNC(avs_row_size);
  816. AVSC_DECLARE_FUNC(avs_bmp_size);
  817. AVSC_DECLARE_FUNC(avs_get_pitch_p);
  818. AVSC_DECLARE_FUNC(avs_get_row_size_p);
  819. AVSC_DECLARE_FUNC(avs_get_height_p);
  820. AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
  821. AVSC_DECLARE_FUNC(avs_is_writable);
  822. AVSC_DECLARE_FUNC(avs_get_write_ptr_p);
  823. // Avisynth+ specific
  824. // Note: these functions are simulated/use fallback to existing functions
  825. AVSC_DECLARE_FUNC(avs_is_rgb48);
  826. AVSC_DECLARE_FUNC(avs_is_rgb64);
  827. AVSC_DECLARE_FUNC(avs_is_yuv444p16);
  828. AVSC_DECLARE_FUNC(avs_is_yuv422p16);
  829. AVSC_DECLARE_FUNC(avs_is_yuv420p16);
  830. AVSC_DECLARE_FUNC(avs_is_y16);
  831. AVSC_DECLARE_FUNC(avs_is_yuv444ps);
  832. AVSC_DECLARE_FUNC(avs_is_yuv422ps);
  833. AVSC_DECLARE_FUNC(avs_is_yuv420ps);
  834. AVSC_DECLARE_FUNC(avs_is_y32);
  835. AVSC_DECLARE_FUNC(avs_is_444);
  836. AVSC_DECLARE_FUNC(avs_is_422);
  837. AVSC_DECLARE_FUNC(avs_is_420);
  838. AVSC_DECLARE_FUNC(avs_is_y);
  839. AVSC_DECLARE_FUNC(avs_is_yuva);
  840. AVSC_DECLARE_FUNC(avs_is_planar_rgb);
  841. AVSC_DECLARE_FUNC(avs_is_planar_rgba);
  842. AVSC_DECLARE_FUNC(avs_num_components);
  843. AVSC_DECLARE_FUNC(avs_component_size);
  844. AVSC_DECLARE_FUNC(avs_bits_per_component);
  845. // end of Avisynth+ specific
  846. };
  847. #undef AVSC_DECLARE_FUNC
  848. // Helper functions for fallback simulation
  849. // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
  850. AVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p)
  851. {
  852. return 0;
  853. }
  854. // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
  855. AVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p)
  856. {
  857. switch (p->pixel_type) {
  858. case AVS_CS_UNKNOWN:
  859. return 0;
  860. case AVS_CS_RAW32:
  861. case AVS_CS_Y8:
  862. return 1;
  863. case AVS_CS_BGR32:
  864. return 4; // not planar but return the count
  865. default:
  866. return 3;
  867. }
  868. }
  869. // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
  870. AVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p)
  871. {
  872. return 1;
  873. }
  874. // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
  875. AVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p)
  876. {
  877. return 8;
  878. }
  879. // End of helper functions for fallback simulation
  880. // avs_load_library() allocates an array for API procedure entries
  881. // reads and fills the entries with live procedure addresses.
  882. // AVSC_INLINE helpers which are calling into API procedures are not treated here (todo)
  883. AVSC_INLINE AVS_Library * avs_load_library() {
  884. AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));
  885. if (library == NULL)
  886. return NULL;
  887. library->handle = LoadLibrary("avisynth");
  888. if (library->handle == NULL)
  889. goto fail;
  890. #define __AVSC_STRINGIFY(x) #x
  891. #define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)
  892. #define AVSC_LOAD_FUNC(name) {\
  893. library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
  894. if (library->name == NULL)\
  895. goto fail;\
  896. }
  897. #if 0
  898. // FFmpeg-specific: we don't use the FALLBACK stuff, and it causes build errors,
  899. // so ifdef it out on our side.
  900. // When an API function is not loadable, let's try a replacement
  901. // Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods
  902. /*
  903. Avisynth+ When method is missing (classic Avisynth)
  904. avs_is_rgb48 constant false
  905. avs_is_rgb64 constant false
  906. avs_is_yuv444p16 constant false
  907. avs_is_yuv422p16 constant false
  908. avs_is_yuv420p16 constant false
  909. avs_is_y16 constant false
  910. avs_is_yuv444ps constant false
  911. avs_is_yuv422ps constant false
  912. avs_is_yuv420ps constant false
  913. avs_is_y32 constant false
  914. avs_is_444 avs_is_yv24
  915. avs_is_422 avs_is_yv16
  916. avs_is_420 avs_is_yv12
  917. avs_is_y avs_is_y8
  918. avs_is_yuva constant false
  919. avs_is_planar_rgb constant false
  920. avs_is_planar_rgba constant false
  921. avs_num_components special: avs_num_components_fake Y8:1 RGB32:4 else 3
  922. avs_component_size constant 1 (1 bytes/component)
  923. avs_bits_per_component constant 8 (8 bits/component)
  924. */
  925. // try to load an alternative function
  926. #define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\
  927. library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
  928. if (library->name == NULL)\
  929. library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\
  930. if (library->name == NULL)\
  931. goto fail;\
  932. }
  933. // try to assign a replacement function
  934. #define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\
  935. library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
  936. if (library->name == NULL)\
  937. library->name = name2;\
  938. if (library->name == NULL)\
  939. goto fail;\
  940. }
  941. #endif
  942. AVSC_LOAD_FUNC(avs_add_function);
  943. AVSC_LOAD_FUNC(avs_at_exit);
  944. AVSC_LOAD_FUNC(avs_bit_blt);
  945. AVSC_LOAD_FUNC(avs_check_version);
  946. AVSC_LOAD_FUNC(avs_clip_get_error);
  947. AVSC_LOAD_FUNC(avs_copy_clip);
  948. AVSC_LOAD_FUNC(avs_copy_value);
  949. AVSC_LOAD_FUNC(avs_copy_video_frame);
  950. AVSC_LOAD_FUNC(avs_create_script_environment);
  951. AVSC_LOAD_FUNC(avs_delete_script_environment);
  952. AVSC_LOAD_FUNC(avs_function_exists);
  953. AVSC_LOAD_FUNC(avs_get_audio);
  954. AVSC_LOAD_FUNC(avs_get_cpu_flags);
  955. AVSC_LOAD_FUNC(avs_get_frame);
  956. AVSC_LOAD_FUNC(avs_get_parity);
  957. AVSC_LOAD_FUNC(avs_get_var);
  958. AVSC_LOAD_FUNC(avs_get_version);
  959. AVSC_LOAD_FUNC(avs_get_video_info);
  960. AVSC_LOAD_FUNC(avs_invoke);
  961. AVSC_LOAD_FUNC(avs_make_writable);
  962. AVSC_LOAD_FUNC(avs_new_c_filter);
  963. AVSC_LOAD_FUNC(avs_new_video_frame_a);
  964. AVSC_LOAD_FUNC(avs_release_clip);
  965. AVSC_LOAD_FUNC(avs_release_value);
  966. AVSC_LOAD_FUNC(avs_release_video_frame);
  967. AVSC_LOAD_FUNC(avs_save_string);
  968. AVSC_LOAD_FUNC(avs_set_cache_hints);
  969. AVSC_LOAD_FUNC(avs_set_global_var);
  970. AVSC_LOAD_FUNC(avs_set_memory_max);
  971. AVSC_LOAD_FUNC(avs_set_to_clip);
  972. AVSC_LOAD_FUNC(avs_set_var);
  973. AVSC_LOAD_FUNC(avs_set_working_dir);
  974. AVSC_LOAD_FUNC(avs_sprintf);
  975. AVSC_LOAD_FUNC(avs_subframe);
  976. AVSC_LOAD_FUNC(avs_subframe_planar);
  977. AVSC_LOAD_FUNC(avs_take_clip);
  978. AVSC_LOAD_FUNC(avs_vsprintf);
  979. AVSC_LOAD_FUNC(avs_get_error);
  980. AVSC_LOAD_FUNC(avs_is_yv24);
  981. AVSC_LOAD_FUNC(avs_is_yv16);
  982. AVSC_LOAD_FUNC(avs_is_yv12);
  983. AVSC_LOAD_FUNC(avs_is_yv411);
  984. AVSC_LOAD_FUNC(avs_is_y8);
  985. AVSC_LOAD_FUNC(avs_is_color_space);
  986. AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);
  987. AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);
  988. AVSC_LOAD_FUNC(avs_bits_per_pixel);
  989. AVSC_LOAD_FUNC(avs_bytes_from_pixels);
  990. AVSC_LOAD_FUNC(avs_row_size);
  991. AVSC_LOAD_FUNC(avs_bmp_size);
  992. AVSC_LOAD_FUNC(avs_get_pitch_p);
  993. AVSC_LOAD_FUNC(avs_get_row_size_p);
  994. AVSC_LOAD_FUNC(avs_get_height_p);
  995. AVSC_LOAD_FUNC(avs_get_read_ptr_p);
  996. AVSC_LOAD_FUNC(avs_is_writable);
  997. AVSC_LOAD_FUNC(avs_get_write_ptr_p);
  998. #if 0
  999. // Avisynth+ specific but made them callable for classic Avisynth hosts
  1000. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false);
  1001. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false);
  1002. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444p16, avs_is_xx_fallback_return_false);
  1003. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422p16, avs_is_xx_fallback_return_false);
  1004. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420p16, avs_is_xx_fallback_return_false);
  1005. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y16, avs_is_xx_fallback_return_false);
  1006. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444ps, avs_is_xx_fallback_return_false);
  1007. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422ps, avs_is_xx_fallback_return_false);
  1008. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420ps, avs_is_xx_fallback_return_false);
  1009. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y32, avs_is_xx_fallback_return_false);
  1010. AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24);
  1011. AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16);
  1012. AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12);
  1013. AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8);
  1014. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false);
  1015. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false);
  1016. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false);
  1017. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback);
  1018. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback);
  1019. AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback);
  1020. #endif
  1021. #undef __AVSC_STRINGIFY
  1022. #undef AVSC_STRINGIFY
  1023. #undef AVSC_LOAD_FUNC
  1024. #undef AVSC_LOAD_FUNC_FALLBACK
  1025. #undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED
  1026. return library;
  1027. fail:
  1028. free(library);
  1029. return NULL;
  1030. }
  1031. AVSC_INLINE void avs_free_library(AVS_Library *library) {
  1032. if (library == NULL)
  1033. return;
  1034. FreeLibrary(library->handle);
  1035. free(library);
  1036. }
  1037. #endif
  1038. #endif