1545
|
1 #ifndef __LIBWIN32_H
|
|
2 #define __LIBWIN32_H
|
|
3
|
|
4 #define VFW_E_INVALIDMEDIATYPE 0x80040200
|
|
5 #define VFW_E_INVALIDSUBTYPE 0x80040201
|
|
6 #define VFW_E_ALREADY_CONNECTED 0x80040204
|
|
7 #define VFW_E_FILTER_ACTIVE 0x80040205
|
|
8 #define VFW_E_NO_ACCEPTABLE_TYPES 0x80040207
|
|
9 #define VFW_E_NOT_CONNECTED 0x80040209
|
|
10 #define VFW_E_NO_ALLOCATOR 0x8004020A
|
|
11 #define VFW_E_NOT_RUNNING 0x80040226
|
|
12 #define VFW_E_TYPE_NOT_ACCEPTED 0x8004022A
|
|
13 #define VFW_E_SAMPLE_REJECTED 0x8004022B
|
|
14
|
|
15 #include <sys/types.h>
|
|
16 #include <inttypes.h>
|
|
17
|
|
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
|
|
30 #include <wine/mmreg.h>
|
|
31 #include <wine/winreg.h>
|
|
32 #include <wine/vfw.h>
|
|
33 #include <com.h>
|
|
34 #include <string>
|
|
35
|
|
36 typedef unsigned int fourcc_t;
|
|
37 struct FatalError
|
|
38 {
|
|
39 FatalError();
|
|
40 void PrintAll() {}
|
|
41 };
|
|
42
|
|
43 struct CodecInfo
|
|
44 {
|
|
45 std::string dll;
|
|
46 GUID guid;
|
|
47 };
|
|
48
|
|
49 struct CImage { // public your_libvo_mem
|
|
50 char* ptr;
|
|
51 char* Data() { return ptr; } // pointer to memory block
|
|
52 /* if you support such surface: */
|
|
53 static bool Supported(fourcc_t csp, int bits) { return true; }
|
|
54 };
|
|
55
|
|
56 // might be minimalized to contain just those which are needed by DS_VideoDecoder
|
|
57
|
|
58 #ifndef mmioFOURCC
|
|
59 #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
|
|
60 ( (long)(unsigned char)(ch0) | ( (long)(unsigned char)(ch1) << 8 ) | \
|
|
61 ( (long)(unsigned char)(ch2) << 16 ) | ( (long)(unsigned char)(ch3) << 24 ) )
|
|
62 #endif /* mmioFOURCC */
|
|
63
|
|
64 /* OpenDivX */
|
|
65 #define fccMP4S mmioFOURCC('M', 'P', '4', 'S')
|
|
66 #define fccmp4s mmioFOURCC('m', 'p', '4', 's')
|
|
67 #define fccDIVX mmioFOURCC('D', 'I', 'V', 'X')
|
|
68 #define fccdivx mmioFOURCC('d', 'i', 'v', 'x')
|
|
69 #define fccDIV1 mmioFOURCC('D', 'I', 'V', '1')
|
|
70 #define fccdiv1 mmioFOURCC('d', 'i', 'v', '1')
|
|
71
|
|
72 /* DivX codecs */
|
|
73 #define fccDIV2 mmioFOURCC('D', 'I', 'V', '2')
|
|
74 #define fccdiv2 mmioFOURCC('d', 'i', 'v', '2')
|
|
75 #define fccDIV3 mmioFOURCC('D', 'I', 'V', '3')
|
|
76 #define fccdiv3 mmioFOURCC('d', 'i', 'v', '3')
|
|
77 #define fccDIV4 mmioFOURCC('D', 'I', 'V', '4')
|
|
78 #define fccdiv4 mmioFOURCC('d', 'i', 'v', '4')
|
|
79 #define fccDIV5 mmioFOURCC('D', 'I', 'V', '5')
|
|
80 #define fccdiv5 mmioFOURCC('d', 'i', 'v', '5')
|
|
81 #define fccDIV6 mmioFOURCC('D', 'I', 'V', '6')
|
|
82 #define fccdiv6 mmioFOURCC('d', 'i', 'v', '6')
|
|
83 #define fccMP41 mmioFOURCC('M', 'P', '4', '1')
|
|
84 #define fccmp41 mmioFOURCC('m', 'p', '4', '1')
|
|
85 #define fccMP43 mmioFOURCC('M', 'P', '4', '3')
|
|
86 #define fccmp43 mmioFOURCC('m', 'p', '4', '3')
|
|
87 /* old ms mpeg-4 codecs */
|
|
88 #define fccMP42 mmioFOURCC('M', 'P', '4', '2')
|
|
89 #define fccmp42 mmioFOURCC('m', 'p', '4', '2')
|
|
90 #define fccMPG4 mmioFOURCC('M', 'P', 'G', '4')
|
|
91 #define fccmpg4 mmioFOURCC('m', 'p', 'g', '4')
|
|
92 /* Windows media codecs */
|
|
93 #define fccWMV1 mmioFOURCC('W', 'M', 'V', '1')
|
|
94 #define fccwmv1 mmioFOURCC('w', 'm', 'v', '1')
|
|
95 #define fccWMV2 mmioFOURCC('W', 'M', 'V', '2')
|
|
96 #define fccwmv2 mmioFOURCC('w', 'm', 'v', '2')
|
|
97 #define fccMWV1 mmioFOURCC('M', 'W', 'V', '1')
|
|
98
|
|
99 /* Angel codecs */
|
|
100 #define fccAP41 mmioFOURCC('A', 'P', '4', '1')
|
|
101 #define fccap41 mmioFOURCC('a', 'p', '4', '1')
|
|
102 #define fccAP42 mmioFOURCC('A', 'P', '4', '2')
|
|
103 #define fccap42 mmioFOURCC('a', 'p', '4', '2')
|
|
104
|
|
105 /* other codecs */
|
|
106 #define fccIV31 mmioFOURCC('I', 'V', '3', '1')
|
|
107 #define fcciv31 mmioFOURCC('i', 'v', '3', '1')
|
|
108 #define fccIV32 mmioFOURCC('I', 'V', '3', '2')
|
|
109 #define fcciv32 mmioFOURCC('i', 'v', '3', '2')
|
|
110 #define fccIV41 mmioFOURCC('I', 'V', '4', '1')
|
|
111 #define fcciv41 mmioFOURCC('i', 'v', '4', '1')
|
|
112 #define fccIV50 mmioFOURCC('I', 'V', '5', '0')
|
|
113 #define fcciv50 mmioFOURCC('i', 'v', '5', '0')
|
|
114 #define fccI263 mmioFOURCC('I', '2', '6', '3')
|
|
115 #define fcci263 mmioFOURCC('i', '2', '6', '3')
|
|
116
|
|
117 #define fccMJPG mmioFOURCC('M', 'J', 'P', 'G')
|
|
118 #define fccmjpg mmioFOURCC('m', 'j', 'p', 'g')
|
|
119
|
|
120 #define fccHFYU mmioFOURCC('H', 'F', 'Y', 'U')
|
|
121
|
|
122 #define fcccvid mmioFOURCC('c', 'v', 'i', 'd')
|
|
123 #define fccdvsd mmioFOURCC('d', 'v', 's', 'd')
|
|
124
|
|
125 /* Ati codecs */
|
|
126 #define fccVCR2 mmioFOURCC('V', 'C', 'R', '2')
|
|
127 #define fccVCR1 mmioFOURCC('V', 'C', 'R', '1')
|
|
128 #define fccVYUY mmioFOURCC('V', 'Y', 'U', 'Y')
|
|
129 #define fccYVU9 mmioFOURCC('I', 'Y', 'U', '9')
|
|
130
|
|
131 /* Asus codecs */
|
|
132 #define fccASV1 mmioFOURCC('A', 'S', 'V', '1')
|
|
133 #define fccASV2 mmioFOURCC('A', 'S', 'V', '2')
|
|
134
|
|
135 /* Microsoft video */
|
|
136 #define fcccram mmioFOURCC('c', 'r', 'a', 'm')
|
|
137 #define fccCRAM mmioFOURCC('C', 'R', 'A', 'M')
|
|
138 #define fccMSVC mmioFOURCC('M', 'S', 'V', 'C')
|
|
139
|
|
140
|
|
141 #define fccMSZH mmioFOURCC('M', 'S', 'Z', 'H')
|
|
142
|
|
143 #define fccZLIB mmioFOURCC('Z', 'L', 'I', 'B')
|
|
144
|
|
145 #define fccTM20 mmioFOURCC('T', 'M', '2', '0')
|
|
146
|
|
147 #define fccYUV mmioFOURCC('Y', 'U', 'V', ' ')
|
|
148 #define fccYUY2 mmioFOURCC('Y', 'U', 'Y', '2')
|
|
149 #define fccYV12 mmioFOURCC('Y', 'V', '1', '2')/* Planar mode: Y + V + U (3 planes) */
|
|
150 #define fccI420 mmioFOURCC('I', '4', '2', '0')
|
|
151 #define fccIYUV mmioFOURCC('I', 'Y', 'U', 'V')/* Planar mode: Y + U + V (3 planes) */
|
|
152 #define fccUYVY mmioFOURCC('U', 'Y', 'V', 'Y')/* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
|
153 #define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
|
154
|
|
155
|
|
156 struct BitmapInfo : public BITMAPINFOHEADER
|
|
157 {
|
|
158 int colors[3];
|
|
159
|
|
160 void SetBitFields16(){
|
|
161 biSize=sizeof(BITMAPINFOHEADER)+12;
|
|
162 biCompression=3;//BI_BITFIELDS
|
|
163 biBitCount=16;
|
|
164 biSizeImage=abs((int)(2*biWidth*biHeight));
|
|
165 colors[0]=0xF800;
|
|
166 colors[1]=0x07E0;
|
|
167 colors[2]=0x001F;
|
|
168 }
|
|
169 void SetBitFields15(){
|
|
170 biSize=sizeof(BITMAPINFOHEADER)+12;
|
|
171 biCompression=3;//BI_BITFIELDS
|
|
172 biBitCount=16;
|
|
173 biSizeImage=abs((int)(2*biWidth*biHeight));
|
|
174 colors[0]=0x7C00;
|
|
175 colors[1]=0x03E0;
|
|
176 colors[2]=0x001F;
|
|
177 }
|
|
178 void SetRGB(){
|
|
179 biSize = sizeof(BITMAPINFOHEADER);
|
|
180 biCompression = 0; //BI_RGB
|
|
181 //biHeight = labs(biHeight);
|
|
182 biSizeImage = labs(biWidth * biHeight) * ((biBitCount + 7) / 8);
|
|
183 }
|
|
184 void SetBits(int bits) {
|
|
185 switch (bits){
|
|
186 case 15: SetBitFields15();break;
|
|
187 case 16: SetBitFields16();break;
|
|
188 default: biBitCount = bits; SetRGB();break;
|
|
189 }
|
|
190 }
|
|
191 void SetSpace(int csp,int bits) {
|
|
192 biSize = sizeof(BITMAPINFOHEADER);
|
|
193 biCompression=csp;
|
|
194 biBitCount=bits;
|
|
195 biSizeImage=labs(biBitCount*biWidth*biHeight)>>3;
|
|
196 }
|
|
197 void SetSpace(int csp) {
|
|
198 int bits=0;
|
|
199 switch(csp){
|
|
200 case fccYUV:
|
|
201 bits=24;break;
|
|
202 case fccYUY2:
|
|
203 case fccUYVY:
|
|
204 case fccYVYU:
|
|
205 bits=16;break;
|
|
206 case fccYV12:
|
|
207 case fccIYUV:
|
|
208 case fccI420:
|
|
209 bits=12;break;
|
|
210 }
|
|
211 if (csp != 0 && csp != 3 && biHeight > 0)
|
|
212 biHeight *= -1; // YUV formats uses should have height < 0
|
|
213 SetSpace(csp,bits);
|
|
214 }
|
|
215
|
|
216 };
|
|
217
|
|
218 struct IAudioDecoder
|
|
219 {
|
|
220 WAVEFORMATEX in_fmt;
|
|
221 const CodecInfo& record;
|
|
222 IAudioDecoder(const CodecInfo& r, const WAVEFORMATEX* w) : record(r)
|
|
223 {
|
|
224 in_fmt = *w;
|
|
225 }
|
|
226 };
|
|
227
|
|
228 struct IAudioEncoder
|
|
229 {
|
|
230 IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {}
|
|
231 // you do not need this one...
|
|
232 };
|
|
233
|
|
234 struct IVideoDecoder
|
|
235 {
|
|
236 int VBUFSIZE;
|
|
237 int QMARKHI;
|
|
238 int QMARKLO;
|
|
239 int DMARKHI;
|
|
240 int DMARKLO;
|
|
241
|
|
242 enum CAPS
|
|
243 {
|
|
244 CAP_NONE = 0,
|
|
245 CAP_YUY2 = 1,
|
|
246 CAP_YV12 = 2,
|
|
247 CAP_IYUV = 4,
|
|
248 CAP_UYVY = 8,
|
|
249 CAP_YVYU = 16,
|
|
250 CAP_I420 = 32,
|
|
251 };
|
|
252 enum DecodingMode
|
|
253 {
|
|
254 DIRECT = 0,
|
|
255 REALTIME,
|
|
256 REALTIME_QUALITY_AUTO,
|
|
257 };
|
|
258 enum DecodingState
|
|
259 {
|
|
260 STOP = 0,
|
|
261 START,
|
|
262 };
|
|
263 IVideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format) : record(info)
|
|
264 {
|
|
265 // implement init part
|
|
266 unsigned bihs = (format.biSize < (int) sizeof(BITMAPINFOHEADER)) ?
|
|
267 sizeof(BITMAPINFOHEADER) : format.biSize;
|
|
268 m_bh = (BITMAPINFOHEADER*) new char[bihs];
|
|
269 memcpy(m_bh, &format, bihs);
|
|
270 m_State = STOP;
|
|
271 //m_pFrame = 0;
|
|
272 m_Mode = DIRECT;
|
|
273 m_iDecpos = 0;
|
|
274 m_iPlaypos = -1;
|
|
275 m_fQuality = 0.0f;
|
|
276 m_bCapable16b = true;
|
|
277
|
|
278 }
|
|
279 virtual ~IVideoDecoder(){};
|
|
280 virtual void StartInternal()=0;
|
|
281 virtual void StopInternal()=0;
|
|
282 void Stop(){ StopInternal();}
|
|
283 void Start(){StartInternal();}
|
|
284
|
|
285 const CodecInfo& record;
|
|
286 DecodingMode m_Mode; // should we do precaching (or even change Quality on the fly)
|
|
287 DecodingState m_State;
|
|
288 int m_iDecpos;
|
|
289 int m_iPlaypos;
|
|
290 float m_fQuality; // quality for the progress bar 0..1(best)
|
|
291 bool m_bCapable16b;
|
|
292
|
|
293 BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv)
|
|
294 BitmapInfo m_decoder; // format of decoder output
|
|
295 BitmapInfo m_obh; // format of returned frames
|
|
296 };
|
|
297
|
|
298 struct IRtConfig
|
|
299 {
|
|
300 };
|
|
301
|
|
302
|
|
303
|
|
304 #endif
|
|
305
|
|
306 #endif
|