home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / plugin / vdinputdriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  8.5 KB  |  276 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Plugin headers
  3. //    Copyright (C) 1998-2007 Avery Lee, All Rights Reserved.
  4. //
  5. //    The plugin headers in the VirtualDub plugin SDK are licensed differently
  6. //    differently than VirtualDub and the Plugin SDK themselves.  This
  7. //    particular file is thus licensed as follows (the "zlib" license):
  8. //
  9. //    This software is provided 'as-is', without any express or implied
  10. //    warranty.  In no event will the authors be held liable for any
  11. //    damages arising from the use of this software.
  12. //
  13. //    Permission is granted to anyone to use this software for any purpose,
  14. //    including commercial applications, and to alter it and redistribute it
  15. //    freely, subject to the following restrictions:
  16. //
  17. //    1.    The origin of this software must not be misrepresented; you must
  18. //        not claim that you wrote the original software. If you use this
  19. //        software in a product, an acknowledgment in the product
  20. //        documentation would be appreciated but is not required.
  21. //    2.    Altered source versions must be plainly marked as such, and must
  22. //        not be misrepresented as being the original software.
  23. //    3.    This notice may not be removed or altered from any source
  24. //        distribution.
  25.  
  26. #ifndef f_VD2_PLUGIN_VDINPUTDRIVER_H
  27. #define f_VD2_PLUGIN_VDINPUTDRIVER_H
  28.  
  29. #include "vdplugin.h"
  30.  
  31. /// Unsigned 32-bit fraction.
  32. struct VDXFraction {
  33.     uint32 mNumerator;
  34.     uint32 mDenominator;
  35. };
  36.  
  37. typedef struct VDXHWNDStruct *VDXHWND;
  38. typedef struct VDXBITMAPINFOHEADERStruct {
  39.     enum { kCompressionRGB = 0 };
  40.     uint32            mSize;
  41.     sint32            mWidth;
  42.     sint32            mHeight;
  43.     uint16            mPlanes;
  44.     uint16            mBitCount;
  45.     uint32            mCompression;
  46.     uint32            mSizeImage;
  47.     sint32            mXPelsPerMeter;
  48.     sint32            mYPelsPerMeter;
  49.     uint32            mClrUsed;
  50.     uint32            mClrImportant;
  51. } VDXBITMAPINFOHEADER;
  52.  
  53. typedef struct VDXWAVEFORMATEXStruct {
  54.     enum { kFormatPCM = 1 };
  55.     uint16            mFormatTag;
  56.     uint16            mChannels;
  57.     uint32            mSamplesPerSec;
  58.     uint32            mAvgBytesPerSec;
  59.     uint16            mBlockAlign;
  60.     uint16            mBitsPerSample;
  61.     uint16            mExtraSize;
  62. } VDXWAVEFORMATEX;
  63.  
  64. struct VDXStreamSourceInfo {
  65.     VDXFraction        mSampleRate;
  66.     sint64            mSampleCount;
  67.     VDXFraction        mPixelAspectRatio;
  68. };
  69.  
  70. // V3+ (1.7.X) only
  71. struct VDXStreamSourceInfoV3 {
  72.     VDXStreamSourceInfo    mInfo;
  73.  
  74.     enum {
  75.         kFlagVariableSizeSamples    = 0x00000001
  76.     };
  77.  
  78.     uint32            mFlags;
  79.     uint32            mfccHandler;    ///< If non-zero, specifies the FOURCC of a codec handler that should be preferred.
  80. };
  81.  
  82. class IVDXStreamSource : public IVDXUnknown {
  83. public:
  84.     enum { kIID = VDXMAKEFOURCC('X', 's', 't', 's') };
  85.  
  86.     virtual void                VDXAPIENTRY GetStreamSourceInfo(VDXStreamSourceInfo&) = 0;
  87.  
  88.     virtual bool                VDXAPIENTRY Read(sint64 lStart, uint32 lCount, void *lpBuffer, uint32 cbBuffer, uint32 *lBytesRead, uint32 *lSamplesRead) = 0;
  89.  
  90.     virtual const void *        VDXAPIENTRY GetDirectFormat() = 0;
  91.     virtual int                    VDXAPIENTRY GetDirectFormatLen() = 0;
  92.  
  93.     enum ErrorMode {
  94.         kErrorModeReportAll = 0,
  95.         kErrorModeConceal,
  96.         kErrorModeDecodeAnyway,
  97.         kErrorModeCount
  98.     };
  99.  
  100.     virtual ErrorMode            VDXAPIENTRY GetDecodeErrorMode() = 0;
  101.     virtual void                VDXAPIENTRY SetDecodeErrorMode(ErrorMode mode) = 0;
  102.     virtual bool                VDXAPIENTRY IsDecodeErrorModeSupported(ErrorMode mode) = 0;
  103.  
  104.     virtual bool                VDXAPIENTRY IsVBR() = 0;
  105.     virtual sint64                VDXAPIENTRY TimeToPositionVBR(sint64 us) = 0;
  106.     virtual sint64                VDXAPIENTRY PositionToTimeVBR(sint64 samples) = 0;
  107. };
  108.  
  109. // V3+ (1.7.X)
  110. class IVDXStreamSourceV3 : public IVDXUnknown {
  111. public:
  112.     enum { kIID = VDXMAKEFOURCC('X', 's', 't', '2') };
  113.  
  114.     virtual void                VDXAPIENTRY GetStreamSourceInfoV3(VDXStreamSourceInfoV3&) = 0;
  115. };
  116.  
  117. class IVDXVideoDecoderModel : public IVDXUnknown {
  118. public:
  119.     enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'm') };
  120.  
  121.     virtual void                VDXAPIENTRY Reset() = 0;
  122.     virtual void                VDXAPIENTRY SetDesiredFrame(sint64 frame_num) = 0;
  123.     virtual sint64                VDXAPIENTRY GetNextRequiredSample(bool& is_preroll) = 0;
  124.     virtual int                    VDXAPIENTRY GetRequiredCount() = 0;
  125. };
  126.  
  127. class IVDXVideoDecoder : public IVDXUnknown {
  128. public:
  129.     enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'e') };
  130.  
  131.     virtual const void *        VDXAPIENTRY DecodeFrame(const void *inputBuffer, uint32 data_len, bool is_preroll, sint64 sampleNumber, sint64 targetFrame) = 0;
  132.     virtual uint32                VDXAPIENTRY GetDecodePadding() = 0;
  133.     virtual void                VDXAPIENTRY Reset() = 0;
  134.     virtual    bool                VDXAPIENTRY IsFrameBufferValid() = 0;
  135.     virtual const VDXPixmap&    VDXAPIENTRY GetFrameBuffer() = 0;
  136.     virtual bool                VDXAPIENTRY SetTargetFormat(int format, bool useDIBAlignment) = 0;
  137.     virtual bool                VDXAPIENTRY SetDecompressedFormat(const VDXBITMAPINFOHEADER *pbih) = 0;
  138.  
  139.     virtual bool                VDXAPIENTRY IsDecodable(sint64 sample_num) = 0;
  140.     virtual const void *        VDXAPIENTRY GetFrameBufferBase() = 0;
  141. };
  142.  
  143. enum VDXVideoFrameType {
  144.     kVDXVFT_Independent,
  145.     kVDXVFT_Predicted,
  146.     kVDXVFT_Bidirectional,
  147.     kVDXVFT_Null,
  148. };
  149.  
  150. struct VDXVideoFrameInfo {
  151.     char    mTypeChar;
  152.     uint8    mFrameType;
  153.     sint64    mBytePosition;
  154. };
  155.  
  156. struct VDXVideoSourceInfo {
  157.     enum DecoderModel {
  158.         kDecoderModelCustom,    ///< A custom decoder model is provided.
  159.         kDecoderModelDefaultIP    ///< Use the default I/P decoder model.
  160.     };
  161.  
  162.     enum Flags {
  163.         kFlagNone            = 0,
  164.         kFlagKeyframeOnly    = 0x00000001,
  165.         kFlagAll            = 0xFFFFFFFF
  166.     };
  167.  
  168. public:
  169.     uint32    mFlags;
  170.     uint32    mWidth;
  171.     uint32    mHeight;
  172.     uint8    mDecoderModel;
  173.     uint8    unused[3];
  174. };
  175.  
  176. class IVDXVideoSource : public IVDXUnknown {
  177. public:
  178.     enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 's') };
  179.  
  180.     virtual void    VDXAPIENTRY GetVideoSourceInfo(VDXVideoSourceInfo& info) = 0;
  181.  
  182.     virtual bool    VDXAPIENTRY CreateVideoDecoderModel(IVDXVideoDecoderModel **) = 0;
  183.     virtual bool    VDXAPIENTRY CreateVideoDecoder(IVDXVideoDecoder **) = 0;
  184.  
  185.     virtual void    VDXAPIENTRY GetSampleInfo(sint64 sample_num, VDXVideoFrameInfo& frameInfo) = 0;
  186.  
  187.     virtual bool    VDXAPIENTRY IsKey(sint64 sample_num) = 0;
  188.  
  189.     virtual sint64    VDXAPIENTRY GetFrameNumberForSample(sint64 sample_num) = 0;
  190.     virtual sint64    VDXAPIENTRY GetSampleNumberForFrame(sint64 frame_num) = 0;
  191.     virtual sint64    VDXAPIENTRY GetRealFrame(sint64 frame_num) = 0;
  192.  
  193.     virtual sint64    VDXAPIENTRY GetSampleBytePosition(sint64 sample_num) = 0;
  194. };
  195.  
  196. struct VDXAudioSourceInfo {
  197. public:
  198.     uint32    mFlags;
  199. };
  200.  
  201. class IVDXAudioSource : public IVDXUnknown {
  202. public:
  203.     enum { kIID = VDXMAKEFOURCC('X', 'a', 'd', 's') };
  204.  
  205.     virtual void VDXAPIENTRY GetAudioSourceInfo(VDXAudioSourceInfo& info) = 0;
  206. };
  207.  
  208. class IVDXInputOptions : public IVDXUnknown {
  209. public:
  210.     enum { kIID = VDXMAKEFOURCC('X', 'i', 'o', 'p') };
  211.  
  212.     virtual uint32        VDXAPIENTRY Write(void *buf, uint32 buflen) = 0;
  213. };
  214.  
  215. class IVDXInputFile : public IVDXUnknown {
  216. public:
  217.     enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'l') };
  218.  
  219.     virtual bool    VDXAPIENTRY PromptForOptions(VDXHWND, IVDXInputOptions **ppOptions) = 0;
  220.     virtual bool    VDXAPIENTRY CreateOptions(const void *buf, uint32 len, IVDXInputOptions **ppOptions) = 0;
  221.  
  222.     virtual void    VDXAPIENTRY Init(const wchar_t *path, IVDXInputOptions *options) = 0;
  223.     virtual bool    VDXAPIENTRY Append(const wchar_t *path) = 0;
  224.  
  225.     virtual void    VDXAPIENTRY DisplayInfo(VDXHWND hwndParent) = 0;
  226.  
  227.     virtual bool    VDXAPIENTRY GetVideoSource(int index, IVDXVideoSource **ppVS) = 0;
  228.     virtual bool    VDXAPIENTRY GetAudioSource(int index, IVDXAudioSource **ppAS) = 0;
  229. };
  230.  
  231. ///////////////////////////////////////////////////////////////////////////////
  232. // IVDXInputFileDriver
  233. //
  234. class IVDXInputFileDriver : public IVDXUnknown {
  235. public:
  236.     enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'd') };
  237.  
  238.     virtual int        VDXAPIENTRY DetectBySignature(const void *pHeader, sint32 nHeaderSize, const void *pFooter, sint32 nFooterSize, sint64 nFileSize) = 0;
  239.     virtual bool    VDXAPIENTRY CreateInputFile(uint32 flags, IVDXInputFile **ppFile) = 0;
  240. };
  241.  
  242. struct VDXInputDriverContext {
  243.     uint32    mAPIVersion;
  244.     IVDPluginCallbacks *mpCallbacks;
  245. };
  246.  
  247. typedef bool (VDXAPIENTRY *VDXInputDriverCreateProc)(const VDXInputDriverContext *pContext, IVDXInputFileDriver **);
  248.  
  249. struct VDXInputDriverDefinition {
  250.     enum {
  251.         kFlagNone                = 0x00000000,
  252.         kFlagSupportsVideo        = 0x00000001,
  253.         kFlagSupportsAudio        = 0x00000002,
  254.         kFlagCustomSignature    = 0x00010000,
  255.         kFlagAll                = 0xFFFFFFFF
  256.     };
  257.     uint32        mSize;                // size of this structure in bytes
  258.     uint32        mFlags;
  259.     sint32        mPriority;
  260.     uint32        mSignatureLength;
  261.     const void *mpSignature;
  262.     const wchar_t *mpFilenameDetectPattern;
  263.     const wchar_t *mpFilenamePattern;
  264.     const wchar_t *mpDriverTagName;
  265.  
  266.     VDXInputDriverCreateProc        mpCreate;
  267. };
  268.  
  269. enum {
  270.     // V1 (1.7.4.28204): Initial version
  271.     // V2 (1.7.5): Default I/P frame model fixed.
  272.     kVDXPlugin_InputDriverAPIVersion = 2
  273. };
  274.  
  275. #endif
  276.