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
|
1558
|
29 //#define FATAL(a) // you don't need exception - if you want - just fill more code
|
|
30 #define FATAL(X...) FatalError(__MODULE__,__FILE__,__LINE__,X)
|
1545
|
31 #include <wine/mmreg.h>
|
|
32 #include <wine/winreg.h>
|
|
33 #include <wine/vfw.h>
|
|
34 #include <com.h>
|
1558
|
35 #include <stdarg.h>
|
2072
|
36 //#include <string>
|
1558
|
37 #include <stdio.h>
|
2073
|
38 #include <stdlib.h>
|
1545
|
39
|
2069
|
40 typedef unsigned int uint_t; // use as generic type -
|
|
41
|
1545
|
42 typedef unsigned int fourcc_t;
|
1558
|
43
|
1545
|
44 struct FatalError
|
|
45 {
|
1558
|
46 FatalError(const char* mod, const char* f, int l, const char* desc,...)
|
|
47 {
|
|
48 printf("FATAL: module: %s source: %s line %d ", mod, f, l);
|
|
49 va_list va;
|
|
50 va_start(va, desc);
|
|
51 vprintf(desc, va);
|
|
52 va_end(va);
|
|
53 }
|
1545
|
54 void PrintAll() {}
|
|
55 };
|
|
56
|
|
57 struct CodecInfo
|
|
58 {
|
2072
|
59 // std::string dll;
|
|
60 char* dll;
|
1545
|
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
|
|
71 // might be minimalized to contain just those which are needed by DS_VideoDecoder
|
|
72
|
|
73 #ifndef mmioFOURCC
|
|
74 #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
|
|
75 ( (long)(unsigned char)(ch0) | ( (long)(unsigned char)(ch1) << 8 ) | \
|
|
76 ( (long)(unsigned char)(ch2) << 16 ) | ( (long)(unsigned char)(ch3) << 24 ) )
|
|
77 #endif /* mmioFOURCC */
|
|
78
|
|
79 /* OpenDivX */
|
|
80 #define fccMP4S mmioFOURCC('M', 'P', '4', 'S')
|
|
81 #define fccmp4s mmioFOURCC('m', 'p', '4', 's')
|
|
82 #define fccDIVX mmioFOURCC('D', 'I', 'V', 'X')
|
|
83 #define fccdivx mmioFOURCC('d', 'i', 'v', 'x')
|
|
84 #define fccDIV1 mmioFOURCC('D', 'I', 'V', '1')
|
|
85 #define fccdiv1 mmioFOURCC('d', 'i', 'v', '1')
|
|
86
|
|
87 /* DivX codecs */
|
|
88 #define fccDIV2 mmioFOURCC('D', 'I', 'V', '2')
|
|
89 #define fccdiv2 mmioFOURCC('d', 'i', 'v', '2')
|
|
90 #define fccDIV3 mmioFOURCC('D', 'I', 'V', '3')
|
|
91 #define fccdiv3 mmioFOURCC('d', 'i', 'v', '3')
|
|
92 #define fccDIV4 mmioFOURCC('D', 'I', 'V', '4')
|
|
93 #define fccdiv4 mmioFOURCC('d', 'i', 'v', '4')
|
|
94 #define fccDIV5 mmioFOURCC('D', 'I', 'V', '5')
|
|
95 #define fccdiv5 mmioFOURCC('d', 'i', 'v', '5')
|
|
96 #define fccDIV6 mmioFOURCC('D', 'I', 'V', '6')
|
|
97 #define fccdiv6 mmioFOURCC('d', 'i', 'v', '6')
|
|
98 #define fccMP41 mmioFOURCC('M', 'P', '4', '1')
|
|
99 #define fccmp41 mmioFOURCC('m', 'p', '4', '1')
|
|
100 #define fccMP43 mmioFOURCC('M', 'P', '4', '3')
|
|
101 #define fccmp43 mmioFOURCC('m', 'p', '4', '3')
|
|
102 /* old ms mpeg-4 codecs */
|
|
103 #define fccMP42 mmioFOURCC('M', 'P', '4', '2')
|
|
104 #define fccmp42 mmioFOURCC('m', 'p', '4', '2')
|
|
105 #define fccMPG4 mmioFOURCC('M', 'P', 'G', '4')
|
|
106 #define fccmpg4 mmioFOURCC('m', 'p', 'g', '4')
|
|
107 /* Windows media codecs */
|
|
108 #define fccWMV1 mmioFOURCC('W', 'M', 'V', '1')
|
|
109 #define fccwmv1 mmioFOURCC('w', 'm', 'v', '1')
|
|
110 #define fccWMV2 mmioFOURCC('W', 'M', 'V', '2')
|
|
111 #define fccwmv2 mmioFOURCC('w', 'm', 'v', '2')
|
|
112 #define fccMWV1 mmioFOURCC('M', 'W', 'V', '1')
|
|
113
|
|
114 /* Angel codecs */
|
|
115 #define fccAP41 mmioFOURCC('A', 'P', '4', '1')
|
|
116 #define fccap41 mmioFOURCC('a', 'p', '4', '1')
|
|
117 #define fccAP42 mmioFOURCC('A', 'P', '4', '2')
|
|
118 #define fccap42 mmioFOURCC('a', 'p', '4', '2')
|
|
119
|
|
120 /* other codecs */
|
|
121 #define fccIV31 mmioFOURCC('I', 'V', '3', '1')
|
|
122 #define fcciv31 mmioFOURCC('i', 'v', '3', '1')
|
|
123 #define fccIV32 mmioFOURCC('I', 'V', '3', '2')
|
|
124 #define fcciv32 mmioFOURCC('i', 'v', '3', '2')
|
|
125 #define fccIV41 mmioFOURCC('I', 'V', '4', '1')
|
|
126 #define fcciv41 mmioFOURCC('i', 'v', '4', '1')
|
|
127 #define fccIV50 mmioFOURCC('I', 'V', '5', '0')
|
|
128 #define fcciv50 mmioFOURCC('i', 'v', '5', '0')
|
|
129 #define fccI263 mmioFOURCC('I', '2', '6', '3')
|
|
130 #define fcci263 mmioFOURCC('i', '2', '6', '3')
|
|
131
|
|
132 #define fccMJPG mmioFOURCC('M', 'J', 'P', 'G')
|
|
133 #define fccmjpg mmioFOURCC('m', 'j', 'p', 'g')
|
|
134
|
|
135 #define fccHFYU mmioFOURCC('H', 'F', 'Y', 'U')
|
|
136
|
|
137 #define fcccvid mmioFOURCC('c', 'v', 'i', 'd')
|
|
138 #define fccdvsd mmioFOURCC('d', 'v', 's', 'd')
|
|
139
|
|
140 /* Ati codecs */
|
|
141 #define fccVCR2 mmioFOURCC('V', 'C', 'R', '2')
|
|
142 #define fccVCR1 mmioFOURCC('V', 'C', 'R', '1')
|
|
143 #define fccVYUY mmioFOURCC('V', 'Y', 'U', 'Y')
|
|
144 #define fccYVU9 mmioFOURCC('I', 'Y', 'U', '9')
|
|
145
|
|
146 /* Asus codecs */
|
|
147 #define fccASV1 mmioFOURCC('A', 'S', 'V', '1')
|
|
148 #define fccASV2 mmioFOURCC('A', 'S', 'V', '2')
|
|
149
|
|
150 /* Microsoft video */
|
|
151 #define fcccram mmioFOURCC('c', 'r', 'a', 'm')
|
|
152 #define fccCRAM mmioFOURCC('C', 'R', 'A', 'M')
|
|
153 #define fccMSVC mmioFOURCC('M', 'S', 'V', 'C')
|
|
154
|
|
155
|
|
156 #define fccMSZH mmioFOURCC('M', 'S', 'Z', 'H')
|
|
157
|
|
158 #define fccZLIB mmioFOURCC('Z', 'L', 'I', 'B')
|
|
159
|
|
160 #define fccTM20 mmioFOURCC('T', 'M', '2', '0')
|
|
161
|
|
162 #define fccYUV mmioFOURCC('Y', 'U', 'V', ' ')
|
|
163 #define fccYUY2 mmioFOURCC('Y', 'U', 'Y', '2')
|
|
164 #define fccYV12 mmioFOURCC('Y', 'V', '1', '2')/* Planar mode: Y + V + U (3 planes) */
|
|
165 #define fccI420 mmioFOURCC('I', '4', '2', '0')
|
|
166 #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) */
|
|
168 #define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
|
169
|
|
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(){};
|
1558
|
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;
|
1545
|
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
|
|
325
|
|
326 #endif
|