FFmpeg
avisynth_c.h
Go to the documentation of this file.
1 // Avisynth C Interface Version 0.20
2 // Copyright 2003 Kevin Atkinson
3 
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 // MA 02110-1301 USA, or visit
18 // http://www.gnu.org/copyleft/gpl.html .
19 //
20 // As a special exception, I give you permission to link to the
21 // Avisynth C interface with independent modules that communicate with
22 // the Avisynth C interface solely through the interfaces defined in
23 // avisynth_c.h, regardless of the license terms of these independent
24 // modules, and to copy and distribute the resulting combined work
25 // under terms of your choice, provided that every copy of the
26 // combined work is accompanied by a complete copy of the source code
27 // of the Avisynth C interface and Avisynth itself (with the version
28 // used to produce the combined work), being distributed under the
29 // terms of the GNU General Public License plus this exception. An
30 // independent module is a module which is not derived from or based
31 // on Avisynth C Interface, such as 3rd-party filters, import and
32 // export plugins, or graphical user interfaces.
33 
34 // NOTE: this is a partial update of the Avisynth C interface to recognize
35 // new color spaces added in Avisynth 2.60. By no means is this document
36 // completely Avisynth 2.60 compliant.
37 // 170103: added new CPU constants (FMA4, AVX512xx)
38 // 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64.
39 // 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access
40 // 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access
41 // 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init
42 // 180524: avs_is_same_colorspace VideoInfo parameters to const
43 // 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff
44 // 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions
45 // 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define)
46 // 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN
47 // 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference)
48 // 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions:
49 // if they are not loadable, they will work in a classic Avisynth compatible mode
50 // Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead
51 // Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel)
52 // Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL
53 
54 #ifndef __AVISYNTH_C__
55 #define __AVISYNTH_C__
56 
57 #include "avs/config.h"
58 #include "avs/capi.h"
59 #include "avs/types.h"
60 
61 #define AVS_FRAME_ALIGN FRAME_ALIGN
62 /////////////////////////////////////////////////////////////////////
63 //
64 // Constants
65 //
66 
67 #ifndef __AVISYNTH_6_H__
69 #endif
70 
71 enum {AVS_SAMPLE_INT8 = 1<<0,
76 
77 enum {AVS_PLANAR_Y=1<<0,
92 
93  // Colorspace properties.
94 enum {
95  AVS_CS_YUVA = 1 << 27,
96  AVS_CS_BGR = 1 << 28,
97  AVS_CS_YUV = 1 << 29,
98  AVS_CS_INTERLEAVED = 1 << 30,
99  AVS_CS_PLANAR = 1 << 31,
100 
104 
107  AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
109 
110  AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
111  AVS_CS_UPLANEFIRST = 1 << 4, // I420
112 
114  AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
117 
125 
128 
129  AVS_CS_RGB_TYPE = 1 << 0,
131 
141 
142 
143  // Specific color formats
144 enum {
149  // AVS_CS_YV12 = 1<<3 Reserved
150  // AVS_CS_I420 = 1<<4 Reserved
152 
161 
162  //-------------------------
163  // AVS16: new planar constants go live! Experimental PF 160613
164  // 10-12-14-16 bit + planar RGB + BGR48/64 160725
168  AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples
169 
173  AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples
174 
178  AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples
179 
183  AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples
184 
185  // 32 bit samples (float)
189  AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples
190 
191  // RGB packed
194  // no packed 32 bit (float) support for these legacy types
195 
196  // RGB planar
197  AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples
198  AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples
199  AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples
200  AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples
201  AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples
202  AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples
203 
204  // RGBA planar
205  AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples
210  AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples
211 
212  // Planar YUVA
216 
220 
224 
228 
232 
236 
237 };
238 
239 enum {
240  AVS_IT_BFF = 1<<0,
241  AVS_IT_TFF = 1<<1,
243 
244 enum {
255 
256 enum { //SUBTYPES
261 
262 enum {
263  // New 2.6 explicitly defined cache hints.
264  AVS_CACHE_NOTHING=10, // Do not cache video.
265  AVS_CACHE_WINDOW=11, // Hard protect up to X frames within a range of X from the current frame N.
266  AVS_CACHE_GENERIC=12, // LRU cache up to X frames.
267  AVS_CACHE_FORCE_GENERIC=13, // LRU cache up to X frames, override any previous CACHE_WINDOW.
268 
269  AVS_CACHE_GET_POLICY=30, // Get the current policy.
270  AVS_CACHE_GET_WINDOW=31, // Get the current window h_span.
271  AVS_CACHE_GET_RANGE=32, // Get the current generic frame range.
272 
273  AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache.
274  AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio.
275  AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte initial cache.
276  AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte initial cache.
277 
278  AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy.
279  AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size.
280 
281  AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N.
282  AVS_CACHE_PREFETCH_GO=101, // Action video prefetches.
283 
284  AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section).
285  AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start.
286  AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start.
287  AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length.
288  AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section).
289  AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches.
290 
291  AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode.
292  AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size.
293  AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode.
294  AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size.
295 
296  AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost.
297  AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only).
298  AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit).
299  AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast)
300  AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time)
301  AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow)
302 
303  AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safety.
304  AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default!
305  AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default!
306  AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance.
307  AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded.
308 
309  AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern.
310  AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic.
311  AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost)
312  AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost)
313  };
314 
315 #ifdef BUILDING_AVSCORE
316 AVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0);
317 
318 struct AVS_ScriptEnvironment {
319  IScriptEnvironment * env;
320  const char * error;
321  AVS_ScriptEnvironment(IScriptEnvironment * e = 0)
322  : env(e), error(0) {}
323 };
324 #endif
325 
326 typedef struct AVS_Clip AVS_Clip;
328 
329 /////////////////////////////////////////////////////////////////////
330 //
331 // AVS_VideoInfo
332 //
333 
334 // AVS_VideoInfo is laid out identically to VideoInfo
335 typedef struct AVS_VideoInfo {
336  int width, height; // width=0 means no video
337  unsigned fps_numerator, fps_denominator;
339 
341 
342  int audio_samples_per_second; // 0 means no audio
346 
347  // Image type properties
348 
350 } AVS_VideoInfo;
351 
352 // useful functions of the above
354  { return (p->width!=0); }
355 
357  { return (p->audio_samples_per_second!=0); }
358 
360  { return !!(p->pixel_type&AVS_CS_BGR); }
361 
364 
367 
369  { return !!(p->pixel_type&AVS_CS_YUV ); }
370 
372  { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
373 
374 AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444
375 
376 AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422
377 
378 AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420
379 
380 AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);
381 
382 AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y
383 
384 AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);
385 
386 AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);
387 
388 AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);
389 
391 
392 AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);
393 
394 AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);
395 
397 
398 // no API for these, inline helper functions
399 AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
400 {
401  return ((p->image_type & property) == property);
402 }
403 
405 {
406  return !!(p->pixel_type & AVS_CS_PLANAR);
407 }
408 
410 {
411  return !!(p->image_type & AVS_IT_FIELDBASED);
412 }
413 
415 {
416  return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF)));
417 }
418 
420 {
421  return !!(p->image_type & AVS_IT_BFF);
422 }
423 
425 {
426  return !!(p->image_type & AVS_IT_TFF);
427 }
428 
430  { return p->audio_samples_per_second; }
431 
433 {
434  switch (p->sample_type) {
435  case AVS_SAMPLE_INT8: return sizeof(signed char);
436  case AVS_SAMPLE_INT16: return sizeof(signed short);
437  case AVS_SAMPLE_INT24: return 3;
438  case AVS_SAMPLE_INT32: return sizeof(signed int);
439  case AVS_SAMPLE_FLOAT: return sizeof(float);
440  default: return 0;
441  }
442 }
443 
445  { return p->nchannels*avs_bytes_per_channel_sample(p);}
446 
448  { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
449 
451  { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); }
452 
454  { return bytes / avs_bytes_per_audio_sample(p); }
455 
457  { return samples * avs_bytes_per_audio_sample(p); }
458 
460  { return p->nchannels; }
461 
463  { return p->sample_type;}
464 
465 // useful mutator
467  { p->image_type|=property; }
468 
470  { p->image_type&=~property; }
471 
472 AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
473  { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
474 
475 AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
476 {
477  unsigned x=numerator, y=denominator;
478  while (y) { // find gcd
479  unsigned t = x%y; x = y; y = t;
480  }
481  p->fps_numerator = numerator/x;
482  p->fps_denominator = denominator/x;
483 }
484 
485 #ifndef AVSC_NO_DECLSPEC
486 // this inline function is calling an API function
488 {
489  return (x->pixel_type == y->pixel_type)
490  || (avs_is_yv12(x) && avs_is_yv12(y));
491 }
492 #endif
493 
494 // Avisynth+ extensions
495 AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);
496 
497 AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);
498 
499 AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444
500 
501 AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422
502 
503 AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420
504 
505 AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // obsolete, use avs_is_y
506 
507 AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444
508 
509 AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422
510 
511 AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420
512 
513 AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // obsolete, use avs_is_y
514 
515 AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);
516 
517 AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);
518 
519 AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);
520 
521 AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);
522 
523 AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);
524 
525 AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);
526 
527 AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);
528 
529 AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);
530 
531 AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);
532 
533 AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);
534 // end of Avisynth+ specific
535 
536 /////////////////////////////////////////////////////////////////////
537 //
538 // AVS_VideoFrame
539 //
540 
541 // VideoFrameBuffer holds information about a memory block which is used
542 // for video data. For efficiency, instances of this class are not deleted
543 // when the refcount reaches zero; instead they're stored in a linked list
544 // to be reused. The instances are deleted when the corresponding AVS
545 // file is closed.
546 
547 // AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer
548 // DO NOT USE THIS STRUCTURE DIRECTLY
549 typedef struct AVS_VideoFrameBuffer {
551 #ifdef SIZETMOD
552  size_t data_size;
553 #else
555 #endif
556  // sequence_number is incremented every time the buffer is changed, so
557  // that stale views can tell they're no longer valid.
558  volatile long sequence_number;
559 
560  volatile long refcount;
562 
563 // VideoFrame holds a "window" into a VideoFrameBuffer.
564 
565 // AVS_VideoFrame is laid out identically to IVideoFrame
566 // DO NOT USE THIS STRUCTURE DIRECTLY
567 typedef struct AVS_VideoFrame {
568  volatile long refcount;
570 #ifdef SIZETMOD
571  size_t offset;
572 #else
573  int offset;
574 #endif
575  int pitch, row_size, height;
576 #ifdef SIZETMOD
577  size_t offsetU, offsetV;
578 #else
579  int offsetU, offsetV;
580 #endif
581  int pitchUV; // U&V offsets are from top of picture.
582  int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.
583  // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)
584  // the decision on existence of UV is checked by zero pitch
585  // AVS+ extension, avisynth.h: class does not break plugins if appended here
586 #ifdef SIZETMOD
587  size_t offsetA;
588 #else
589  int offsetA;
590 #endif
591  int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none
593 
594 // Access functions for AVS_VideoFrame
595 AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);
596 
597 AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);
598 
599 AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);
600 
601 AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);
602 
603 AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);
604 
606 
607 AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
608 // makes a shallow copy of a video frame
609 AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
610 
611 // no API for these, inline helper functions
612 #ifndef AVSC_NO_DECLSPEC
613 // this inline function is calling an API function
615  return avs_get_pitch_p(p, 0);
616 }
617 #endif
618 
619 #ifndef AVSC_NO_DECLSPEC
620 // this inline function is calling an API function
622  return avs_get_row_size_p(p, 0); }
623 #endif
624 
625 
626 #ifndef AVSC_NO_DECLSPEC
627 // this inline function is calling an API function
629  return avs_get_height_p(p, 0);
630 }
631 #endif
632 
633 #ifndef AVSC_NO_DECLSPEC
634 // this inline function is calling an API function
636  return avs_get_read_ptr_p(p, 0);}
637 #endif
638 
639 #ifndef AVSC_NO_DECLSPEC
640 // this inline function is calling an API function
642  return avs_get_write_ptr_p(p, 0);}
643 #endif
644 
645 #ifndef AVSC_NO_DECLSPEC
646 // this inline function is calling an API function
648  {avs_release_video_frame(f);}
649 #endif
650 
651 #ifndef AVSC_NO_DECLSPEC
652 // this inline function is calling an API function
654  {return avs_copy_video_frame(f);}
655 #endif
656 
657 /////////////////////////////////////////////////////////////////////
658 //
659 // AVS_Value
660 //
661 
662 // Treat AVS_Value as a fat pointer. That is use avs_copy_value
663 // and avs_release_value appropriately as you would if AVS_Value was
664 // a pointer.
665 
666 // To maintain source code compatibility with future versions of the
667 // avisynth_c API don't use the AVS_Value directly. Use the helper
668 // functions below.
669 
670 // AVS_Value is laid out identically to AVSValue
671 typedef struct AVS_Value AVS_Value;
672 struct AVS_Value {
673  short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
674  // for some function e'rror
675  short array_size;
676  union {
677  void * clip; // do not use directly, use avs_take_clip
678  char boolean;
679  int integer;
680  float floating_pt;
681  const char * string;
682  const AVS_Value * array;
683  } d;
684 };
685 
686 // AVS_Value should be initialized with avs_void.
687 // Should also set to avs_void after the value is released
688 // with avs_copy_value. Consider it the equivalent of setting
689 // a pointer to NULL
690 static const AVS_Value avs_void = {'v'};
691 
692 AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
693 AVSC_API(void, avs_release_value)(AVS_Value);
694 AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
695 AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
696 
697 
698 // no API for these, inline helper functions
699 AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
700 AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
701 AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
702 AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }
703 AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }
704 AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
705 AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
706 AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
707 
708 AVSC_INLINE int avs_as_bool(AVS_Value v)
709  { return v.d.boolean; }
710 AVSC_INLINE int avs_as_int(AVS_Value v)
711  { return v.d.integer; }
712 AVSC_INLINE const char * avs_as_string(AVS_Value v)
713  { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
714 AVSC_INLINE double avs_as_float(AVS_Value v)
715  { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }
716 AVSC_INLINE const char * avs_as_error(AVS_Value v)
717  { return avs_is_error(v) ? v.d.string : 0; }
718 AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
719  { return v.d.array; }
720 AVSC_INLINE int avs_array_size(AVS_Value v)
721  { return avs_is_array(v) ? v.array_size : 1; }
722 AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
723  { return avs_is_array(v) ? v.d.array[index] : v; }
724 
725 // only use these functions on an AVS_Value that does not already have
726 // an active value. Remember, treat AVS_Value as a fat pointer.
728  { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
730  { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }
731 AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
732  { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
734  { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
735 AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
736  { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }
737 #ifndef AVSC_NO_DECLSPEC
738 // this inline function is calling an API function
740  { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
741 #endif
742 AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
743  { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; }
744 // end of inline helper functions
745 
746 /////////////////////////////////////////////////////////////////////
747 //
748 // AVS_Clip
749 //
750 
751 AVSC_API(void, avs_release_clip)(AVS_Clip *);
752 AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
753 
754 AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
755 
756 AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
757 
758 AVSC_API(int, avs_get_version)(AVS_Clip *);
759 
760 AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
761 // The returned video frame must be released with avs_release_video_frame
762 
763 AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
764 // return field parity if field_based, else parity of first field in frame
765 
766 AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
768 // start and count are in samples
769 
770 AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
772 
773 // This is the callback type used by avs_add_function
774 typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
775  (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);
776 
777 typedef struct AVS_FilterInfo AVS_FilterInfo;
779 {
780  // these members should not be modified outside of the AVS_ApplyFunc callback
785  int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
786  int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
788  int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
789  int frame_range);
790  void (AVSC_CC * free_filter)(AVS_FilterInfo *);
791 
792  // Should be set when ever there is an error to report.
793  // It is cleared before any of the above methods are called
794  const char * error;
795  // this is to store whatever and may be modified at will
796  void * user_data;
797 };
798 
799 // Create a new filter
800 // fi is set to point to the AVS_FilterInfo so that you can
801 // modify it once it is initialized.
802 // store_child should generally be set to true. If it is not
803 // set than ALL methods (the function pointers) must be defined
804 // If it is set than you do not need to worry about freeing the child
805 // clip.
806 AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
808  AVS_Value child, int store_child);
809 
810 /////////////////////////////////////////////////////////////////////
811 //
812 // AVS_ScriptEnvironment
813 //
814 
815 // For GetCPUFlags. These are backwards-compatible with those in VirtualDub.
816 enum {
817  /* slowest CPU to support extension */
818  AVS_CPU_FORCE = 0x01, // N/A
819  AVS_CPU_FPU = 0x02, // 386/486DX
820  AVS_CPU_MMX = 0x04, // P55C, K6, PII
821  AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
822  AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
823  AVS_CPU_SSE2 = 0x20, // PIV, Hammer
824  AVS_CPU_3DNOW = 0x40, // K6-2
825  AVS_CPU_3DNOW_EXT = 0x80, // Athlon
826  AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
827  // which only Hammer will have anyway)
828  AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice
829  AVS_CPUF_SSSE3 = 0x200, // Core 2
830  AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield
832  AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer
833  AVS_CPUF_SSE4_2 = 0x1000, // Nehalem
834  // AVS+
835  AVS_CPUF_AVX2 = 0x2000, // Haswell
836  AVS_CPUF_FMA3 = 0x4000,
837  AVS_CPUF_F16C = 0x8000,
838  AVS_CPUF_MOVBE = 0x10000, // Big Endian Move
839  AVS_CPUF_POPCNT = 0x20000,
840  AVS_CPUF_AES = 0x40000,
841  AVS_CPUF_FMA4 = 0x80000,
842 
843  AVS_CPUF_AVX512F = 0x100000, // AVX-512 Foundation.
844  AVS_CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions
845  AVS_CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch
846  AVS_CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal
847  AVS_CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection
848  AVS_CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions
849  AVS_CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions
850  AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit
851  AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI
852 };
853 
854 
855 AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
856 
857 AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
858 AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
859 
860 AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
861 AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
862 
863 AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val);
864  // note: val is really a va_list; I hope everyone typedefs va_list to a pointer
865 
866 AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
867  const char * name, const char * params,
868  AVS_ApplyFunc apply, void * user_data);
869 
870 AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
871 
872 AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
873  AVS_Value args, const char** arg_names);
874 // The returned value must be be released with avs_release_value
875 
876 AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
877 // The returned value must be be released with avs_release_value
878 
879 AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
880 
881 AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
882 
883 //void avs_push_context(AVS_ScriptEnvironment *, int level=0);
884 //void avs_pop_context(AVS_ScriptEnvironment *);
885 
886 AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
887  const AVS_VideoInfo * vi, int align);
888 // align should be at least 16 for classic Avisynth
889 // Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided
890 
891 // no API for these, inline helper functions
892 #ifndef AVSC_NO_DECLSPEC
893 // this inline function is calling an API function
895  const AVS_VideoInfo * vi)
896  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
897 
898 // an older compatibility alias
899 // this inline function is calling an API function
901  const AVS_VideoInfo * vi)
902  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
903 #endif
904 // end of inline helper functions
905 
906 AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
907 
908 AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);
909 
911 AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
912 
914 // The returned video frame must be be released
915 
916 AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
917 
918 AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
919 
920 // avisynth.dll exports this; it's a way to use it as a library, without
921 // writing an AVS script or without going through AVIFile.
922 AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
923 
924 // this symbol is the entry point for the plugin and must
925 // be defined
928 
929 
930 AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
931 
932 
934 // The returned video frame must be be released
935 
936 #ifdef AVSC_NO_DECLSPEC
937 // This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)
938 // When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct
939 // AVSC_INLINE functions which call onto an API functions should be treated specially (todo)
940 
941 /*
942  The following functions needs to have been declared, probably from windows.h
943 
944  void* malloc(size_t)
945  void free(void*);
946 
947  HMODULE LoadLibrary(const char*);
948  void* GetProcAddress(HMODULE, const char*);
949  FreeLibrary(HMODULE);
950 */
951 
952 
953 typedef struct AVS_Library AVS_Library;
954 
955 #define AVSC_DECLARE_FUNC(name) name##_func name
956 
957 // AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx
958 // e.g. "AVSC_DECLARE_FUNC(avs_add_function);"
959 // is a shortcut for "avs_add_function_func avs_add_function;"
960 
961 // Note: AVSC_INLINE functions which call into API,
962 // are guarded by #ifndef AVSC_NO_DECLSPEC
963 // They should call the appropriate library-> API entry
964 
965 struct AVS_Library {
966  HMODULE handle;
967 
968  AVSC_DECLARE_FUNC(avs_add_function);
969  AVSC_DECLARE_FUNC(avs_at_exit);
970  AVSC_DECLARE_FUNC(avs_bit_blt);
971  AVSC_DECLARE_FUNC(avs_check_version);
972  AVSC_DECLARE_FUNC(avs_clip_get_error);
973  AVSC_DECLARE_FUNC(avs_copy_clip);
974  AVSC_DECLARE_FUNC(avs_copy_value);
975  AVSC_DECLARE_FUNC(avs_copy_video_frame);
976  AVSC_DECLARE_FUNC(avs_create_script_environment);
977  AVSC_DECLARE_FUNC(avs_delete_script_environment);
978  AVSC_DECLARE_FUNC(avs_function_exists);
979  AVSC_DECLARE_FUNC(avs_get_audio);
980  AVSC_DECLARE_FUNC(avs_get_cpu_flags);
981  AVSC_DECLARE_FUNC(avs_get_frame);
982  AVSC_DECLARE_FUNC(avs_get_parity);
983  AVSC_DECLARE_FUNC(avs_get_var);
984  AVSC_DECLARE_FUNC(avs_get_version);
985  AVSC_DECLARE_FUNC(avs_get_video_info);
986  AVSC_DECLARE_FUNC(avs_invoke);
987  AVSC_DECLARE_FUNC(avs_make_writable);
988  AVSC_DECLARE_FUNC(avs_new_c_filter);
989  AVSC_DECLARE_FUNC(avs_new_video_frame_a);
990  AVSC_DECLARE_FUNC(avs_release_clip);
991  AVSC_DECLARE_FUNC(avs_release_value);
992  AVSC_DECLARE_FUNC(avs_release_video_frame);
993  AVSC_DECLARE_FUNC(avs_save_string);
994  AVSC_DECLARE_FUNC(avs_set_cache_hints);
995  AVSC_DECLARE_FUNC(avs_set_global_var);
996  AVSC_DECLARE_FUNC(avs_set_memory_max);
997  AVSC_DECLARE_FUNC(avs_set_to_clip);
998  AVSC_DECLARE_FUNC(avs_set_var);
999  AVSC_DECLARE_FUNC(avs_set_working_dir);
1000  AVSC_DECLARE_FUNC(avs_sprintf);
1001  AVSC_DECLARE_FUNC(avs_subframe);
1002  AVSC_DECLARE_FUNC(avs_subframe_planar);
1003  AVSC_DECLARE_FUNC(avs_take_clip);
1004  AVSC_DECLARE_FUNC(avs_vsprintf);
1005 
1006  AVSC_DECLARE_FUNC(avs_get_error);
1007  AVSC_DECLARE_FUNC(avs_is_yv24);
1008  AVSC_DECLARE_FUNC(avs_is_yv16);
1010  AVSC_DECLARE_FUNC(avs_is_yv411);
1011  AVSC_DECLARE_FUNC(avs_is_y8);
1013 
1014  AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);
1015  AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);
1026 
1027  // Avisynth+ specific
1028  // Note: these functions are simulated/use fallback to existing functions
1029  AVSC_DECLARE_FUNC(avs_is_rgb48);
1030  AVSC_DECLARE_FUNC(avs_is_rgb64);
1031  AVSC_DECLARE_FUNC(avs_is_yuv444p16);
1032  AVSC_DECLARE_FUNC(avs_is_yuv422p16);
1033  AVSC_DECLARE_FUNC(avs_is_yuv420p16);
1034  AVSC_DECLARE_FUNC(avs_is_y16);
1035  AVSC_DECLARE_FUNC(avs_is_yuv444ps);
1036  AVSC_DECLARE_FUNC(avs_is_yuv422ps);
1037  AVSC_DECLARE_FUNC(avs_is_yuv420ps);
1038  AVSC_DECLARE_FUNC(avs_is_y32);
1039  AVSC_DECLARE_FUNC(avs_is_444);
1040  AVSC_DECLARE_FUNC(avs_is_422);
1041  AVSC_DECLARE_FUNC(avs_is_420);
1042  AVSC_DECLARE_FUNC(avs_is_y);
1043  AVSC_DECLARE_FUNC(avs_is_yuva);
1044  AVSC_DECLARE_FUNC(avs_is_planar_rgb);
1045  AVSC_DECLARE_FUNC(avs_is_planar_rgba);
1046  AVSC_DECLARE_FUNC(avs_num_components);
1047  AVSC_DECLARE_FUNC(avs_component_size);
1048  AVSC_DECLARE_FUNC(avs_bits_per_component);
1049  // end of Avisynth+ specific
1050 
1051 };
1052 
1053 #undef AVSC_DECLARE_FUNC
1054 
1055 // Helper functions for fallback simulation
1056 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1057 AVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p)
1058 {
1059  return 0;
1060 }
1061 
1062 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1063 AVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p)
1064 {
1065  switch (p->pixel_type) {
1066  case AVS_CS_UNKNOWN:
1067  return 0;
1068  case AVS_CS_RAW32:
1069  case AVS_CS_Y8:
1070  return 1;
1071  case AVS_CS_BGR32:
1072  return 4; // not planar but return the count
1073  default:
1074  return 3;
1075  }
1076 }
1077 
1078 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1079 AVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p)
1080 {
1081  return 1;
1082 }
1083 
1084 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1085 AVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p)
1086 {
1087  return 8;
1088 }
1089 // End of helper functions for fallback simulation
1090 
1091 // avs_load_library() allocates an array for API procedure entries
1092 // reads and fills the entries with live procedure addresses.
1093 // AVSC_INLINE helpers which are calling into API procedures are not treated here (todo)
1094 
1095 AVSC_INLINE AVS_Library * avs_load_library() {
1096  AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));
1097  if (library == NULL)
1098  return NULL;
1099  library->handle = LoadLibraryA("avisynth");
1100  if (library->handle == NULL)
1101  goto fail;
1102 
1103 #define __AVSC_STRINGIFY(x) #x
1104 #define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)
1105 #define AVSC_LOAD_FUNC(name) {\
1106  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1107  if (library->name == NULL)\
1108  goto fail;\
1109 }
1110 
1111 #if 0
1112 // FFmpeg-specific: we don't use the FALLBACK stuff, and it causes build errors,
1113 // so ifdef it out on our side.
1114 
1115 // When an API function is not loadable, let's try a replacement
1116 // Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods
1117 /*
1118 Avisynth+ When method is missing (classic Avisynth)
1119 avs_is_rgb48 constant false
1120 avs_is_rgb64 constant false
1121 avs_is_yuv444p16 constant false
1122 avs_is_yuv422p16 constant false
1123 avs_is_yuv420p16 constant false
1124 avs_is_y16 constant false
1125 avs_is_yuv444ps constant false
1126 avs_is_yuv422ps constant false
1127 avs_is_yuv420ps constant false
1128 avs_is_y32 constant false
1129 avs_is_444 avs_is_yv24
1130 avs_is_422 avs_is_yv16
1131 avs_is_420 avs_is_yv12
1132 avs_is_y avs_is_y8
1133 avs_is_yuva constant false
1134 avs_is_planar_rgb constant false
1135 avs_is_planar_rgba constant false
1136 avs_num_components special: avs_num_components_fake Y8:1 RGB32:4 else 3
1137 avs_component_size constant 1 (1 bytes/component)
1138 avs_bits_per_component constant 8 (8 bits/component)
1139 */
1140 
1141  // try to load an alternative function
1142 #define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\
1143  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1144  if (library->name == NULL)\
1145  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\
1146  if (library->name == NULL)\
1147  goto fail;\
1148 }
1149 
1150  // try to assign a replacement function
1151 #define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\
1152  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1153  if (library->name == NULL)\
1154  library->name = name2;\
1155  if (library->name == NULL)\
1156  goto fail;\
1157 }
1158 #endif
1159 
1160  AVSC_LOAD_FUNC(avs_add_function);
1161  AVSC_LOAD_FUNC(avs_at_exit);
1162  AVSC_LOAD_FUNC(avs_bit_blt);
1163  AVSC_LOAD_FUNC(avs_check_version);
1164  AVSC_LOAD_FUNC(avs_clip_get_error);
1165  AVSC_LOAD_FUNC(avs_copy_clip);
1166  AVSC_LOAD_FUNC(avs_copy_value);
1167  AVSC_LOAD_FUNC(avs_copy_video_frame);
1168  AVSC_LOAD_FUNC(avs_create_script_environment);
1169  AVSC_LOAD_FUNC(avs_delete_script_environment);
1170  AVSC_LOAD_FUNC(avs_function_exists);
1171  AVSC_LOAD_FUNC(avs_get_audio);
1172  AVSC_LOAD_FUNC(avs_get_cpu_flags);
1173  AVSC_LOAD_FUNC(avs_get_frame);
1174  AVSC_LOAD_FUNC(avs_get_parity);
1175  AVSC_LOAD_FUNC(avs_get_var);
1176  AVSC_LOAD_FUNC(avs_get_version);
1177  AVSC_LOAD_FUNC(avs_get_video_info);
1178  AVSC_LOAD_FUNC(avs_invoke);
1179  AVSC_LOAD_FUNC(avs_make_writable);
1180  AVSC_LOAD_FUNC(avs_new_c_filter);
1181  AVSC_LOAD_FUNC(avs_new_video_frame_a);
1182  AVSC_LOAD_FUNC(avs_release_clip);
1183  AVSC_LOAD_FUNC(avs_release_value);
1184  AVSC_LOAD_FUNC(avs_release_video_frame);
1185  AVSC_LOAD_FUNC(avs_save_string);
1186  AVSC_LOAD_FUNC(avs_set_cache_hints);
1187  AVSC_LOAD_FUNC(avs_set_global_var);
1188  AVSC_LOAD_FUNC(avs_set_memory_max);
1189  AVSC_LOAD_FUNC(avs_set_to_clip);
1190  AVSC_LOAD_FUNC(avs_set_var);
1191  AVSC_LOAD_FUNC(avs_set_working_dir);
1192  AVSC_LOAD_FUNC(avs_sprintf);
1193  AVSC_LOAD_FUNC(avs_subframe);
1194  AVSC_LOAD_FUNC(avs_subframe_planar);
1195  AVSC_LOAD_FUNC(avs_take_clip);
1196  AVSC_LOAD_FUNC(avs_vsprintf);
1197 
1198  AVSC_LOAD_FUNC(avs_get_error);
1199  AVSC_LOAD_FUNC(avs_is_yv24);
1200  AVSC_LOAD_FUNC(avs_is_yv16);
1201  AVSC_LOAD_FUNC(avs_is_yv12);
1202  AVSC_LOAD_FUNC(avs_is_yv411);
1203  AVSC_LOAD_FUNC(avs_is_y8);
1204  AVSC_LOAD_FUNC(avs_is_color_space);
1205 
1206  AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);
1207  AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);
1208  AVSC_LOAD_FUNC(avs_bits_per_pixel);
1209  AVSC_LOAD_FUNC(avs_bytes_from_pixels);
1210  AVSC_LOAD_FUNC(avs_row_size);
1211  AVSC_LOAD_FUNC(avs_bmp_size);
1212  AVSC_LOAD_FUNC(avs_get_pitch_p);
1213  AVSC_LOAD_FUNC(avs_get_row_size_p);
1214  AVSC_LOAD_FUNC(avs_get_height_p);
1215  AVSC_LOAD_FUNC(avs_get_read_ptr_p);
1216  AVSC_LOAD_FUNC(avs_is_writable);
1217  AVSC_LOAD_FUNC(avs_get_write_ptr_p);
1218 
1219 #if 0
1220  // Avisynth+ specific but made them callable for classic Avisynth hosts
1221  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false);
1222  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false);
1223  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444p16, avs_is_xx_fallback_return_false);
1224  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422p16, avs_is_xx_fallback_return_false);
1225  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420p16, avs_is_xx_fallback_return_false);
1226  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y16, avs_is_xx_fallback_return_false);
1227  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444ps, avs_is_xx_fallback_return_false);
1228  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422ps, avs_is_xx_fallback_return_false);
1229  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420ps, avs_is_xx_fallback_return_false);
1230  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y32, avs_is_xx_fallback_return_false);
1231  AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24);
1232  AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16);
1233  AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12);
1234  AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8);
1235  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false);
1236  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false);
1237  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false);
1238  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback);
1239  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback);
1240  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback);
1241 #endif
1242 
1243 #undef __AVSC_STRINGIFY
1244 #undef AVSC_STRINGIFY
1245 #undef AVSC_LOAD_FUNC
1246 #undef AVSC_LOAD_FUNC_FALLBACK
1247 #undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED
1248 
1249  return library;
1250 
1251 fail:
1252  free(library);
1253  return NULL;
1254 }
1255 
1256 AVSC_INLINE void avs_free_library(AVS_Library *library) {
1257  if (library == NULL)
1258  return;
1259  FreeLibrary(library->handle);
1260  free(library);
1261 }
1262 #endif
1263 
1264 #endif
int plane
Definition: avisynth_c.h:384
int cachehints
Definition: avisynth_c.h:771
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:863
const char * s
Definition: avisynth_c.h:860
AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo *p)
Definition: avisynth_c.h:365
BYTE int const BYTE int int row_size
Definition: avisynth_c.h:908
AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment *env, const AVS_VideoInfo *vi)
Definition: avisynth_c.h:894
volatile long sequence_number
Definition: avisynth_c.h:558
BYTE int const BYTE int src_pitch
Definition: avisynth_c.h:908
AVS_Value src
Definition: avisynth_c.h:692
AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
Definition: avisynth_c.h:718
const char AVS_Value const char ** arg_names
Definition: avisynth_c.h:872
const char * fmt
Definition: avisynth_c.h:861
AVSC_INLINE const char * avs_as_string(AVS_Value v)
Definition: avisynth_c.h:712
AVSC_INLINE int avs_is_tff(const AVS_VideoInfo *p)
Definition: avisynth_c.h:424
short array_size
Definition: avisynth_c.h:675
AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo *p)
Definition: avisynth_c.h:444
AVS_VideoFrame int int int int int int rel_offsetV
Definition: avisynth_c.h:933
AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame *f)
Definition: avisynth_c.h:653
AVSC_INLINE int avs_bytes_from_pixels(const AVS_VideoInfo *p, int pixels)
Definition: avxsynth_c.h:232
AVSC_INLINE AVS_Value avs_new_value_error(const char *v0)
Definition: avisynth_c.h:735
char boolean
Definition: avisynth_c.h:678
static const AVS_Value avs_void
Definition: avisynth_c.h:690
AVS_VideoFrame int int int int new_height
Definition: avisynth_c.h:913
int version
Definition: avisynth_c.h:858
AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo *p, INT64 bytes)
Definition: avisynth_c.h:453
GLfloat v0
Definition: opengl_enc.c:106
AVSC_INLINE void avs_set_fps(AVS_VideoInfo *p, unsigned numerator, unsigned denominator)
Definition: avisynth_c.h:475
static void error(const char *err)
AVSC_INLINE AVS_Value avs_new_value_int(int v0)
Definition: avisynth_c.h:729
if it could not because there are no more frames
const char * string
Definition: avisynth_c.h:681
long long int INT64
Definition: types.h:52
AVSC_INLINE BYTE * avs_get_write_ptr(const AVS_VideoFrame *p)
Definition: avisynth_c.h:641
AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo *p)
Definition: avisynth_c.h:414
AVSC_INLINE int avs_bmp_size(const AVS_VideoInfo *vi)
Definition: avxsynth_c.h:238
BYTE int const BYTE * srcp
Definition: avisynth_c.h:908
short type
Definition: avisynth_c.h:673
#define AVSC_EXPORT
Definition: capi.h:86
typedef AVS_Value(AVSC_CC *AVS_ApplyFunc)(AVS_ScriptEnvironment *
int mem
Definition: avisynth_c.h:916
AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo *p)
Definition: avisynth_c.h:459
AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo *p)
Definition: avisynth_c.h:429
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define f(width, name)
Definition: cbs_vp9.c:255
AVS_FilterInfo AVS_Value child
Definition: avisynth_c.h:807
#define AVSC_DECLARE_FUNC(name)
Definition: avisynth.c:50
AVSC_INLINE int avs_is_property(const AVS_VideoInfo *p, int property)
Definition: avisynth_c.h:399
const AVS_Value * array
Definition: avisynth_c.h:682
AVS_VideoFrame int int int int int rel_offsetU
Definition: avisynth_c.h:933
AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame *p)
Definition: avisynth_c.h:614
AVS_ScriptEnvironment * env
Definition: avisynth_c.h:783
AVSC_INLINE int avs_as_bool(AVS_Value v)
Definition: avisynth_c.h:708
AVSC_INLINE int avs_is_int(AVS_Value v)
Definition: avisynth_c.h:702
const char * newdir
Definition: avisynth_c.h:918
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
Definition: avisynth_c.h:359
AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
Definition: avisynth_c.h:722
AVSC_INLINE int avs_array_size(AVS_Value v)
Definition: avisynth_c.h:720
AVSC_INLINE int avs_as_int(AVS_Value v)
Definition: avisynth_c.h:710
AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo *p, INT64 samples)
Definition: avisynth_c.h:456
volatile long refcount
Definition: avisynth_c.h:568
AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo *p)
void * clip
Definition: avisynth_c.h:677
AVSC_INLINE int avs_is_array(AVS_Value v)
Definition: avisynth_c.h:705
volatile long refcount
Definition: avisynth_c.h:560
ptrdiff_t size
Definition: opengl_enc.c:100
AVSC_INLINE int avs_is_bool(AVS_Value v)
Definition: avisynth_c.h:701
AVSC_INLINE int avs_get_height(const AVS_VideoFrame *p)
Definition: avisynth_c.h:628
int int frame_range
Definition: avisynth_c.h:771
AVSC_INLINE const BYTE * avs_get_read_ptr(const AVS_VideoFrame *p)
Definition: avisynth_c.h:635
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:340
AVSC_INLINE int avs_is_float(AVS_Value v)
Definition: avisynth_c.h:703
INT64 num_audio_samples
Definition: avisynth_c.h:344
AVSC_INLINE AVS_Value avs_new_value_float(float v0)
Definition: avisynth_c.h:733
AVS_Clip * child
Definition: avisynth_c.h:781
AVS_FilterInfo ** fi
Definition: avisynth_c.h:807
const AVS_VideoInfo * vi
Definition: avisynth_c.h:887
AVSC_INLINE int avs_is_planar(const AVS_VideoInfo *p)
Definition: avisynth_c.h:404
AVSC_EXPORT const char *AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment *env)
AVSC_INLINE void avs_set_property(AVS_VideoInfo *p, int property)
Definition: avisynth_c.h:466
BYTE * dstp
Definition: avisynth_c.h:908
void * HMODULE
AVS_Value void * user_data
Definition: avisynth_c.h:775
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo *p)
Definition: avisynth_c.h:362
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
Definition: avisynth_c.h:353
struct AVS_Clip AVS_Clip
Definition: avisynth_c.h:326
AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo *p, int c_space)
Definition: avxsynth_c.h:200
#define fail()
Definition: checkasm.h:122
const char * name
Definition: avisynth_c.h:867
static int get_frame(AVFilterContext *ctx, int is_second)
Definition: vf_nnedi.c:689
unsigned fps_numerator
Definition: avisynth_c.h:337
AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
Definition: avisynth_c.h:727
int int frame_range
Definition: avisynth_c.h:788
AVSC_INLINE int avs_is_clip(AVS_Value v)
Definition: avisynth_c.h:700
AVSC_INLINE unsigned char * avs_get_write_ptr_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:404
AVSC_INLINE AVS_Value avs_new_value_string(const char *v0)
Definition: avisynth_c.h:731
AVSC_INLINE const char * avs_as_error(AVS_Value v)
Definition: avisynth_c.h:716
union AVS_Value::@10 d
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVS_Value args
Definition: avisynth_c.h:775
AVS_ScriptEnvironment AVS_Clip *AVSC_INLINE int avs_defined(AVS_Value v)
Definition: avisynth_c.h:699
AVS_VideoInfo vi
Definition: avisynth_c.h:782
AVSC_INLINE int avs_is_bff(const AVS_VideoInfo *p)
Definition: avisynth_c.h:419
int n
Definition: avisynth_c.h:760
AVSC_INLINE double avs_as_float(AVS_Value v)
Definition: avisynth_c.h:714
AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame *p)
Definition: avisynth_c.h:621
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:221
const AVS_VideoInfo int align
Definition: avisynth_c.h:887
void INT64 start
Definition: avisynth_c.h:786
unsigned char BYTE
Definition: types.h:46
AVSC_INLINE const unsigned char * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:384
AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:197
AVSC_INLINE int avs_is_error(AVS_Value v)
Definition: avisynth_c.h:706
AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo *p)
Definition: avisynth_c.h:409
const char * error
Definition: avisynth_c.h:794
void * buf
Definition: avisynth_c.h:766
AVS_VideoFrame int rel_offset
Definition: avisynth_c.h:913
BYTE int const BYTE int int int height
Definition: avisynth_c.h:908
#define AVSC_INLINE
Definition: capi.h:80
AVS_VideoFrame ** pvf
Definition: avisynth_c.h:906
AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value *v0, int size)
Definition: avisynth_c.h:742
int index
Definition: gxfenc.c:89
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
Definition: avisynth_c.h:432
AVSC_INLINE void avs_set_field_based(AVS_VideoInfo *p, int isfieldbased)
Definition: avisynth_c.h:472
AVS_VideoFrame int int int new_row_size
Definition: avisynth_c.h:913
AVS_VideoFrameBuffer * vfb
Definition: avisynth_c.h:569
#define AVS_FRAME_ALIGN
Definition: avisynth_c.h:61
#define AVSC_CC
Definition: capi.h:55
AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo *p)
Definition: avisynth_c.h:368
void(AVSC_CC * AVS_ShutdownFunc)(void *user_data, AVS_ScriptEnvironment *env)
Definition: avisynth_c.h:910
AVSC_INLINE void avs_clear_property(AVS_VideoInfo *p, int property)
Definition: avisynth_c.h:469
AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment *env, const AVS_VideoInfo *vi)
Definition: avisynth_c.h:900
const char const char * params
Definition: avisynth_c.h:867
struct AVS_ScriptEnvironment AVS_ScriptEnvironment
Definition: avisynth_c.h:327
int
AVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo *x, const AVS_VideoInfo *y)
Definition: avisynth_c.h:487
AVSC_INLINE void avs_release_frame(AVS_VideoFrame *f)
Definition: avisynth_c.h:647
float floating_pt
Definition: avisynth_c.h:680
AVS_VideoFrame int int new_pitch
Definition: avisynth_c.h:913
int integer
Definition: avisynth_c.h:679
AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip *v0)
Definition: avisynth_c.h:739
AVSC_INLINE int avs_is_string(AVS_Value v)
Definition: avisynth_c.h:704
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:373
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are short
AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo *p, INT64 samples)
Definition: avisynth_c.h:450
int pixels
Definition: avisynth_c.h:390
int c_space
Definition: avisynth_c.h:396
AVSC_INLINE int avs_sample_type(const AVS_VideoInfo *p)
Definition: avisynth_c.h:462
AVSC_INLINE int avs_row_size(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:235
AVS_VideoFrame int int int int int int int new_pitchUV
Definition: avisynth_c.h:933
unsigned fps_denominator
Definition: avisynth_c.h:337
AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo *p, INT64 frames)
Definition: avisynth_c.h:447
AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo *p)
Definition: avisynth_c.h:371
Filter the word “frame” indicates either a video frame or a group of audio samples
void INT64 INT64 count
Definition: avisynth_c.h:766
void INT64 start
Definition: avisynth_c.h:766
void * user_data
Definition: avisynth_c.h:796
const char int length
Definition: avisynth_c.h:860
BYTE int dst_pitch
Definition: avisynth_c.h:908
const char const char AVS_ApplyFunc apply
Definition: avisynth_c.h:867
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:348
AVS_FilterInfo AVS_Value int store_child
Definition: avisynth_c.h:807
AVSC_INLINE int avs_is_writable(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:392
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo *p)
Definition: avisynth_c.h:356
int audio_samples_per_second
Definition: avisynth_c.h:342