⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avisynth.h

📁 avisynth-source-0.3.zip,avi edit src
💻 H
字号:
// Avisynth v0.3.  Copyright 2000 Ben Rudiak-Gould.  For distribution
// conditions, please see http://www.math.berkeley.edu/~benrg/avisynth.html .


#ifndef __AVISYNTH_H__
#define __AVISYNTH_H__

// doesn't belong here, but it's useful
template<typename T> static inline
void swap(T& a, T& b) { T t = a; a = b; b = t; }


#pragma pack(push,8)

struct VideoInfo {
  int width, height;    // width=0 means no video
  int fps_numerator, fps_denominator;
  int num_frames;
  enum { UNKNOWN=0, YUY2=2, BGR24=3 } pixel_type;

  int audio_samples_per_second;   // 0 means no audio
  int num_audio_samples;
  bool stereo, sixteen_bit;

  bool field_based;

  // useful functions of the above
  bool HasVideo() const { return !!width; }
  bool HasAudio() const { return !!audio_samples_per_second; }
  bool IsYUY2() const { return pixel_type == YUY2; }
  bool IsRGB() const { return pixel_type == BGR24; }
  int ImageSize() const { return width * height * pixel_type; }
  int RowSize() const { return width * pixel_type; }
  int BitsPerPixel() const { return pixel_type * 8; }
  unsigned AudioSamplesFromFrames(int frames) const { return int(__int64(frames) * audio_samples_per_second * __int64(fps_denominator) / fps_numerator); }
  int FramesFromAudioSamples(unsigned samples) const { return int(__int64(samples) * fps_numerator / fps_denominator / audio_samples_per_second); }
  int AudioSamplesFromBytes(int bytes) const { return bytes >> (stereo + sixteen_bit); }
  int BytesFromAudioSamples(int samples) const { return samples << (stereo + sixteen_bit); }
  int BytesPerAudioSample() const { return BytesFromAudioSamples(1); }
};


// bare filter interface
class VideoFilter {
public:
  virtual void GetFrame(int n, unsigned char* buf) = 0;
  virtual void GetAudio(void* buf, int start, int count) = 0;  // start is in *samples*, count is in *bytes*
  virtual void GetVideoInfo(VideoInfo* pvi) throw() = 0;
  virtual bool GetParity(int n) throw() = 0;  // return field parity if field_based, else parity of first field in frame
  virtual ~VideoFilter() throw() {}
};


// exception class
struct FilterChainError {
  const char* const msg;
  FilterChainError(const char* s) : msg(s) {}
};


// maintains refcount
class VideoFilterWithRefcount : public VideoFilter {
  int refcnt;
public:
  VideoFilterWithRefcount() : refcnt(1) {}
  VideoFilter* AddRef() throw() { ++refcnt; return this; }
  void Release() throw() { if (!--refcnt) { delete this; } }
};


// smart pointer to VideoFilterWithRefcount
class PVideoFilter {
  VideoFilterWithRefcount* p;
public:
  PVideoFilter() throw() { p = 0; }

  PVideoFilter(const PVideoFilter& x) throw() {
    p = x.p;
    if (p) p->AddRef();
  }
  void operator=(const PVideoFilter& x) throw() {
    if (x.p) x.p->AddRef();
    if (p) p->Release();
    p = x.p;
  }

  // The conversions from plain pointers are intended for assigning the
  // result of a 'new', and hence do not increment the refcount.
  PVideoFilter(VideoFilterWithRefcount* x) throw() { p=x; }
  void operator=(VideoFilterWithRefcount* x) throw() {
    if (p) p->Release();
    p = x;
  }

  VideoFilter* operator->() const throw() { return p; }

  // for conditional expressions
  operator void*() const throw() { return p; }
  bool operator!() const throw() { return !p; }

  ~PVideoFilter() throw() { if (p) p->Release(); }
};


// instantiable null filter
class GenericVideoFilter : public VideoFilterWithRefcount {
protected:
  const PVideoFilter child;
  VideoInfo vi;
public:
  GenericVideoFilter(PVideoFilter _child) : child(_child) { child->GetVideoInfo(&vi); }
  void GetFrame(int n, unsigned char* buf) { child->GetFrame(n, buf); }
  void GetAudio(void* buf, int start, int count) { child->GetAudio(buf, start, count); }
  void GetVideoInfo(VideoInfo* pvi) { *pvi = vi; }
  bool GetParity(int n) { return child->GetParity(n); }
};


struct Arg {
  // because 'clip' has a constructor and destructor, it must be stored separately
  PVideoFilter clip;   // 'c'
  union {
    const char* string;   // 's'
    int integer;   // 'i'
    float floating_pt;   // 'f'
  };
};


struct FilterInfo {
  const char* name;
  const char* param_types;
  PVideoFilter (__cdecl *pFilterFactoryFunction)(const FilterInfo* self, const Arg* args, const char* arg_types);
  void* user_data;
  void* reserved[4];
};


struct PluginCallbacks {
  int size;
  FilterInfo* (__cdecl *FindFilter)(const char* name, const char* arg_types);
};


// DLL exports
const char* SearchForFilterName(const char* search_name);
FilterInfo* __cdecl SearchForMatchingFilter(const char* search_name, const char* arg_types);
void __cdecl LoadPlugin(const char* filename);

#pragma pack(pop)

#endif //__AVISYNTH_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -