Mercurial > mplayer.hg
comparison loader/dshow/libwin32.h @ 3063:004e3199fee0
mplayer integration
author | arpi |
---|---|
date | Thu, 22 Nov 2001 03:16:31 +0000 |
parents | 8500ef44bf5c |
children | 1baa35e06053 |
comparison
equal
deleted
inserted
replaced
3062:7ea7e5fce639 | 3063:004e3199fee0 |
---|---|
1 #ifndef __LIBWIN32_H | 1 #ifndef __LIBWIN32_H |
2 #define __LIBWIN32_H | 2 #define __LIBWIN32_H |
3 | 3 |
4 #define VFW_E_INVALIDMEDIATYPE 0x80040200 | 4 #ifndef NOAVIFILE_HEADERS |
5 #define VFW_E_INVALIDSUBTYPE 0x80040201 | 5 #error this header file should not be used without -DNOAVIFILE_HEADERS |
6 #define VFW_E_ALREADY_CONNECTED 0x80040204 | 6 #endif |
7 #define VFW_E_FILTER_ACTIVE 0x80040205 | 7 |
8 #define VFW_E_NO_ACCEPTABLE_TYPES 0x80040207 | 8 // this file is only included when NOAVIFILE_HEADERS are defined |
9 #define VFW_E_NOT_CONNECTED 0x80040209 | 9 // serves mainly for mplayer |
10 #define VFW_E_NO_ALLOCATOR 0x8004020A | 10 |
11 #define VFW_E_NOT_RUNNING 0x80040226 | 11 #define VFW_E_NOT_RUNNING 0x80040226 |
12 #define VFW_E_TYPE_NOT_ACCEPTED 0x8004022A | 12 |
13 #define VFW_E_SAMPLE_REJECTED 0x8004022B | |
14 | |
15 #include <sys/types.h> | |
16 #include <inttypes.h> | 13 #include <inttypes.h> |
17 | 14 |
18 #ifndef NOAVIFILE_HEADERS | |
19 #include <audiodecoder.h> | |
20 #include <audioencoder.h> | |
21 #include <videodecoder.h> | |
22 #include <videoencoder.h> | |
23 #include <except.h> | |
24 #include <fourcc.h> | |
25 | |
26 #else | |
27 // code for mplayer team | |
28 | |
29 //#define FATAL(a) // you don't need exception - if you want - just fill more code | 15 //#define FATAL(a) // you don't need exception - if you want - just fill more code |
30 #define FATAL(X...) FatalError(__MODULE__,__FILE__,__LINE__,X) | 16 #include "wine/mmreg.h" |
31 #include <wine/mmreg.h> | 17 #include "wine/winreg.h" |
32 #include <wine/winreg.h> | 18 #include "wine/vfw.h" |
33 #include <wine/vfw.h> | 19 #include "com.h" |
34 #include <com.h> | 20 |
35 #include <stdarg.h> | 21 typedef uint32_t fourcc_t; |
36 //#include <string> | 22 |
37 #include <stdio.h> | 23 /* |
38 #include <stdlib.h> | 24 typedef struct _FatalError |
39 | 25 { |
40 typedef unsigned int uint_t; // use as generic type - | 26 FatalError(); |
41 | 27 void PrintAll() {} |
42 typedef unsigned int fourcc_t; | 28 }FatalError; |
43 | 29 */ |
44 struct FatalError | 30 |
45 { | 31 typedef struct _CodecInfo |
46 FatalError(const char* mod, const char* f, int l, const char* desc,...) | 32 { |
47 { | 33 char* dll; |
48 printf("FATAL: module: %s source: %s line %d ", mod, f, l); | 34 GUID* guid; |
49 va_list va; | 35 }CodecInfo; |
50 va_start(va, desc); | 36 |
51 vprintf(desc, va); | 37 |
52 va_end(va); | 38 typedef struct _CImage // public your_libvo_mem |
39 { | |
40 char* ptr; | |
41 | |
42 /*char* (*Data)(); | |
43 { | |
44 return 0; | |
45 // pointer to memory block | |
46 }*/ | |
47 /*int (*Supported)(fourcc_t csp, int bits); | |
48 { | |
49 return true; | |
50 // if you support such surface | |
51 }*/ | |
52 }CImage; | |
53 | |
54 | |
55 #if 0 | |
56 struct BitmapInfo : public BITMAPINFOHEADER | |
57 { | |
58 void SetBits(int b) { return; /*fixme*/ } | |
59 void SetSpace(int b) { return; /*fixme*/ } | |
60 }; | |
61 #endif | |
62 | |
63 typedef struct _IAudioDecoder | |
64 { | |
65 WAVEFORMATEX in_fmt; | |
66 CodecInfo record; | |
67 /*(*IAudioDecoder)( CodecInfo * r, const WAVEFORMATEX* w); | |
68 { | |
69 memcpy(&this->record,r,sizeof(CodecInfo)); | |
70 in_fmt = *w; | |
71 }*/ | |
72 }IAudioDecoder; | |
73 | |
74 /* | |
75 struct IAudioEncoder | |
76 { | |
77 IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {} | |
78 // you do not need this one... | |
79 }; | |
80 */ | |
81 | |
82 enum CAPS | |
83 { | |
84 CAP_NONE = 0, | |
85 CAP_YUY2 = 1, | |
86 CAP_YV12 = 2, | |
87 CAP_IYUV = 4, | |
88 CAP_UYVY = 8, | |
89 CAP_YVYU = 16, | |
90 CAP_I420 = 32, | |
91 }; | |
92 enum DecodingMode | |
93 { | |
94 DIRECT = 0, | |
95 REALTIME, | |
96 REALTIME_QUALITY_AUTO, | |
97 }; | |
98 enum DecodingState | |
99 { | |
100 STOP = 0, | |
101 START, | |
102 }; | |
103 | |
104 typedef struct _BitmapInfo | |
105 { | |
106 long biSize; | |
107 long biWidth; | |
108 long biHeight; | |
109 short biPlanes; | |
110 short biBitCount; | |
111 long biCompression; | |
112 long biSizeImage; | |
113 long biXPelsPerMeter; | |
114 long biYPelsPerMeter; | |
115 long biClrUsed; | |
116 long biClrImportant; | |
117 int colors[3]; | |
118 } BitmapInfo; | |
119 | |
120 typedef struct _IVideoDecoder | |
121 { | |
122 int VBUFSIZE; | |
123 int QMARKHI; | |
124 int QMARKLO; | |
125 int DMARKHI; | |
126 int DMARKLO; | |
127 | |
128 /* | |
129 IVideoDecoder(CodecInfo& info, const BITMAPINFOHEADER& format) : record(info) | |
130 { | |
131 // implement init part | |
53 } | 132 } |
54 void PrintAll() {} | 133 virtual ~IVideoDecoder(); |
134 void Stop() | |
135 { | |
136 } | |
137 void Start() | |
138 { | |
139 } | |
140 */ | |
141 const CodecInfo record; | |
142 int m_Mode; // should we do precaching (or even change Quality on the fly) | |
143 int m_State; | |
144 int m_iDecpos; | |
145 int m_iPlaypos; | |
146 float m_fQuality; // quality for the progress bar 0..1(best) | |
147 int m_bCapable16b; | |
148 | |
149 BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv) | |
150 BitmapInfo m_decoder; // format of decoder output | |
151 BitmapInfo m_obh; // format of returned frames | |
152 }IVideoDecoder; | |
153 | |
154 /* | |
155 struct IRtConfig | |
156 { | |
55 }; | 157 }; |
56 | 158 */ |
57 struct CodecInfo | |
58 { | |
59 // std::string dll; | |
60 char* dll; | |
61 GUID guid; | |
62 }; | |
63 | |
64 struct CImage { // public your_libvo_mem | |
65 char* ptr; | |
66 char* Data() { return ptr; } // pointer to memory block | |
67 /* if you support such surface: */ | |
68 static bool Supported(fourcc_t csp, int bits) { return true; } | |
69 }; | |
70 | 159 |
71 // might be minimalized to contain just those which are needed by DS_VideoDecoder | 160 // might be minimalized to contain just those which are needed by DS_VideoDecoder |
72 | 161 |
73 #ifndef mmioFOURCC | 162 #ifndef mmioFOURCC |
74 #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ | 163 #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ |
165 #define fccI420 mmioFOURCC('I', '4', '2', '0') | 254 #define fccI420 mmioFOURCC('I', '4', '2', '0') |
166 #define fccIYUV mmioFOURCC('I', 'Y', 'U', 'V')/* Planar mode: Y + U + V (3 planes) */ | 255 #define fccIYUV mmioFOURCC('I', 'Y', 'U', 'V')/* Planar mode: Y + U + V (3 planes) */ |
167 #define fccUYVY mmioFOURCC('U', 'Y', 'V', 'Y')/* Packed mode: U0+Y0+V0+Y1 (1 plane) */ | 256 #define fccUYVY mmioFOURCC('U', 'Y', 'V', 'Y')/* Packed mode: U0+Y0+V0+Y1 (1 plane) */ |
168 #define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */ | 257 #define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */ |
169 | 258 |
170 | |
171 struct BitmapInfo : public BITMAPINFOHEADER | |
172 { | |
173 int colors[3]; | |
174 | |
175 void SetBitFields16(){ | |
176 biSize=sizeof(BITMAPINFOHEADER)+12; | |
177 biCompression=3;//BI_BITFIELDS | |
178 biBitCount=16; | |
179 biSizeImage=abs((int)(2*biWidth*biHeight)); | |
180 colors[0]=0xF800; | |
181 colors[1]=0x07E0; | |
182 colors[2]=0x001F; | |
183 } | |
184 void SetBitFields15(){ | |
185 biSize=sizeof(BITMAPINFOHEADER)+12; | |
186 biCompression=3;//BI_BITFIELDS | |
187 biBitCount=16; | |
188 biSizeImage=abs((int)(2*biWidth*biHeight)); | |
189 colors[0]=0x7C00; | |
190 colors[1]=0x03E0; | |
191 colors[2]=0x001F; | |
192 } | |
193 void SetRGB(){ | |
194 biSize = sizeof(BITMAPINFOHEADER); | |
195 biCompression = 0; //BI_RGB | |
196 //biHeight = labs(biHeight); | |
197 biSizeImage = labs(biWidth * biHeight) * ((biBitCount + 7) / 8); | |
198 } | |
199 void SetBits(int bits) { | |
200 switch (bits){ | |
201 case 15: SetBitFields15();break; | |
202 case 16: SetBitFields16();break; | |
203 default: biBitCount = bits; SetRGB();break; | |
204 } | |
205 } | |
206 void SetSpace(int csp,int bits) { | |
207 biSize = sizeof(BITMAPINFOHEADER); | |
208 biCompression=csp; | |
209 biBitCount=bits; | |
210 biSizeImage=labs(biBitCount*biWidth*biHeight)>>3; | |
211 } | |
212 void SetSpace(int csp) { | |
213 int bits=0; | |
214 switch(csp){ | |
215 case fccYUV: | |
216 bits=24;break; | |
217 case fccYUY2: | |
218 case fccUYVY: | |
219 case fccYVYU: | |
220 bits=16;break; | |
221 case fccYV12: | |
222 case fccIYUV: | |
223 case fccI420: | |
224 bits=12;break; | |
225 } | |
226 if (csp != 0 && csp != 3 && biHeight > 0) | |
227 biHeight *= -1; // YUV formats uses should have height < 0 | |
228 SetSpace(csp,bits); | |
229 } | |
230 | |
231 }; | |
232 | |
233 struct IAudioDecoder | |
234 { | |
235 WAVEFORMATEX in_fmt; | |
236 const CodecInfo& record; | |
237 IAudioDecoder(const CodecInfo& r, const WAVEFORMATEX* w) : record(r) | |
238 { | |
239 in_fmt = *w; | |
240 } | |
241 }; | |
242 | |
243 struct IAudioEncoder | |
244 { | |
245 IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {} | |
246 // you do not need this one... | |
247 }; | |
248 | |
249 struct IVideoDecoder | |
250 { | |
251 int VBUFSIZE; | |
252 int QMARKHI; | |
253 int QMARKLO; | |
254 int DMARKHI; | |
255 int DMARKLO; | |
256 | |
257 enum CAPS | |
258 { | |
259 CAP_NONE = 0, | |
260 CAP_YUY2 = 1, | |
261 CAP_YV12 = 2, | |
262 CAP_IYUV = 4, | |
263 CAP_UYVY = 8, | |
264 CAP_YVYU = 16, | |
265 CAP_I420 = 32, | |
266 }; | |
267 enum DecodingMode | |
268 { | |
269 DIRECT = 0, | |
270 REALTIME, | |
271 REALTIME_QUALITY_AUTO, | |
272 }; | |
273 enum DecodingState | |
274 { | |
275 STOP = 0, | |
276 START, | |
277 }; | |
278 IVideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format) : record(info) | |
279 { | |
280 // implement init part | |
281 unsigned bihs = (format.biSize < (int) sizeof(BITMAPINFOHEADER)) ? | |
282 sizeof(BITMAPINFOHEADER) : format.biSize; | |
283 m_bh = (BITMAPINFOHEADER*) new char[bihs]; | |
284 memcpy(m_bh, &format, bihs); | |
285 m_State = STOP; | |
286 //m_pFrame = 0; | |
287 m_Mode = DIRECT; | |
288 m_iDecpos = 0; | |
289 m_iPlaypos = -1; | |
290 m_fQuality = 0.0f; | |
291 m_bCapable16b = true; | |
292 | |
293 } | |
294 virtual ~IVideoDecoder(){}; | |
295 // use this one | |
296 int Decode(void* src, size_t size, int is_keyframe, CImage* pImage) | |
297 { return DecodeInternal(src, size, is_keyframe, pImage); } | |
298 void Stop(){ StopInternal(); m_State = STOP;} | |
299 void Start(){StartInternal(); m_State = START;} | |
300 protected: | |
301 virtual int DecodeInternal(void* src, size_t size, int is_keyframe, CImage* pImage) = 0; | |
302 virtual void StartInternal()=0; | |
303 virtual void StopInternal()=0; | |
304 | |
305 const CodecInfo& record; | |
306 DecodingMode m_Mode; // should we do precaching (or even change Quality on the fly) | |
307 DecodingState m_State; | |
308 int m_iDecpos; | |
309 int m_iPlaypos; | |
310 float m_fQuality; // quality for the progress bar 0..1(best) | |
311 bool m_bCapable16b; | |
312 | |
313 BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv) | |
314 BitmapInfo m_decoder; // format of decoder output | |
315 BitmapInfo m_obh; // format of returned frames | |
316 }; | |
317 | |
318 struct IRtConfig | |
319 { | |
320 }; | |
321 | |
322 | |
323 | |
324 #endif | 259 #endif |
325 | |
326 #endif |