avxsynth_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., 675 Mass Ave, Cambridge, MA 02139, 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 
33 #ifndef __AVXSYNTH_C__
34 #define __AVXSYNTH_C__
35 
37 #include <stdarg.h>
38 
39 #ifdef __cplusplus
40 # define EXTERN_C extern "C"
41 #else
42 # define EXTERN_C
43 #endif
44 
45 #define AVSC_USE_STDCALL 1
46 
47 #ifndef AVSC_USE_STDCALL
48 # define AVSC_CC __cdecl
49 #else
50 # define AVSC_CC __stdcall
51 #endif
52 
53 #define AVSC_INLINE static __inline
54 
55 #ifdef AVISYNTH_C_EXPORTS
56 # define AVSC_EXPORT EXTERN_C
57 # define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name
58 #else
59 # define AVSC_EXPORT EXTERN_C __declspec(dllexport)
60 # ifndef AVSC_NO_DECLSPEC
61 # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name
62 # else
63 # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func)
64 # endif
65 #endif
66 
67 #ifdef __GNUC__
68 typedef long long int INT64;
69 #else
70 typedef __int64 INT64;
71 #endif
72 
73 
74 /////////////////////////////////////////////////////////////////////
75 //
76 // Constants
77 //
78 
79 #ifndef __AVXSYNTH_H__
81 #endif
82 
83 enum {AVS_SAMPLE_INT8 = 1<<0,
88 
89 enum {AVS_PLANAR_Y=1<<0,
96 
97  // Colorspace properties.
98 enum {AVS_CS_BGR = 1<<28,
99  AVS_CS_YUV = 1<<29,
101  AVS_CS_PLANAR = 1<<31};
102 
103  // Specific colorformats
104 enum {
109  AVS_CS_YV12 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR, // y-v-u, planar
110  AVS_CS_I420 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR, // y-u-v, planar
111  AVS_CS_IYUV = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR // same as above
112 };
113 
114 enum {
115  AVS_IT_BFF = 1<<0,
116  AVS_IT_TFF = 1<<1,
118 
119 enum {
130 
131 enum { //SUBTYPES
136 
137 enum {
144 };
145 
146 #define AVS_FRAME_ALIGN 16
147 
148 typedef struct AVS_Clip AVS_Clip;
150 
151 /////////////////////////////////////////////////////////////////////
152 //
153 // AVS_VideoInfo
154 //
155 
156 // AVS_VideoInfo is layed out identicly to VideoInfo
157 typedef struct AVS_VideoInfo {
158  int width, height; // width=0 means no video
159  unsigned fps_numerator, fps_denominator;
160  int num_frames;
161 
162  int pixel_type;
163 
164  int audio_samples_per_second; // 0 means no audio
165  int sample_type;
167  int nchannels;
168 
169  // Imagetype properties
170 
171  int image_type;
172 } AVS_VideoInfo;
173 
174 // useful functions of the above
176  { return (p->width!=0); }
177 
179  { return (p->audio_samples_per_second!=0); }
180 
182  { return !!(p->pixel_type&AVS_CS_BGR); }
183 
185  { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties
186 
188  { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; }
189 
191  { return !!(p->pixel_type&AVS_CS_YUV ); }
192 
194  { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
195 
197  { return ((p->pixel_type & AVS_CS_YV12) == AVS_CS_YV12)||((p->pixel_type & AVS_CS_I420) == AVS_CS_I420); }
198 
199 AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo * p, int c_space)
200  { return ((p->pixel_type & c_space) == c_space); }
201 
202 AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
203  { return ((p->pixel_type & property)==property ); }
204 
206  { return !!(p->pixel_type & AVS_CS_PLANAR); }
207 
209  { return !!(p->image_type & AVS_IT_FIELDBASED); }
210 
212  { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); }
213 
215  { return !!(p->image_type & AVS_IT_BFF); }
216 
218  { return !!(p->image_type & AVS_IT_TFF); }
219 
221 {
222  switch (p->pixel_type) {
223  case AVS_CS_BGR24: return 24;
224  case AVS_CS_BGR32: return 32;
225  case AVS_CS_YUY2: return 16;
226  case AVS_CS_YV12:
227  case AVS_CS_I420: return 12;
228  default: return 0;
229  }
230 }
232  { return pixels * (avs_bits_per_pixel(p)>>3); } // Will work on planar images, but will return only luma planes
233 
235  { return avs_bytes_from_pixels(p,p->width); } // Also only returns first plane on planar images
236 
238  { if (avs_is_planar(vi)) {int p = vi->height * ((avs_row_size(vi)+3) & ~3); p+=p>>1; return p; } return vi->height * ((avs_row_size(vi)+3) & ~3); }
239 
241  { return p->audio_samples_per_second; }
242 
243 
245 {
246  switch (p->sample_type) {
247  case AVS_SAMPLE_INT8: return sizeof(signed char);
248  case AVS_SAMPLE_INT16: return sizeof(signed short);
249  case AVS_SAMPLE_INT24: return 3;
250  case AVS_SAMPLE_INT32: return sizeof(signed int);
251  case AVS_SAMPLE_FLOAT: return sizeof(float);
252  default: return 0;
253  }
254 }
256  { return p->nchannels*avs_bytes_per_channel_sample(p);}
257 
259  { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
260 
262  { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); }
263 
265  { return bytes / avs_bytes_per_audio_sample(p); }
266 
268  { return samples * avs_bytes_per_audio_sample(p); }
269 
271  { return p->nchannels; }
272 
274  { return p->sample_type;}
275 
276 // useful mutator
278  { p->image_type|=property; }
279 
281  { p->image_type&=~property; }
282 
283 AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
284  { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
285 
286 AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
287 {
288  unsigned x=numerator, y=denominator;
289  while (y) { // find gcd
290  unsigned t = x%y; x = y; y = t;
291  }
292  p->fps_numerator = numerator/x;
293  p->fps_denominator = denominator/x;
294 }
295 
297 {
298  return (x->pixel_type == y->pixel_type)
299  || (avs_is_yv12(x) && avs_is_yv12(y));
300 }
301 
302 /////////////////////////////////////////////////////////////////////
303 //
304 // AVS_VideoFrame
305 //
306 
307 // VideoFrameBuffer holds information about a memory block which is used
308 // for video data. For efficiency, instances of this class are not deleted
309 // when the refcount reaches zero; instead they're stored in a linked list
310 // to be reused. The instances are deleted when the corresponding AVS
311 // file is closed.
312 
313 // AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer
314 // DO NOT USE THIS STRUCTURE DIRECTLY
315 typedef struct AVS_VideoFrameBuffer {
316  unsigned char * data;
317  int data_size;
318  // sequence_number is incremented every time the buffer is changed, so
319  // that stale views can tell they're no longer valid.
321 
322  long refcount;
324 
325 // VideoFrame holds a "window" into a VideoFrameBuffer.
326 
327 // AVS_VideoFrame is layed out identicly to IVideoFrame
328 // DO NOT USE THIS STRUCTURE DIRECTLY
329 typedef struct AVS_VideoFrame {
330  int refcount;
331  AVS_VideoFrameBuffer * vfb;
332  int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture.
334 
335 // Access functions for AVS_VideoFrame
337  return p->pitch;}
338 
339 AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) {
340  switch (plane) {
341  case AVS_PLANAR_U: case AVS_PLANAR_V: return p->pitchUV;}
342  return p->pitch;}
343 
345  return p->row_size; }
346 
347 AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame * p, int plane) {
348  int r;
349  switch (plane) {
350  case AVS_PLANAR_U: case AVS_PLANAR_V:
351  if (p->pitchUV) return p->row_size>>1;
352  else return 0;
354  if (p->pitchUV) {
355  r = ((p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)) )>>1; // Aligned rowsize
356  if (r < p->pitchUV)
357  return r;
358  return p->row_size>>1;
359  } else return 0;
361  r = (p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)); // Aligned rowsize
362  if (r <= p->pitch)
363  return r;
364  return p->row_size;
365  }
366  return p->row_size;
367 }
368 
370  return p->height;}
371 
372 AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame * p, int plane) {
373  switch (plane) {
374  case AVS_PLANAR_U: case AVS_PLANAR_V:
375  if (p->pitchUV) return p->height>>1;
376  return 0;
377  }
378  return p->height;}
379 
380 AVSC_INLINE const unsigned char* avs_get_read_ptr(const AVS_VideoFrame * p) {
381  return p->vfb->data + p->offset;}
382 
383 AVSC_INLINE const unsigned char* avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane)
384 {
385  switch (plane) {
386  case AVS_PLANAR_U: return p->vfb->data + p->offsetU;
387  case AVS_PLANAR_V: return p->vfb->data + p->offsetV;
388  default: return p->vfb->data + p->offset;}
389 }
390 
392  return (p->refcount == 1 && p->vfb->refcount == 1);}
393 
395 {
396  if (avs_is_writable(p)) {
397  ++p->vfb->sequence_number;
398  return p->vfb->data + p->offset;
399  } else
400  return 0;
401 }
402 
403 AVSC_INLINE unsigned char* avs_get_write_ptr_p(const AVS_VideoFrame * p, int plane)
404 {
405  if (plane==AVS_PLANAR_Y && avs_is_writable(p)) {
406  ++p->vfb->sequence_number;
407  return p->vfb->data + p->offset;
408  } else if (plane==AVS_PLANAR_Y) {
409  return 0;
410  } else {
411  switch (plane) {
412  case AVS_PLANAR_U: return p->vfb->data + p->offsetU;
413  case AVS_PLANAR_V: return p->vfb->data + p->offsetV;
414  default: return p->vfb->data + p->offset;
415  }
416  }
417 }
418 
419 #if defined __cplusplus
420 extern "C"
421 {
422 #endif // __cplusplus
423 AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
424 // makes a shallow copy of a video frame
425 AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
426 #if defined __cplusplus
427 }
428 #endif // __cplusplus
429 
430 #ifndef AVSC_NO_DECLSPEC
432  {avs_release_video_frame(f);}
434  {return avs_copy_video_frame(f);}
435 #endif
436 
437 /////////////////////////////////////////////////////////////////////
438 //
439 // AVS_Value
440 //
441 
442 // Treat AVS_Value as a fat pointer. That is use avs_copy_value
443 // and avs_release_value appropiaty as you would if AVS_Value was
444 // a pointer.
445 
446 // To maintain source code compatibility with future versions of the
447 // avisynth_c API don't use the AVS_Value directly. Use the helper
448 // functions below.
449 
450 // AVS_Value is layed out identicly to AVSValue
451 typedef struct AVS_Value AVS_Value;
452 struct AVS_Value {
453  short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
454  // for some function e'rror
455  short array_size;
456  union {
457  void * clip; // do not use directly, use avs_take_clip
458  char boolean;
459  int integer;
460  INT64 integer64; // match addition of __int64 to avxplugin.h
461  float floating_pt;
462  const char * string;
463  const AVS_Value * array;
464  } d;
465 };
466 
467 // AVS_Value should be initilized with avs_void.
468 // Should also set to avs_void after the value is released
469 // with avs_copy_value. Consider it the equalvent of setting
470 // a pointer to NULL
471 static const AVS_Value avs_void = {'v'};
472 
473 AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
474 AVSC_API(void, avs_release_value)(AVS_Value);
475 
476 AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
477 AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
478 AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
479 AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }
480 AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }
481 AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
482 AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
483 AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
484 
485 #if defined __cplusplus
486 extern "C"
487 {
488 #endif // __cplusplus
489 AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
490 AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
491 #if defined __cplusplus
492 }
493 #endif // __cplusplus
494 
496  { return v.d.boolean; }
498  { return v.d.integer; }
500  { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
502  { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }
504  { return avs_is_error(v) ? v.d.string : 0; }
506  { return v.d.array; }
508  { return avs_is_array(v) ? v.array_size : 1; }
510  { return avs_is_array(v) ? v.d.array[index] : v; }
511 
512 // only use these functions on am AVS_Value that does not already have
513 // an active value. Remember, treat AVS_Value as a fat pointer.
515  { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
517  { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }
519  { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
521  { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
523  { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }
524 #ifndef AVSC_NO_DECLSPEC
526  { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
527 #endif
529  { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
530 
531 /////////////////////////////////////////////////////////////////////
532 //
533 // AVS_Clip
534 //
535 #if defined __cplusplus
536 extern "C"
537 {
538 #endif // __cplusplus
539 AVSC_API(void, avs_release_clip)(AVS_Clip *);
540 AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
541 
542 AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
543 
544 AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
545 
546 AVSC_API(int, avs_get_version)(AVS_Clip *);
547 
548 AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
549 // The returned video frame must be released with avs_release_video_frame
550 
551 AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
552 // return field parity if field_based, else parity of first field in frame
553 
554 AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
556 // start and count are in samples
557 
558 AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
559  int cachehints, size_t frame_range);
560 #if defined __cplusplus
561 }
562 #endif // __cplusplus
563 
564 // This is the callback type used by avs_add_function
565 typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
567 
569 struct AVS_FilterInfo
570 {
571  // these members should not be modified outside of the AVS_ApplyFunc callback
572  AVS_Clip * child;
574  AVS_ScriptEnvironment * env;
575  AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
576  int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
577  int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
579  int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
580  int frame_range);
581  void (AVSC_CC * free_filter)(AVS_FilterInfo *);
582 
583  // Should be set when ever there is an error to report.
584  // It is cleared before any of the above methods are called
585  const char * error;
586  // this is to store whatever and may be modified at will
587  void * user_data;
588 };
589 
590 // Create a new filter
591 // fi is set to point to the AVS_FilterInfo so that you can
592 // modify it once it is initilized.
593 // store_child should generally be set to true. If it is not
594 // set than ALL methods (the function pointers) must be defined
595 // If it is set than you do not need to worry about freeing the child
596 // clip.
597 #if defined __cplusplus
598 extern "C"
599 {
600 #endif // __cplusplus
601 AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
604 #if defined __cplusplus
605 }
606 #endif // __cplusplus
607 
608 
609 /////////////////////////////////////////////////////////////////////
610 //
611 // AVS_ScriptEnvironment
612 //
613 
614 // For GetCPUFlags. These are backwards-compatible with those in VirtualDub.
615 enum {
616  /* slowest CPU to support extension */
617  AVS_CPU_FORCE = 0x01, // N/A
618  AVS_CPU_FPU = 0x02, // 386/486DX
619  AVS_CPU_MMX = 0x04, // P55C, K6, PII
620  AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
621  AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
622  AVS_CPU_SSE2 = 0x20, // PIV, Hammer
623  AVS_CPU_3DNOW = 0x40, // K6-2
624  AVS_CPU_3DNOW_EXT = 0x80, // Athlon
625  AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
626  // which only Hammer will have anyway)
627 };
628 
629 #if defined __cplusplus
630 extern "C"
631 {
632 #endif // __cplusplus
633 AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
634 
635 AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
636 AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
637 
638 AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
639 AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
640 
641 AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val);
642  // note: val is really a va_list; I hope everyone typedefs va_list to a pointer
643 
644 AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
645  const char * name, const char * params,
646  AVS_ApplyFunc apply, void * user_data);
647 
648 AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
649 
650 AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
651  AVS_Value args, const char** arg_names);
652 // The returned value must be be released with avs_release_value
653 
654 AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
655 // The returned value must be be released with avs_release_value
656 
657 AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
658 
659 AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
660 
661 //void avs_push_context(AVS_ScriptEnvironment *, int level=0);
662 //void avs_pop_context(AVS_ScriptEnvironment *);
663 
664 AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
665  const AVS_VideoInfo * vi, int align);
666 // align should be at least 16
667 #if defined __cplusplus
668 }
669 #endif // __cplusplus
670 
671 #ifndef AVSC_NO_DECLSPEC
674  const AVS_VideoInfo * vi)
675  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
676 
679  const AVS_VideoInfo * vi)
680  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
681 #endif
682 
683 #if defined __cplusplus
684 extern "C"
685 {
686 #endif // __cplusplus
687 AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
688 
689 AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, unsigned char* dstp, int dst_pitch, const unsigned char* srcp, int src_pitch, int row_size, int height);
690 
692 AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
693 
695 // The returned video frame must be be released
696 
697 AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
698 
699 AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
700 
701 // avisynth.dll exports this; it's a way to use it as a library, without
702 // writing an AVS script or without going through AVIFile.
703 AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
704 #if defined __cplusplus
705 }
706 #endif // __cplusplus
707 
708 // this symbol is the entry point for the plugin and must
709 // be defined
712 
713 
714 #if defined __cplusplus
715 extern "C"
716 {
717 #endif // __cplusplus
718 AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
719 
720 
722 // The returned video frame must be be released
723 #if defined __cplusplus
724 }
725 #endif // __cplusplus
726 
727 #endif //__AVXSYNTH_C__
int mem
Definition: avxsynth_c.h:697
float v
AVSC_INLINE int avs_is_string(AVS_Value v)
Definition: avxsynth_c.h:481
struct AVS_Value AVS_Value
Definition: avxsynth_c.h:451
volatile long sequence_number
Definition: avisynth_c.h:376
struct AVS_VideoFrameBuffer AVS_VideoFrameBuffer
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:181
AVSC_INLINE int avs_array_size(AVS_Value v)
Definition: avxsynth_c.h:507
AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip *v0)
Definition: avxsynth_c.h:525
AVSC_INLINE int avs_is_array(AVS_Value v)
Definition: avxsynth_c.h:482
short array_size
Definition: avisynth_c.h:506
AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:240
AVS_FilterInfo AVS_Value child
Definition: avxsynth_c.h:602
AVSC_INLINE int avs_is_bool(AVS_Value v)
Definition: avxsynth_c.h:478
AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo *p, INT64 samples)
Definition: avxsynth_c.h:261
AVS_Value void * user_data
Definition: avxsynth_c.h:566
const char * newdir
Definition: avxsynth_c.h:699
AVSC_INLINE int avs_bytes_from_pixels(const AVS_VideoInfo *p, int pixels)
Definition: avxsynth_c.h:231
AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
Definition: avxsynth_c.h:509
AVSC_INLINE int avs_sample_type(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:273
char boolean
Definition: avisynth_c.h:509
AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo *p, INT64 samples)
Definition: avxsynth_c.h:267
#define AVSC_CC
Definition: avxsynth_c.h:50
Sinusoidal phase f
AVSC_INLINE AVS_Value avs_new_value_float(float v0)
Definition: avxsynth_c.h:520
AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo *p, INT64 frames)
Definition: avxsynth_c.h:258
void INT64 start
Definition: avxsynth_c.h:554
const char * string
Definition: avisynth_c.h:512
set threshold d
const char * s
Definition: avxsynth_c.h:638
AVSC_INLINE int avs_is_planar(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:205
AVSC_INLINE int avs_bmp_size(const AVS_VideoInfo *vi)
Definition: avxsynth_c.h:237
AVSC_INLINE void avs_set_property(AVS_VideoInfo *p, int property)
Definition: avxsynth_c.h:277
INT64 integer64
Definition: avxsynth_c.h:460
short type
Definition: avisynth_c.h:504
#define AVSC_INLINE
Definition: avxsynth_c.h:53
__int64 INT64
Definition: avisynth_c.h:72
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:178
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:184
const char AVS_Value const char ** arg_names
Definition: avxsynth_c.h:650
const char const char va_list val
Definition: avxsynth_c.h:641
struct AVS_VideoFrame AVS_VideoFrame
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:175
const AVS_Value * array
Definition: avisynth_c.h:513
const char * name
Definition: avxsynth_c.h:645
AVSC_INLINE AVS_Value avs_new_value_string(const char *v0)
Definition: avxsynth_c.h:518
volatile long refcount
Definition: avisynth_c.h:386
volatile long refcount
Definition: avisynth_c.h:378
AVS_VideoFrame int int int int new_height
Definition: avxsynth_c.h:694
int n
Definition: avxsynth_c.h:548
AVSC_INLINE void avs_set_fps(AVS_VideoInfo *p, unsigned numerator, unsigned denominator)
Definition: avxsynth_c.h:286
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:339
unsigned char * dstp
Definition: avxsynth_c.h:689
AVSC_INLINE AVS_Value avs_new_value_int(int v0)
Definition: avxsynth_c.h:516
#define AVSC_API(ret, name)
Definition: avxsynth_c.h:61
Discrete Time axis x
struct AVS_VideoInfo AVS_VideoInfo
INT64 num_audio_samples
Definition: avisynth_c.h:210
AVSC_INLINE const unsigned char * avs_get_read_ptr(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:380
const char * r
Definition: vf_curves.c:94
AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:344
const AVS_VideoInfo int align
Definition: avxsynth_c.h:665
struct AVS_Clip AVS_Clip
Definition: avisynth_c.h:192
AVSC_INLINE int avs_is_property(const AVS_VideoInfo *p, int property)
Definition: avxsynth_c.h:202
AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:211
AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo *p, int c_space)
Definition: avxsynth_c.h:199
static const uint8_t offset[127][2]
Definition: vf_spp.c:70
void * buf
Definition: avxsynth_c.h:554
AVS_VideoFrame int int int int int rel_offsetU
Definition: avxsynth_c.h:721
union AVS_Value::@12 d
AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:336
unsigned fps_numerator
Definition: avisynth_c.h:203
int size
AVS_VideoFrame ** pvf
Definition: avxsynth_c.h:687
int64_t __int64
AVSC_INLINE int avs_as_int(AVS_Value v)
Definition: avxsynth_c.h:497
AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:270
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:244
AVSC_INLINE int avs_get_height(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:369
AVSC_INLINE unsigned char * avs_get_write_ptr_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:403
AVSC_INLINE int avs_is_int(AVS_Value v)
Definition: avxsynth_c.h:479
AVS_ScriptEnvironment AVS_Clip *AVSC_INLINE int avs_as_bool(AVS_Value v)
Definition: avxsynth_c.h:495
t
Definition: genspecsines3.m:6
AVS_VideoFrame int int int new_row_size
Definition: avxsynth_c.h:694
AVS_FilterInfo ** fi
Definition: avxsynth_c.h:602
if it could not because there are no more frames
AVSC_INLINE void avs_release_frame(AVS_VideoFrame *f)
Definition: avxsynth_c.h:431
AVSC_INLINE int avs_is_float(AVS_Value v)
Definition: avxsynth_c.h:480
const AVS_VideoInfo * vi
Definition: avxsynth_c.h:665
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:220
AVS_VideoFrame int int new_pitch
Definition: avxsynth_c.h:694
const char const char * params
Definition: avxsynth_c.h:645
AVSC_EXPORT const char *AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment *env)
const char * fmt
Definition: avxsynth_c.h:639
dest
Definition: start.py:60
AVSC_INLINE const unsigned char * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:383
typedef void(RENAME(mix_any_func_type))
AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:196
AVSC_INLINE const char * avs_as_error(AVS_Value v)
Definition: avxsynth_c.h:503
AVSC_INLINE int avs_defined(AVS_Value v)
Definition: avxsynth_c.h:476
int index
Definition: gxfenc.c:89
AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
Definition: avxsynth_c.h:514
AVSC_INLINE int avs_is_clip(AVS_Value v)
Definition: avxsynth_c.h:477
AVS_VideoFrame int int int int int int int new_pitchUV
Definition: avxsynth_c.h:721
unsigned char int const unsigned char * srcp
Definition: avxsynth_c.h:689
int size_t frame_range
Definition: avxsynth_c.h:559
AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:193
AVS_VideoFrameBuffer * vfb
Definition: avisynth_c.h:387
#define type
void INT64 INT64 count
Definition: avxsynth_c.h:554
const char int length
Definition: avxsynth_c.h:638
AVS_Value args
Definition: avxsynth_c.h:566
const char const char AVS_ApplyFunc apply
Definition: avxsynth_c.h:645
AVS_FilterInfo AVS_Value int store_child
Definition: avxsynth_c.h:602
AVSC_INLINE int avs_is_bff(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:214
#define v0
Definition: regdef.h:26
struct AVS_ScriptEnvironment AVS_ScriptEnvironment
Definition: avisynth_c.h:193
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
Definition: vf_lut.c:139
float floating_pt
Definition: avisynth_c.h:511
AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment *env, const AVS_VideoInfo *vi)
Definition: avxsynth_c.h:673
AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo *x, AVS_VideoInfo *y)
Definition: avxsynth_c.h:296
AVSC_INLINE double avs_as_float(AVS_Value v)
Definition: avxsynth_c.h:501
int cachehints
Definition: avxsynth_c.h:559
AVSC_INLINE const char * avs_as_string(AVS_Value v)
Definition: avxsynth_c.h:499
int integer
Definition: avisynth_c.h:510
function y
Definition: D.m:1
AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:208
AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:255
AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:187
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:372
AVS_Value src
Definition: avxsynth_c.h:473
AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value *v0, int size)
Definition: avxsynth_c.h:528
AVS_VideoFrame int int int int int int rel_offsetV
Definition: avxsynth_c.h:721
AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame *f)
Definition: avxsynth_c.h:433
AVSC_INLINE AVS_Value avs_new_value_error(const char *v0)
Definition: avxsynth_c.h:522
AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
Definition: avxsynth_c.h:505
AVSC_INLINE int avs_row_size(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:234
AVSC_INLINE int avs_is_error(AVS_Value v)
Definition: avxsynth_c.h:483
unsigned fps_denominator
Definition: avisynth_c.h:203
AVSC_INLINE int avs_is_tff(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:217
AVSC_INLINE void avs_set_field_based(AVS_VideoInfo *p, int isfieldbased)
Definition: avxsynth_c.h:283
static const AVS_Value avs_void
Definition: avxsynth_c.h:471
unsigned char * data
Definition: avxsynth_c.h:316
AVS_VideoFrame int rel_offset
Definition: avxsynth_c.h:694
int version
Definition: avxsynth_c.h:636
Filter the word “frame” indicates either a video frame or a group of audio samples
int integer
AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo *p, INT64 bytes)
Definition: avxsynth_c.h:264
#define AVSC_EXPORT
Definition: avxsynth_c.h:59
unsigned char int const unsigned char int src_pitch
Definition: avxsynth_c.h:689
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:347
AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:190
void(AVSC_CC * AVS_ShutdownFunc)(void *user_data, AVS_ScriptEnvironment *env)
Definition: avxsynth_c.h:691
static int get_parity(uint8_t value)
Get parity bit of bit 2..7.
AVSC_INLINE void avs_clear_property(AVS_VideoInfo *p, int property)
Definition: avxsynth_c.h:280
unsigned char int const unsigned char int int row_size
Definition: avxsynth_c.h:689
AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment *env, const AVS_VideoInfo *vi)
Definition: avxsynth_c.h:678
AVSC_INLINE unsigned char * avs_get_write_ptr(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:394
unsigned char int dst_pitch
Definition: avxsynth_c.h:689
#define AVS_FRAME_ALIGN
Definition: avxsynth_c.h:146
__int64 INT64
Definition: avxsynth_c.h:70
AVSC_INLINE int avs_is_writable(const AVS_VideoFrame *p)
Definition: avxsynth_c.h:391
int audio_samples_per_second
Definition: avisynth_c.h:208