1 // VirtualDub - Video processing and capture application
3 // Copyright (C) 1998-2007 Avery Lee, All Rights Reserved.
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):
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
26 #ifndef f_VD2_PLUGIN_VDINPUTDRIVER_H
27 #define f_VD2_PLUGIN_VDINPUTDRIVER_H
36 /// Unsigned 32-bit fraction.
42 typedef struct VDXHWNDStruct
*VDXHWND
;
43 typedef struct VDXBITMAPINFOHEADERStruct
{
44 enum { kCompressionRGB
= 0 };
52 sint32 mXPelsPerMeter
;
53 sint32 mYPelsPerMeter
;
56 } VDXBITMAPINFOHEADER
;
58 typedef struct VDXWAVEFORMATEXStruct
{
59 enum { kFormatPCM
= 1 };
62 uint32 mSamplesPerSec
;
63 uint32 mAvgBytesPerSec
;
65 uint16 mBitsPerSample
;
69 struct VDXStreamSourceInfo
{
70 VDXFraction mSampleRate
;
72 VDXFraction mPixelAspectRatio
;
76 struct VDXStreamSourceInfoV3
{
77 VDXStreamSourceInfo mInfo
;
80 kFlagVariableSizeSamples
= 0x00000001
84 uint32 mfccHandler
; ///< If non-zero, specifies the FOURCC of a codec handler that should be preferred.
87 class IVDXStreamSource
: public IVDXUnknown
{
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;
99 kErrorModeReportAll
= 0,
101 kErrorModeDecodeAnyway
,
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;
115 class IVDXStreamSourceV3
: public IVDXUnknown
{
117 enum { kIID
= VDXMAKEFOURCC('X', 's', 't', '2') };
119 virtual void VDXAPIENTRY
GetStreamSourceInfoV3(VDXStreamSourceInfoV3
&) = 0;
122 class IVDXVideoDecoderModel
: public IVDXUnknown
{
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
{
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
{
151 kVDXVFT_Bidirectional
,
155 struct VDXVideoFrameInfo
{
158 sint64 mBytePosition
;
161 struct VDXVideoSourceInfo
{
163 kDecoderModelCustom
, ///< A custom decoder model is provided.
164 kDecoderModelDefaultIP
///< Use the default I/P decoder model.
169 kFlagKeyframeOnly
= 0x00000001,
170 kFlagAll
= 0xFFFFFFFF
181 class IVDXVideoSource
: public IVDXUnknown
{
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
{
206 class IVDXAudioSource
: public IVDXUnknown
{
208 enum { kIID
= VDXMAKEFOURCC('X', 'a', 'd', 's') };
210 virtual void VDXAPIENTRY
GetAudioSourceInfo(VDXAudioSourceInfo
& info
) = 0;
213 class IVDXInputOptions
: public IVDXUnknown
{
215 enum { kIID
= VDXMAKEFOURCC('X', 'i', 'o', 'p') };
217 virtual uint32 VDXAPIENTRY
Write(void *buf
, uint32 buflen
) = 0;
220 class IVDXInputFile
: public IVDXUnknown
{
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
{
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
{
249 IVDPluginCallbacks
*mpCallbacks
;
252 typedef bool (VDXAPIENTRY
*VDXInputDriverCreateProc
)(const VDXInputDriverContext
*pContext
, IVDXInputFileDriver
**);
254 struct VDXInputDriverDefinition
{
256 kFlagNone
= 0x00000000,
257 kFlagSupportsVideo
= 0x00000001,
258 kFlagSupportsAudio
= 0x00000002,
259 kFlagCustomSignature
= 0x00010000,
260 kFlagAll
= 0xFFFFFFFF
262 uint32 mSize
; // size of this structure in bytes
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
;
275 // V1 (1.7.4.28204): Initial version
276 // V2 (1.7.5): Default I/P frame model fixed.
277 kVDXPlugin_InputDriverAPIVersion
= 2