2 * Copyright 1998 Marcus Meissner
3 * Copyright 2000 Bradley Baetz
5 * FIXME: This all assumes 32 bit codecs
6 * Win95 appears to prefer 32 bit codecs, even from 16 bit code.
7 * There is the ICOpenFunction16 to worry about still, though.
18 #include "wine/winestring.h"
19 #include "debugtools.h"
22 #include "stackframe.h"
24 DEFAULT_DEBUG_CHANNEL(msvideo
);
26 /* ### start build ### */
27 extern LONG CALLBACK
MSVIDEO_CallTo16_long_lwwll(FARPROC16
,LONG
,WORD
,WORD
,LONG
,LONG
);
28 /* ### stop build ### */
30 LPVOID
MSVIDEO_MapMsg16To32(UINT msg
, LPDWORD lParam1
, LPDWORD lParam2
);
31 void MSVIDEO_UnmapMsg16To32(UINT msg
, LPVOID lpv
, LPDWORD lParam1
, LPDWORD lParam2
);
32 LRESULT
MSVIDEO_SendMessage(HIC hic
, UINT msg
, DWORD lParam1
, DWORD lParam2
, BOOL bFrom32
);
34 /***********************************************************************
35 * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
36 * Returns the version in major.minor form.
37 * In Windows95 this returns 0x040003b6 (4.950)
39 DWORD WINAPI
VideoForWindowsVersion(void) {
40 return 0x040003B6; /* 4.950 */
43 /***********************************************************************
44 * VideoCapDriverDescAndVer [MSVIDEO.22]
46 DWORD WINAPI
VideoCapDriverDescAndVer(WORD nr
,LPVOID buf1
,WORD buf1len
,LPVOID buf2
,WORD buf2len
) {
47 FIXME("(%d,%p,%d,%p,%d), stub!\n",nr
,buf1
,buf1len
,buf2
,buf2len
);
51 /* system.ini: [drivers] */
53 /***********************************************************************
55 * Get information about an installable compressor. Return TRUE if there
59 DWORD fccType
, /* [in] type of compressor ('vidc') */
60 DWORD fccHandler
, /* [in] <n>th compressor */
61 ICINFO
*lpicinfo
) /* [out] information about compressor */
63 char type
[5],buf
[2000];
65 memcpy(type
,&fccType
,4);type
[4]=0;
66 TRACE("(%s,%ld,%p).\n",type
,fccHandler
,lpicinfo
);
67 /* does OpenDriver/CloseDriver */
68 lpicinfo
->dwSize
= sizeof(ICINFO
);
69 lpicinfo
->fccType
= fccType
;
70 lpicinfo
->dwFlags
= 0;
71 if (GetPrivateProfileStringA("drivers32",NULL
,NULL
,buf
,2000,"system.ini")) {
74 if (!lstrncmpiA(type
,s
,4)) {
76 lpicinfo
->fccHandler
= mmioStringToFOURCCA(s
+5,0);
80 s
=s
+strlen(s
)+1; /* either next char or \0 */
86 BOOL16 VFWAPI
ICInfo16(DWORD fccType
, DWORD fccHandler
, ICINFO16
* /*SEGPTR*/ lpicinfo
) {
89 DWORD lParam
= (DWORD
)lpicinfo
;
90 DWORD size
= ((ICINFO
*)(PTR_SEG_TO_LIN(lpicinfo
)))->dwSize
;
92 /* Use the mapping functions to map the ICINFO structure */
93 lpv
= MSVIDEO_MapMsg16To32(ICM_GETINFO
,&lParam
,&size
);
95 ret
= ICInfo(fccType
,fccHandler
,(ICINFO
*)lParam
);
97 MSVIDEO_UnmapMsg16To32(ICM_GETINFO
,lpv
,&lParam
,&size
);
102 /***********************************************************************
104 * Opens an installable compressor. Return special handle.
106 HIC VFWAPI
ICOpen(DWORD fccType
,DWORD fccHandler
,UINT wMode
) {
107 char type
[5],handler
[5],codecname
[20];
113 memcpy(type
,&fccType
,4);type
[4]=0;
114 memcpy(handler
,&fccHandler
,4);handler
[4]=0;
115 TRACE("(%s,%s,0x%08lx)\n",type
,handler
,(DWORD
)wMode
);
117 sprintf(codecname
,"%s.%s",type
,handler
);
119 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
120 * same layout as ICOPEN
122 icopen
.fccType
= fccType
;
123 icopen
.fccHandler
= fccHandler
;
124 icopen
.dwSize
= sizeof(ICOPEN
);
125 icopen
.dwFlags
= wMode
;
126 /* FIXME: do we need to fill out the rest too? */
127 hdrv
=OpenDriverA(codecname
,"drivers32",(LPARAM
)&icopen
);
129 if (!strcasecmp(type
,"vids")) {
130 sprintf(codecname
,"vidc.%s",handler
);
131 fccType
= mmioFOURCC('v','i','d','c');
133 hdrv
=OpenDriverA(codecname
,"drivers32",(LPARAM
)&icopen
);
137 /* The handle should be a valid 16-bit handle as well */
138 hic
= GlobalAlloc16(GHND
,sizeof(WINE_HIC
));
139 whic
= (WINE_HIC
*)GlobalLock16(hic
);
141 whic
->driverproc
= NULL
;
144 TRACE("=> 0x%08lx\n",(DWORD
)hic
);
148 HIC
MSVIDEO_OpenFunc(DWORD fccType
, DWORD fccHandler
, UINT wMode
, FARPROC lpfnHandler
, BOOL bFrom32
) {
149 char type
[5],handler
[5],codecname
[20];
151 ICOPEN
* icopen
= SEGPTR_NEW(ICOPEN
);
154 memcpy(type
,&fccType
,4);type
[4]=0;
155 memcpy(handler
,&fccHandler
,4);handler
[4]=0;
156 TRACE("(%s,%s,%d,%p,%d)\n",type
,handler
,wMode
,lpfnHandler
,bFrom32
?32:16);
158 icopen
->fccType
= fccType
;
159 icopen
->fccHandler
= fccHandler
;
160 icopen
->dwSize
= sizeof(ICOPEN
);
161 icopen
->dwFlags
= wMode
;
163 sprintf(codecname
,"%s.%s",type
,handler
);
165 hic
= GlobalAlloc16(GHND
,sizeof(WINE_HIC
));
168 whic
= GlobalLock16(hic
);
169 whic
->driverproc
= lpfnHandler
;
171 whic
->private = bFrom32
;
173 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
174 /* What if the function is used more than once? */
176 if (MSVIDEO_SendMessage(hic
,DRV_LOAD
,0L,0L,bFrom32
) != DRV_SUCCESS
) {
177 WARN("DRV_LOAD failed for hic 0x%08lx\n",(DWORD
)hic
);
181 if (MSVIDEO_SendMessage(hic
,DRV_ENABLE
,0L,0L,bFrom32
) != DRV_SUCCESS
) {
182 WARN("DRV_ENABLE failed for hic 0x%08lx\n",(DWORD
)hic
);
186 whic
->hdrv
= MSVIDEO_SendMessage(hic
,DRV_OPEN
,0,(LPARAM
)(SEGPTR_GET(icopen
)),FALSE
);
187 if (whic
->hdrv
== 0) {
188 WARN("DRV_OPEN failed for hic 0x%08lx\n",(DWORD
)hic
);
194 TRACE("=> 0x%08lx\n",(DWORD
)hic
);
198 /***********************************************************************
199 * ICOpenFunction [MSVFW.38]
201 HIC VFWAPI
ICOpenFunction(DWORD fccType
, DWORD fccHandler
, UINT wMode
, FARPROC lpfnHandler
) {
202 return MSVIDEO_OpenFunc(fccType
,fccHandler
,wMode
,lpfnHandler
,TRUE
);
205 HIC16 VFWAPI
ICOpen16(DWORD fccType
, DWORD fccHandler
, UINT16 wMode
) {
206 return (HIC16
)ICOpen(fccType
, fccHandler
, wMode
);
209 HIC16 VFWAPI
ICOpenFunction16(DWORD fccType
, DWORD fccHandler
, UINT16 wMode
, FARPROC16 lpfnHandler
) {
210 return MSVIDEO_OpenFunc(fccType
, fccHandler
, wMode
, lpfnHandler
,FALSE
);
213 /***********************************************************************
214 * ICGetInfo [MSVFW.30]
216 LRESULT VFWAPI
ICGetInfo(HIC hic
,ICINFO
*picinfo
,DWORD cb
) {
219 TRACE("(0x%08lx,%p,%ld)\n",(DWORD
)hic
,picinfo
,cb
);
220 ret
= ICSendMessage(hic
,ICM_GETINFO
,(DWORD
)picinfo
,cb
);
221 TRACE(" -> 0x%08lx\n",ret
);
225 LRESULT VFWAPI
ICGetInfo16(HIC16 hic
, ICINFO16
*picinfo
,DWORD cb
) {
228 TRACE("(0x%08lx,%p,%ld)\n",(DWORD
)hic
,picinfo
,cb
);
229 ret
= ICSendMessage16(hic
,ICM_GETINFO
,(DWORD
)picinfo
,cb
);
230 TRACE(" -> 0x%08lx\n",ret
);
234 /***********************************************************************
235 * ICLocate [MSVFW.35]
238 DWORD fccType
, DWORD fccHandler
, LPBITMAPINFOHEADER lpbiIn
,
239 LPBITMAPINFOHEADER lpbiOut
, WORD wMode
)
241 char type
[5],handler
[5];
246 TRACE("(0x%08lx,0x%08lx,%p,%p,0x%04x)\n", fccType
, fccHandler
, lpbiIn
, lpbiOut
, wMode
);
249 case ICMODE_FASTCOMPRESS
:
250 case ICMODE_COMPRESS
:
251 querymsg
= ICM_COMPRESS_QUERY
;
253 case ICMODE_FASTDECOMPRESS
:
254 case ICMODE_DECOMPRESS
:
255 querymsg
= ICM_DECOMPRESS_QUERY
;
258 querymsg
= ICM_DRAW_QUERY
;
261 WARN("Unknown mode (%d)\n",wMode
);
265 /* Easy case: handler/type match, we just fire a query and return */
266 hic
= ICOpen(fccType
,fccHandler
,wMode
);
268 if (!ICSendMessage(hic
,querymsg
,(DWORD
)lpbiIn
,(DWORD
)lpbiOut
))
273 type
[4]='.';memcpy(type
,&fccType
,4);
274 handler
[4]='.';memcpy(handler
,&fccHandler
,4);
276 /* Now try each driver in turn. 32 bit codecs only. */
277 /* FIXME: Move this to an init routine? */
279 pszBuffer
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,1024);
280 if (GetPrivateProfileSectionA("drivers32",pszBuffer
,1024,"system.ini")) {
283 if (!lstrncmpiA(type
,s
,5)) {
285 while (*s2
!= '\0' && *s2
!= '.') s2
++;
290 h
= ICOpen(fccType
,*(DWORD
*)s2
,wMode
);
292 if (!ICSendMessage(h
,querymsg
,(DWORD
)lpbiIn
,(DWORD
)lpbiOut
))
301 HeapFree(GetProcessHeap(),0,pszBuffer
);
303 if (fccType
==streamtypeVIDEO
) {
304 hic
= ICLocate(ICTYPE_VIDEO
,fccHandler
,lpbiIn
,lpbiOut
,wMode
);
309 type
[4] = handler
[4] = '\0';
310 FIXME("(%.4s,%.4s,%p,%p,0x%04x),unhandled!\n",type
,handler
,lpbiIn
,lpbiOut
,wMode
);
314 HIC16 VFWAPI
ICLocate16(DWORD fccType
, DWORD fccHandler
, LPBITMAPINFOHEADER lpbiIn
,
315 LPBITMAPINFOHEADER lpbiOut
, WORD wFlags
) {
316 return (HIC16
)ICLocate(fccType
, fccHandler
, lpbiIn
, lpbiOut
, wFlags
);
319 /***********************************************************************
320 * ICGetDisplayFormat [MSVFW.29]
322 HIC VFWAPI
ICGetDisplayFormat(
323 HIC hic
,LPBITMAPINFOHEADER lpbiIn
,LPBITMAPINFOHEADER lpbiOut
,
324 INT depth
,INT dx
,INT dy
)
329 FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD
)hic
,lpbiIn
,lpbiOut
,depth
,dx
,dy
);
331 tmphic
=ICLocate(ICTYPE_VIDEO
,0,lpbiIn
,NULL
,ICMODE_DECOMPRESS
);
335 if ((dy
== lpbiIn
->biHeight
) || (dx
== lpbiIn
->biWidth
))
336 dy
= dx
= 0; /* no resize needed */
337 /* Can we decompress it ? */
338 lres
= ICDecompressQuery(tmphic
,lpbiIn
,NULL
);
340 goto errout
; /* no, sorry */
341 ICDecompressGetFormat(tmphic
,lpbiIn
,lpbiOut
);
343 lpbiOut
->biCompression
= 0;
344 lpbiOut
->biSize
= sizeof(*lpbiOut
);
349 depth
= GetDeviceCaps(hdc
,12)*GetDeviceCaps(hdc
,14);
351 if (depth
==15) depth
= 16;
352 if (depth
<8) depth
= 8;
354 if (lpbiIn
->biBitCount
== 8)
357 TRACE("=> 0x%08lx\n",(DWORD
)tmphic
);
367 HIC16 VFWAPI
ICGetDisplayFormat16(HIC16 hic
, LPBITMAPINFOHEADER lpbiIn
,
368 LPBITMAPINFOHEADER lpbiOut
, INT16 depth
, INT16 dx
, INT16 dy
) {
369 return (HIC16
)ICGetDisplayFormat(hic
,lpbiIn
,lpbiOut
,depth
,dx
,dy
);
372 /***********************************************************************
373 * ICCompress [MSVFW.23]
377 HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiOutput
,LPVOID lpData
,
378 LPBITMAPINFOHEADER lpbiInput
,LPVOID lpBits
,LPDWORD lpckid
,
379 LPDWORD lpdwFlags
,LONG lFrameNum
,DWORD dwFrameSize
,DWORD dwQuality
,
380 LPBITMAPINFOHEADER lpbiPrev
,LPVOID lpPrev
)
384 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD
)hic
,dwFlags
,lpbiOutput
,lpData
,lpbiInput
,lpBits
);
386 iccmp
.dwFlags
= dwFlags
;
388 iccmp
.lpbiOutput
= lpbiOutput
;
389 iccmp
.lpOutput
= lpData
;
390 iccmp
.lpbiInput
= lpbiInput
;
391 iccmp
.lpInput
= lpBits
;
393 iccmp
.lpckid
= lpckid
;
394 iccmp
.lpdwFlags
= lpdwFlags
;
395 iccmp
.lFrameNum
= lFrameNum
;
396 iccmp
.dwFrameSize
= dwFrameSize
;
397 iccmp
.dwQuality
= dwQuality
;
398 iccmp
.lpbiPrev
= lpbiPrev
;
399 iccmp
.lpPrev
= lpPrev
;
400 return ICSendMessage(hic
,ICM_COMPRESS
,(DWORD
)&iccmp
,sizeof(iccmp
));
403 DWORD VFWAPIV
ICCompress16(HIC16 hic
, DWORD dwFlags
, LPBITMAPINFOHEADER lpbiOutput
, LPVOID lpData
,
404 LPBITMAPINFOHEADER lpbiInput
, LPVOID lpBits
, LPDWORD lpckid
,
405 LPDWORD lpdwFlags
, LONG lFrameNum
, DWORD dwFrameSize
, DWORD dwQuality
,
406 LPBITMAPINFOHEADER lpbiPrev
, LPVOID lpPrev
) {
409 ICCOMPRESS
*iccmp
= SEGPTR_NEW(ICCOMPRESS
);
411 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD
)hic
,dwFlags
,lpbiOutput
,lpData
,lpbiInput
,lpBits
);
413 iccmp
->dwFlags
= dwFlags
;
415 iccmp
->lpbiOutput
= lpbiOutput
;
416 iccmp
->lpOutput
= lpData
;
417 iccmp
->lpbiInput
= lpbiInput
;
418 iccmp
->lpInput
= lpBits
;
420 iccmp
->lpckid
= lpckid
;
421 iccmp
->lpdwFlags
= lpdwFlags
;
422 iccmp
->lFrameNum
= lFrameNum
;
423 iccmp
->dwFrameSize
= dwFrameSize
;
424 iccmp
->dwQuality
= dwQuality
;
425 iccmp
->lpbiPrev
= lpbiPrev
;
426 iccmp
->lpPrev
= lpPrev
;
427 ret
= ICSendMessage16(hic
,ICM_COMPRESS
,(DWORD
)SEGPTR_GET(iccmp
),sizeof(ICCOMPRESS
));
432 /***********************************************************************
433 * ICDecompress [MSVFW.26]
435 DWORD VFWAPIV
ICDecompress(HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiFormat
,
436 LPVOID lpData
,LPBITMAPINFOHEADER lpbi
,LPVOID lpBits
)
441 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD
)hic
,dwFlags
,lpbiFormat
,lpData
,lpbi
,lpBits
);
443 TRACE("lpBits[0] == %ld\n",((LPDWORD
)lpBits
)[0]);
445 icd
.dwFlags
= dwFlags
;
446 icd
.lpbiInput
= lpbiFormat
;
447 icd
.lpInput
= lpData
;
449 icd
.lpbiOutput
= lpbi
;
450 icd
.lpOutput
= lpBits
;
452 ret
= ICSendMessage(hic
,ICM_DECOMPRESS
,(DWORD
)&icd
,sizeof(ICDECOMPRESS
));
454 TRACE("lpBits[0] == %ld\n",((LPDWORD
)lpBits
)[0]);
456 TRACE("-> %ld\n",ret
);
461 DWORD VFWAPIV
ICDecompress16(HIC16 hic
, DWORD dwFlags
, LPBITMAPINFOHEADER lpbiFormat
,
462 LPVOID lpData
, LPBITMAPINFOHEADER lpbi
, LPVOID lpBits
) {
464 ICDECOMPRESS
*icd
= SEGPTR_NEW(ICDECOMPRESS
);
467 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD
)hic
,dwFlags
,lpbiFormat
,lpData
,lpbi
,lpBits
);
469 icd
->dwFlags
= dwFlags
;
470 icd
->lpbiInput
= lpbiFormat
;
471 icd
->lpInput
= lpData
;
472 icd
->lpbiOutput
= lpbi
;
473 icd
->lpOutput
= lpBits
;
476 ret
= ICSendMessage16(hic
,ICM_DECOMPRESS
,(DWORD
)SEGPTR_GET(icd
),sizeof(ICDECOMPRESS
));
482 #define COPY(x,y) (##x##->##y = ##x##16->##y);
483 #define COPYPTR(x,y) (##x##->##y = PTR_SEG_TO_LIN(##x##16->##y));
485 LPVOID
MSVIDEO_MapICDEX16To32(LPDWORD lParam
) {
488 ICDECOMPRESSEX
*icdx
= HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESSEX
));
489 ICDECOMPRESSEX16
*icdx16
= (ICDECOMPRESSEX16
*)PTR_SEG_TO_LIN(*lParam
);
493 COPYPTR(icdx
,lpbiSrc
);
495 COPYPTR(icdx
,lpbiDst
);
506 *lParam
= (DWORD
)(icdx
);
510 LPVOID
MSVIDEO_MapMsg16To32(UINT msg
, LPDWORD lParam1
, LPDWORD lParam2
) {
513 TRACE("Mapping %d\n",msg
);
523 case ICM_COMPRESS_END
:
524 case ICM_DECOMPRESS_END
:
525 case ICM_DECOMPRESSEX_END
:
529 case ICM_GETDEFAULTQUALITY
:
531 *lParam1
= (DWORD
)PTR_SEG_TO_LIN(*lParam1
);
535 ICINFO
*ici
= HeapAlloc(GetProcessHeap(),0,sizeof(ICINFO
));
538 ici16
= (ICINFO16
*)PTR_SEG_TO_LIN(*lParam1
);
541 ici
->dwSize
= sizeof(ICINFO
);
543 COPY(ici
,fccHandler
);
546 COPY(ici
,dwVersionICM
);
547 lstrcpynAtoW(ici
->szName
,ici16
->szName
,16);
548 lstrcpynAtoW(ici
->szDescription
,ici16
->szDescription
,128);
549 lstrcpynAtoW(ici
->szDriver
,ici16
->szDriver
,128);
551 *lParam1
= (DWORD
)(ici
);
552 *lParam2
= sizeof(ICINFO
);
557 ICCOMPRESS
*icc
= HeapAlloc(GetProcessHeap(),0,sizeof(ICCOMPRESS
));
560 icc16
= (ICCOMPRESS
*)PTR_SEG_TO_LIN(*lParam1
);
564 COPYPTR(icc
,lpbiOutput
);
565 COPYPTR(icc
,lpOutput
);
566 COPYPTR(icc
,lpbiInput
);
567 COPYPTR(icc
,lpInput
);
569 COPYPTR(icc
,lpdwFlags
);
571 COPY(icc
,dwFrameSize
);
573 COPYPTR(icc
,lpbiPrev
);
576 *lParam1
= (DWORD
)(icc
);
577 *lParam2
= sizeof(ICCOMPRESS
);
582 ICDECOMPRESS
*icd
= HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESS
));
583 ICDECOMPRESS
*icd16
; /* Same structure except for the pointers */
585 icd16
= (ICDECOMPRESS
*)PTR_SEG_TO_LIN(*lParam1
);
589 COPYPTR(icd
,lpbiInput
);
590 COPYPTR(icd
,lpInput
);
591 COPYPTR(icd
,lpbiOutput
);
592 COPYPTR(icd
,lpOutput
);
595 *lParam1
= (DWORD
)(icd
);
596 *lParam2
= sizeof(ICDECOMPRESS
);
599 case ICM_COMPRESS_BEGIN
:
600 case ICM_COMPRESS_GET_FORMAT
:
601 case ICM_COMPRESS_GET_SIZE
:
602 case ICM_COMPRESS_QUERY
:
603 case ICM_DECOMPRESS_GET_FORMAT
:
604 case ICM_DECOMPRESS_QUERY
:
605 case ICM_DECOMPRESS_BEGIN
:
606 case ICM_DECOMPRESS_SET_PALETTE
:
607 case ICM_DECOMPRESS_GET_PALETTE
:
608 *lParam1
= (DWORD
)PTR_SEG_TO_LIN(*lParam1
);
609 *lParam2
= (DWORD
)PTR_SEG_TO_LIN(*lParam2
);
611 case ICM_DECOMPRESSEX_QUERY
:
612 if ((*lParam2
!= sizeof(ICDECOMPRESSEX16
)) && (*lParam2
!= 0))
613 WARN("*lParam2 has unknown value %p\n",(ICDECOMPRESSEX16
*)*lParam2
);
614 /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
615 * This is because of ICMessage(). Special case it?
617 LPVOID* addr = HeapAlloc(GetProcessHeap(),0,2*sizeof(LPVOID));
618 addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
620 addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
627 case ICM_DECOMPRESSEX_BEGIN
:
628 case ICM_DECOMPRESSEX
:
629 ret
= MSVIDEO_MapICDEX16To32(lParam1
);
630 *lParam2
= sizeof(ICDECOMPRESSEX
);
634 ICDRAWBEGIN
*icdb
= HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWBEGIN
));
635 ICDRAWBEGIN16
*icdb16
= (ICDRAWBEGIN16
*)PTR_SEG_TO_LIN(*lParam1
);
654 *lParam1
= (DWORD
)(icdb
);
655 *lParam2
= sizeof(ICDRAWBEGIN
);
658 case ICM_DRAW_SUGGESTFORMAT
:
660 ICDRAWSUGGEST
*icds
= HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWSUGGEST
));
661 ICDRAWSUGGEST16
*icds16
= (ICDRAWSUGGEST16
*)PTR_SEG_TO_LIN(*lParam1
);
666 COPYPTR(icds
,lpbiIn
);
667 COPYPTR(icds
,lpbiSuggest
);
672 COPY(icds
,hicDecompressor
);
674 *lParam1
= (DWORD
)(icds
);
675 *lParam2
= sizeof(ICDRAWSUGGEST
);
680 ICDRAW
*icd
= HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAW
));
681 ICDRAW
*icd16
= (ICDRAW
*)PTR_SEG_TO_LIN(*lParam1
);
685 COPYPTR(icd
,lpFormat
);
690 *lParam1
= (DWORD
)(icd
);
691 *lParam2
= sizeof(ICDRAW
);
695 FIXME("%d is not yet handled. Expect a crash.\n",msg
);
703 void MSVIDEO_UnmapMsg16To32(UINT msg
, LPVOID data16
, LPDWORD lParam1
, LPDWORD lParam2
) {
704 TRACE("Unmapping %d\n",msg
);
706 #define UNCOPY(x,y) (##x##16->##y = ##x##->##y);
711 ICINFO
*ici
= (ICINFO
*)(*lParam1
);
712 ICINFO16
*ici16
= (ICINFO16
*)data16
;
715 UNCOPY(ici
,fccHandler
);
717 UNCOPY(ici
,dwVersion
);
718 UNCOPY(ici
,dwVersionICM
);
719 lstrcpynWtoA(ici16
->szName
,ici
->szName
,16);
720 lstrcpynWtoA(ici16
->szDescription
,ici
->szDescription
,128);
721 /* This just gives garbage for some reason - BB
722 lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/
724 HeapFree(GetProcessHeap(),0,ici
);
727 case ICM_DECOMPRESS_QUERY
:
730 HeapFree(GetProcessHeap(),0,x[0]);
732 HeapFree(GetProcessHeap(),0,x[1]);
737 case ICM_DECOMPRESSEX_QUERY
:
738 case ICM_DECOMPRESSEX_BEGIN
:
739 case ICM_DECOMPRESSEX
:
741 case ICM_DRAW_SUGGESTFORMAT
:
743 HeapFree(GetProcessHeap(),0,data16
);
746 ERR("Unmapping unmapped msg %d\n",msg
);
751 LRESULT
MSVIDEO_SendMessage(HIC hic
,UINT msg
,DWORD lParam1
,DWORD lParam2
, BOOL bFrom32
) {
753 WINE_HIC
*whic
= GlobalLock16(hic
);
757 #define XX(x) case x: TRACE("(0x%08lx,"#x",0x%08lx,0x%08lx,%d)\n",(DWORD)hic,lParam1,lParam2,bFrom32?32:16);break;
772 XX(ICM_GETDEFAULTQUALITY
);
779 XX(ICM_COMPRESS_FRAMES_INFO
);
780 XX(ICM_COMPRESS_GET_FORMAT
);
781 XX(ICM_COMPRESS_GET_SIZE
);
782 XX(ICM_COMPRESS_QUERY
);
783 XX(ICM_COMPRESS_BEGIN
);
785 XX(ICM_COMPRESS_END
);
786 XX(ICM_DECOMPRESS_GET_FORMAT
);
787 XX(ICM_DECOMPRESS_QUERY
);
788 XX(ICM_DECOMPRESS_BEGIN
);
790 XX(ICM_DECOMPRESS_END
);
791 XX(ICM_DECOMPRESS_SET_PALETTE
);
792 XX(ICM_DECOMPRESS_GET_PALETTE
);
795 XX(ICM_DRAW_GET_PALETTE
);
799 XX(ICM_DRAW_GETTIME
);
802 XX(ICM_DRAW_SETTIME
);
803 XX(ICM_DRAW_REALIZE
);
805 XX(ICM_DRAW_RENDERBUFFER
);
806 XX(ICM_DRAW_START_PLAY
);
807 XX(ICM_DRAW_STOP_PLAY
);
808 XX(ICM_DRAW_SUGGESTFORMAT
);
809 XX(ICM_DRAW_CHANGEPALETTE
);
810 XX(ICM_GETBUFFERSWANTED
);
811 XX(ICM_GETDEFAULTKEYFRAMERATE
);
812 XX(ICM_DECOMPRESSEX_BEGIN
);
813 XX(ICM_DECOMPRESSEX_QUERY
);
814 XX(ICM_DECOMPRESSEX
);
815 XX(ICM_DECOMPRESSEX_END
);
816 XX(ICM_SET_STATUS_PROC
);
818 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,%i) unknown message\n",(DWORD
)hic
,(DWORD
)msg
,lParam1
,lParam2
,bFrom32
?32:16);
823 if (whic
->driverproc
) { /* IC is a function */
824 bDrv32
= whic
->private;
826 bDrv32
= ((GetDriverFlags(whic
->hdrv
) & (WINE_GDF_EXIST
|WINE_GDF_16BIT
)) == WINE_GDF_EXIST
);
831 data16
= MSVIDEO_MapMsg16To32(msg
,&lParam1
,&lParam2
);
834 ERR("Can't do 32->16 mappings\n");
840 if (whic
->driverproc
) {
842 ret
= whic
->driverproc(whic
->hdrv
,hic
,msg
,lParam1
,lParam2
);
844 ret
= MSVIDEO_CallTo16_long_lwwll((FARPROC16
)whic
->driverproc
,whic
->hdrv
,hic
,msg
,lParam1
,lParam2
);
847 ret
= SendDriverMessage(whic
->hdrv
,msg
,lParam1
,lParam2
);
851 MSVIDEO_UnmapMsg16To32(msg
,data16
,&lParam1
,&lParam2
);
856 TRACE(" -> 0x%08lx\n",ret
);
860 /***********************************************************************
861 * ICSendMessage [MSVFW.40]
863 LRESULT VFWAPI
ICSendMessage(HIC hic
, UINT msg
, DWORD lParam1
, DWORD lParam2
) {
864 return MSVIDEO_SendMessage(hic
,msg
,lParam1
,lParam2
,TRUE
);
867 LRESULT VFWAPI
ICSendMessage16(HIC16 hic
, UINT16 msg
, DWORD lParam1
, DWORD lParam2
) {
868 return MSVIDEO_SendMessage(hic
,msg
,lParam1
,lParam2
,FALSE
);
871 LRESULT VFWAPIV
ICMessage16(void) {
882 hic
= VA_ARG16(valist
, HIC16
);
883 msg
= VA_ARG16(valist
, UINT16
);
884 cb
= VA_ARG16(valist
, UINT16
);
886 lpData
= SEGPTR_ALLOC(cb
);
888 TRACE("0x%08lx, %u, %u, ...)\n",(DWORD
)hic
,msg
,cb
);
890 for(i
=0;i
<cb
/sizeof(WORD
);i
++) {
891 lpData
[i
] = VA_ARG16(valist
, WORD
);
895 ret
= ICSendMessage16(hic
, msg
, (DWORD
)(SEGPTR_GET(lpData
)), (DWORD
)cb
);
901 /***********************************************************************
902 * ICDrawBegin [MSVFW.28]
904 DWORD VFWAPIV
ICDrawBegin(
906 DWORD dwFlags
,/* flags */
907 HPALETTE hpal
, /* palette to draw with */
908 HWND hwnd
, /* window to draw to */
909 HDC hdc
, /* HDC to draw to */
910 INT xDst
, /* destination rectangle */
914 LPBITMAPINFOHEADER lpbi
, /* format of frame to draw */
915 INT xSrc
, /* source rectangle */
919 DWORD dwRate
, /* frames/second = (dwRate/dwScale) */
924 TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
925 (DWORD
)hic
, dwFlags
, (DWORD
)hpal
, (DWORD
)hwnd
, (DWORD
)hdc
, xDst
, yDst
, dxDst
, dyDst
,
926 lpbi
, xSrc
, ySrc
, dxSrc
, dySrc
, dwRate
, dwScale
);
928 icdb
.dwFlags
= dwFlags
;
941 icdb
.dwRate
= dwRate
;
942 icdb
.dwScale
= dwScale
;
943 return ICSendMessage(hic
,ICM_DRAW_BEGIN
,(DWORD
)&icdb
,sizeof(icdb
));
946 DWORD VFWAPIV
ICDrawBegin16(
948 DWORD dwFlags
,/* flags */
949 HPALETTE16 hpal
, /* palette to draw with */
950 HWND16 hwnd
, /* window to draw to */
951 HDC16 hdc
, /* HDC to draw to */
952 INT16 xDst
, /* destination rectangle */
956 LPBITMAPINFOHEADER
/*SEGPTR*/ lpbi
, /* format of frame to draw */
957 INT16 xSrc
, /* source rectangle */
961 DWORD dwRate
, /* frames/second = (dwRate/dwScale) */
965 ICDRAWBEGIN16
* icdb
= SEGPTR_NEW(ICDRAWBEGIN16
); /* SEGPTR for mapper to deal with */
967 TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
968 (DWORD
)hic
, dwFlags
, (DWORD
)hpal
, (DWORD
)hwnd
, (DWORD
)hdc
, xDst
, yDst
, dxDst
, dyDst
,
969 lpbi
, xSrc
, ySrc
, dxSrc
, dySrc
, dwRate
, dwScale
);
971 icdb
->dwFlags
= dwFlags
;
979 icdb
->lpbi
= lpbi
; /* Keep this as SEGPTR for the mapping code to deal with */
984 icdb
->dwRate
= dwRate
;
985 icdb
->dwScale
= dwScale
;
987 ret
= (DWORD
)ICSendMessage16(hic
,ICM_DRAW_BEGIN
,(DWORD
)SEGPTR_GET(icdb
),sizeof(ICDRAWBEGIN16
));
992 /***********************************************************************
995 DWORD VFWAPIV
ICDraw(HIC hic
, DWORD dwFlags
, LPVOID lpFormat
, LPVOID lpData
, DWORD cbData
, LONG lTime
) {
998 TRACE("(0x%09lx,%ld,%p,%p,%ld,%ld)\n",(DWORD
)hic
,dwFlags
,lpFormat
,lpData
,cbData
,lTime
);
1000 icd
.dwFlags
= dwFlags
;
1001 icd
.lpFormat
= lpFormat
;
1002 icd
.lpData
= lpData
;
1003 icd
.cbData
= cbData
;
1006 return ICSendMessage(hic
,ICM_DRAW
,(DWORD
)&icd
,sizeof(icd
));
1009 DWORD VFWAPIV
ICDraw16(HIC16 hic
, DWORD dwFlags
, LPVOID
/*SEGPTR*/ lpFormat
,
1010 LPVOID
/*SEGPTR*/ lpData
, DWORD cbData
, LONG lTime
) {
1012 ICDRAW
* icd
= SEGPTR_NEW(ICDRAW
); /* SEGPTR for mapper to deal with */
1014 TRACE("(0x%08lx,0x%08lx,%p,%p,%ld,%ld)\n",(DWORD
)hic
,dwFlags
,lpFormat
,lpData
,cbData
,lTime
);
1015 icd
->dwFlags
= dwFlags
;
1016 icd
->lpFormat
= lpFormat
;
1017 icd
->lpData
= lpData
;
1018 icd
->cbData
= cbData
;
1021 return ICSendMessage16(hic
,ICM_DRAW
,(DWORD
)SEGPTR_GET(icd
),sizeof(ICDRAW
));
1024 /***********************************************************************
1025 * ICClose [MSVFW.22]
1027 LRESULT WINAPI
ICClose(HIC hic
) {
1028 WINE_HIC
*whic
= GlobalLock16(hic
);
1029 TRACE("(0x%08lx)\n",(DWORD
)hic
);
1030 if (whic
->driverproc
) {
1031 ICSendMessage16(hic
,DRV_CLOSE
,0,0);
1032 ICSendMessage16(hic
,DRV_DISABLE
,0,0);
1033 ICSendMessage16(hic
,DRV_FREE
,0,0);
1035 CloseDriver(whic
->hdrv
,0,0);
1038 GlobalUnlock16(hic
);
1043 LRESULT WINAPI
ICClose16(HIC16 hic
) {
1044 return ICClose(hic
);
1047 /***********************************************************************
1048 * MCIWndCreateA [MSVFW.44 & MSVFW.45]
1050 HWND VFWAPIV
MCIWndCreateA(HWND hwndParent
, HINSTANCE hInstance
,
1051 DWORD dwStyle
,LPCSTR szFile
)
1053 FIXME("%x %x %lx %s\n",hwndParent
, hInstance
, dwStyle
, szFile
);
1057 /***********************************************************************
1058 * MCIWndCreateW [MSVFW.46]
1060 HWND VFWAPIV
MCIWndCreateW(HWND hwndParent
, HINSTANCE hInstance
,
1061 DWORD dwStyle
,LPCWSTR szFile
)
1063 FIXME("%x %x %lx %s\n",hwndParent
, hInstance
, dwStyle
, debugstr_w(szFile
));