xref: /reactos/sdk/include/psdk/vfw.h (revision 34593d93)
1 /*
2  * Copyright (C) the Wine project
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef __WINE_VFW_H
20 #define __WINE_VFW_H
21 
22 #include <mmsystem.h>
23 #include <mmreg.h>
24 #include <msacm.h>
25 
26 #define VFWAPI	WINAPI
27 #define VFWAPIV	WINAPIV
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif  /* __cplusplus */
32 
33 typedef HANDLE HDRAWDIB;
34 
35 /*****************************************************************************
36  * Predeclare the interfaces
37  */
38 typedef struct IAVIStream *PAVISTREAM;
39 typedef struct IAVIFile *PAVIFILE;
40 typedef struct IGetFrame *PGETFRAME;
41 typedef struct IAVIEditStream *PAVIEDITSTREAM;
42 
43 /* Installable Compressor Manager */
44 
45 #define ICVERSION 0x0104
46 
47 DECLARE_HANDLE(HIC);
48 
49 /* error return codes */
50 #define	ICERR_OK		0
51 #define	ICERR_DONTDRAW		1
52 #define	ICERR_NEWPALETTE	2
53 #define	ICERR_GOTOKEYFRAME	3
54 #define	ICERR_STOPDRAWING	4
55 
56 #define	ICERR_UNSUPPORTED	-1
57 #define	ICERR_BADFORMAT		-2
58 #define	ICERR_MEMORY		-3
59 #define	ICERR_INTERNAL		-4
60 #define	ICERR_BADFLAGS		-5
61 #define	ICERR_BADPARAM		-6
62 #define	ICERR_BADSIZE		-7
63 #define	ICERR_BADHANDLE		-8
64 #define	ICERR_CANTUPDATE	-9
65 #define	ICERR_ABORT		-10
66 #define	ICERR_ERROR		-100
67 #define	ICERR_BADBITDEPTH	-200
68 #define	ICERR_BADIMAGESIZE	-201
69 
70 #define	ICERR_CUSTOM		-400
71 
72 /* ICM Messages */
73 #define	ICM_USER		(DRV_USER+0x0000)
74 
75 /* ICM driver message range */
76 #define	ICM_RESERVED_LOW	(DRV_USER+0x1000)
77 #define	ICM_RESERVED_HIGH	(DRV_USER+0x2000)
78 #define	ICM_RESERVED		ICM_RESERVED_LOW
79 
80 #define	ICM_GETSTATE		(ICM_RESERVED+0)
81 #define	ICM_SETSTATE		(ICM_RESERVED+1)
82 #define	ICM_GETINFO		(ICM_RESERVED+2)
83 
84 #define	ICM_CONFIGURE		(ICM_RESERVED+10)
85 #define	ICM_ABOUT		(ICM_RESERVED+11)
86 /* */
87 
88 #define	ICM_GETDEFAULTQUALITY	(ICM_RESERVED+30)
89 #define	ICM_GETQUALITY		(ICM_RESERVED+31)
90 #define	ICM_SETQUALITY		(ICM_RESERVED+32)
91 
92 #define	ICM_SET			(ICM_RESERVED+40)
93 #define	ICM_GET			(ICM_RESERVED+41)
94 
95 /* 2 constant FOURCC codes */
96 #define ICM_FRAMERATE		mmioFOURCC('F','r','m','R')
97 #define ICM_KEYFRAMERATE	mmioFOURCC('K','e','y','R')
98 
99 #define	ICM_COMPRESS_GET_FORMAT		(ICM_USER+4)
100 #define	ICM_COMPRESS_GET_SIZE		(ICM_USER+5)
101 #define	ICM_COMPRESS_QUERY		(ICM_USER+6)
102 #define	ICM_COMPRESS_BEGIN		(ICM_USER+7)
103 #define	ICM_COMPRESS			(ICM_USER+8)
104 #define	ICM_COMPRESS_END		(ICM_USER+9)
105 
106 #define	ICM_DECOMPRESS_GET_FORMAT	(ICM_USER+10)
107 #define	ICM_DECOMPRESS_QUERY		(ICM_USER+11)
108 #define	ICM_DECOMPRESS_BEGIN		(ICM_USER+12)
109 #define	ICM_DECOMPRESS			(ICM_USER+13)
110 #define	ICM_DECOMPRESS_END		(ICM_USER+14)
111 #define	ICM_DECOMPRESS_SET_PALETTE	(ICM_USER+29)
112 #define	ICM_DECOMPRESS_GET_PALETTE	(ICM_USER+30)
113 
114 #define	ICM_DRAW_QUERY			(ICM_USER+31)
115 #define	ICM_DRAW_BEGIN			(ICM_USER+15)
116 #define	ICM_DRAW_GET_PALETTE		(ICM_USER+16)
117 #define	ICM_DRAW_START			(ICM_USER+18)
118 #define	ICM_DRAW_STOP			(ICM_USER+19)
119 #define	ICM_DRAW_END			(ICM_USER+21)
120 #define	ICM_DRAW_GETTIME		(ICM_USER+32)
121 #define	ICM_DRAW			(ICM_USER+33)
122 #define	ICM_DRAW_WINDOW			(ICM_USER+34)
123 #define	ICM_DRAW_SETTIME		(ICM_USER+35)
124 #define	ICM_DRAW_REALIZE		(ICM_USER+36)
125 #define	ICM_DRAW_FLUSH			(ICM_USER+37)
126 #define	ICM_DRAW_RENDERBUFFER		(ICM_USER+38)
127 
128 #define	ICM_DRAW_START_PLAY		(ICM_USER+39)
129 #define	ICM_DRAW_STOP_PLAY		(ICM_USER+40)
130 
131 #define	ICM_DRAW_SUGGESTFORMAT		(ICM_USER+50)
132 #define	ICM_DRAW_CHANGEPALETTE		(ICM_USER+51)
133 
134 #define	ICM_GETBUFFERSWANTED		(ICM_USER+41)
135 
136 #define	ICM_GETDEFAULTKEYFRAMERATE	(ICM_USER+42)
137 
138 #define	ICM_DECOMPRESSEX_BEGIN		(ICM_USER+60)
139 #define	ICM_DECOMPRESSEX_QUERY		(ICM_USER+61)
140 #define	ICM_DECOMPRESSEX		(ICM_USER+62)
141 #define	ICM_DECOMPRESSEX_END		(ICM_USER+63)
142 
143 #define	ICM_COMPRESS_FRAMES_INFO	(ICM_USER+70)
144 #define	ICM_SET_STATUS_PROC		(ICM_USER+72)
145 
146 #ifndef comptypeDIB
147 #define comptypeDIB  mmioFOURCC('D','I','B',' ')
148 #endif
149 
150 /* structs */
151 
152 /* NOTE: Only the 16 bit structs are packed. Structs that are packed anyway
153  * have not been changed. If a structure is later extended, you may need to create
154  * two versions of it.
155  */
156 
157 typedef struct {
158 	DWORD	dwSize;		/* 00: size */
159 	DWORD	fccType;	/* 04: type 'vidc' usually */
160 	DWORD	fccHandler;	/* 08: */
161 	DWORD	dwVersion;	/* 0c: version of compman opening you */
162 	DWORD	dwFlags;	/* 10: LOWORD is type specific */
163 	LRESULT	dwError;	/* 14: */
164 	LPVOID	pV1Reserved;	/* 18: */
165 	LPVOID	pV2Reserved;	/* 1c: */
166 	DWORD	dnDevNode;	/* 20: */
167 				/* 24: */
168 } ICOPEN,*LPICOPEN;
169 
170 #define ICCOMPRESS_KEYFRAME     0x00000001L
171 
172 typedef struct {
173   DWORD dwFlags;
174   LPBITMAPINFOHEADER lpbiOutput;
175   _Field_size_bytes_(lpbiOutput->biSizeImage) LPVOID lpOutput;
176   LPBITMAPINFOHEADER lpbiInput;
177   _Field_size_bytes_(lpbiInput->biSizeImage) LPVOID lpInput;
178   LPDWORD lpckid;
179   LPDWORD lpdwFlags;
180   LONG lFrameNum;
181   DWORD dwFrameSize;
182   DWORD dwQuality;
183   LPBITMAPINFOHEADER lpbiPrev;
184   _Field_size_bytes_(lpbiPrev->biSizeImage) LPVOID lpPrev;
185 } ICCOMPRESS;
186 
187 DWORD
188 VFWAPIV
189 ICCompress(
190   _In_ HIC hic,
191   _In_ DWORD dwFlags,
192   _In_ LPBITMAPINFOHEADER lpbiOutput,
193   _Out_writes_bytes_(lpbiOutput->biSizeImage) LPVOID lpData,
194   _In_ LPBITMAPINFOHEADER lpbiInput,
195   _In_reads_bytes_(lpbiInput->biSizeImage) LPVOID lpBits,
196   _Out_opt_ LPDWORD lpckid,
197   _Out_opt_ LPDWORD lpdwFlags,
198   _In_ LONG lFrameNum,
199   _In_ DWORD dwFrameSize,
200   _In_ DWORD dwQuality,
201   _In_opt_ LPBITMAPINFOHEADER lpbiPrev,
202   _In_reads_bytes_opt_(lpbiPrev->biSizeImage) LPVOID lpPrev);
203 
204 #define ICCompressGetFormat(hic, lpbiInput, lpbiOutput) 		\
205 	ICSendMessage(							\
206 	    hic,ICM_COMPRESS_GET_FORMAT,(DWORD_PTR)(LPVOID)(lpbiInput),	\
207 	    (DWORD_PTR)(LPVOID)(lpbiOutput)					\
208 	)
209 
210 #define ICCompressGetFormatSize(hic,lpbi) ICCompressGetFormat(hic,lpbi,NULL)
211 
212 #define ICCompressBegin(hic, lpbiInput, lpbiOutput) 			\
213     ICSendMessage(							\
214     	hic, ICM_COMPRESS_BEGIN, (DWORD_PTR)(LPVOID)(lpbiInput),		\
215 	(DWORD_PTR)(LPVOID)(lpbiOutput)					\
216     )
217 
218 #define ICCompressGetSize(hic, lpbiInput, lpbiOutput) 			\
219     ICSendMessage(							\
220     	hic, ICM_COMPRESS_GET_SIZE, (DWORD_PTR)(LPVOID)(lpbiInput), 	\
221 	(DWORD_PTR)(LPVOID)(lpbiOutput)					\
222     )
223 
224 #define ICCompressQuery(hic, lpbiInput, lpbiOutput)		\
225     ICSendMessage(						\
226     	hic, ICM_COMPRESS_QUERY, (DWORD_PTR)(LPVOID)(lpbiInput),	\
227 	(DWORD_PTR)(LPVOID)(lpbiOutput)				\
228     )
229 
230 #define ICCompressEnd(hic) ICSendMessage(hic, ICM_COMPRESS_END, 0, 0)
231 
232 /* ICCOMPRESSFRAMES.dwFlags */
233 #define ICCOMPRESSFRAMES_PADDING        0x00000001
234 typedef struct {
235     DWORD               dwFlags;
236     LPBITMAPINFOHEADER  lpbiOutput;
237     LPARAM              lOutput;
238     LPBITMAPINFOHEADER  lpbiInput;
239     LPARAM              lInput;
240     LONG                lStartFrame;
241     LONG                lFrameCount;
242     LONG                lQuality;
243     LONG                lDataRate;
244     LONG                lKeyRate;
245     DWORD               dwRate;
246     DWORD               dwScale;
247     DWORD               dwOverheadPerFrame;
248     DWORD               dwReserved2;
249     LONG (CALLBACK *GetData)(_In_ LPARAM lInput, _In_ LONG lFrame, _Out_writes_bytes_(len) LPVOID lpBits, _In_ LONG len);
250     LONG (CALLBACK *PutData)(_In_ LPARAM lOutput, _In_ LONG lFrame, _In_reads_bytes_(len) LPVOID lpBits, _In_ LONG len);
251 } ICCOMPRESSFRAMES;
252 
253 typedef struct {
254     DWORD		dwFlags;
255     LPARAM		lParam;
256    /* messages for Status callback */
257 #define ICSTATUS_START	    0
258 #define ICSTATUS_STATUS	    1
259 #define ICSTATUS_END	    2
260 #define ICSTATUS_ERROR	    3
261 #define ICSTATUS_YIELD	    4
262     /* FIXME: some X11 libs define Status as int... */
263     /* LONG (CALLBACK *zStatus)(LPARAM lParam, UINT message, LONG l); */
264     LONG (CALLBACK *zStatus)(LPARAM lParam, UINT message, LONG l);
265 } ICSETSTATUSPROC;
266 
267 /* Values for wMode of ICOpen() */
268 #define	ICMODE_COMPRESS		1
269 #define	ICMODE_DECOMPRESS	2
270 #define	ICMODE_FASTDECOMPRESS	3
271 #define	ICMODE_QUERY		4
272 #define	ICMODE_FASTCOMPRESS	5
273 #define	ICMODE_DRAW		8
274 
275 /* quality flags */
276 #define ICQUALITY_LOW       0
277 #define ICQUALITY_HIGH      10000
278 #define ICQUALITY_DEFAULT   -1
279 
280 typedef struct {
281 	DWORD	dwSize;		/* 00: */
282 	DWORD	fccType;	/* 04:compressor type     'vidc' 'audc' */
283 	DWORD	fccHandler;	/* 08:compressor sub-type 'rle ' 'jpeg' 'pcm '*/
284 	DWORD	dwFlags;	/* 0c:flags LOWORD is type specific */
285 	DWORD	dwVersion;	/* 10:version of the driver */
286 	DWORD	dwVersionICM;	/* 14:version of the ICM used */
287 	/*
288 	 * under Win32, the driver always returns UNICODE strings.
289 	 */
290 	WCHAR	szName[16];		/* 18:short name */
291 	WCHAR	szDescription[128];	/* 38:long name */
292 	WCHAR	szDriver[128];		/* 138:driver that contains compressor*/
293 					/* 238: */
294 } ICINFO;
295 
296 /* ICINFO.dwFlags */
297 #define	VIDCF_QUALITY		0x0001  /* supports quality */
298 #define	VIDCF_CRUNCH		0x0002  /* supports crunching to a frame size */
299 #define	VIDCF_TEMPORAL		0x0004  /* supports inter-frame compress */
300 #define	VIDCF_COMPRESSFRAMES	0x0008  /* wants the compress all frames message */
301 #define	VIDCF_DRAW		0x0010  /* supports drawing */
302 #define	VIDCF_FASTTEMPORALC	0x0020  /* does not need prev frame on compress */
303 #define	VIDCF_FASTTEMPORALD	0x0080  /* does not need prev frame on decompress */
304 #define	VIDCF_QUALITYTIME	0x0040  /* supports temporal quality */
305 
306 #define	VIDCF_FASTTEMPORAL	(VIDCF_FASTTEMPORALC|VIDCF_FASTTEMPORALD)
307 
308 
309 /* function shortcuts */
310 /* ICM_ABOUT */
311 #define ICMF_ABOUT_QUERY         0x00000001
312 
313 #define ICQueryAbout(hic) \
314 	(ICSendMessage(hic,ICM_ABOUT,(DWORD_PTR)-1,ICMF_ABOUT_QUERY)==ICERR_OK)
315 
316 #define ICAbout(hic, hwnd) ICSendMessage(hic,ICM_ABOUT,(DWORD_PTR)(UINT_PTR)(hwnd),0)
317 
318 /* ICM_CONFIGURE */
319 #define ICMF_CONFIGURE_QUERY	0x00000001
320 #define ICQueryConfigure(hic) \
321 	(ICSendMessage(hic,ICM_CONFIGURE,(DWORD_PTR)-1,ICMF_CONFIGURE_QUERY)==ICERR_OK)
322 
323 #define ICConfigure(hic,hwnd) \
324 	ICSendMessage(hic,ICM_CONFIGURE,(DWORD_PTR)(UINT_PTR)(hwnd),0)
325 
326 /* Decompression stuff */
327 #define ICDECOMPRESS_HURRYUP		0x80000000	/* don't draw just buffer (hurry up!) */
328 #define ICDECOMPRESS_UPDATE		0x40000000	/* don't draw just update screen */
329 #define ICDECOMPRESS_PREROLL		0x20000000	/* this frame is before real start */
330 #define ICDECOMPRESS_NULLFRAME		0x10000000	/* repeat last frame */
331 #define ICDECOMPRESS_NOTKEYFRAME	0x08000000	/* this frame is not a key frame */
332 
333 typedef struct {
334   DWORD dwFlags; /* flags (from AVI index...) */
335   LPBITMAPINFOHEADER lpbiInput; /* BITMAPINFO of compressed data */
336   _Field_size_bytes_(lpbiInput->biSizeImage) LPVOID lpInput; /* compressed data */
337   LPBITMAPINFOHEADER lpbiOutput; /* DIB to decompress to */
338   _Field_size_bytes_(lpbiOutput->biSizeImage) LPVOID	 lpOutput;
339   DWORD ckid; /* ckid from AVI file */
340 } ICDECOMPRESS;
341 
342 typedef struct {
343     DWORD		dwFlags;
344     LPBITMAPINFOHEADER	lpbiSrc;
345     LPVOID		lpSrc;
346     LPBITMAPINFOHEADER	lpbiDst;
347     LPVOID		lpDst;
348 
349     /* changed for ICM_DECOMPRESSEX */
350     INT			xDst;       /* destination rectangle */
351     INT			yDst;
352     INT			dxDst;
353     INT			dyDst;
354 
355     INT			xSrc;       /* source rectangle */
356     INT			ySrc;
357     INT			dxSrc;
358     INT			dySrc;
359 } ICDECOMPRESSEX;
360 
361 DWORD
362 VFWAPIV
363 ICDecompress(
364   _In_ HIC hic,
365   _In_ DWORD dwFlags,
366   _In_ LPBITMAPINFOHEADER lpbiFormat,
367   _In_reads_bytes_(lpbiFormat->biSizeImage) LPVOID lpData,
368   _In_ LPBITMAPINFOHEADER lpbi,
369   _Out_writes_bytes_(lpbi->biSizeImage) LPVOID lpBits);
370 
371 #define ICDecompressBegin(hic, lpbiInput, lpbiOutput) 	\
372     ICSendMessage(						\
373     	hic, ICM_DECOMPRESS_BEGIN, (DWORD_PTR)(LPVOID)(lpbiInput),	\
374 	(DWORD_PTR)(LPVOID)(lpbiOutput)				\
375     )
376 
377 #define ICDecompressQuery(hic, lpbiInput, lpbiOutput) 	\
378     ICSendMessage(						\
379     	hic,ICM_DECOMPRESS_QUERY, (DWORD_PTR)(LPVOID)(lpbiInput),	\
380 	(DWORD_PTR) (LPVOID)(lpbiOutput)				\
381     )
382 
383 #define ICDecompressGetFormat(hic, lpbiInput, lpbiOutput)		\
384     ((LONG)ICSendMessage(						\
385     	hic,ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)(LPVOID)(lpbiInput),	\
386 	(DWORD_PTR)(LPVOID)(lpbiOutput)					\
387     ))
388 
389 #define ICDecompressGetFormatSize(hic, lpbi) 				\
390 	ICDecompressGetFormat(hic, lpbi, NULL)
391 
392 #define ICDecompressGetPalette(hic, lpbiInput, lpbiOutput)		\
393     ICSendMessage(							\
394     	hic, ICM_DECOMPRESS_GET_PALETTE, (DWORD_PTR)(LPVOID)(lpbiInput), 	\
395 	(DWORD_PTR)(LPVOID)(lpbiOutput)					\
396     )
397 
398 #define ICDecompressSetPalette(hic,lpbiPalette)	\
399         ICSendMessage(				\
400 		hic,ICM_DECOMPRESS_SET_PALETTE,		\
401 		(DWORD_PTR)(LPVOID)(lpbiPalette),0		\
402 	)
403 
404 #define ICDecompressEnd(hic) ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0)
405 
406 LRESULT
407 VFWAPI
408 ICSendMessage(
409   _In_ HIC hic,
410   _In_ UINT msg,
411   _In_ DWORD_PTR dw1,
412   _In_ DWORD_PTR dw2);
413 
414 static inline
415 LRESULT
416 VFWAPI
417 ICDecompressEx(_In_ HIC hic,
418                _In_ DWORD dwFlags,
419                _In_ LPBITMAPINFOHEADER lpbiSrc,
420                _In_reads_bytes_(lpbiSrc->biSizeImage) LPVOID lpSrc,
421                _In_ int xSrc,
422                _In_ int ySrc,
423                _In_ int dxSrc,
424                _In_ int dySrc,
425                _In_ LPBITMAPINFOHEADER lpbiDst,
426                _Out_writes_bytes_(lpbiDst->biSizeImage) LPVOID lpDst,
427                _In_ int xDst,
428                _In_ int yDst,
429                _In_ int dxDst,
430                _In_ int dyDst)
431 {
432     ICDECOMPRESSEX ic;
433 
434     ic.dwFlags = dwFlags;
435     ic.lpbiSrc = lpbiSrc;
436     ic.lpSrc = lpSrc;
437     ic.xSrc = xSrc;
438     ic.ySrc = ySrc;
439     ic.dxSrc = dxSrc;
440     ic.dySrc = dySrc;
441     ic.lpbiDst = lpbiDst;
442     ic.lpDst = lpDst;
443     ic.xDst = xDst;
444     ic.yDst = yDst;
445     ic.dxDst = dxDst;
446     ic.dyDst = dyDst;
447     return ICSendMessage(hic, ICM_DECOMPRESSEX, (DWORD_PTR)&ic, sizeof(ic));
448 }
449 
450 static inline
451 LRESULT
452 VFWAPI
ICDecompressExBegin(_In_ HIC hic,_In_ DWORD dwFlags,_In_ LPBITMAPINFOHEADER lpbiSrc,_In_opt_ LPVOID lpSrc,_In_ int xSrc,_In_ int ySrc,_In_ int dxSrc,_In_ int dySrc,_In_ LPBITMAPINFOHEADER lpbiDst,_Out_opt_ LPVOID lpDst,_In_ int xDst,_In_ int yDst,_In_ int dxDst,_In_ int dyDst)453 ICDecompressExBegin(_In_ HIC hic,
454                     _In_ DWORD dwFlags,
455                     _In_ LPBITMAPINFOHEADER lpbiSrc,
456                     _In_opt_ LPVOID lpSrc,
457                     _In_ int xSrc,
458                     _In_ int ySrc,
459                     _In_ int dxSrc,
460                     _In_ int dySrc,
461                     _In_ LPBITMAPINFOHEADER lpbiDst,
462                     _Out_opt_ LPVOID lpDst,
463                     _In_ int xDst,
464                     _In_ int yDst,
465                     _In_ int dxDst,
466                     _In_ int dyDst)
467 {
468     ICDECOMPRESSEX ic;
469 
470     ic.dwFlags = dwFlags;
471     ic.lpbiSrc = lpbiSrc;
472     ic.lpSrc = lpSrc;
473     ic.xSrc = xSrc;
474     ic.ySrc = ySrc;
475     ic.dxSrc = dxSrc;
476     ic.dySrc = dySrc;
477     ic.lpbiDst = lpbiDst;
478     ic.lpDst = lpDst;
479     ic.xDst = xDst;
480     ic.yDst = yDst;
481     ic.dxDst = dxDst;
482     ic.dyDst = dyDst;
483     return ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, (DWORD_PTR)&ic, sizeof(ic));
484 }
485 
486 static inline
487 LRESULT
488 VFWAPI
ICDecompressExQuery(_In_ HIC hic,_In_ DWORD dwFlags,_In_ LPBITMAPINFOHEADER lpbiSrc,_Reserved_ LPVOID lpSrc,_In_ int xSrc,_In_ int ySrc,_In_ int dxSrc,_In_ int dySrc,_In_opt_ LPBITMAPINFOHEADER lpbiDst,_Out_opt_ LPVOID lpDst,_In_ int xDst,_In_ int yDst,_In_ int dxDst,_In_ int dyDst)489 ICDecompressExQuery(_In_ HIC hic,
490                     _In_ DWORD dwFlags,
491                     _In_ LPBITMAPINFOHEADER lpbiSrc,
492                     _Reserved_ LPVOID lpSrc,
493                     _In_ int xSrc,
494                     _In_ int ySrc,
495                     _In_ int dxSrc,
496                     _In_ int dySrc,
497                     _In_opt_ LPBITMAPINFOHEADER lpbiDst,
498                     _Out_opt_ LPVOID lpDst,
499                     _In_ int xDst,
500                     _In_ int yDst,
501                     _In_ int dxDst,
502                     _In_ int dyDst)
503 {
504     ICDECOMPRESSEX ic;
505 
506     ic.dwFlags = dwFlags;
507     ic.lpbiSrc = lpbiSrc;
508     ic.lpSrc = lpSrc;
509     ic.xSrc = xSrc;
510     ic.ySrc = ySrc;
511     ic.dxSrc = dxSrc;
512     ic.dySrc = dySrc;
513     ic.lpbiDst = lpbiDst;
514     ic.lpDst = lpDst;
515     ic.xDst = xDst;
516     ic.yDst = yDst;
517     ic.dxDst = dxDst;
518     ic.dyDst = dyDst;
519     return ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, (DWORD_PTR)&ic, sizeof(ic));
520 }
521 
522 #define ICDecompressExEnd(hic) \
523     ICSendMessage(hic, ICM_DECOMPRESSEX_END, 0, 0)
524 
525 #define ICDRAW_QUERY        0x00000001L   /* test for support */
526 #define ICDRAW_FULLSCREEN   0x00000002L   /* draw to full screen */
527 #define ICDRAW_HDC          0x00000004L   /* draw to a HDC/HWND */
528 #define ICDRAW_ANIMATE	    0x00000008L	  /* expect palette animation */
529 #define ICDRAW_CONTINUE	    0x00000010L	  /* draw is a continuation of previous draw */
530 #define ICDRAW_MEMORYDC	    0x00000020L	  /* DC is offscreen, by the way */
531 #define ICDRAW_UPDATING	    0x00000040L	  /* We're updating, as opposed to playing */
532 #define ICDRAW_RENDER       0x00000080L   /* used to render data not draw it */
533 #define ICDRAW_BUFFER       0x00000100L   /* buffer data offscreen, we will need to update it */
534 
535 #define ICDecompressOpen(fccType, fccHandler, lpbiIn, lpbiOut) \
536     ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS)
537 
538 #define ICDrawOpen(fccType, fccHandler, lpbiIn) \
539     ICLocate(fccType, fccHandler, lpbiIn, NULL, ICMODE_DRAW)
540 
541 HANDLE
542 VFWAPI
543 ICImageCompress(
544   _In_ HIC hic,
545   _In_ UINT uiFlags,
546   _In_ LPBITMAPINFO lpbiIn,
547   _In_ LPVOID lpBits,
548   _In_opt_ LPBITMAPINFO lpbiOut,
549   _In_ LONG lQuality,
550   _Inout_opt_ LONG* plSize);
551 
552 HANDLE
553 VFWAPI
554 ICImageDecompress(
555   _In_opt_ HIC hic,
556   _In_ UINT uiFlags,
557   _In_ LPBITMAPINFO lpbiIn,
558   _In_ LPVOID lpBits,
559   _In_opt_ LPBITMAPINFO lpbiOut);
560 
561 BOOL
562 VFWAPI
563 ICInfo(
564   _In_ DWORD fccType,
565   _In_ DWORD fccHandler,
566   _Out_ ICINFO * lpicinfo);
567 
568 BOOL
569 VFWAPI
570 ICInstall(
571   _In_ DWORD fccType,
572   _In_ DWORD fccHandler,
573   _In_ LPARAM lParam,
574   _In_ LPSTR szDesc,
575   _In_ UINT wFlags);
576 
577 BOOL
578 VFWAPI
579 ICRemove(
580   _In_ DWORD fccType,
581   _In_ DWORD fccHandler,
582   _In_ UINT wFlags);
583 
584 _Success_(return != 0)
585 LRESULT
586 VFWAPI
587 ICGetInfo(
588   _In_ HIC hic,
589   _Out_writes_bytes_to_(cb, return) ICINFO *picinfo,
590   _In_ DWORD cb);
591 
592 HIC VFWAPI ICOpen(_In_ DWORD fccType, _In_ DWORD fccHandler, _In_ UINT wMode);
593 
594 HIC
595 VFWAPI
596 ICOpenFunction(
597   _In_ DWORD fccType,
598   _In_ DWORD fccHandler,
599   _In_ UINT wMode,
600   _In_ DRIVERPROC lpfnHandler);
601 
602 LRESULT VFWAPI ICClose(_In_ HIC hic);
603 
604 HIC
605 VFWAPI
606 ICLocate(
607   _In_ DWORD fccType,
608   _In_ DWORD fccHandler,
609   _In_ LPBITMAPINFOHEADER lpbiIn,
610   _In_opt_ LPBITMAPINFOHEADER lpbiOut,
611   _In_ WORD wFlags);
612 
613 HIC
614 VFWAPI
615 ICGetDisplayFormat(
616   _In_opt_ HIC hic,
617   _In_ LPBITMAPINFOHEADER lpbiIn,
618   _Out_ LPBITMAPINFOHEADER lpbiOut,
619   _In_ int BitDepth,
620   _In_ int dx,
621   _In_ int dy);
622 
623 /* Values for wFlags of ICInstall() */
624 #define ICINSTALL_UNICODE       0x8000
625 #define ICINSTALL_FUNCTION      0x0001
626 #define ICINSTALL_DRIVER        0x0002
627 #define ICINSTALL_HDRV          0x0004
628 #define ICINSTALL_DRIVERW       0x8002
629 
630 #define ICGetState(hic, pv, cb) \
631     ICSendMessage(hic, ICM_GETSTATE, (DWORD_PTR)(LPVOID)(pv), (DWORD_PTR)(cb))
632 #define ICSetState(hic, pv, cb) \
633     ICSendMessage(hic, ICM_SETSTATE, (DWORD_PTR)(LPVOID)(pv), (DWORD_PTR)(cb))
634 #define ICGetStateSize(hic) \
635     ICGetState(hic, NULL, 0)
636 
ICGetDefaultQuality(HIC hic)637 static inline DWORD ICGetDefaultQuality(HIC hic)
638 {
639    DWORD dwICValue;
640    ICSendMessage(hic, ICM_GETDEFAULTQUALITY, (DWORD_PTR)(LPVOID)&dwICValue, sizeof(DWORD));
641    return dwICValue;
642 }
643 
ICGetDefaultKeyFrameRate(HIC hic)644 static inline DWORD ICGetDefaultKeyFrameRate(HIC hic)
645 {
646    DWORD dwICValue;
647    ICSendMessage(hic, ICM_GETDEFAULTKEYFRAMERATE, (DWORD_PTR)(LPVOID)&dwICValue, sizeof(DWORD));
648    return dwICValue;
649 }
650 
651 #define ICDrawWindow(hic, prc) \
652     ICSendMessage(hic, ICM_DRAW_WINDOW, (DWORD_PTR)(LPVOID)(prc), sizeof(RECT))
653 
654 /* As passed to ICM_DRAW_SUGGESTFORMAT */
655 typedef struct {
656 	DWORD dwFlags;
657 	LPBITMAPINFOHEADER lpbiIn;
658 	LPBITMAPINFOHEADER lpbiSuggest;
659 	INT dxSrc;
660 	INT dySrc;
661 	INT dxDst;
662 	INT dyDst;
663 	HIC hicDecompressor;
664 } ICDRAWSUGGEST;
665 
666 typedef struct {
667     DWORD               dwFlags;
668     int                 iStart;
669     int                 iLen;
670     LPPALETTEENTRY      lppe;
671 } ICPALETTE;
672 
673 DWORD
674 VFWAPIV
675 ICDrawBegin(
676   _In_ HIC hic,
677   _In_ DWORD dwFlags,
678   _In_opt_ HPALETTE hpal,
679   _In_opt_ HWND hwnd,
680   _In_opt_ HDC hdc,
681   _In_ INT xDst,
682   _In_ INT yDst,
683   _In_ INT dxDst,
684   _In_ INT dyDst,
685   _In_ LPBITMAPINFOHEADER lpbi,
686   _In_ INT xSrc,
687   _In_ INT ySrc,
688   _In_ INT dxSrc,
689   _In_ INT dySrc,
690   _In_ DWORD dwRate,
691   _In_ DWORD dwScale);
692 
693 /* as passed to ICM_DRAW_BEGIN */
694 typedef struct {
695 	DWORD		dwFlags;
696 	HPALETTE	hpal;
697 	HWND		hwnd;
698 	HDC		hdc;
699 	INT		xDst;
700 	INT		yDst;
701 	INT		dxDst;
702 	INT		dyDst;
703 	LPBITMAPINFOHEADER	lpbi;
704 	INT		xSrc;
705 	INT		ySrc;
706 	INT		dxSrc;
707 	INT		dySrc;
708 	DWORD		dwRate;
709 	DWORD		dwScale;
710 } ICDRAWBEGIN;
711 
712 #define ICDRAW_HURRYUP      0x80000000L   /* don't draw just buffer (hurry up!) */
713 #define ICDRAW_UPDATE       0x40000000L   /* don't draw just update screen */
714 #define ICDRAW_PREROLL      0x20000000L   /* this frame is before real start */
715 #define ICDRAW_NULLFRAME    0x10000000L   /* repeat last frame */
716 #define ICDRAW_NOTKEYFRAME  0x08000000L   /* this frame is not a key frame */
717 
718 typedef struct {
719 	DWORD	dwFlags;
720 	LPVOID	lpFormat;
721 	LPVOID	lpData;
722 	DWORD	cbData;
723 	LONG	lTime;
724 } ICDRAW;
725 
726 DWORD
727 VFWAPIV
728 ICDraw(
729   _In_ HIC hic,
730   _In_ DWORD dwFlags,
731   _In_ LPVOID lpFormat,
732   _In_reads_bytes_opt_(cbData) LPVOID lpData,
733   _In_ DWORD cbData,
734   _In_ LONG lTime);
735 
736 static inline
737 LRESULT
738 VFWAPI
ICDrawSuggestFormat(_In_ HIC hic,_In_ LPBITMAPINFOHEADER lpbiIn,_Out_ LPBITMAPINFOHEADER lpbiOut,_In_ int dxSrc,_In_ int dySrc,_In_ int dxDst,_In_ int dyDst,_In_ HIC hicDecomp)739 ICDrawSuggestFormat(_In_ HIC hic,
740                     _In_ LPBITMAPINFOHEADER lpbiIn,
741                     _Out_ LPBITMAPINFOHEADER lpbiOut,
742                     _In_ int dxSrc,
743                     _In_ int dySrc,
744                     _In_ int dxDst,
745                     _In_ int dyDst,
746                     _In_ HIC hicDecomp)
747 {
748     ICDRAWSUGGEST ic;
749 
750     ic.lpbiIn = lpbiIn;
751     ic.lpbiSuggest = lpbiOut;
752     ic.dxSrc = dxSrc;
753     ic.dySrc = dySrc;
754     ic.dxDst = dxDst;
755     ic.dyDst = dyDst;
756     ic.hicDecompressor = hicDecomp;
757     return ICSendMessage(hic, ICM_DRAW_SUGGESTFORMAT, (DWORD_PTR)&ic, sizeof(ic));
758 }
759 
760 #define ICDrawQuery(hic, lpbiInput) \
761     ICSendMessage(hic, ICM_DRAW_QUERY, (DWORD_PTR)(LPVOID)(lpbiInput), 0L)
762 
763 #define ICDrawChangePalette(hic, lpbiInput) \
764     ICSendMessage(hic, ICM_DRAW_CHANGEPALETTE, (DWORD_PTR)(LPVOID)(lpbiInput), 0L)
765 
766 #define ICGetBuffersWanted(hic, lpdwBuffers) \
767     ICSendMessage(hic, ICM_GETBUFFERSWANTED, (DWORD_PTR)(LPVOID)(lpdwBuffers), 0)
768 
769 #define ICDrawEnd(hic) \
770     ICSendMessage(hic, ICM_DRAW_END, 0, 0)
771 
772 #define ICDrawStart(hic) \
773     ICSendMessage(hic, ICM_DRAW_START, 0, 0)
774 
775 #define ICDrawStartPlay(hic, lFrom, lTo) \
776     ICSendMessage(hic, ICM_DRAW_START_PLAY, (DWORD_PTR)(lFrom), (DWORD_PTR)(lTo))
777 
778 #define ICDrawStop(hic) \
779     ICSendMessage(hic, ICM_DRAW_STOP, 0, 0)
780 
781 #define ICDrawStopPlay(hic) \
782     ICSendMessage(hic, ICM_DRAW_STOP_PLAY, 0, 0)
783 
784 #define ICDrawGetTime(hic, lplTime) \
785     ICSendMessage(hic, ICM_DRAW_GETTIME, (DWORD_PTR)(LPVOID)(lplTime), 0)
786 
787 #define ICDrawSetTime(hic, lTime) \
788     ICSendMessage(hic, ICM_DRAW_SETTIME, (DWORD_PTR)lTime, 0)
789 
790 #define ICDrawRealize(hic, hdc, fBackground) \
791     ICSendMessage(hic, ICM_DRAW_REALIZE, (DWORD_PTR)(UINT_PTR)(HDC)(hdc), (DWORD_PTR)(BOOL)(fBackground))
792 
793 #define ICDrawFlush(hic) \
794     ICSendMessage(hic, ICM_DRAW_FLUSH, 0, 0)
795 
796 #define ICDrawRenderBuffer(hic) \
797     ICSendMessage(hic, ICM_DRAW_RENDERBUFFER, 0, 0)
798 
799 static inline
800 LRESULT
801 VFWAPI
ICSetStatusProc(_In_ HIC hic,_In_ DWORD dwFlags,_In_ LRESULT lParam,_In_ LONG (CALLBACK * fpfnStatus)(_In_ LPARAM,_In_ UINT,_In_ LONG))802 ICSetStatusProc(_In_ HIC hic,
803                 _In_ DWORD dwFlags,
804                 _In_ LRESULT lParam,
805                 _In_ LONG(CALLBACK *fpfnStatus)(_In_ LPARAM, _In_ UINT, _In_ LONG))
806 {
807     ICSETSTATUSPROC ic;
808 
809     ic.dwFlags = dwFlags;
810     ic.lParam = lParam;
811     /* FIXME: see comment in ICSETSTATUSPROC definition */
812     ic.zStatus = fpfnStatus;
813 
814     return ICSendMessage(hic, ICM_SET_STATUS_PROC, (DWORD_PTR)&ic, sizeof(ic));
815 }
816 
817 typedef struct {
818     LONG		cbSize;
819     DWORD		dwFlags;
820     HIC			hic;
821     DWORD               fccType;
822     DWORD               fccHandler;
823     LPBITMAPINFO	lpbiIn;
824     LPBITMAPINFO	lpbiOut;
825     LPVOID		lpBitsOut;
826     LPVOID		lpBitsPrev;
827     LONG		lFrame;
828     LONG		lKey;
829     LONG		lDataRate;
830     LONG		lQ;
831     LONG		lKeyCount;
832     LPVOID		lpState;
833     LONG		cbState;
834 } COMPVARS, *PCOMPVARS;
835 
836 #define ICMF_COMPVARS_VALID	0x00000001
837 
838 BOOL
839 VFWAPI
840 ICCompressorChoose(
841   _In_opt_ HWND hwnd,
842   _In_ UINT uiFlags,
843   _In_opt_ LPVOID pvIn,
844   _In_opt_ LPVOID lpData,
845   _Inout_ PCOMPVARS pc,
846   _In_opt_ LPSTR lpszTitle);
847 
848 #define ICMF_CHOOSE_KEYFRAME		0x0001
849 #define ICMF_CHOOSE_DATARATE		0x0002
850 #define ICMF_CHOOSE_PREVIEW		0x0004
851 #define ICMF_CHOOSE_ALLCOMPRESSORS	0x0008
852 
853 BOOL
854 VFWAPI
855 ICSeqCompressFrameStart(
856   _In_ PCOMPVARS pc,
857   _In_ LPBITMAPINFO lpbiIn);
858 
859 void VFWAPI ICSeqCompressFrameEnd(_In_ PCOMPVARS pc);
860 
861 LPVOID
862 VFWAPI
863 ICSeqCompressFrame(
864   _In_ PCOMPVARS pc,
865   _Reserved_ UINT uiFlags,
866   _In_ LPVOID lpBits,
867   _Out_ BOOL *pfKey,
868   _Inout_opt_ LONG *plSize);
869 
870 void VFWAPI ICCompressorFree(_In_ PCOMPVARS pc);
871 
872 /********************* AVIFILE function declarations *************************/
873 
874 #ifndef mmioFOURCC
875 #define mmioFOURCC( ch0, ch1, ch2, ch3 )				\
876 	( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) |		\
877 	( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
878 #endif
879 
880 #ifndef aviTWOCC
881 #define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
882 #endif
883 
884 typedef WORD TWOCC;
885 
886 #define ICTYPE_VIDEO		mmioFOURCC('v', 'i', 'd', 'c')
887 #define ICTYPE_AUDIO		mmioFOURCC('a', 'u', 'd', 'c')
888 
889 #define formtypeAVI             mmioFOURCC('A', 'V', 'I', ' ')
890 #define listtypeAVIHEADER       mmioFOURCC('h', 'd', 'r', 'l')
891 #define ckidAVIMAINHDR          mmioFOURCC('a', 'v', 'i', 'h')
892 #define listtypeSTREAMHEADER    mmioFOURCC('s', 't', 'r', 'l')
893 #define ckidSTREAMHEADER        mmioFOURCC('s', 't', 'r', 'h')
894 #define ckidSTREAMFORMAT        mmioFOURCC('s', 't', 'r', 'f')
895 #define ckidSTREAMHANDLERDATA   mmioFOURCC('s', 't', 'r', 'd')
896 #define ckidSTREAMNAME		mmioFOURCC('s', 't', 'r', 'n')
897 
898 #define listtypeAVIMOVIE        mmioFOURCC('m', 'o', 'v', 'i')
899 #define listtypeAVIRECORD       mmioFOURCC('r', 'e', 'c', ' ')
900 
901 #define ckidAVINEWINDEX         mmioFOURCC('i', 'd', 'x', '1')
902 
903 #define streamtypeANY           0UL
904 #define streamtypeVIDEO         mmioFOURCC('v', 'i', 'd', 's')
905 #define streamtypeAUDIO         mmioFOURCC('a', 'u', 'd', 's')
906 #define streamtypeMIDI          mmioFOURCC('m', 'i', 'd', 's')
907 #define streamtypeTEXT          mmioFOURCC('t', 'x', 't', 's')
908 
909 /* Basic chunk types */
910 #define cktypeDIBbits           aviTWOCC('d', 'b')
911 #define cktypeDIBcompressed     aviTWOCC('d', 'c')
912 #define cktypePALchange         aviTWOCC('p', 'c')
913 #define cktypeWAVEbytes         aviTWOCC('w', 'b')
914 
915 /* Chunk id to use for extra chunks for padding. */
916 #define ckidAVIPADDING          mmioFOURCC('J', 'U', 'N', 'K')
917 
918 #define FromHex(n)		(((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
919 #define StreamFromFOURCC(fcc)	((WORD)((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
920 					(FromHex(HIBYTE(LOWORD(fcc))))))
921 #define TWOCCFromFOURCC(fcc)    HIWORD(fcc)
922 #define ToHex(n)		((BYTE)(((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
923 #define MAKEAVICKID(tcc, stream) \
924                                 MAKELONG((ToHex((stream) & 0x0f) << 8) | \
925 			                 (ToHex(((stream) & 0xf0) >> 4)), tcc)
926 
927 /* AVIFileHdr.dwFlags */
928 #define AVIF_HASINDEX		0x00000010	/* Index at end of file? */
929 #define AVIF_MUSTUSEINDEX	0x00000020
930 #define AVIF_ISINTERLEAVED	0x00000100
931 #define AVIF_TRUSTCKTYPE	0x00000800	/* Use CKType to find key frames*/
932 #define AVIF_WASCAPTUREFILE	0x00010000
933 #define AVIF_COPYRIGHTED	0x00020000
934 
935 #define AVI_HEADERSIZE	2048
936 
937 typedef BOOL (CALLBACK *AVISAVECALLBACK)(INT);
938 
939 typedef struct _MainAVIHeader
940 {
941     DWORD	dwMicroSecPerFrame;
942     DWORD	dwMaxBytesPerSec;
943     DWORD	dwPaddingGranularity;
944     DWORD	dwFlags;
945     DWORD	dwTotalFrames;
946     DWORD	dwInitialFrames;
947     DWORD	dwStreams;
948     DWORD	dwSuggestedBufferSize;
949     DWORD	dwWidth;
950     DWORD	dwHeight;
951     DWORD	dwReserved[4];
952 } MainAVIHeader;
953 
954 /* AVIStreamHeader.dwFlags */
955 #define AVISF_DISABLED                  0x00000001
956 #define AVISF_VIDEO_PALCHANGES          0x00010000
957 
958 typedef struct {
959     FOURCC	fccType;
960     FOURCC	fccHandler;
961     DWORD	dwFlags;        /* AVISF_* */
962     WORD	wPriority;
963     WORD	wLanguage;
964     DWORD	dwInitialFrames;
965     DWORD	dwScale;
966     DWORD	dwRate; /* dwRate / dwScale == samples/second */
967     DWORD	dwStart;
968     DWORD	dwLength; /* In units above... */
969     DWORD	dwSuggestedBufferSize;
970     DWORD	dwQuality;
971     DWORD	dwSampleSize;
972     struct { SHORT left, top, right, bottom; } rcFrame; /* word.word - word.word in file */
973 } AVIStreamHeader;
974 
975 /* AVIINDEXENTRY.dwFlags */
976 #define AVIIF_LIST	0x00000001	/* chunk is a 'LIST' */
977 #define AVIIF_TWOCC	0x00000002
978 #define AVIIF_KEYFRAME	0x00000010	/* this frame is a key frame. */
979 #define AVIIF_FIRSTPART 0x00000020
980 #define AVIIF_LASTPART  0x00000040
981 #define AVIIF_MIDPART   (AVIIF_LASTPART|AVIIF_FIRSTPART)
982 #define AVIIF_NOTIME	0x00000100	/* this frame doesn't take any time */
983 #define AVIIF_COMPUSE	0x0FFF0000
984 
985 typedef struct _AVIINDEXENTRY {
986     DWORD	ckid;
987     DWORD	dwFlags;
988     DWORD	dwChunkOffset;
989     DWORD	dwChunkLength;
990 } AVIINDEXENTRY;
991 
992 typedef struct _AVIPALCHANGE {
993     BYTE		bFirstEntry;
994     BYTE		bNumEntries;
995     WORD		wFlags;		/* pad */
996     PALETTEENTRY	peNew[1];
997 } AVIPALCHANGE;
998 
999 #define AVIIF_KEYFRAME	0x00000010	/* this frame is a key frame. */
1000 
1001 #define	AVIGETFRAMEF_BESTDISPLAYFMT	1
1002 
1003 typedef struct _AVISTREAMINFOA {
1004     DWORD	fccType;
1005     DWORD	fccHandler;
1006     DWORD	dwFlags;        /* AVIIF_* */
1007     DWORD	dwCaps;
1008     WORD	wPriority;
1009     WORD	wLanguage;
1010     DWORD	dwScale;
1011     DWORD	dwRate;		/* dwRate / dwScale == samples/second */
1012     DWORD	dwStart;
1013     DWORD	dwLength;	/* In units above... */
1014     DWORD	dwInitialFrames;
1015     DWORD	dwSuggestedBufferSize;
1016     DWORD	dwQuality;
1017     DWORD	dwSampleSize;
1018     RECT	rcFrame;
1019     DWORD	dwEditCount;
1020     DWORD	dwFormatChangeCount;
1021     CHAR	szName[64];
1022 } AVISTREAMINFOA, * LPAVISTREAMINFOA, *PAVISTREAMINFOA;
1023 
1024 typedef struct _AVISTREAMINFOW {
1025     DWORD	fccType;
1026     DWORD	fccHandler;
1027     DWORD	dwFlags;
1028     DWORD	dwCaps;
1029     WORD	wPriority;
1030     WORD	wLanguage;
1031     DWORD	dwScale;
1032     DWORD	dwRate;		/* dwRate / dwScale == samples/second */
1033     DWORD	dwStart;
1034     DWORD	dwLength;	/* In units above... */
1035     DWORD	dwInitialFrames;
1036     DWORD	dwSuggestedBufferSize;
1037     DWORD	dwQuality;
1038     DWORD	dwSampleSize;
1039     RECT	rcFrame;
1040     DWORD	dwEditCount;
1041     DWORD	dwFormatChangeCount;
1042     WCHAR	szName[64];
1043 } AVISTREAMINFOW, * LPAVISTREAMINFOW, *PAVISTREAMINFOW;
1044 DECL_WINELIB_TYPE_AW(AVISTREAMINFO)
1045 DECL_WINELIB_TYPE_AW(LPAVISTREAMINFO)
1046 DECL_WINELIB_TYPE_AW(PAVISTREAMINFO)
1047 
1048 #define AVISTREAMINFO_DISABLED		0x00000001
1049 #define AVISTREAMINFO_FORMATCHANGES	0x00010000
1050 
1051 /* AVIFILEINFO.dwFlags */
1052 #define AVIFILEINFO_HASINDEX		0x00000010
1053 #define AVIFILEINFO_MUSTUSEINDEX	0x00000020
1054 #define AVIFILEINFO_ISINTERLEAVED	0x00000100
1055 #define AVIFILEINFO_TRUSTCKTYPE         0x00000800
1056 #define AVIFILEINFO_WASCAPTUREFILE	0x00010000
1057 #define AVIFILEINFO_COPYRIGHTED		0x00020000
1058 
1059 /* AVIFILEINFO.dwCaps */
1060 #define AVIFILECAPS_CANREAD		0x00000001
1061 #define AVIFILECAPS_CANWRITE		0x00000002
1062 #define AVIFILECAPS_ALLKEYFRAMES	0x00000010
1063 #define AVIFILECAPS_NOCOMPRESSION	0x00000020
1064 
1065 typedef struct _AVIFILEINFOW {
1066     DWORD               dwMaxBytesPerSec;
1067     DWORD               dwFlags;
1068     DWORD               dwCaps;
1069     DWORD               dwStreams;
1070     DWORD               dwSuggestedBufferSize;
1071     DWORD               dwWidth;
1072     DWORD               dwHeight;
1073     DWORD               dwScale;
1074     DWORD               dwRate;
1075     DWORD               dwLength;
1076     DWORD               dwEditCount;
1077     WCHAR               szFileType[64];
1078 } AVIFILEINFOW, * LPAVIFILEINFOW, *PAVIFILEINFOW;
1079 typedef struct _AVIFILEINFOA {
1080     DWORD               dwMaxBytesPerSec;
1081     DWORD               dwFlags;
1082     DWORD               dwCaps;
1083     DWORD               dwStreams;
1084     DWORD               dwSuggestedBufferSize;
1085     DWORD               dwWidth;
1086     DWORD               dwHeight;
1087     DWORD               dwScale;
1088     DWORD               dwRate;
1089     DWORD               dwLength;
1090     DWORD               dwEditCount;
1091     CHAR		szFileType[64];
1092 } AVIFILEINFOA, * LPAVIFILEINFOA, *PAVIFILEINFOA;
1093 DECL_WINELIB_TYPE_AW(AVIFILEINFO)
1094 DECL_WINELIB_TYPE_AW(PAVIFILEINFO)
1095 DECL_WINELIB_TYPE_AW(LPAVIFILEINFO)
1096 
1097 /* AVICOMPRESSOPTIONS.dwFlags. determines presence of fields in below struct */
1098 #define AVICOMPRESSF_INTERLEAVE	0x00000001
1099 #define AVICOMPRESSF_DATARATE	0x00000002
1100 #define AVICOMPRESSF_KEYFRAMES	0x00000004
1101 #define AVICOMPRESSF_VALID	0x00000008
1102 
1103 typedef struct {
1104     DWORD	fccType;		/* stream type, for consistency */
1105     DWORD	fccHandler;		/* compressor */
1106     DWORD	dwKeyFrameEvery;	/* keyframe rate */
1107     DWORD	dwQuality;		/* compress quality 0-10,000 */
1108     DWORD	dwBytesPerSecond;	/* bytes per second */
1109     DWORD	dwFlags;		/* flags... see below */
1110     LPVOID	lpFormat;		/* save format */
1111     DWORD	cbFormat;
1112     LPVOID	lpParms;		/* compressor options */
1113     DWORD	cbParms;
1114     DWORD	dwInterleaveEvery;	/* for non-video streams only */
1115 } AVICOMPRESSOPTIONS, *LPAVICOMPRESSOPTIONS,*PAVICOMPRESSOPTIONS;
1116 
1117 #define FIND_DIR        0x0000000FL     /* direction mask */
1118 #define FIND_NEXT       0x00000001L     /* search forward */
1119 #define FIND_PREV       0x00000004L     /* search backward */
1120 #define FIND_FROM_START 0x00000008L     /* start at the logical beginning */
1121 
1122 #define FIND_TYPE       0x000000F0L     /* type mask */
1123 #define FIND_KEY        0x00000010L     /* find a key frame */
1124 #define FIND_ANY        0x00000020L     /* find any (non-empty) sample */
1125 #define FIND_FORMAT     0x00000040L     /* find a formatchange */
1126 
1127 #define FIND_RET        0x0000F000L     /* return mask */
1128 #define FIND_POS        0x00000000L     /* return logical position */
1129 #define FIND_LENGTH     0x00001000L     /* return logical size */
1130 #define FIND_OFFSET     0x00002000L     /* return physical position */
1131 #define FIND_SIZE       0x00003000L     /* return physical size */
1132 #define FIND_INDEX      0x00004000L     /* return physical index position */
1133 
1134 #include <ole2.h>
1135 
1136 #define DEFINE_AVIGUID(name, l, w1, w2) \
1137     DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
1138 
1139 DEFINE_AVIGUID(IID_IAVIFile,            0x00020020, 0, 0);
1140 DEFINE_AVIGUID(IID_IAVIStream,          0x00020021, 0, 0);
1141 DEFINE_AVIGUID(IID_IAVIStreaming,       0x00020022, 0, 0);
1142 DEFINE_AVIGUID(IID_IGetFrame,           0x00020023, 0, 0);
1143 DEFINE_AVIGUID(IID_IAVIEditStream,      0x00020024, 0, 0);
1144 
1145 DEFINE_AVIGUID(CLSID_AVISimpleUnMarshal,0x00020009, 0, 0);
1146 DEFINE_AVIGUID(CLSID_AVIFile,           0x00020000, 0, 0);
1147 
1148 /*****************************************************************************
1149  * IAVIStream interface
1150  */
1151 #define INTERFACE IAVIStream
DECLARE_INTERFACE_(IAVIStream,IUnknown)1152 DECLARE_INTERFACE_(IAVIStream,IUnknown)
1153 {
1154     /*** IUnknown methods ***/
1155     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, _Outptr_ void** ppvObject) PURE;
1156     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1157     STDMETHOD_(ULONG,Release)(THIS) PURE;
1158     /*** IAVIStream methods ***/
1159     STDMETHOD(Create)(THIS_ LPARAM lParam1, LPARAM lParam2) PURE;
1160     STDMETHOD(Info)(THIS_ _Out_writes_bytes_(lSize) AVISTREAMINFOW *psi, _In_ LONG lSize) PURE;
1161     STDMETHOD_(LONG,FindSample)(THIS_ _In_ LONG lPos, _In_ LONG lFlags) PURE;
1162     STDMETHOD(ReadFormat)(THIS_ _In_ LONG lPos, _Out_writes_bytes_to_opt_(*lpcbFormat, *lpcbFormat) LPVOID lpFormat, _Inout_ LONG *lpcbFormat) PURE;
1163     STDMETHOD(SetFormat)(THIS_ _In_ LONG lPos, _In_reads_bytes_(cbFormat) LPVOID lpFormat, _In_ LONG cbFormat) PURE;
1164     STDMETHOD(Read)(THIS_ _In_ LONG lStart, _In_ LONG lSamples, _Out_writes_bytes_opt_(cbBuffer) LPVOID lpBuffer, _In_ LONG cbBuffer, _Out_opt_ LONG *plBytes, _Out_opt_ LONG *plSamples) PURE;
1165     STDMETHOD(Write)(THIS_ _In_ LONG lStart, _In_ LONG lSamples, _In_reads_bytes_(cbBuffer) LPVOID lpBuffer, _In_ LONG cbBuffer, _In_ DWORD dwFlags, _Out_opt_ LONG *plSampWritten, _Out_opt_ LONG *plBytesWritten) PURE;
1166     STDMETHOD(Delete)(THIS_ _In_ LONG lStart, _In_ LONG lSamples) PURE;
1167     STDMETHOD(ReadData)(THIS_ _In_ DWORD fcc, _Out_writes_bytes_to_opt_(*lpcbBuffer, *lpcbBuffer) LPVOID lpBuffer, _Inout_ LONG *lpcbBuffer) PURE;
1168     STDMETHOD(WriteData)(THIS_ _In_ DWORD fcc, _In_reads_bytes_(cbBuffer) LPVOID lpBuffer, _In_ LONG cbBuffer) PURE;
1169     STDMETHOD(SetInfo)(THIS_ _In_reads_bytes_(cbInfo) AVISTREAMINFOW *plInfo, _In_ LONG cbInfo) PURE;
1170 };
1171 #undef INTERFACE
1172 
1173 #if !defined(__cplusplus) || defined(CINTERFACE)
1174 /*** IUnknown methods ***/
1175 #define IAVIStream_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1176 #define IAVIStream_AddRef(p)             (p)->lpVtbl->AddRef(p)
1177 #define IAVIStream_Release(p)            (p)->lpVtbl->Release(p)
1178 /*** IAVIStream methods ***/
1179 #define IAVIStream_Create(p,a,b)          (p)->lpVtbl->Create(p,a,b)
1180 #define IAVIStream_Info(p,a,b)            (p)->lpVtbl->Info(p,a,b)
1181 #define IAVIStream_FindSample(p,a,b)      (p)->lpVtbl->FindSample(p,a,b)
1182 #define IAVIStream_ReadFormat(p,a,b,c)    (p)->lpVtbl->ReadFormat(p,a,b,c)
1183 #define IAVIStream_SetFormat(p,a,b,c)     (p)->lpVtbl->SetFormat(p,a,b,c)
1184 #define IAVIStream_Read(p,a,b,c,d,e,f)    (p)->lpVtbl->Read(p,a,b,c,d,e,f)
1185 #define IAVIStream_Write(p,a,b,c,d,e,f,g) (p)->lpVtbl->Write(p,a,b,c,d,e,f,g)
1186 #define IAVIStream_Delete(p,a,b)          (p)->lpVtbl->Delete(p,a,b)
1187 #define IAVIStream_ReadData(p,a,b,c)      (p)->lpVtbl->ReadData(p,a,b,c)
1188 #define IAVIStream_WriteData(p,a,b,c)     (p)->lpVtbl->WriteData(p,a,b,c)
1189 #define IAVIStream_SetInfo(p,a,b)         (p)->lpVtbl->SetInfo(p,a,b)
1190 #endif
1191 
1192 #define AVISTREAMREAD_CONVENIENT	  (-1L)
1193 
1194 ULONG WINAPI AVIStreamAddRef(PAVISTREAM iface);
1195 ULONG WINAPI AVIStreamRelease(PAVISTREAM iface);
1196 
1197 HRESULT
1198 WINAPI
1199 AVIStreamCreate(
1200   _Outptr_ PAVISTREAM*,
1201   _In_ LONG,
1202   _In_ LONG,
1203   _In_opt_ CLSID*);
1204 
1205 HRESULT
1206 WINAPI
1207 AVIStreamInfoA(
1208   _In_ PAVISTREAM iface,
1209   _Out_writes_bytes_(size) AVISTREAMINFOA *asi,
1210   _In_ LONG size);
1211 
1212 HRESULT
1213 WINAPI
1214 AVIStreamInfoW(
1215   _In_ PAVISTREAM iface,
1216   _Out_writes_bytes_(size) AVISTREAMINFOW *asi,
1217   _In_ LONG size);
1218 
1219 #define AVIStreamInfo WINELIB_NAME_AW(AVIStreamInfo)
1220 
1221 LONG
1222 WINAPI
1223 AVIStreamFindSample(
1224   _In_ PAVISTREAM pstream,
1225   _In_ LONG pos,
1226   _In_ LONG flags);
1227 
1228 HRESULT
1229 WINAPI
1230 AVIStreamReadFormat(
1231   _In_ PAVISTREAM iface,
1232   _In_ LONG pos,
1233   _Out_writes_bytes_to_opt_(*formatsize, *formatsize) LPVOID format,
1234   _Inout_ LONG *formatsize);
1235 
1236 HRESULT
1237 WINAPI
1238 AVIStreamSetFormat(
1239   _In_ PAVISTREAM iface,
1240   _In_ LONG pos,
1241   _In_reads_bytes_(formatsize) LPVOID format,
1242   _In_ LONG formatsize);
1243 
1244 HRESULT
1245 WINAPI
1246 AVIStreamRead(
1247   _In_ PAVISTREAM iface,
1248   _In_ LONG start,
1249   _In_ LONG samples,
1250   _Out_writes_bytes_opt_(buffersize) LPVOID buffer,
1251   _In_ LONG buffersize,
1252   _Out_opt_ LONG *bytesread,
1253   _Out_opt_ LONG *samplesread);
1254 
1255 HRESULT
1256 WINAPI
1257 AVIStreamWrite(
1258   _In_ PAVISTREAM iface,
1259   _In_ LONG start,
1260   _In_ LONG samples,
1261   _In_reads_bytes_(buffersize) LPVOID buffer,
1262   _In_ LONG buffersize,
1263   _In_ DWORD flags,
1264   _Out_opt_ LONG *sampwritten,
1265   _Out_opt_ LONG *byteswritten);
1266 
1267 HRESULT
1268 WINAPI
1269 AVIStreamReadData(
1270   _In_ PAVISTREAM iface,
1271   _In_ DWORD fcc,
1272   _Out_writes_bytes_to_opt_(*lpread, *lpread) LPVOID lp,
1273   _Inout_ LONG *lpread);
1274 
1275 HRESULT
1276 WINAPI
1277 AVIStreamWriteData(
1278   _In_ PAVISTREAM iface,
1279   _In_ DWORD fcc,
1280   _In_reads_bytes_(size) LPVOID lp,
1281   _In_ LONG size);
1282 
1283 PGETFRAME
1284 WINAPI
1285 AVIStreamGetFrameOpen(
1286   _In_ PAVISTREAM pavi,
1287   _In_opt_ LPBITMAPINFOHEADER lpbiWanted);
1288 
1289 LPVOID  WINAPI AVIStreamGetFrame(_In_ PGETFRAME pg, _In_ LONG pos);
1290 HRESULT WINAPI AVIStreamGetFrameClose(_In_ PGETFRAME pg);
1291 
1292 HRESULT
1293 WINAPI
1294 AVIMakeCompressedStream(
1295   _Outptr_ PAVISTREAM *ppsCompressed,
1296   _In_ PAVISTREAM ppsSource,
1297   _In_ AVICOMPRESSOPTIONS *lpOptions,
1298   _In_opt_ CLSID *pclsidHandler);
1299 
1300 HRESULT
1301 WINAPI
1302 AVIMakeFileFromStreams(
1303   _Outptr_ PAVIFILE *ppfile,
1304   _In_ int nStreams,
1305   _In_reads_(nStreams) PAVISTREAM *ppStreams);
1306 
1307 HRESULT
1308 WINAPI
1309 AVIMakeStreamFromClipboard(
1310   UINT cfFormat,
1311   _In_ HANDLE hGlobal,
1312   _Outptr_ PAVISTREAM * ppstream);
1313 
1314 HRESULT
1315 WINAPI
1316 AVIStreamOpenFromFileA(
1317   _Outptr_ PAVISTREAM *ppavi,
1318   _In_ LPCSTR szFile,
1319   _In_ DWORD fccType,
1320   _In_ LONG lParam,
1321   _In_ UINT mode,
1322   _In_opt_ CLSID *pclsidHandler);
1323 
1324 HRESULT
1325 WINAPI
1326 AVIStreamOpenFromFileW(
1327   _Outptr_ PAVISTREAM *ppavi,
1328   _In_ LPCWSTR szFile,
1329   _In_ DWORD fccType,
1330   _In_ LONG lParam,
1331   _In_ UINT mode,
1332   _In_opt_ CLSID *pclsidHandler);
1333 
1334 #define AVIStreamOpenFromFile WINELIB_NAME_AW(AVIStreamOpenFromFile)
1335 
1336 LONG
1337 WINAPI
1338 AVIStreamBeginStreaming(
1339   _In_ PAVISTREAM pavi,
1340   _In_ LONG lStart,
1341   _In_ LONG lEnd,
1342   _In_ LONG lRate);
1343 
1344 LONG WINAPI AVIStreamEndStreaming(_In_ PAVISTREAM pavi);
1345 
1346 HRESULT
1347 WINAPI
1348 AVIBuildFilterA(
1349   _Out_writes_(cbFilter) LPSTR szFilter,
1350   _In_ LONG cbFilter,
1351   _In_ BOOL fSaving);
1352 
1353 HRESULT
1354 WINAPI
1355 AVIBuildFilterW(
1356   _Out_writes_(cbFilter) LPWSTR szFilter,
1357   _In_ LONG cbFilter,
1358   _In_ BOOL fSaving);
1359 
1360 #define AVIBuildFilter WINELIB_NAME_AW(AVIBuildFilter)
1361 
1362 BOOL
1363 WINAPI
1364 AVISaveOptions(
1365   _In_ HWND hWnd,
1366   _In_ UINT uFlags,
1367   _In_ INT nStream,
1368   _In_reads_(nStream) PAVISTREAM *ppavi,
1369   _Inout_updates_(nStream) LPAVICOMPRESSOPTIONS *ppOptions);
1370 
1371 HRESULT
1372 WINAPI
1373 AVISaveOptionsFree(
1374   INT nStreams,
1375   _In_reads_(nStreams) LPAVICOMPRESSOPTIONS *ppOptions);
1376 
1377 HRESULT
1378 CDECL
1379 AVISaveA(
1380   LPCSTR szFile,
1381   _In_opt_ CLSID *pclsidHandler,
1382   _In_ AVISAVECALLBACK lpfnCallback,
1383   _In_ int nStreams,
1384   _In_ PAVISTREAM pavi,
1385   _In_ LPAVICOMPRESSOPTIONS lpOptions,
1386   ...);
1387 
1388 HRESULT
1389 CDECL
1390 AVISaveW(
1391   LPCWSTR szFile,
1392   _In_opt_ CLSID *pclsidHandler,
1393   _In_ AVISAVECALLBACK lpfnCallback,
1394   _In_ int nStreams,
1395   _In_ PAVISTREAM pavi,
1396   _In_ LPAVICOMPRESSOPTIONS lpOptions,
1397   ...);
1398 
1399 #define AVISave WINELIB_NAME_AW(AVISave)
1400 
1401 HRESULT
1402 WINAPI
1403 AVISaveVA(
1404   LPCSTR szFile,
1405   _In_opt_ CLSID *pclsidHandler,
1406   _In_ AVISAVECALLBACK lpfnCallback,
1407   _In_ int nStream,
1408   _In_reads_(nStream) PAVISTREAM *ppavi,
1409   _In_reads_(nStream) LPAVICOMPRESSOPTIONS *plpOptions);
1410 
1411 HRESULT
1412 WINAPI
1413 AVISaveVW(
1414   LPCWSTR szFile,
1415   _In_opt_ CLSID *pclsidHandler,
1416   _In_ AVISAVECALLBACK lpfnCallback,
1417   _In_ int nStream,
1418   _In_reads_(nStream) PAVISTREAM *ppavi,
1419   _In_reads_(nStream) LPAVICOMPRESSOPTIONS *plpOptions);
1420 
1421 #define AVISaveV WINELIB_NAME_AW(AVISaveV)
1422 
1423 LONG WINAPI AVIStreamStart(_In_ PAVISTREAM iface);
1424 LONG WINAPI AVIStreamLength(_In_ PAVISTREAM iface);
1425 LONG WINAPI AVIStreamSampleToTime(_In_ PAVISTREAM pstream, _In_ LONG lSample);
1426 LONG WINAPI AVIStreamTimeToSample(_In_ PAVISTREAM pstream, _In_ LONG lTime);
1427 
1428 #define AVIFileClose(pavi) \
1429     AVIFileRelease(pavi)
1430 #define AVIStreamClose(pavi) \
1431     AVIStreamRelease(pavi);
1432 #define AVIStreamEnd(pavi) \
1433     (AVIStreamStart(pavi) + AVIStreamLength(pavi))
1434 #define AVIStreamEndTime(pavi) \
1435     AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi))
1436 #define AVIStreamFormatSize(pavi, lPos, plSize) \
1437     AVIStreamReadFormat(pavi, lPos, NULL, plSize)
1438 #define AVIStreamLengthTime(pavi) \
1439     AVIStreamSampleToTime(pavi, AVIStreamLength(pavi))
1440 #define AVIStreamSampleSize(pavi,pos,psize) \
1441     AVIStreamRead(pavi,pos,1,NULL,0,psize,NULL)
1442 #define AVIStreamSampleToSample(pavi1, pavi2, samp2) \
1443     AVIStreamTimeToSample(pavi1, AVIStreamSampleToTime(pavi2, samp2))
1444 #define AVIStreamStartTime(pavi) \
1445     AVIStreamSampleToTime(pavi, AVIStreamStart(pavi))
1446 
1447 #define AVIStreamNextSample(pavi, pos) \
1448     AVIStreamFindSample(pavi, pos + 1, FIND_NEXT | FIND_ANY)
1449 #define AVIStreamPrevSample(pavi, pos) \
1450     AVIStreamFindSample(pavi, pos - 1, FIND_PREV | FIND_ANY)
1451 #define AVIStreamNearestSample(pavi, pos) \
1452     AVIStreamFindSample(pavi, pos, FIND_PREV | FIND_ANY)
1453 #define AVStreamNextKeyFrame(pavi,pos) \
1454     AVIStreamFindSample(pavi, pos + 1, FIND_NEXT | FIND_KEY)
1455 #define AVStreamPrevKeyFrame(pavi,pos) \
1456     AVIStreamFindSample(pavi, pos - 1, FIND_NEXT | FIND_KEY)
1457 #define AVIStreamNearestKeyFrame(pavi,pos) \
1458     AVIStreamFindSample(pavi, pos, FIND_PREV | FIND_KEY)
1459 #define AVIStreamIsKeyFrame(pavi, pos) \
1460     (AVIStreamNearestKeyFrame(pavi, pos) == pos)
1461 
1462 /*****************************************************************************
1463  * IAVIStreaming interface
1464  */
1465 #define INTERFACE IAVIStreaming
DECLARE_INTERFACE_(IAVIStreaming,IUnknown)1466 DECLARE_INTERFACE_(IAVIStreaming,IUnknown)
1467 {
1468     /*** IUnknown methods ***/
1469     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, _Outptr_ void** ppvObject) PURE;
1470     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1471     STDMETHOD_(ULONG,Release)(THIS) PURE;
1472     /*** IAVIStreaming methods ***/
1473     STDMETHOD(Begin)(IAVIStreaming *iface, _In_ LONG lStart, _In_ LONG lEnd, _In_ LONG lRate) PURE;
1474     STDMETHOD(End)(IAVIStreaming *iface) PURE;
1475 };
1476 #undef INTERFACE
1477 
1478 #if !defined(__cplusplus) || defined(CINTERFACE)
1479 /*** IUnknown methods ***/
1480 #define IAVIStreaming_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1481 #define IAVIStreaming_AddRef(p)             (p)->lpVtbl->AddRef(p)
1482 #define IAVIStreaming_Release(p)            (p)->lpVtbl->Release(p)
1483 /*** IAVIStreaming methods ***/
1484 #define IAVIStreaming_Begin(p,a,b,c)        (p)->lpVtbl->Begin(p,a,b,c)
1485 #define IAVIStreaming_End(p)                (p)->lpVtbl->End(p)
1486 #endif
1487 
1488 /*****************************************************************************
1489  * IAVIEditStream interface
1490  */
1491 #define INTERFACE IAVIEditStream
DECLARE_INTERFACE_(IAVIEditStream,IUnknown)1492 DECLARE_INTERFACE_(IAVIEditStream,IUnknown)
1493 {
1494     /*** IUnknown methods ***/
1495     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, _Outptr_ void** ppvObject) PURE;
1496     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1497     STDMETHOD_(ULONG,Release)(THIS) PURE;
1498     /*** IAVIEditStream methods ***/
1499     STDMETHOD(Cut)(IAVIEditStream *iface, _Inout_ LONG *plStart, _Inout_ LONG *plLength, _Outptr_ PAVISTREAM *ppResult) PURE;
1500     STDMETHOD(Copy)(IAVIEditStream *iface, _Inout_ LONG *plStart, _Inout_ LONG *plLength, _Outptr_ PAVISTREAM *ppResult) PURE;
1501     STDMETHOD(Paste)(IAVIEditStream *iface, _Inout_ LONG *plStart, _Inout_ LONG *plLength, _Inout_ PAVISTREAM pSource, _In_ LONG lStart, _In_ LONG lEnd) PURE;
1502     STDMETHOD(Clone)(IAVIEditStream *iface, _Outptr_ PAVISTREAM *ppResult) PURE;
1503     STDMETHOD(SetInfo)(IAVIEditStream *iface, _In_reads_bytes_(size) LPAVISTREAMINFOW asi, _In_ LONG size) PURE;
1504 };
1505 #undef INTERFACE
1506 
1507 #if !defined(__cplusplus) || defined(CINTERFACE)
1508 /*** IUnknown methods ***/
1509 #define IAVIEditStream_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1510 #define IAVIEditStream_AddRef(p)             (p)->lpVtbl->AddRef(p)
1511 #define IAVIEditStream_Release(p)            (p)->lpVtbl->Release(p)
1512 /*** IAVIEditStream methods ***/
1513 #define IAVIEditStream_Cut(p,a,b,c)	     (p)->lpVtbl->Cut(p,a,b,c)
1514 #define IAVIEditStream_Copy(p,a,b,c)	     (p)->lpVtbl->Copy(p,a,b,c)
1515 #define IAVIEditStream_Paste(p,a,b,c,d,e)    (p)->lpVtbl->Paste(p,a,b,c,d,e)
1516 #define IAVIEditStream_Clone(p,a)	     (p)->lpVtbl->Clone(p,a)
1517 #define IAVIEditStream_SetInfo(p,a,b)	     (p)->lpVtbl->SetInfo(p,a,b)
1518 #endif
1519 
1520 HRESULT
1521 WINAPI
1522 CreateEditableStream(
1523   _Outptr_ PAVISTREAM *ppEditable,
1524   _In_ PAVISTREAM pSource);
1525 
1526 HRESULT
1527 WINAPI
1528 EditStreamClone(
1529   _In_ PAVISTREAM pStream,
1530   _Outptr_ PAVISTREAM *ppResult);
1531 
1532 HRESULT
1533 WINAPI
1534 EditStreamCopy(
1535   _In_ PAVISTREAM pStream,
1536   _Inout_ LONG *plStart,
1537   _Inout_ LONG *plLength,
1538   _Outptr_ PAVISTREAM *ppResult);
1539 
1540 HRESULT
1541 WINAPI
1542 EditStreamCut(
1543   _In_ PAVISTREAM pStream,
1544   _Inout_ LONG *plStart,
1545   _Inout_ LONG *plLength,
1546   _Outptr_ PAVISTREAM *ppResult);
1547 
1548 HRESULT
1549 WINAPI
1550 EditStreamPaste(
1551   _In_ PAVISTREAM pDest,
1552   _Inout_ LONG *plStart,
1553   _Inout_ LONG *plLength,
1554   _In_ PAVISTREAM pSource,
1555   _In_ LONG lStart,
1556   _In_ LONG lEnd);
1557 
1558 HRESULT
1559 WINAPI
1560 EditStreamSetInfoA(
1561   _In_ PAVISTREAM pstream,
1562   _In_reads_bytes_(size) LPAVISTREAMINFOA asi,
1563   _In_ LONG size);
1564 
1565 HRESULT
1566 WINAPI
1567 EditStreamSetInfoW(
1568   _In_ PAVISTREAM pstream,
1569   _In_reads_bytes_(size) LPAVISTREAMINFOW asi,
1570   _In_ LONG size);
1571 
1572 #define EditStreamSetInfo WINELIB_NAME_AW(EditStreamSetInfo)
1573 
1574 HRESULT WINAPI EditStreamSetNameA(_In_ PAVISTREAM pstream, _In_ LPCSTR szName);
1575 HRESULT WINAPI EditStreamSetNameW(_In_ PAVISTREAM pstream, _In_ LPCWSTR szName);
1576 #define EditStreamSetName WINELIB_NAME_AW(EditStreamSetName)
1577 
1578 /*****************************************************************************
1579  * IAVIFile interface
1580  */
1581 /* In Win32 this interface uses UNICODE only */
1582 #define INTERFACE IAVIFile
DECLARE_INTERFACE_(IAVIFile,IUnknown)1583 DECLARE_INTERFACE_(IAVIFile,IUnknown)
1584 {
1585     /*** IUnknown methods ***/
1586     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, _Outptr_ void** ppvObject) PURE;
1587     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1588     STDMETHOD_(ULONG,Release)(THIS) PURE;
1589     /*** IAVIFile methods ***/
1590     STDMETHOD(Info)(THIS_ _Out_writes_bytes_(lSize) AVIFILEINFOW *pfi, _In_ LONG lSize) PURE;
1591     STDMETHOD(GetStream)(THIS_ _Outptr_ PAVISTREAM *ppStream, _In_ DWORD fccType, _In_ LONG lParam) PURE;
1592     STDMETHOD(CreateStream)(THIS_ _Outptr_ PAVISTREAM *ppStream, _In_ AVISTREAMINFOW *psi) PURE;
1593     STDMETHOD(WriteData)(THIS_ _In_ DWORD fcc, _In_reads_bytes_(cbBuffer) LPVOID lpBuffer, _In_ LONG cbBuffer) PURE;
1594     STDMETHOD(ReadData)(THIS_ _In_ DWORD fcc, _Out_writes_bytes_to_(*lpcbBuffer, *lpcbBuffer) LPVOID lpBuffer, _Inout_ LONG *lpcbBuffer) PURE;
1595     STDMETHOD(EndRecord)(THIS) PURE;
1596     STDMETHOD(DeleteStream)(THIS_ _In_ DWORD fccType, _In_ LONG lParam) PURE;
1597 };
1598 #undef INTERFACE
1599 
1600 #if !defined(__cplusplus) || defined(CINTERFACE)
1601 /*** IUnknown methods ***/
1602 #define IAVIFile_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1603 #define IAVIFile_AddRef(p)             (p)->lpVtbl->AddRef(p)
1604 #define IAVIFile_Release(p)            (p)->lpVtbl->Release(p)
1605 /*** IAVIFile methods ***/
1606 #define IAVIFile_Info(p,a,b)         (p)->lpVtbl->Info(p,a,b)
1607 #define IAVIFile_GetStream(p,a,b,c)  (p)->lpVtbl->GetStream(p,a,b,c)
1608 #define IAVIFile_CreateStream(p,a,b) (p)->lpVtbl->CreateStream(p,a,b)
1609 #define IAVIFile_WriteData(p,a,b,c)  (p)->lpVtbl->WriteData(p,a,b,c)
1610 #define IAVIFile_ReadData(p,a,b,c)   (p)->lpVtbl->ReadData(p,a,b,c)
1611 #define IAVIFile_EndRecord(p)        (p)->lpVtbl->EndRecord(p)
1612 #define IAVIFile_DeleteStream(p,a,b) (p)->lpVtbl->DeleteStream(p,a,b)
1613 #endif
1614 
1615 void WINAPI AVIFileInit(void);
1616 void WINAPI AVIFileExit(void);
1617 
1618 HRESULT
1619 WINAPI
1620 AVIFileOpenA(
1621   _Outptr_ PAVIFILE* ppfile,
1622   _In_ LPCSTR szFile,
1623   UINT uMode,
1624   _In_opt_ LPCLSID lpHandler);
1625 
1626 HRESULT
1627 WINAPI
1628 AVIFileOpenW(
1629   _Outptr_ PAVIFILE* ppfile,
1630   _In_ LPCWSTR szFile,
1631   UINT uMode,
1632   _In_opt_ LPCLSID lpHandler);
1633 
1634 #define AVIFileOpen WINELIB_NAME_AW(AVIFileOpen)
1635 
1636 ULONG   WINAPI AVIFileAddRef(PAVIFILE pfile);
1637 ULONG   WINAPI AVIFileRelease(PAVIFILE pfile);
1638 
1639 HRESULT
1640 WINAPI
1641 AVIFileInfoA(
1642   _In_ PAVIFILE pfile,
1643   _Out_writes_bytes_(lSize) PAVIFILEINFOA pfi,
1644   _In_ LONG lSize);
1645 
1646 HRESULT
1647 WINAPI
1648 AVIFileInfoW(
1649   _In_ PAVIFILE pfile,
1650   _Out_writes_bytes_(lSize) PAVIFILEINFOW pfi,
1651   _In_ LONG lSize);
1652 
1653 #define AVIFileInfo WINELIB_NAME_AW(AVIFileInfo)
1654 
1655 HRESULT
1656 WINAPI
1657 AVIFileGetStream(
1658   _In_ PAVIFILE pfile,
1659   _Outptr_ PAVISTREAM* avis,
1660   _In_ DWORD fccType,
1661   _In_ LONG lParam);
1662 
1663 HRESULT
1664 WINAPI
1665 AVIFileCreateStreamA(
1666   _In_ PAVIFILE pfile,
1667   _Outptr_ PAVISTREAM* ppavi,
1668   _In_ AVISTREAMINFOA* psi);
1669 
1670 HRESULT
1671 WINAPI
1672 AVIFileCreateStreamW(
1673   _In_ PAVIFILE pfile,
1674   _Outptr_ PAVISTREAM* ppavi,
1675   _In_ AVISTREAMINFOW* psi);
1676 
1677 #define AVIFileCreateStream WINELIB_NAME_AW(AVIFileCreateStream)
1678 
1679 HRESULT
1680 WINAPI
1681 AVIFileWriteData(
1682   _In_ PAVIFILE pfile,
1683   _In_ DWORD fcc,
1684   _In_reads_bytes_(size) LPVOID lp,
1685   _In_ LONG size);
1686 
1687 HRESULT
1688 WINAPI
1689 AVIFileReadData(
1690   _In_ PAVIFILE pfile,
1691   _In_ DWORD fcc,
1692   _Out_writes_bytes_to_(*size, *size) LPVOID lp,
1693   _Inout_ LPLONG size);
1694 
1695 HRESULT WINAPI AVIFileEndRecord(_In_ PAVIFILE pfile);
1696 
1697 /*****************************************************************************
1698  * IGetFrame interface
1699  */
1700 #define INTERFACE IGetFrame
DECLARE_INTERFACE_(IGetFrame,IUnknown)1701 DECLARE_INTERFACE_(IGetFrame,IUnknown)
1702 {
1703     /*** IUnknown methods ***/
1704     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, _Outptr_ void** ppvObject) PURE;
1705     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1706     STDMETHOD_(ULONG,Release)(THIS) PURE;
1707     /*** IGetFrame methods ***/
1708     STDMETHOD_(LPVOID,GetFrame)(THIS_ _In_ LONG lPos) PURE;
1709     STDMETHOD(Begin)(THIS_ _In_ LONG lStart, _In_ LONG lEnd, _In_ LONG lRate) PURE;
1710     STDMETHOD(End)(THIS) PURE;
1711     STDMETHOD(SetFormat)(THIS_ _In_ LPBITMAPINFOHEADER lpbi, _In_opt_ LPVOID lpBits, _In_ INT x, _In_ INT y, _In_ INT dx, _In_ INT dy) PURE;
1712 };
1713 #undef INTERFACE
1714 
1715 #if !defined(__cplusplus) || defined(CINTERFACE)
1716 /*** IUnknown methods ***/
1717 #define IGetFrame_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1718 #define IGetFrame_AddRef(p)             (p)->lpVtbl->AddRef(p)
1719 #define IGetFrame_Release(p)            (p)->lpVtbl->Release(p)
1720 /*** IGetFrame methods ***/
1721 #define IGetFrame_GetFrame(p,a)            (p)->lpVtbl->GetFrame(p,a)
1722 #define IGetFrame_Begin(p,a,b,c)           (p)->lpVtbl->Begin(p,a,b,c)
1723 #define IGetFrame_End(p)                   (p)->lpVtbl->End(p)
1724 #define IGetFrame_SetFormat(p,a,b,c,d,e,f) (p)->lpVtbl->SetFormat(p,a,b,c,d,e,f)
1725 #endif
1726 
1727 HRESULT WINAPI AVIClearClipboard(void);
1728 HRESULT WINAPI AVIGetFromClipboard(_Outptr_ PAVIFILE *ppfile);
1729 HRESULT WINAPI AVIPutFileOnClipboard(_In_ PAVIFILE pfile);
1730 
1731 #ifdef OFN_READONLY
1732 BOOL WINAPI GetOpenFileNamePreviewA(_Inout_ LPOPENFILENAMEA lpofn);
1733 BOOL WINAPI GetOpenFileNamePreviewW(_Inout_ LPOPENFILENAMEW lpofn);
1734 #define GetOpenFileNamePreview WINELIB_NAME_AW(GetOpenFileNamePreview)
1735 BOOL WINAPI GetSaveFileNamePreviewA(_Inout_ LPOPENFILENAMEA lpofn);
1736 BOOL WINAPI GetSaveFileNamePreviewW(_Inout_ LPOPENFILENAMEW lpofn);
1737 #define GetSaveFileNamePreview WINELIB_NAME_AW(GetSaveFileNamePreview)
1738 #endif
1739 
1740 #define AVIERR_OK		0
1741 #define MAKE_AVIERR(error)	MAKE_SCODE(SEVERITY_ERROR,FACILITY_ITF,0x4000+error)
1742 
1743 #define AVIERR_UNSUPPORTED	MAKE_AVIERR(101)
1744 #define AVIERR_BADFORMAT	MAKE_AVIERR(102)
1745 #define AVIERR_MEMORY		MAKE_AVIERR(103)
1746 #define AVIERR_INTERNAL		MAKE_AVIERR(104)
1747 #define AVIERR_BADFLAGS		MAKE_AVIERR(105)
1748 #define AVIERR_BADPARAM		MAKE_AVIERR(106)
1749 #define AVIERR_BADSIZE		MAKE_AVIERR(107)
1750 #define AVIERR_BADHANDLE	MAKE_AVIERR(108)
1751 #define AVIERR_FILEREAD		MAKE_AVIERR(109)
1752 #define AVIERR_FILEWRITE	MAKE_AVIERR(110)
1753 #define AVIERR_FILEOPEN		MAKE_AVIERR(111)
1754 #define AVIERR_COMPRESSOR	MAKE_AVIERR(112)
1755 #define AVIERR_NOCOMPRESSOR	MAKE_AVIERR(113)
1756 #define AVIERR_READONLY		MAKE_AVIERR(114)
1757 #define AVIERR_NODATA		MAKE_AVIERR(115)
1758 #define AVIERR_BUFFERTOOSMALL	MAKE_AVIERR(116)
1759 #define AVIERR_CANTCOMPRESS	MAKE_AVIERR(117)
1760 #define AVIERR_USERABORT	MAKE_AVIERR(198)
1761 #define AVIERR_ERROR		MAKE_AVIERR(199)
1762 
1763 BOOL VFWAPIV MCIWndRegisterClass(void);
1764 
1765 HWND
1766 VFWAPIV
1767 MCIWndCreateA(
1768   _In_opt_ HWND,
1769   _In_opt_ HINSTANCE,
1770   _In_ DWORD,
1771   _In_opt_ LPCSTR);
1772 
1773 HWND
1774 VFWAPIV
1775 MCIWndCreateW(
1776   _In_opt_ HWND,
1777   _In_opt_ HINSTANCE,
1778   _In_ DWORD,
1779   _In_opt_ LPCWSTR);
1780 
1781 #define MCIWndCreate WINELIB_NAME_AW(MCIWndCreate)
1782 
1783 #define MCIWNDOPENF_NEW			0x0001
1784 
1785 #define MCIWNDF_NOAUTOSIZEWINDOW	0x0001
1786 #define MCIWNDF_NOPLAYBAR		0x0002
1787 #define MCIWNDF_NOAUTOSIZEMOVIE		0x0004
1788 #define MCIWNDF_NOMENU			0x0008
1789 #define MCIWNDF_SHOWNAME		0x0010
1790 #define MCIWNDF_SHOWPOS			0x0020
1791 #define MCIWNDF_SHOWMODE		0x0040
1792 #define MCIWNDF_SHOWALL			0x0070
1793 
1794 #define MCIWNDF_NOTIFYMODE		0x0100
1795 #define MCIWNDF_NOTIFYPOS		0x0200
1796 #define MCIWNDF_NOTIFYSIZE		0x0400
1797 #define MCIWNDF_NOTIFYERROR		0x1000
1798 #define MCIWNDF_NOTIFYALL		0x1F00
1799 
1800 #define MCIWNDF_NOTIFYANSI		0x0080
1801 
1802 #define MCIWNDF_NOTIFYMEDIAA		0x0880
1803 #define MCIWNDF_NOTIFYMEDIAW		0x0800
1804 #define MCIWNDF_NOTIFYMEDIA WINELIB_NAME_AW(MCIWNDF_NOTIFYMEDIA)
1805 
1806 #define MCIWNDF_RECORD			0x2000
1807 #define MCIWNDF_NOERRORDLG		0x4000
1808 #define MCIWNDF_NOOPEN			0x8000
1809 
1810 #ifdef __cplusplus
1811 #define MCIWndSM ::SendMessage
1812 #else
1813 #define MCIWndSM SendMessage
1814 #endif
1815 
1816 #define MCIWndCanPlay(hWnd)         (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_PLAY,0,0)
1817 #define MCIWndCanRecord(hWnd)       (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_RECORD,0,0)
1818 #define MCIWndCanSave(hWnd)         (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_SAVE,0,0)
1819 #define MCIWndCanWindow(hWnd)       (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_WINDOW,0,0)
1820 #define MCIWndCanEject(hWnd)        (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_EJECT,0,0)
1821 #define MCIWndCanConfig(hWnd)       (BOOL)MCIWndSM(hWnd,MCIWNDM_CAN_CONFIG,0,0)
1822 #define MCIWndPaletteKick(hWnd)     (BOOL)MCIWndSM(hWnd,MCIWNDM_PALETTEKICK,0,0)
1823 
1824 #define MCIWndSave(hWnd,szFile)	    (LONG)MCIWndSM(hWnd,MCI_SAVE,0,(LPARAM)(LPVOID)(szFile))
1825 #define MCIWndSaveDialog(hWnd)      MCIWndSave(hWnd,-1)
1826 
1827 #define MCIWndNew(hWnd,lp)          (LONG)MCIWndSM(hWnd,MCIWNDM_NEW,0,(LPARAM)(LPVOID)(lp))
1828 
1829 #define MCIWndRecord(hWnd)          (LONG)MCIWndSM(hWnd,MCI_RECORD,0,0)
1830 #define MCIWndOpen(hWnd,sz,f)       (LONG)MCIWndSM(hWnd,MCIWNDM_OPEN,(WPARAM)(UINT)(f),(LPARAM)(LPVOID)(sz))
1831 #define MCIWndOpenDialog(hWnd)      MCIWndOpen(hWnd,-1,0)
1832 #define MCIWndClose(hWnd)           (LONG)MCIWndSM(hWnd,MCI_CLOSE,0,0)
1833 #define MCIWndPlay(hWnd)            (LONG)MCIWndSM(hWnd,MCI_PLAY,0,0)
1834 #define MCIWndStop(hWnd)            (LONG)MCIWndSM(hWnd,MCI_STOP,0,0)
1835 #define MCIWndPause(hWnd)           (LONG)MCIWndSM(hWnd,MCI_PAUSE,0,0)
1836 #define MCIWndResume(hWnd)          (LONG)MCIWndSM(hWnd,MCI_RESUME,0,0)
1837 #define MCIWndSeek(hWnd,lPos)       (LONG)MCIWndSM(hWnd,MCI_SEEK,0,(LPARAM)(LONG)(lPos))
1838 #define MCIWndEject(hWnd)           (LONG)MCIWndSM(hWnd,MCIWNDM_EJECT,0,0)
1839 
1840 #define MCIWndHome(hWnd)            MCIWndSeek(hWnd,MCIWND_START)
1841 #define MCIWndEnd(hWnd)             MCIWndSeek(hWnd,MCIWND_END)
1842 
1843 #define MCIWndGetSource(hWnd,prc)   (LONG)MCIWndSM(hWnd,MCIWNDM_GET_SOURCE,0,(LPARAM)(LPRECT)(prc))
1844 #define MCIWndPutSource(hWnd,prc)   (LONG)MCIWndSM(hWnd,MCIWNDM_PUT_SOURCE,0,(LPARAM)(LPRECT)(prc))
1845 
1846 #define MCIWndGetDest(hWnd,prc)     (LONG)MCIWndSM(hWnd,MCIWNDM_GET_DEST,0,(LPARAM)(LPRECT)(prc))
1847 #define MCIWndPutDest(hWnd,prc)     (LONG)MCIWndSM(hWnd,MCIWNDM_PUT_DEST,0,(LPARAM)(LPRECT)(prc))
1848 
1849 #define MCIWndPlayReverse(hWnd)     (LONG)MCIWndSM(hWnd,MCIWNDM_PLAYREVERSE,0,0)
1850 #define MCIWndPlayFrom(hWnd,lPos)   (LONG)MCIWndSM(hWnd,MCIWNDM_PLAYFROM,0,(LPARAM)(LONG)(lPos))
1851 #define MCIWndPlayTo(hWnd,lPos)     (LONG)MCIWndSM(hWnd,MCIWNDM_PLAYTO,  0,(LPARAM)(LONG)(lPos))
1852 #define MCIWndPlayFromTo(hWnd,lStart,lEnd) (MCIWndSeek(hWnd,lStart),MCIWndPlayTo(hWnd,lEnd))
1853 
1854 #define MCIWndGetDeviceID(hWnd)     (UINT)MCIWndSM(hWnd,MCIWNDM_GETDEVICEID,0,0)
1855 #define MCIWndGetAlias(hWnd)        (UINT)MCIWndSM(hWnd,MCIWNDM_GETALIAS,0,0)
1856 #define MCIWndGetMode(hWnd,lp,len)  (LONG)MCIWndSM(hWnd,MCIWNDM_GETMODE,(WPARAM)(UINT)(len),(LPARAM)(LPTSTR)(lp))
1857 #define MCIWndGetPosition(hWnd)     (LONG)MCIWndSM(hWnd,MCIWNDM_GETPOSITION,0,0)
1858 #define MCIWndGetPositionString(hWnd,lp,len) (LONG)MCIWndSM(hWnd,MCIWNDM_GETPOSITION,(WPARAM)(UINT)(len),(LPARAM)(LPTSTR)(lp))
1859 #define MCIWndGetStart(hWnd)        (LONG)MCIWndSM(hWnd,MCIWNDM_GETSTART,0,0)
1860 #define MCIWndGetLength(hWnd)       (LONG)MCIWndSM(hWnd,MCIWNDM_GETLENGTH,0,0)
1861 #define MCIWndGetEnd(hWnd)          (LONG)MCIWndSM(hWnd,MCIWNDM_GETEND,0,0)
1862 
1863 #define MCIWndStep(hWnd,n)          (LONG)MCIWndSM(hWnd,MCI_STEP,0,(LPARAM)(LONG)(n))
1864 
1865 #define MCIWndDestroy(hWnd)         (VOID)MCIWndSM(hWnd,WM_CLOSE,0,0)
1866 #define MCIWndSetZoom(hWnd,iZoom)   (VOID)MCIWndSM(hWnd,MCIWNDM_SETZOOM,0,(LPARAM)(UINT)(iZoom))
1867 #define MCIWndGetZoom(hWnd)         (UINT)MCIWndSM(hWnd,MCIWNDM_GETZOOM,0,0)
1868 #define MCIWndSetVolume(hWnd,iVol)  (LONG)MCIWndSM(hWnd,MCIWNDM_SETVOLUME,0,(LPARAM)(UINT)(iVol))
1869 #define MCIWndGetVolume(hWnd)       (LONG)MCIWndSM(hWnd,MCIWNDM_GETVOLUME,0,0)
1870 #define MCIWndSetSpeed(hWnd,iSpeed) (LONG)MCIWndSM(hWnd,MCIWNDM_SETSPEED,0,(LPARAM)(UINT)(iSpeed))
1871 #define MCIWndGetSpeed(hWnd)        (LONG)MCIWndSM(hWnd,MCIWNDM_GETSPEED,0,0)
1872 #define MCIWndSetTimeFormat(hWnd,lp) (LONG)MCIWndSM(hWnd,MCIWNDM_SETTIMEFORMAT,0,(LPARAM)(LPTSTR)(lp))
1873 #define MCIWndGetTimeFormat(hWnd,lp,len) (LONG)MCIWndSM(hWnd,MCIWNDM_GETTIMEFORMAT,(WPARAM)(UINT)(len),(LPARAM)(LPTSTR)(lp))
1874 #define MCIWndValidateMedia(hWnd)   (VOID)MCIWndSM(hWnd,MCIWNDM_VALIDATEMEDIA,0,0)
1875 
1876 #define MCIWndSetRepeat(hWnd,f)     (void)MCIWndSM(hWnd,MCIWNDM_SETREPEAT,0,(LPARAM)(BOOL)(f))
1877 #define MCIWndGetRepeat(hWnd)       (BOOL)MCIWndSM(hWnd,MCIWNDM_GETREPEAT,0,0)
1878 
1879 #define MCIWndUseFrames(hWnd)       MCIWndSetTimeFormat(hWnd,TEXT("frames"))
1880 #define MCIWndUseTime(hWnd)         MCIWndSetTimeFormat(hWnd,TEXT("ms"))
1881 
1882 #define MCIWndSetActiveTimer(hWnd,active)				\
1883 	(VOID)MCIWndSM(hWnd,MCIWNDM_SETACTIVETIMER,			\
1884 	(WPARAM)(UINT)(active),0L)
1885 #define MCIWndSetInactiveTimer(hWnd,inactive)				\
1886 	(VOID)MCIWndSM(hWnd,MCIWNDM_SETINACTIVETIMER,			\
1887 	(WPARAM)(UINT)(inactive),0L)
1888 #define MCIWndSetTimers(hWnd,active,inactive)				\
1889 	    (VOID)MCIWndSM(hWnd,MCIWNDM_SETTIMERS,(WPARAM)(UINT)(active),\
1890 	    (LPARAM)(UINT)(inactive))
1891 #define MCIWndGetActiveTimer(hWnd)					\
1892 	(UINT)MCIWndSM(hWnd,MCIWNDM_GETACTIVETIMER,0,0L);
1893 #define MCIWndGetInactiveTimer(hWnd)					\
1894 	(UINT)MCIWndSM(hWnd,MCIWNDM_GETINACTIVETIMER,0,0L);
1895 
1896 #define MCIWndRealize(hWnd,fBkgnd) (LONG)MCIWndSM(hWnd,MCIWNDM_REALIZE,(WPARAM)(BOOL)(fBkgnd),0)
1897 
1898 #define MCIWndSendString(hWnd,sz)  (LONG)MCIWndSM(hWnd,MCIWNDM_SENDSTRING,0,(LPARAM)(LPTSTR)(sz))
1899 #define MCIWndReturnString(hWnd,lp,len)  (LONG)MCIWndSM(hWnd,MCIWNDM_RETURNSTRING,(WPARAM)(UINT)(len),(LPARAM)(LPVOID)(lp))
1900 #define MCIWndGetError(hWnd,lp,len) (LONG)MCIWndSM(hWnd,MCIWNDM_GETERROR,(WPARAM)(UINT)(len),(LPARAM)(LPVOID)(lp))
1901 
1902 #define MCIWndGetPalette(hWnd)      (HPALETTE)MCIWndSM(hWnd,MCIWNDM_GETPALETTE,0,0)
1903 #define MCIWndSetPalette(hWnd,hpal) (LONG)MCIWndSM(hWnd,MCIWNDM_SETPALETTE,(WPARAM)(HPALETTE)(hpal),0)
1904 
1905 #define MCIWndGetFileName(hWnd,lp,len) (LONG)MCIWndSM(hWnd,MCIWNDM_GETFILENAME,(WPARAM)(UINT)(len),(LPARAM)(LPVOID)(lp))
1906 #define MCIWndGetDevice(hWnd,lp,len)   (LONG)MCIWndSM(hWnd,MCIWNDM_GETDEVICE,(WPARAM)(UINT)(len),(LPARAM)(LPVOID)(lp))
1907 
1908 #define MCIWndGetStyles(hWnd) (UINT)MCIWndSM(hWnd,MCIWNDM_GETSTYLES,0,0L)
1909 #define MCIWndChangeStyles(hWnd,mask,value) (LONG)MCIWndSM(hWnd,MCIWNDM_CHANGESTYLES,(WPARAM)(UINT)(mask),(LPARAM)(LONG)(value))
1910 
1911 #define MCIWndOpenInterface(hWnd,pUnk)  (LONG)MCIWndSM(hWnd,MCIWNDM_OPENINTERFACE,0,(LPARAM)(LPUNKNOWN)(pUnk))
1912 
1913 #define MCIWndSetOwner(hWnd,hWndP)  (LONG)MCIWndSM(hWnd,MCIWNDM_SETOWNER,(WPARAM)(hWndP),0)
1914 
1915 #define MCIWNDM_GETDEVICEID	(WM_USER + 100)
1916 #define MCIWNDM_GETSTART	(WM_USER + 103)
1917 #define MCIWNDM_GETLENGTH	(WM_USER + 104)
1918 #define MCIWNDM_GETEND		(WM_USER + 105)
1919 #define MCIWNDM_EJECT		(WM_USER + 107)
1920 #define MCIWNDM_SETZOOM		(WM_USER + 108)
1921 #define MCIWNDM_GETZOOM         (WM_USER + 109)
1922 #define MCIWNDM_SETVOLUME	(WM_USER + 110)
1923 #define MCIWNDM_GETVOLUME	(WM_USER + 111)
1924 #define MCIWNDM_SETSPEED	(WM_USER + 112)
1925 #define MCIWNDM_GETSPEED	(WM_USER + 113)
1926 #define MCIWNDM_SETREPEAT	(WM_USER + 114)
1927 #define MCIWNDM_GETREPEAT	(WM_USER + 115)
1928 #define MCIWNDM_REALIZE         (WM_USER + 118)
1929 #define MCIWNDM_VALIDATEMEDIA   (WM_USER + 121)
1930 #define MCIWNDM_PLAYFROM	(WM_USER + 122)
1931 #define MCIWNDM_PLAYTO          (WM_USER + 123)
1932 #define MCIWNDM_GETPALETTE      (WM_USER + 126)
1933 #define MCIWNDM_SETPALETTE      (WM_USER + 127)
1934 #define MCIWNDM_SETTIMERS	(WM_USER + 129)
1935 #define MCIWNDM_SETACTIVETIMER	(WM_USER + 130)
1936 #define MCIWNDM_SETINACTIVETIMER (WM_USER + 131)
1937 #define MCIWNDM_GETACTIVETIMER	(WM_USER + 132)
1938 #define MCIWNDM_GETINACTIVETIMER (WM_USER + 133)
1939 #define MCIWNDM_CHANGESTYLES	(WM_USER + 135)
1940 #define MCIWNDM_GETSTYLES	(WM_USER + 136)
1941 #define MCIWNDM_GETALIAS	(WM_USER + 137)
1942 #define MCIWNDM_PLAYREVERSE	(WM_USER + 139)
1943 #define MCIWNDM_GET_SOURCE      (WM_USER + 140)
1944 #define MCIWNDM_PUT_SOURCE      (WM_USER + 141)
1945 #define MCIWNDM_GET_DEST        (WM_USER + 142)
1946 #define MCIWNDM_PUT_DEST        (WM_USER + 143)
1947 #define MCIWNDM_CAN_PLAY        (WM_USER + 144)
1948 #define MCIWNDM_CAN_WINDOW      (WM_USER + 145)
1949 #define MCIWNDM_CAN_RECORD      (WM_USER + 146)
1950 #define MCIWNDM_CAN_SAVE        (WM_USER + 147)
1951 #define MCIWNDM_CAN_EJECT       (WM_USER + 148)
1952 #define MCIWNDM_CAN_CONFIG      (WM_USER + 149)
1953 #define MCIWNDM_PALETTEKICK     (WM_USER + 150)
1954 #define MCIWNDM_OPENINTERFACE	(WM_USER + 151)
1955 #define MCIWNDM_SETOWNER	(WM_USER + 152)
1956 
1957 #define MCIWNDM_SENDSTRINGA	(WM_USER + 101)
1958 #define MCIWNDM_GETPOSITIONA	(WM_USER + 102)
1959 #define MCIWNDM_GETMODEA	(WM_USER + 106)
1960 #define MCIWNDM_SETTIMEFORMATA  (WM_USER + 119)
1961 #define MCIWNDM_GETTIMEFORMATA  (WM_USER + 120)
1962 #define MCIWNDM_GETFILENAMEA    (WM_USER + 124)
1963 #define MCIWNDM_GETDEVICEA      (WM_USER + 125)
1964 #define MCIWNDM_GETERRORA       (WM_USER + 128)
1965 #define MCIWNDM_NEWA		(WM_USER + 134)
1966 #define MCIWNDM_RETURNSTRINGA	(WM_USER + 138)
1967 #define MCIWNDM_OPENA		(WM_USER + 153)
1968 
1969 #define MCIWNDM_SENDSTRINGW	(WM_USER + 201)
1970 #define MCIWNDM_GETPOSITIONW	(WM_USER + 202)
1971 #define MCIWNDM_GETMODEW	(WM_USER + 206)
1972 #define MCIWNDM_SETTIMEFORMATW  (WM_USER + 219)
1973 #define MCIWNDM_GETTIMEFORMATW  (WM_USER + 220)
1974 #define MCIWNDM_GETFILENAMEW    (WM_USER + 224)
1975 #define MCIWNDM_GETDEVICEW      (WM_USER + 225)
1976 #define MCIWNDM_GETERRORW       (WM_USER + 228)
1977 #define MCIWNDM_NEWW		(WM_USER + 234)
1978 #define MCIWNDM_RETURNSTRINGW	(WM_USER + 238)
1979 #define MCIWNDM_OPENW		(WM_USER + 252)
1980 
1981 #define MCIWNDM_SENDSTRING	WINELIB_NAME_AW(MCIWNDM_SENDSTRING)
1982 #define MCIWNDM_GETPOSITION	WINELIB_NAME_AW(MCIWNDM_GETPOSITION)
1983 #define MCIWNDM_GETMODE		WINELIB_NAME_AW(MCIWNDM_GETMODE)
1984 #define MCIWNDM_SETTIMEFORMAT	WINELIB_NAME_AW(MCIWNDM_SETTIMEFORMAT)
1985 #define MCIWNDM_GETTIMEFORMAT	WINELIB_NAME_AW(MCIWNDM_GETTIMEFORMAT)
1986 #define MCIWNDM_GETFILENAME	WINELIB_NAME_AW(MCIWNDM_GETFILENAME)
1987 #define MCIWNDM_GETDEVICE	WINELIB_NAME_AW(MCIWNDM_GETDEVICE)
1988 #define MCIWNDM_GETERROR	WINELIB_NAME_AW(MCIWNDM_GETERROR)
1989 #define MCIWNDM_NEW		WINELIB_NAME_AW(MCIWNDM_NEW)
1990 #define MCIWNDM_RETURNSTRING	WINELIB_NAME_AW(MCIWNDM_RETURNSTRING)
1991 #define MCIWNDM_OPEN		WINELIB_NAME_AW(MCIWNDM_OPEN)
1992 
1993 #define MCIWNDM_NOTIFYMODE      (WM_USER + 200)
1994 #define MCIWNDM_NOTIFYPOS	(WM_USER + 201)
1995 #define MCIWNDM_NOTIFYSIZE	(WM_USER + 202)
1996 #define MCIWNDM_NOTIFYMEDIA     (WM_USER + 203)
1997 #define MCIWNDM_NOTIFYERROR     (WM_USER + 205)
1998 
1999 #define MCIWND_START                -1
2000 #define MCIWND_END                  -2
2001 
2002 /********************************************
2003  * DrawDib declarations
2004  */
2005 
2006 typedef struct
2007 {
2008     LONG    timeCount;
2009     LONG    timeDraw;
2010     LONG    timeDecompress;
2011     LONG    timeDither;
2012     LONG    timeStretch;
2013     LONG    timeBlt;
2014     LONG    timeSetDIBits;
2015 } DRAWDIBTIME, *LPDRAWDIBTIME;
2016 
2017 HDRAWDIB VFWAPI DrawDibOpen( void );
2018 
2019 UINT
2020 VFWAPI
2021 DrawDibRealize(
2022   _In_ HDRAWDIB hdd,
2023   _In_ HDC hdc,
2024   _In_ BOOL fBackground);
2025 
2026 BOOL
2027 VFWAPI
2028 DrawDibBegin(
2029   _In_ HDRAWDIB hdd,
2030   _In_opt_ HDC hdc,
2031   _In_ INT dxDst,
2032   _In_ INT dyDst,
2033   _In_ LPBITMAPINFOHEADER lpbi,
2034   _In_ INT dxSrc,
2035   _In_ INT dySrc,
2036   _In_ UINT wFlags);
2037 
2038 BOOL
2039 VFWAPI
2040 DrawDibDraw(
2041   _In_ HDRAWDIB hdd,
2042   _In_ HDC hdc,
2043   _In_ INT xDst,
2044   _In_ INT yDst,
2045   _In_ INT dxDst,
2046   _In_ INT dyDst,
2047   _In_opt_ LPBITMAPINFOHEADER lpbi,
2048   _In_opt_ LPVOID lpBits,
2049   _In_ INT xSrc,
2050   _In_ INT ySrc,
2051   _In_ INT dxSrc,
2052   _In_ INT dySrc,
2053   _In_ UINT wFlags);
2054 
2055 /* DrawDibDraw flags */
2056 
2057 #define DDF_UPDATE			0x0002
2058 #define DDF_SAME_HDC			0x0004
2059 #define DDF_SAME_DRAW			0x0008
2060 #define DDF_DONTDRAW			0x0010
2061 #define DDF_ANIMATE			0x0020
2062 #define DDF_BUFFER			0x0040
2063 #define DDF_JUSTDRAWIT			0x0080
2064 #define DDF_FULLSCREEN			0x0100
2065 #define DDF_BACKGROUNDPAL		0x0200
2066 #define DDF_NOTKEYFRAME			0x0400
2067 #define DDF_HURRYUP			0x0800
2068 #define DDF_HALFTONE			0x1000
2069 
2070 #define DDF_PREROLL         		DDF_DONTDRAW
2071 #define DDF_SAME_DIB        		DDF_SAME_DRAW
2072 #define DDF_SAME_SIZE       		DDF_SAME_DRAW
2073 
2074 BOOL VFWAPI DrawDibSetPalette(_In_ HDRAWDIB hdd, _In_opt_ HPALETTE hpal);
2075 HPALETTE VFWAPI DrawDibGetPalette(_In_ HDRAWDIB hdd);
2076 
2077 BOOL
2078 VFWAPI
2079 DrawDibChangePalette(
2080   _In_ HDRAWDIB hdd,
2081   _In_ int iStart,
2082   _In_ int iLen,
2083   _In_reads_(iLen) LPPALETTEENTRY lppe);
2084 
2085 LPVOID
2086 VFWAPI
2087 DrawDibGetBuffer(
2088   _In_ HDRAWDIB hdd,
2089   _Out_ LPBITMAPINFOHEADER lpbi,
2090   _In_ DWORD dwSize,
2091   _In_ DWORD dwFlags);
2092 
2093 BOOL VFWAPI DrawDibStart(_In_ HDRAWDIB hdd, _In_ DWORD rate);
2094 BOOL VFWAPI DrawDibStop(_In_ HDRAWDIB hdd);
2095 
2096 #define DrawDibUpdate(hdd, hdc, x, y) \
2097         DrawDibDraw(hdd, hdc, x, y, 0, 0, NULL, NULL, 0, 0, 0, 0, DDF_UPDATE)
2098 
2099 BOOL VFWAPI DrawDibEnd(_In_ HDRAWDIB hdd);
2100 BOOL VFWAPI DrawDibClose(_In_ HDRAWDIB hdd);
2101 BOOL VFWAPI DrawDibTime(_In_ HDRAWDIB hdd, _Out_ LPDRAWDIBTIME lpddtime);
2102 
2103 /* display profiling */
2104 #define PD_CAN_DRAW_DIB         0x0001
2105 #define PD_CAN_STRETCHDIB       0x0002
2106 #define PD_STRETCHDIB_1_1_OK    0x0004
2107 #define PD_STRETCHDIB_1_2_OK    0x0008
2108 #define PD_STRETCHDIB_1_N_OK    0x0010
2109 
2110 DWORD VFWAPI DrawDibProfileDisplay(_In_ LPBITMAPINFOHEADER lpbi);
2111 
2112 DECLARE_HANDLE(HVIDEO);
2113 typedef HVIDEO *LPHVIDEO;
2114 
2115 DWORD VFWAPI VideoForWindowsVersion(void);
2116 
2117 LONG  VFWAPI InitVFW(void);
2118 LONG  VFWAPI TermVFW(void);
2119 
2120 #define DV_ERR_OK            (0)
2121 #define DV_ERR_BASE          (1)
2122 #define DV_ERR_NONSPECIFIC   (DV_ERR_BASE)
2123 #define DV_ERR_BADFORMAT     (DV_ERR_BASE + 1)
2124 #define DV_ERR_STILLPLAYING  (DV_ERR_BASE + 2)
2125 #define DV_ERR_UNPREPARED    (DV_ERR_BASE + 3)
2126 #define DV_ERR_SYNC          (DV_ERR_BASE + 4)
2127 #define DV_ERR_TOOMANYCHANNELS (DV_ERR_BASE + 5)
2128 #define DV_ERR_NOTDETECTED   (DV_ERR_BASE + 6)
2129 #define DV_ERR_BADINSTALL    (DV_ERR_BASE + 7)
2130 #define DV_ERR_CREATEPALETTE (DV_ERR_BASE + 8)
2131 #define DV_ERR_SIZEFIELD     (DV_ERR_BASE + 9)
2132 #define DV_ERR_PARAM1        (DV_ERR_BASE + 10)
2133 #define DV_ERR_PARAM2        (DV_ERR_BASE + 11)
2134 #define DV_ERR_CONFIG1       (DV_ERR_BASE + 12)
2135 #define DV_ERR_CONFIG2       (DV_ERR_BASE + 13)
2136 #define DV_ERR_FLAGS         (DV_ERR_BASE + 14)
2137 #define DV_ERR_13            (DV_ERR_BASE + 15)
2138 
2139 #define DV_ERR_NOTSUPPORTED  (DV_ERR_BASE + 16)
2140 #define DV_ERR_NOMEM         (DV_ERR_BASE + 17)
2141 #define DV_ERR_ALLOCATED     (DV_ERR_BASE + 18)
2142 #define DV_ERR_BADDEVICEID   (DV_ERR_BASE + 19)
2143 #define DV_ERR_INVALHANDLE   (DV_ERR_BASE + 20)
2144 #define DV_ERR_BADERRNUM     (DV_ERR_BASE + 21)
2145 #define DV_ERR_NO_BUFFERS    (DV_ERR_BASE + 22)
2146 
2147 #define DV_ERR_MEM_CONFLICT  (DV_ERR_BASE + 23)
2148 #define DV_ERR_IO_CONFLICT   (DV_ERR_BASE + 24)
2149 #define DV_ERR_DMA_CONFLICT  (DV_ERR_BASE + 25)
2150 #define DV_ERR_INT_CONFLICT  (DV_ERR_BASE + 26)
2151 #define DV_ERR_PROTECT_ONLY  (DV_ERR_BASE + 27)
2152 #define DV_ERR_LASTERROR     (DV_ERR_BASE + 27)
2153 
2154 #define DV_ERR_USER_MSG      (DV_ERR_BASE + 1000)
2155 
2156 #ifndef MM_DRVM_OPEN
2157 #define MM_DRVM_OPEN       0x3D0
2158 #define MM_DRVM_CLOSE      0x3D1
2159 #define MM_DRVM_DATA       0x3D2
2160 #define MM_DRVM_ERROR      0x3D3
2161 
2162 #define DV_VM_OPEN         MM_DRVM_OPEN
2163 #define DV_VM_CLOSE        MM_DRVM_CLOSE
2164 #define DV_VM_DATA         MM_DRVM_DATA
2165 #define DV_VM_ERROR        MM_DRVM_ERROR
2166 #endif
2167 
2168 typedef struct videohdr_tag {
2169     LPBYTE      lpData;
2170     DWORD       dwBufferLength;
2171     DWORD       dwBytesUsed;
2172     DWORD       dwTimeCaptured;
2173     DWORD_PTR   dwUser;
2174     DWORD       dwFlags;
2175     DWORD_PTR   dwReserved[4];
2176 } VIDEOHDR, *PVIDEOHDR, *LPVIDEOHDR;
2177 
2178 #define VHDR_DONE       0x00000001
2179 #define VHDR_PREPARED   0x00000002
2180 #define VHDR_INQUEUE    0x00000004
2181 #define VHDR_KEYFRAME   0x00000008
2182 
2183 typedef struct channel_caps_tag {
2184     DWORD       dwFlags;
2185     DWORD       dwSrcRectXMod;
2186     DWORD       dwSrcRectYMod;
2187     DWORD       dwSrcRectWidthMod;
2188     DWORD       dwSrcRectHeightMod;
2189     DWORD       dwDstRectXMod;
2190     DWORD       dwDstRectYMod;
2191     DWORD       dwDstRectWidthMod;
2192     DWORD       dwDstRectHeightMod;
2193 } CHANNEL_CAPS, *PCHANNEL_CAPS, *LPCHANNEL_CAPS;
2194 
2195 #define VCAPS_OVERLAY       0x00000001
2196 #define VCAPS_SRC_CAN_CLIP  0x00000002
2197 #define VCAPS_DST_CAN_CLIP  0x00000004
2198 #define VCAPS_CAN_SCALE     0x00000008
2199 
2200 #define VIDEO_EXTERNALIN        0x0001
2201 #define VIDEO_EXTERNALOUT       0x0002
2202 #define VIDEO_IN                0x0004
2203 #define VIDEO_OUT               0x0008
2204 
2205 #define VIDEO_DLG_QUERY         0x0010
2206 
2207 #define VIDEO_CONFIGURE_QUERY   0x8000
2208 
2209 #define VIDEO_CONFIGURE_SET     0x1000
2210 
2211 #define VIDEO_CONFIGURE_GET     0x2000
2212 #define VIDEO_CONFIGURE_QUERYSIZE 0x0001
2213 
2214 #define VIDEO_CONFIGURE_CURRENT 0x0010
2215 #define VIDEO_CONFIGURE_NOMINAL 0x0020
2216 #define VIDEO_CONFIGURE_MIN     0x0040
2217 #define VIDEO_CONFIGURE_MAX     0x0080
2218 
2219 #define DVM_USER                0x4000
2220 
2221 #define DVM_CONFIGURE_START     0x1000
2222 #define DVM_CONFIGURE_END       0x1FFF
2223 
2224 #define DVM_PALETTE             (DVM_CONFIGURE_START + 1)
2225 #define DVM_FORMAT              (DVM_CONFIGURE_START + 2)
2226 #define DVM_PALETTERGB555       (DVM_CONFIGURE_START + 3)
2227 #define DVM_SRC_RECT            (DVM_CONFIGURE_START + 4)
2228 #define DVM_DST_RECT            (DVM_CONFIGURE_START + 5)
2229 
2230 #define AVICapSM(hwnd,m,w,l) ((IsWindow(hwnd)) ? SendMessage(hwnd,m,w,l) : 0)
2231 
2232 #define WM_CAP_START                    WM_USER
2233 
2234 #define WM_CAP_UNICODE_START            WM_USER+100
2235 
2236 #define WM_CAP_GET_CAPSTREAMPTR         (WM_CAP_START + 1)
2237 
2238 #define WM_CAP_SET_CALLBACK_ERRORW      (WM_CAP_UNICODE_START + 2)
2239 #define WM_CAP_SET_CALLBACK_STATUSW     (WM_CAP_UNICODE_START + 3)
2240 #define WM_CAP_SET_CALLBACK_ERRORA      (WM_CAP_START + 2)
2241 #define WM_CAP_SET_CALLBACK_STATUSA     (WM_CAP_START+ 3)
2242 
2243 #define WM_CAP_SET_CALLBACK_ERROR       WINELIB_NAME_AW(WM_CAP_SET_CALLBACK_ERROR)
2244 #define WM_CAP_SET_CALLBACK_STATUS      WINELIB_NAME_AW(WM_CAP_SET_CALLBACK_STATUS)
2245 
2246 #define WM_CAP_SET_CALLBACK_YIELD       (WM_CAP_START +  4)
2247 #define WM_CAP_SET_CALLBACK_FRAME       (WM_CAP_START +  5)
2248 #define WM_CAP_SET_CALLBACK_VIDEOSTREAM (WM_CAP_START +  6)
2249 #define WM_CAP_SET_CALLBACK_WAVESTREAM  (WM_CAP_START +  7)
2250 #define WM_CAP_GET_USER_DATA            (WM_CAP_START +  8)
2251 #define WM_CAP_SET_USER_DATA            (WM_CAP_START +  9)
2252 
2253 #define WM_CAP_DRIVER_CONNECT           (WM_CAP_START +  10)
2254 #define WM_CAP_DRIVER_DISCONNECT        (WM_CAP_START +  11)
2255 
2256 #define WM_CAP_DRIVER_GET_NAMEA         (WM_CAP_START +  12)
2257 #define WM_CAP_DRIVER_GET_VERSIONA      (WM_CAP_START +  13)
2258 #define WM_CAP_DRIVER_GET_NAMEW         (WM_CAP_UNICODE_START +  12)
2259 #define WM_CAP_DRIVER_GET_VERSIONW      (WM_CAP_UNICODE_START +  13)
2260 
2261 #define WM_CAP_DRIVER_GET_NAME          WINELIB_NAME_AW(WM_CAP_DRIVER_GET_NAME)
2262 #define WM_CAP_DRIVER_GET_VERSION       WINELIB_NAME_AW(WM_CAP_DRIVER_GET_VERSION)
2263 
2264 #define WM_CAP_DRIVER_GET_CAPS          (WM_CAP_START +  14)
2265 
2266 #define WM_CAP_FILE_SET_CAPTURE_FILEA   (WM_CAP_START +  20)
2267 #define WM_CAP_FILE_GET_CAPTURE_FILEA   (WM_CAP_START +  21)
2268 #define WM_CAP_FILE_ALLOCATE            (WM_CAP_START +  22)
2269 #define WM_CAP_FILE_SAVEASA             (WM_CAP_START +  23)
2270 #define WM_CAP_FILE_SET_INFOCHUNK       (WM_CAP_START +  24)
2271 #define WM_CAP_FILE_SAVEDIBA            (WM_CAP_START +  25)
2272 #define WM_CAP_FILE_SET_CAPTURE_FILEW   (WM_CAP_UNICODE_START +  20)
2273 #define WM_CAP_FILE_GET_CAPTURE_FILEW   (WM_CAP_UNICODE_START +  21)
2274 #define WM_CAP_FILE_SAVEASW             (WM_CAP_UNICODE_START +  23)
2275 #define WM_CAP_FILE_SAVEDIBW            (WM_CAP_UNICODE_START +  25)
2276 
2277 #define WM_CAP_FILE_SET_CAPTURE_FILE    WINELIB_NAME_AW(WM_CAP_FILE_SET_CAPTURE_FILE)
2278 #define WM_CAP_FILE_GET_CAPTURE_FILE    WINELIB_NAME_AW(WM_CAP_FILE_GET_CAPTURE_FILE)
2279 #define WM_CAP_FILE_SAVEAS              WINELIB_NAME_AW(WM_CAP_FILE_SAVEAS)
2280 #define WM_CAP_FILE_SAVEDIB             WINELIB_NAME_AW(WM_CAP_FILE_SAVEDIB)
2281 
2282 #define WM_CAP_EDIT_COPY                (WM_CAP_START +  30)
2283 
2284 #define WM_CAP_SET_AUDIOFORMAT          (WM_CAP_START +  35)
2285 #define WM_CAP_GET_AUDIOFORMAT          (WM_CAP_START +  36)
2286 
2287 #define WM_CAP_DLG_VIDEOFORMAT          (WM_CAP_START +  41)
2288 #define WM_CAP_DLG_VIDEOSOURCE          (WM_CAP_START +  42)
2289 #define WM_CAP_DLG_VIDEODISPLAY         (WM_CAP_START +  43)
2290 #define WM_CAP_GET_VIDEOFORMAT          (WM_CAP_START +  44)
2291 #define WM_CAP_SET_VIDEOFORMAT          (WM_CAP_START +  45)
2292 #define WM_CAP_DLG_VIDEOCOMPRESSION     (WM_CAP_START +  46)
2293 
2294 #define WM_CAP_SET_PREVIEW              (WM_CAP_START +  50)
2295 #define WM_CAP_SET_OVERLAY              (WM_CAP_START +  51)
2296 #define WM_CAP_SET_PREVIEWRATE          (WM_CAP_START +  52)
2297 #define WM_CAP_SET_SCALE                (WM_CAP_START +  53)
2298 #define WM_CAP_GET_STATUS               (WM_CAP_START +  54)
2299 #define WM_CAP_SET_SCROLL               (WM_CAP_START +  55)
2300 
2301 #define WM_CAP_GRAB_FRAME               (WM_CAP_START +  60)
2302 #define WM_CAP_GRAB_FRAME_NOSTOP        (WM_CAP_START +  61)
2303 
2304 #define WM_CAP_SEQUENCE                 (WM_CAP_START +  62)
2305 #define WM_CAP_SEQUENCE_NOFILE          (WM_CAP_START +  63)
2306 #define WM_CAP_SET_SEQUENCE_SETUP       (WM_CAP_START +  64)
2307 #define WM_CAP_GET_SEQUENCE_SETUP       (WM_CAP_START +  65)
2308 
2309 #define WM_CAP_SET_MCI_DEVICEA          (WM_CAP_START +  66)
2310 #define WM_CAP_GET_MCI_DEVICEA          (WM_CAP_START +  67)
2311 #define WM_CAP_SET_MCI_DEVICEW          (WM_CAP_UNICODE_START +  66)
2312 #define WM_CAP_GET_MCI_DEVICEW          (WM_CAP_UNICODE_START +  67)
2313 
2314 #define WM_CAP_SET_MCI_DEVICE           WINELIB_NAME_AW(WM_CAP_SET_MCI_DEVICE)
2315 #define WM_CAP_GET_MCI_DEVICE           WINELIB_NAME_AW(WM_CAP_GET_MCI_DEVICE)
2316 
2317 #define WM_CAP_STOP                     (WM_CAP_START +  68)
2318 #define WM_CAP_ABORT                    (WM_CAP_START +  69)
2319 
2320 #define WM_CAP_SINGLE_FRAME_OPEN        (WM_CAP_START +  70)
2321 #define WM_CAP_SINGLE_FRAME_CLOSE       (WM_CAP_START +  71)
2322 #define WM_CAP_SINGLE_FRAME             (WM_CAP_START +  72)
2323 
2324 #define WM_CAP_PAL_OPENA                (WM_CAP_START +  80)
2325 #define WM_CAP_PAL_SAVEA                (WM_CAP_START +  81)
2326 #define WM_CAP_PAL_OPENW                (WM_CAP_UNICODE_START +  80)
2327 #define WM_CAP_PAL_SAVEW                (WM_CAP_UNICODE_START +  81)
2328 
2329 #define WM_CAP_PAL_OPEN                 WINELIB_NAME_AW(WM_CAP_PAL_OPEN)
2330 #define WM_CAP_PAL_SAVE                 WINELIB_NAME_AW(WM_CAP_PAL_SAVE)
2331 
2332 #define WM_CAP_PAL_PASTE                (WM_CAP_START +  82)
2333 #define WM_CAP_PAL_AUTOCREATE           (WM_CAP_START +  83)
2334 #define WM_CAP_PAL_MANUALCREATE         (WM_CAP_START +  84)
2335 
2336 #define WM_CAP_SET_CALLBACK_CAPCONTROL  (WM_CAP_START +  85)
2337 
2338 #define WM_CAP_UNICODE_END              WM_CAP_PAL_SAVEW
2339 #define WM_CAP_END                      WM_CAP_UNICODE_END
2340 
2341 typedef struct tagCapDriverCaps {
2342     UINT        wDeviceIndex;
2343     BOOL        fHasOverlay;
2344     BOOL        fHasDlgVideoSource;
2345     BOOL        fHasDlgVideoFormat;
2346     BOOL        fHasDlgVideoDisplay;
2347     BOOL        fCaptureInitialized;
2348     BOOL        fDriverSuppliesPalettes;
2349     HANDLE      hVideoIn;
2350     HANDLE      hVideoOut;
2351     HANDLE      hVideoExtIn;
2352     HANDLE      hVideoExtOut;
2353 } CAPDRIVERCAPS, *PCAPDRIVERCAPS, *LPCAPDRIVERCAPS;
2354 
2355 typedef struct tagCapStatus {
2356     UINT        uiImageWidth;
2357     UINT        uiImageHeight;
2358     BOOL        fLiveWindow;
2359     BOOL        fOverlayWindow;
2360     BOOL        fScale;
2361     POINT       ptScroll;
2362     BOOL        fUsingDefaultPalette;
2363     BOOL        fAudioHardware;
2364     BOOL        fCapFileExists;
2365     DWORD       dwCurrentVideoFrame;
2366     DWORD       dwCurrentVideoFramesDropped;
2367     DWORD       dwCurrentWaveSamples;
2368     DWORD       dwCurrentTimeElapsedMS;
2369     HPALETTE    hPalCurrent;
2370     BOOL        fCapturingNow;
2371     DWORD       dwReturn;
2372     UINT        wNumVideoAllocated;
2373     UINT        wNumAudioAllocated;
2374 } CAPSTATUS, *PCAPSTATUS, *LPCAPSTATUS;
2375 
2376 
2377 typedef struct tagCaptureParms {
2378     DWORD       dwRequestMicroSecPerFrame;
2379     BOOL        fMakeUserHitOKToCapture;
2380     UINT        wPercentDropForError;
2381     BOOL        fYield;
2382     DWORD       dwIndexSize;
2383     UINT        wChunkGranularity;
2384     BOOL        fUsingDOSMemory;
2385     UINT        wNumVideoRequested;
2386     BOOL        fCaptureAudio;
2387     UINT        wNumAudioRequested;
2388     UINT        vKeyAbort;
2389     BOOL        fAbortLeftMouse;
2390     BOOL        fAbortRightMouse;
2391     BOOL        fLimitEnabled;
2392     UINT        wTimeLimit;
2393     BOOL        fMCIControl;
2394     BOOL        fStepMCIDevice;
2395     DWORD       dwMCIStartTime;
2396     DWORD       dwMCIStopTime;
2397     BOOL        fStepCaptureAt2x;
2398     UINT        wStepCaptureAverageFrames;
2399     DWORD       dwAudioBufferSize;
2400     BOOL        fDisableWriteCache;
2401     UINT        AVStreamMaster;
2402 } CAPTUREPARMS, *PCAPTUREPARMS, *LPCAPTUREPARMS;
2403 
2404 typedef LRESULT (CALLBACK* CAPYIELDCALLBACK)(_In_ HWND hWnd);
2405 
2406 typedef LRESULT
2407 (CALLBACK* CAPSTATUSCALLBACKW)(
2408   _In_ HWND hWnd,
2409   _In_ int nID,
2410   _In_ LPCWSTR lpsz);
2411 
2412 typedef LRESULT
2413 (CALLBACK* CAPERRORCALLBACKW)(
2414   _In_ HWND hWnd,
2415   _In_ int nID,
2416   LPCWSTR lpsz);
2417 
2418 typedef LRESULT
2419 (CALLBACK* CAPSTATUSCALLBACKA)(
2420   _In_ HWND hWnd,
2421   _In_ int nID,
2422   LPCSTR lpsz);
2423 
2424 typedef LRESULT
2425 (CALLBACK* CAPERRORCALLBACKA)(
2426   _In_ HWND hWnd,
2427   _In_ int nID,
2428   LPCSTR lpsz);
2429 
2430 typedef LRESULT
2431 (CALLBACK* CAPVIDEOCALLBACK)(
2432   _In_ HWND hWnd,
2433   _In_ LPVIDEOHDR lpVHdr);
2434 
2435 typedef LRESULT
2436 (CALLBACK* CAPWAVECALLBACK)(
2437   _In_ HWND hWnd,
2438   _In_ LPWAVEHDR lpWHdr);
2439 
2440 typedef LRESULT
2441 (CALLBACK* CAPCONTROLCALLBACK)(
2442   _In_ HWND hWnd,
2443   _In_ int nState);
2444 
2445 HWND
2446 VFWAPI
2447 capCreateCaptureWindowA(
2448   LPCSTR,
2449   _In_ DWORD,
2450   _In_ INT,
2451   _In_ INT,
2452   _In_ INT,
2453   _In_ INT,
2454   _In_opt_ HWND,
2455   _In_ INT);
2456 
2457 HWND
2458 VFWAPI
2459 capCreateCaptureWindowW(
2460   LPCWSTR,
2461   _In_ DWORD,
2462   _In_ INT,
2463   _In_ INT,
2464   _In_ INT,
2465   _In_ INT,
2466   _In_opt_ HWND,
2467   _In_ INT);
2468 
2469 #define capCreateCaptureWindow WINELIB_NAME_AW(capCreateCaptureWindow)
2470 
2471 BOOL
2472 VFWAPI
2473 capGetDriverDescriptionA(
2474   WORD,
2475   _Out_writes_(cbName) LPSTR,
2476   _In_ INT cbName,
2477   _Out_writes_(cbVer) LPSTR,
2478   _In_ INT cbVer);
2479 
2480 BOOL
2481 VFWAPI
2482 capGetDriverDescriptionW(
2483   WORD,
2484   _Out_writes_(cbName) LPWSTR,
2485   _In_ INT cbName,
2486   _Out_writes_(cbVer) LPWSTR,
2487   _In_ INT cbVer);
2488 
2489 #define capGetDriverDescription WINELIB_NAME_AW(capGetDriverDescription)
2490 
2491 #ifdef __cplusplus
2492 }
2493 #endif  /* __cplusplus */
2494 
2495 #endif /* __WINE_VFW_H */
2496