Support unrar64.dll
[xy_vsfilter.git] / include / vd2 / plugin / vdinputdriver.h
blobb75738c98af35e030e169fdce7896009a63d4035
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.
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:
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.
26 #ifndef f_VD2_PLUGIN_VDINPUTDRIVER_H
27 #define f_VD2_PLUGIN_VDINPUTDRIVER_H
29 #ifdef _MSC_VER
30 #pragma once
31 #pragma pack(push, 8)
32 #endif
34 #include "vdplugin.h"
36 /// Unsigned 32-bit fraction.
37 struct VDXFraction {
38 uint32 mNumerator;
39 uint32 mDenominator;
42 typedef struct VDXHWNDStruct *VDXHWND;
43 typedef struct VDXBITMAPINFOHEADERStruct {
44 enum { kCompressionRGB = 0 };
45 uint32 mSize;
46 sint32 mWidth;
47 sint32 mHeight;
48 uint16 mPlanes;
49 uint16 mBitCount;
50 uint32 mCompression;
51 uint32 mSizeImage;
52 sint32 mXPelsPerMeter;
53 sint32 mYPelsPerMeter;
54 uint32 mClrUsed;
55 uint32 mClrImportant;
56 } VDXBITMAPINFOHEADER;
58 typedef struct VDXWAVEFORMATEXStruct {
59 enum { kFormatPCM = 1 };
60 uint16 mFormatTag;
61 uint16 mChannels;
62 uint32 mSamplesPerSec;
63 uint32 mAvgBytesPerSec;
64 uint16 mBlockAlign;
65 uint16 mBitsPerSample;
66 uint16 mExtraSize;
67 } VDXWAVEFORMATEX;
69 struct VDXStreamSourceInfo {
70 VDXFraction mSampleRate;
71 sint64 mSampleCount;
72 VDXFraction mPixelAspectRatio;
75 // V3+ (1.7.X) only
76 struct VDXStreamSourceInfoV3 {
77 VDXStreamSourceInfo mInfo;
79 enum {
80 kFlagVariableSizeSamples = 0x00000001
83 uint32 mFlags;
84 uint32 mfccHandler; ///< If non-zero, specifies the FOURCC of a codec handler that should be preferred.
87 class IVDXStreamSource : public IVDXUnknown {
88 public:
89 enum { kIID = VDXMAKEFOURCC('X', 's', 't', 's') };
91 virtual void VDXAPIENTRY GetStreamSourceInfo(VDXStreamSourceInfo&) = 0;
93 virtual bool VDXAPIENTRY Read(sint64 lStart, uint32 lCount, void *lpBuffer, uint32 cbBuffer, uint32 *lBytesRead, uint32 *lSamplesRead) = 0;
95 virtual const void * VDXAPIENTRY GetDirectFormat() = 0;
96 virtual int VDXAPIENTRY GetDirectFormatLen() = 0;
98 enum ErrorMode {
99 kErrorModeReportAll = 0,
100 kErrorModeConceal,
101 kErrorModeDecodeAnyway,
102 kErrorModeCount
105 virtual ErrorMode VDXAPIENTRY GetDecodeErrorMode() = 0;
106 virtual void VDXAPIENTRY SetDecodeErrorMode(ErrorMode mode) = 0;
107 virtual bool VDXAPIENTRY IsDecodeErrorModeSupported(ErrorMode mode) = 0;
109 virtual bool VDXAPIENTRY IsVBR() = 0;
110 virtual sint64 VDXAPIENTRY TimeToPositionVBR(sint64 us) = 0;
111 virtual sint64 VDXAPIENTRY PositionToTimeVBR(sint64 samples) = 0;
114 // V3+ (1.7.X)
115 class IVDXStreamSourceV3 : public IVDXUnknown {
116 public:
117 enum { kIID = VDXMAKEFOURCC('X', 's', 't', '2') };
119 virtual void VDXAPIENTRY GetStreamSourceInfoV3(VDXStreamSourceInfoV3&) = 0;
122 class IVDXVideoDecoderModel : public IVDXUnknown {
123 public:
124 enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'm') };
126 virtual void VDXAPIENTRY Reset() = 0;
127 virtual void VDXAPIENTRY SetDesiredFrame(sint64 frame_num) = 0;
128 virtual sint64 VDXAPIENTRY GetNextRequiredSample(bool& is_preroll) = 0;
129 virtual int VDXAPIENTRY GetRequiredCount() = 0;
132 class IVDXVideoDecoder : public IVDXUnknown {
133 public:
134 enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'e') };
136 virtual const void * VDXAPIENTRY DecodeFrame(const void *inputBuffer, uint32 data_len, bool is_preroll, sint64 sampleNumber, sint64 targetFrame) = 0;
137 virtual uint32 VDXAPIENTRY GetDecodePadding() = 0;
138 virtual void VDXAPIENTRY Reset() = 0;
139 virtual bool VDXAPIENTRY IsFrameBufferValid() = 0;
140 virtual const VDXPixmap& VDXAPIENTRY GetFrameBuffer() = 0;
141 virtual bool VDXAPIENTRY SetTargetFormat(int format, bool useDIBAlignment) = 0;
142 virtual bool VDXAPIENTRY SetDecompressedFormat(const VDXBITMAPINFOHEADER *pbih) = 0;
144 virtual bool VDXAPIENTRY IsDecodable(sint64 sample_num) = 0;
145 virtual const void * VDXAPIENTRY GetFrameBufferBase() = 0;
148 enum VDXVideoFrameType {
149 kVDXVFT_Independent,
150 kVDXVFT_Predicted,
151 kVDXVFT_Bidirectional,
152 kVDXVFT_Null,
155 struct VDXVideoFrameInfo {
156 char mTypeChar;
157 uint8 mFrameType;
158 sint64 mBytePosition;
161 struct VDXVideoSourceInfo {
162 enum DecoderModel {
163 kDecoderModelCustom, ///< A custom decoder model is provided.
164 kDecoderModelDefaultIP ///< Use the default I/P decoder model.
167 enum Flags {
168 kFlagNone = 0,
169 kFlagKeyframeOnly = 0x00000001,
170 kFlagAll = 0xFFFFFFFF
173 public:
174 uint32 mFlags;
175 uint32 mWidth;
176 uint32 mHeight;
177 uint8 mDecoderModel;
178 uint8 unused[3];
181 class IVDXVideoSource : public IVDXUnknown {
182 public:
183 enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 's') };
185 virtual void VDXAPIENTRY GetVideoSourceInfo(VDXVideoSourceInfo& info) = 0;
187 virtual bool VDXAPIENTRY CreateVideoDecoderModel(IVDXVideoDecoderModel **) = 0;
188 virtual bool VDXAPIENTRY CreateVideoDecoder(IVDXVideoDecoder **) = 0;
190 virtual void VDXAPIENTRY GetSampleInfo(sint64 sample_num, VDXVideoFrameInfo& frameInfo) = 0;
192 virtual bool VDXAPIENTRY IsKey(sint64 sample_num) = 0;
194 virtual sint64 VDXAPIENTRY GetFrameNumberForSample(sint64 sample_num) = 0;
195 virtual sint64 VDXAPIENTRY GetSampleNumberForFrame(sint64 frame_num) = 0;
196 virtual sint64 VDXAPIENTRY GetRealFrame(sint64 frame_num) = 0;
198 virtual sint64 VDXAPIENTRY GetSampleBytePosition(sint64 sample_num) = 0;
201 struct VDXAudioSourceInfo {
202 public:
203 uint32 mFlags;
206 class IVDXAudioSource : public IVDXUnknown {
207 public:
208 enum { kIID = VDXMAKEFOURCC('X', 'a', 'd', 's') };
210 virtual void VDXAPIENTRY GetAudioSourceInfo(VDXAudioSourceInfo& info) = 0;
213 class IVDXInputOptions : public IVDXUnknown {
214 public:
215 enum { kIID = VDXMAKEFOURCC('X', 'i', 'o', 'p') };
217 virtual uint32 VDXAPIENTRY Write(void *buf, uint32 buflen) = 0;
220 class IVDXInputFile : public IVDXUnknown {
221 public:
222 enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'l') };
224 virtual bool VDXAPIENTRY PromptForOptions(VDXHWND, IVDXInputOptions **ppOptions) = 0;
225 virtual bool VDXAPIENTRY CreateOptions(const void *buf, uint32 len, IVDXInputOptions **ppOptions) = 0;
227 virtual void VDXAPIENTRY Init(const wchar_t *path, IVDXInputOptions *options) = 0;
228 virtual bool VDXAPIENTRY Append(const wchar_t *path) = 0;
230 virtual void VDXAPIENTRY DisplayInfo(VDXHWND hwndParent) = 0;
232 virtual bool VDXAPIENTRY GetVideoSource(int index, IVDXVideoSource **ppVS) = 0;
233 virtual bool VDXAPIENTRY GetAudioSource(int index, IVDXAudioSource **ppAS) = 0;
236 ///////////////////////////////////////////////////////////////////////////////
237 // IVDXInputFileDriver
239 class IVDXInputFileDriver : public IVDXUnknown {
240 public:
241 enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'd') };
243 virtual int VDXAPIENTRY DetectBySignature(const void *pHeader, sint32 nHeaderSize, const void *pFooter, sint32 nFooterSize, sint64 nFileSize) = 0;
244 virtual bool VDXAPIENTRY CreateInputFile(uint32 flags, IVDXInputFile **ppFile) = 0;
247 struct VDXInputDriverContext {
248 uint32 mAPIVersion;
249 IVDPluginCallbacks *mpCallbacks;
252 typedef bool (VDXAPIENTRY *VDXInputDriverCreateProc)(const VDXInputDriverContext *pContext, IVDXInputFileDriver **);
254 struct VDXInputDriverDefinition {
255 enum {
256 kFlagNone = 0x00000000,
257 kFlagSupportsVideo = 0x00000001,
258 kFlagSupportsAudio = 0x00000002,
259 kFlagCustomSignature = 0x00010000,
260 kFlagAll = 0xFFFFFFFF
262 uint32 mSize; // size of this structure in bytes
263 uint32 mFlags;
264 sint32 mPriority;
265 uint32 mSignatureLength;
266 const void *mpSignature;
267 const wchar_t *mpFilenameDetectPattern;
268 const wchar_t *mpFilenamePattern;
269 const wchar_t *mpDriverTagName;
271 VDXInputDriverCreateProc mpCreate;
274 enum {
275 // V1 (1.7.4.28204): Initial version
276 // V2 (1.7.5): Default I/P frame model fixed.
277 kVDXPlugin_InputDriverAPIVersion = 2
280 #ifdef _MSC_VER
281 #pragma pack(pop)
282 #endif
284 #endif