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

📄 avisynth.h

📁 从FFMPEG转换而来的H264解码程序,VC下编译..
💻 H
📖 第 1 页 / 共 3 页
字号:
// Avisynth v2.6.  Copyright 2002, 2005 Ben Rudiak-Gould et al.// http://www.avisynth.org// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit// http://www.gnu.org/copyleft/gpl.html .//// Linking Avisynth statically or dynamically with other modules is making a// combined work based on Avisynth.  Thus, the terms and conditions of the GNU// General Public License cover the whole combination.//// As a special exception, the copyright holders of Avisynth give you// permission to link Avisynth with independent modules that communicate with// Avisynth solely through the interfaces defined in avisynth.h, regardless of// the license terms of these independent modules, and to copy and distribute// the resulting combined work under terms of your choice, provided that// every copy of the combined work is accompanied by a complete copy of// the source code of Avisynth (the version of Avisynth used to produce the// combined work), being distributed under the terms of the GNU General// Public License plus this exception.  An independent module is a module// which is not derived from or based on Avisynth, such as 3rd-party filters,// import and export plugins, or graphical user interfaces.#ifndef __AVISYNTH_H__#define __AVISYNTH_H__#pragma warning(disable:4390)enum { AVISYNTH_INTERFACE_VERSION = 2 };/* Define all types necessary for interfacing with avisynth.dll   Moved from internal.h */// Win32 API macros, notably the types BYTE, DWORD, ULONG, etc.#include <windef.h>// COM interface macros#include <objbase.h>// Raster types used by VirtualDub & Avisynth#define in64 (__int64)(unsigned short)typedef unsigned long	Pixel;    // this will break on 64-bit machines!typedef unsigned long	Pixel32;typedef unsigned char	Pixel8;typedef long			PixCoord;typedef long			PixDim;typedef long			PixOffset;/* Compiler-specific crap */// Tell MSVC to stop precompiling here#ifdef _MSC_VER  #pragma hdrstop#endif// Set up debugging macros for MS compilers; for others, step down to the// standard <assert.h> interface#ifdef _MSC_VER  #include <crtdbg.h>#else  #define _RPT0(a,b) ((void)0)  #define _RPT1(a,b,c) ((void)0)  #define _RPT2(a,b,c,d) ((void)0)  #define _RPT3(a,b,c,d,e) ((void)0)  #define _RPT4(a,b,c,d,e,f) ((void)0)  #define _ASSERTE(x) assert(x)  #define _ASSERT(x) assert(x)  #include <assert.h>#endif// I had problems with Premiere wanting 1-byte alignment for its structures,// so I now set the Avisynth struct alignment explicitly here.#pragma pack(push,8)#define FRAME_ALIGN 16// Default frame alignment is 16 bytes, to help P4, when using SSE2// The VideoInfo struct holds global information about a clip (i.e.// information that does not depend on the frame number).  The GetVideoInfo// method in IClip returns this struct.// Audio Sample informationtypedef float SFLOAT;enum {SAMPLE_INT8  = 1<<0,      SAMPLE_INT16 = 1<<1,      SAMPLE_INT24 = 1<<2,    // Int24 is a very stupid thing to code, but it's supported by some hardware.      SAMPLE_INT32 = 1<<3,      SAMPLE_FLOAT = 1<<4};enum {   PLANAR_Y=1<<0,   PLANAR_U=1<<1,   PLANAR_V=1<<2,   PLANAR_ALIGNED=1<<3,   PLANAR_Y_ALIGNED=PLANAR_Y|PLANAR_ALIGNED,   PLANAR_U_ALIGNED=PLANAR_U|PLANAR_ALIGNED,   PLANAR_V_ALIGNED=PLANAR_V|PLANAR_ALIGNED,  };class AvisynthError /* exception */ {public:  const char* const msg;  AvisynthError(const char* _msg) : msg(_msg) {}};struct VideoInfo {  int width, height;    // width=0 means no video  unsigned fps_numerator, fps_denominator;  int num_frames;  // This is more extensible than previous versions. More properties can be added seeminglesly.  // Colorspace properties.  enum {    CS_BGR = 1<<28,    CS_YUV = 1<<29,    CS_INTERLEAVED = 1<<30,    CS_PLANAR = 1<<31 // Probably should move and reserve this bit for 2.5 compatibility  };  // Specific colorformats  enum { CS_UNKNOWN = 0,         CS_BGR24 = 1<<0 | CS_BGR | CS_INTERLEAVED,         CS_BGR32 = 1<<1 | CS_BGR | CS_INTERLEAVED,         CS_YUY2  = 1<<2 | CS_YUV | CS_INTERLEAVED,         CS_YV12  = 1<<3 | CS_YUV | CS_PLANAR,  // y-v-u, 4:2:0 planar         CS_I420  = 1<<4 | CS_YUV | CS_PLANAR,  // y-u-v, 4:2:0 planar         CS_IYUV  = 1<<4 | CS_YUV | CS_PLANAR,  // same as above// New as of 2.6:         CS_YV24  = 1<<6 | CS_YUV | CS_PLANAR,  // YUV 4:4:4 planar         CS_YV16  = 1<<7 | CS_YUV | CS_PLANAR,  // YUV 4:2:2 planar         CS_Y8    = 1<<8 | CS_YUV | CS_PLANAR,  // Y   4:0:0 planar         CS_YV411 = 1<<9 | CS_YUV | CS_PLANAR,  // YUV 4:1:1 planar//       CS_YUV9  = 1<<10| CS_YUV | CS_PLANAR,  // YUV 4:1:0 planar ::FIXME::  };  int pixel_type;                // changed to int as of 2.5  int audio_samples_per_second;   // 0 means no audio  int sample_type;                // as of 2.5  __int64 num_audio_samples;      // changed as of 2.5  int nchannels;                  // as of 2.5  // Imagetype properties  int image_type;  enum {    IT_BFF = 1<<0,    IT_TFF = 1<<1,    IT_FIELDBASED = 1<<2  };  // Chroma placement bits 20 -> 23  ::FIXME:: Really want a Class to support this  enum {    CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,    CS_MPEG1_CHROMA_PLACEMENT   = 1 << 20,    CS_MPEG2_CHROMA_PLACEMENT   = 2 << 20,    CS_YUY2_CHROMA_PLACEMENT    = 3 << 20,    CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20  };  // useful functions of the above  bool HasVideo() const { return (width!=0); }  bool HasAudio() const { return (audio_samples_per_second!=0); }  bool IsRGB() const { return !!(pixel_type&CS_BGR); }  bool IsRGB24() const { return (pixel_type&CS_BGR24)==CS_BGR24; } // Clear out additional properties  bool IsRGB32() const { return (pixel_type & CS_BGR32) == CS_BGR32 ; }  bool IsYUV() const { return !!(pixel_type&CS_YUV ); }  bool IsYUY2() const { return (pixel_type & CS_YUY2) == CS_YUY2; }  bool IsYV12() const { return ((pixel_type & CS_YV12) == CS_YV12)||((pixel_type & CS_I420) == CS_I420); }  bool IsYV24() const { return (pixel_type & CS_YV24) == CS_YV24; }  bool IsYV16() const { return (pixel_type & CS_YV16) == CS_YV16; }  bool IsY8() const { return (pixel_type & CS_Y8) == CS_Y8; }  bool IsYV411() const { return (pixel_type & CS_YV411) == CS_YV411; }  bool IsColorSpace(int c_space) const { return ((pixel_type & c_space) == c_space); }  bool Is(int property) const { return ((pixel_type & property)==property ); }  bool IsPlanar() const { return !!(pixel_type & CS_PLANAR); }  bool IsFieldBased() const { return !!(image_type & IT_FIELDBASED); }  bool IsParityKnown() const { return ((image_type & IT_FIELDBASED)&&(image_type & (IT_BFF|IT_TFF))); }  bool IsBFF() const { return !!(image_type & IT_BFF); }  bool IsTFF() const { return !!(image_type & IT_TFF); }  bool IsVPlaneFirst() const {return IsYV16()|| IsYV24() || IsYV411() || ((pixel_type & CS_YV12) == CS_YV12); }  // Don't use this  int BytesFromPixels(int pixels) const { return IsPlanar() ? pixels : pixels * (BitsPerPixel()>>3); }   // Will not work on planar images, but will return only luma planes  __int64 AudioSamplesFromFrames(__int64 frames) const { return (fps_numerator && HasVideo()) ? ((__int64)(frames) * audio_samples_per_second * fps_denominator / fps_numerator) : 0; }  int FramesFromAudioSamples(__int64 samples) const { return (fps_denominator && HasAudio()) ? (int)((samples * (__int64)fps_numerator)/((__int64)fps_denominator * (__int64)audio_samples_per_second)) : 0; }  __int64 AudioSamplesFromBytes(__int64 bytes) const { return HasAudio() ? bytes / BytesPerAudioSample() : 0; }  __int64 BytesFromAudioSamples(__int64 samples) const { return samples * BytesPerAudioSample(); }  int AudioChannels() const { return nchannels; }  int SampleType() const{ return sample_type;}  bool IsSampleType(int testtype) const{ return !!(sample_type&testtype);}  int SamplesPerSecond() const { return audio_samples_per_second; }  int BytesPerAudioSample() const { return nchannels*BytesPerChannelSample();}  void SetFieldBased(bool isfieldbased)  { if (isfieldbased) image_type|=IT_FIELDBASED; else  image_type&=~IT_FIELDBASED; }  void Set(int property)  { image_type|=property; }  void Clear(int property)  { image_type&=~property; }  int GetPlaneWidthSubsampling(int plane = 0) const {  // Subsampling in bitshifts!    if (!plane || plane == PLANAR_Y)  // No subsampling      return 0;    if (IsYV24())      return 0;    if (IsYV12() || IsYV16() || IsYUY2())      return 1;    if (IsYV411())      return 2;    if (IsY8())      ;//throw AvisynthError("Filter error: GetPlaneWidthSubsampling not available on Y8 pixel type.");    //throw AvisynthError("Filter error: GetPlaneWidthSubsampling called with unknown pixel type.");    return 0;  }  int GetPlaneHeightSubsampling(int plane = 0) const {  // Subsampling in bitshifts!    if (!plane || plane == PLANAR_Y)  // No subsampling      return 0;    if (IsYV12())      return 1;    if (IsYV24() || IsYV16() || IsYUY2() || IsYV411())      return 0;    if (IsY8())      ;//throw AvisynthError("Filter error: GetPlaneHeightSubsampling not available on Y8 pixel type.");    //throw AvisynthError("Filter error: GetPlaneHeightSubsampling called with unknown pixel type.");    return 0;  }  int RowSize(int plane = 0) const {    if (!plane ||  plane == PLANAR_Y) {      return BytesFromPixels(width);    }    if (IsY8()) {      return 0;    }    if (IsPlanar()) {      return BytesFromPixels(width)>>GetPlaneWidthSubsampling(plane);    }    return BytesFromPixels(width);  }  int BMPSize() const {    if (IsY8())      return height * ((RowSize()+3) & ~3);    if (IsPlanar()) {      // Y plane      int Ybytes = height * ((RowSize()+3) & ~3);      if (IsYV12()) {        int UVbytes = Ybytes/2;  // Legacy alignment        return Ybytes+UVbytes;      }      int UVbytes = (((RowSize()>>GetPlaneWidthSubsampling(PLANAR_U))+3) & ~3);      UVbytes *= (height>>GetPlaneHeightSubsampling(PLANAR_V)) * 2;      return Ybytes+UVbytes;    }    return height * ((RowSize()+3) & ~3);  }  int BitsPerPixel() const {    switch (pixel_type) {      case CS_BGR24:      case CS_YV24:        return 24;      case CS_BGR32:        return 32;      case CS_YUY2:      case CS_YV16:        return 16;      case CS_YV12:      case CS_I420:      case CS_YV411:        return 12;//    case CS_YUV9:

⌨️ 快捷键说明

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