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.
19 #include "wine/winbase16.h"
20 #include "wine/winestring.h"
21 #include "debugtools.h"
24 #include "stackframe.h"
26 DEFAULT_DEBUG_CHANNEL(msvideo);
28 /* ### start build ### */
29 extern LONG CALLBACK MSVIDEO_CallTo16_long_lwwll(FARPROC16,LONG,WORD,WORD,LONG,LONG);
30 /* ### stop build ### */
32 LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2);
33 void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID lpv, LPDWORD lParam1, LPDWORD lParam2);
34 LRESULT MSVIDEO_SendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2, BOOL bFrom32);
36 /***********************************************************************
37 * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
38 * Returns the version in major.minor form.
39 * In Windows95 this returns 0x040003b6 (4.950)
41 DWORD WINAPI VideoForWindowsVersion(void) {
42 return 0x040003B6; /* 4.950 */
45 /***********************************************************************
46 * VideoCapDriverDescAndVer [MSVIDEO.22]
48 DWORD WINAPI VideoCapDriverDescAndVer(WORD nr,LPVOID buf1,WORD buf1len,LPVOID buf2,WORD buf2len) {
49 FIXME("(%d,%p,%d,%p,%d), stub!\n",nr,buf1,buf1len,buf2,buf2len);
53 /* system.ini: [drivers] */
55 /***********************************************************************
57 * Get information about an installable compressor. Return TRUE if there
61 DWORD fccType, /* [in] type of compressor ('vidc') */
62 DWORD fccHandler, /* [in] <n>th compressor */
63 ICINFO *lpicinfo) /* [out] information about compressor */
65 char type[5],buf[2000];
67 memcpy(type,&fccType,4);type[4]=0;
68 TRACE("(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
69 /* does OpenDriver/CloseDriver */
70 lpicinfo->dwSize = sizeof(ICINFO);
71 lpicinfo->fccType = fccType;
72 lpicinfo->dwFlags = 0;
73 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
76 if (!strncasecmp(type,s,4)) {
78 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
82 s=s+strlen(s)+1; /* either next char or \0 */
88 BOOL16 VFWAPI ICInfo16(DWORD fccType, DWORD fccHandler, ICINFO16* /*SEGPTR*/ lpicinfo) {
91 DWORD lParam = (DWORD)lpicinfo;
92 DWORD size = ((ICINFO*)(PTR_SEG_TO_LIN(lpicinfo)))->dwSize;
94 /* Use the mapping functions to map the ICINFO structure */
95 lpv = MSVIDEO_MapMsg16To32(ICM_GETINFO,&lParam,&size);
97 ret = ICInfo(fccType,fccHandler,(ICINFO*)lParam);
99 MSVIDEO_UnmapMsg16To32(ICM_GETINFO,lpv,&lParam,&size);
104 /***********************************************************************
106 * Opens an installable compressor. Return special handle.
108 HIC VFWAPI ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
109 char type[5],handler[5],codecname[20];
115 memcpy(type,&fccType,4);type[4]=0;
116 memcpy(handler,&fccHandler,4);handler[4]=0;
117 TRACE("(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
119 sprintf(codecname,"%s.%s",type,handler);
121 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
122 * same layout as ICOPEN
124 icopen.fccType = fccType;
125 icopen.fccHandler = fccHandler;
126 icopen.dwSize = sizeof(ICOPEN);
127 icopen.dwFlags = wMode;
128 /* FIXME: do we need to fill out the rest too? */
129 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
131 if (!strcasecmp(type,"vids")) {
132 sprintf(codecname,"vidc.%s",handler);
133 fccType = mmioFOURCC('v','i','d','c');
135 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
139 /* The handle should be a valid 16-bit handle as well */
140 hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
141 whic = (WINE_HIC*)GlobalLock16(hic);
143 whic->driverproc= NULL;
146 TRACE("=> 0x%08lx\n",(DWORD)hic);
150 HIC MSVIDEO_OpenFunc(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler, BOOL bFrom32) {
151 char type[5],handler[5],codecname[20];
153 ICOPEN* icopen = SEGPTR_NEW(ICOPEN);
156 memcpy(type,&fccType,4);type[4]=0;
157 memcpy(handler,&fccHandler,4);handler[4]=0;
158 TRACE("(%s,%s,%d,%p,%d)\n",type,handler,wMode,lpfnHandler,bFrom32?32:16);
160 icopen->fccType = fccType;
161 icopen->fccHandler = fccHandler;
162 icopen->dwSize = sizeof(ICOPEN);
163 icopen->dwFlags = wMode;
165 sprintf(codecname,"%s.%s",type,handler);
167 hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
170 whic = GlobalLock16(hic);
171 whic->driverproc = lpfnHandler;
173 whic->private = bFrom32;
175 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
176 /* What if the function is used more than once? */
178 if (MSVIDEO_SendMessage(hic,DRV_LOAD,0L,0L,bFrom32) != DRV_SUCCESS) {
179 WARN("DRV_LOAD failed for hic 0x%08lx\n",(DWORD)hic);
183 if (MSVIDEO_SendMessage(hic,DRV_ENABLE,0L,0L,bFrom32) != DRV_SUCCESS) {
184 WARN("DRV_ENABLE failed for hic 0x%08lx\n",(DWORD)hic);
188 whic->hdrv = MSVIDEO_SendMessage(hic,DRV_OPEN,0,(LPARAM)(SEGPTR_GET(icopen)),FALSE);
189 if (whic->hdrv == 0) {
190 WARN("DRV_OPEN failed for hic 0x%08lx\n",(DWORD)hic);
196 TRACE("=> 0x%08lx\n",(DWORD)hic);
200 /***********************************************************************
201 * ICOpenFunction [MSVFW.38]
203 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler) {
204 return MSVIDEO_OpenFunc(fccType,fccHandler,wMode,lpfnHandler,TRUE);
207 HIC16 VFWAPI ICOpen16(DWORD fccType, DWORD fccHandler, UINT16 wMode) {
208 return (HIC16)ICOpen(fccType, fccHandler, wMode);
211 HIC16 VFWAPI ICOpenFunction16(DWORD fccType, DWORD fccHandler, UINT16 wMode, FARPROC16 lpfnHandler) {
212 return MSVIDEO_OpenFunc(fccType, fccHandler, wMode, lpfnHandler,FALSE);
215 /***********************************************************************
216 * ICGetInfo [MSVFW.30]
218 LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
221 TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
222 ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
223 TRACE(" -> 0x%08lx\n",ret);
227 LRESULT VFWAPI ICGetInfo16(HIC16 hic, ICINFO16 *picinfo,DWORD cb) {
230 TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
231 ret = ICSendMessage16(hic,ICM_GETINFO,(DWORD)picinfo,cb);
232 TRACE(" -> 0x%08lx\n",ret);
236 /***********************************************************************
237 * ICLocate [MSVFW.35]
240 DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
241 LPBITMAPINFOHEADER lpbiOut, WORD wMode)
243 char type[5],handler[5];
248 TRACE("(0x%08lx,0x%08lx,%p,%p,0x%04x)\n", fccType, fccHandler, lpbiIn, lpbiOut, wMode);
251 case ICMODE_FASTCOMPRESS:
252 case ICMODE_COMPRESS:
253 querymsg = ICM_COMPRESS_QUERY;
255 case ICMODE_FASTDECOMPRESS:
256 case ICMODE_DECOMPRESS:
257 querymsg = ICM_DECOMPRESS_QUERY;
260 querymsg = ICM_DRAW_QUERY;
263 WARN("Unknown mode (%d)\n",wMode);
267 /* Easy case: handler/type match, we just fire a query and return */
268 hic = ICOpen(fccType,fccHandler,wMode);
270 if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
275 type[4]='.';memcpy(type,&fccType,4);
276 handler[4]='.';memcpy(handler,&fccHandler,4);
278 /* Now try each driver in turn. 32 bit codecs only. */
279 /* FIXME: Move this to an init routine? */
281 pszBuffer = (LPSTR)HeapAlloc(GetProcessHeap(),0,1024);
282 if (GetPrivateProfileSectionA("drivers32",pszBuffer,1024,"system.ini")) {
285 if (!strncasecmp(type,s,5)) {
287 while (*s2 != '\0' && *s2 != '.') s2++;
292 h = ICOpen(fccType,*(DWORD*)s2,wMode);
294 if (!ICSendMessage(h,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
303 HeapFree(GetProcessHeap(),0,pszBuffer);
305 if (fccType==streamtypeVIDEO) {
306 hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
311 type[4] = handler[4] = '\0';
312 FIXME("(%.4s,%.4s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode);
316 HIC16 VFWAPI ICLocate16(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
317 LPBITMAPINFOHEADER lpbiOut, WORD wFlags) {
318 return (HIC16)ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, wFlags);
321 /***********************************************************************
322 * ICGetDisplayFormat [MSVFW.29]
324 HIC VFWAPI ICGetDisplayFormat(
325 HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
326 INT depth,INT dx,INT dy)
331 FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
333 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
337 if ((dy == lpbiIn->biHeight) || (dx == lpbiIn->biWidth))
338 dy = dx = 0; /* no resize needed */
339 /* Can we decompress it ? */
340 lres = ICDecompressQuery(tmphic,lpbiIn,NULL);
342 goto errout; /* no, sorry */
343 ICDecompressGetFormat(tmphic,lpbiIn,lpbiOut);
345 lpbiOut->biCompression = 0;
346 lpbiOut->biSize = sizeof(*lpbiOut);
351 depth = GetDeviceCaps(hdc,12)*GetDeviceCaps(hdc,14);
353 if (depth==15) depth = 16;
354 if (depth<8) depth = 8;
356 if (lpbiIn->biBitCount == 8)
359 TRACE("=> 0x%08lx\n",(DWORD)tmphic);
369 HIC16 VFWAPI ICGetDisplayFormat16(HIC16 hic, LPBITMAPINFOHEADER lpbiIn,
370 LPBITMAPINFOHEADER lpbiOut, INT16 depth, INT16 dx, INT16 dy) {
371 return (HIC16)ICGetDisplayFormat(hic,lpbiIn,lpbiOut,depth,dx,dy);
374 /***********************************************************************
375 * ICCompress [MSVFW.23]
379 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
380 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
381 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
382 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
386 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
388 iccmp.dwFlags = dwFlags;
390 iccmp.lpbiOutput = lpbiOutput;
391 iccmp.lpOutput = lpData;
392 iccmp.lpbiInput = lpbiInput;
393 iccmp.lpInput = lpBits;
395 iccmp.lpckid = lpckid;
396 iccmp.lpdwFlags = lpdwFlags;
397 iccmp.lFrameNum = lFrameNum;
398 iccmp.dwFrameSize = dwFrameSize;
399 iccmp.dwQuality = dwQuality;
400 iccmp.lpbiPrev = lpbiPrev;
401 iccmp.lpPrev = lpPrev;
402 return ICSendMessage(hic,ICM_COMPRESS,(DWORD)&iccmp,sizeof(iccmp));
405 DWORD VFWAPIV ICCompress16(HIC16 hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData,
406 LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid,
407 LPDWORD lpdwFlags, LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality,
408 LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev) {
411 ICCOMPRESS *iccmp = SEGPTR_NEW(ICCOMPRESS);
413 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
415 iccmp->dwFlags = dwFlags;
417 iccmp->lpbiOutput = lpbiOutput;
418 iccmp->lpOutput = lpData;
419 iccmp->lpbiInput = lpbiInput;
420 iccmp->lpInput = lpBits;
422 iccmp->lpckid = lpckid;
423 iccmp->lpdwFlags = lpdwFlags;
424 iccmp->lFrameNum = lFrameNum;
425 iccmp->dwFrameSize = dwFrameSize;
426 iccmp->dwQuality = dwQuality;
427 iccmp->lpbiPrev = lpbiPrev;
428 iccmp->lpPrev = lpPrev;
429 ret = ICSendMessage16(hic,ICM_COMPRESS,(DWORD)SEGPTR_GET(iccmp),sizeof(ICCOMPRESS));
434 /***********************************************************************
435 * ICDecompress [MSVFW.26]
437 DWORD VFWAPIV ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
438 LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
443 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
445 TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
447 icd.dwFlags = dwFlags;
448 icd.lpbiInput = lpbiFormat;
449 icd.lpInput = lpData;
451 icd.lpbiOutput = lpbi;
452 icd.lpOutput = lpBits;
454 ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
456 TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
458 TRACE("-> %ld\n",ret);
463 DWORD VFWAPIV ICDecompress16(HIC16 hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat,
464 LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits) {
466 ICDECOMPRESS *icd = SEGPTR_NEW(ICDECOMPRESS);
469 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
471 icd->dwFlags = dwFlags;
472 icd->lpbiInput = lpbiFormat;
473 icd->lpInput = lpData;
474 icd->lpbiOutput = lpbi;
475 icd->lpOutput = lpBits;
478 ret = ICSendMessage16(hic,ICM_DECOMPRESS,(DWORD)SEGPTR_GET(icd),sizeof(ICDECOMPRESS));
484 #define COPY(x,y) (##x##->##y = ##x##16->##y);
485 #define COPYPTR(x,y) (##x##->##y = PTR_SEG_TO_LIN(##x##16->##y));
487 LPVOID MSVIDEO_MapICDEX16To32(LPDWORD lParam) {
490 ICDECOMPRESSEX *icdx = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESSEX));
491 ICDECOMPRESSEX16 *icdx16 = (ICDECOMPRESSEX16*)PTR_SEG_TO_LIN(*lParam);
495 COPYPTR(icdx,lpbiSrc);
497 COPYPTR(icdx,lpbiDst);
508 *lParam = (DWORD)(icdx);
512 LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2) {
515 TRACE("Mapping %d\n",msg);
525 case ICM_COMPRESS_END:
526 case ICM_DECOMPRESS_END:
527 case ICM_DECOMPRESSEX_END:
531 case ICM_GETDEFAULTQUALITY:
533 *lParam1 = (DWORD)PTR_SEG_TO_LIN(*lParam1);
537 ICINFO *ici = HeapAlloc(GetProcessHeap(),0,sizeof(ICINFO));
540 ici16 = (ICINFO16*)PTR_SEG_TO_LIN(*lParam1);
543 ici->dwSize = sizeof(ICINFO);
545 COPY(ici,fccHandler);
548 COPY(ici,dwVersionICM);
549 lstrcpynAtoW(ici->szName,ici16->szName,16);
550 lstrcpynAtoW(ici->szDescription,ici16->szDescription,128);
551 lstrcpynAtoW(ici->szDriver,ici16->szDriver,128);
553 *lParam1 = (DWORD)(ici);
554 *lParam2 = sizeof(ICINFO);
559 ICCOMPRESS *icc = HeapAlloc(GetProcessHeap(),0,sizeof(ICCOMPRESS));
562 icc16 = (ICCOMPRESS*)PTR_SEG_TO_LIN(*lParam1);
566 COPYPTR(icc,lpbiOutput);
567 COPYPTR(icc,lpOutput);
568 COPYPTR(icc,lpbiInput);
569 COPYPTR(icc,lpInput);
571 COPYPTR(icc,lpdwFlags);
573 COPY(icc,dwFrameSize);
575 COPYPTR(icc,lpbiPrev);
578 *lParam1 = (DWORD)(icc);
579 *lParam2 = sizeof(ICCOMPRESS);
584 ICDECOMPRESS *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESS));
585 ICDECOMPRESS *icd16; /* Same structure except for the pointers */
587 icd16 = (ICDECOMPRESS*)PTR_SEG_TO_LIN(*lParam1);
591 COPYPTR(icd,lpbiInput);
592 COPYPTR(icd,lpInput);
593 COPYPTR(icd,lpbiOutput);
594 COPYPTR(icd,lpOutput);
597 *lParam1 = (DWORD)(icd);
598 *lParam2 = sizeof(ICDECOMPRESS);
601 case ICM_COMPRESS_BEGIN:
602 case ICM_COMPRESS_GET_FORMAT:
603 case ICM_COMPRESS_GET_SIZE:
604 case ICM_COMPRESS_QUERY:
605 case ICM_DECOMPRESS_GET_FORMAT:
606 case ICM_DECOMPRESS_QUERY:
607 case ICM_DECOMPRESS_BEGIN:
608 case ICM_DECOMPRESS_SET_PALETTE:
609 case ICM_DECOMPRESS_GET_PALETTE:
610 *lParam1 = (DWORD)PTR_SEG_TO_LIN(*lParam1);
611 *lParam2 = (DWORD)PTR_SEG_TO_LIN(*lParam2);
613 case ICM_DECOMPRESSEX_QUERY:
614 if ((*lParam2 != sizeof(ICDECOMPRESSEX16)) && (*lParam2 != 0))
615 WARN("*lParam2 has unknown value %p\n",(ICDECOMPRESSEX16*)*lParam2);
616 /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
617 * This is because of ICMessage(). Special case it?
619 LPVOID* addr = HeapAlloc(GetProcessHeap(),0,2*sizeof(LPVOID));
620 addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
622 addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
629 case ICM_DECOMPRESSEX_BEGIN:
630 case ICM_DECOMPRESSEX:
631 ret = MSVIDEO_MapICDEX16To32(lParam1);
632 *lParam2 = sizeof(ICDECOMPRESSEX);
636 ICDRAWBEGIN *icdb = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWBEGIN));
637 ICDRAWBEGIN16 *icdb16 = (ICDRAWBEGIN16*)PTR_SEG_TO_LIN(*lParam1);
656 *lParam1 = (DWORD)(icdb);
657 *lParam2 = sizeof(ICDRAWBEGIN);
660 case ICM_DRAW_SUGGESTFORMAT:
662 ICDRAWSUGGEST *icds = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWSUGGEST));
663 ICDRAWSUGGEST16 *icds16 = (ICDRAWSUGGEST16*)PTR_SEG_TO_LIN(*lParam1);
668 COPYPTR(icds,lpbiIn);
669 COPYPTR(icds,lpbiSuggest);
674 COPY(icds,hicDecompressor);
676 *lParam1 = (DWORD)(icds);
677 *lParam2 = sizeof(ICDRAWSUGGEST);
682 ICDRAW *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAW));
683 ICDRAW *icd16 = (ICDRAW*)PTR_SEG_TO_LIN(*lParam1);
687 COPYPTR(icd,lpFormat);
692 *lParam1 = (DWORD)(icd);
693 *lParam2 = sizeof(ICDRAW);
697 FIXME("%d is not yet handled. Expect a crash.\n",msg);
705 void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID data16, LPDWORD lParam1, LPDWORD lParam2) {
706 TRACE("Unmapping %d\n",msg);
708 #define UNCOPY(x,y) (##x##16->##y = ##x##->##y);
713 ICINFO *ici = (ICINFO*)(*lParam1);
714 ICINFO16 *ici16 = (ICINFO16*)data16;
717 UNCOPY(ici,fccHandler);
719 UNCOPY(ici,dwVersion);
720 UNCOPY(ici,dwVersionICM);
721 lstrcpynWtoA(ici16->szName,ici->szName,16);
722 lstrcpynWtoA(ici16->szDescription,ici->szDescription,128);
723 /* This just gives garbage for some reason - BB
724 lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/
726 HeapFree(GetProcessHeap(),0,ici);
729 case ICM_DECOMPRESS_QUERY:
732 HeapFree(GetProcessHeap(),0,x[0]);
734 HeapFree(GetProcessHeap(),0,x[1]);
739 case ICM_DECOMPRESSEX_QUERY:
740 case ICM_DECOMPRESSEX_BEGIN:
741 case ICM_DECOMPRESSEX:
743 case ICM_DRAW_SUGGESTFORMAT:
745 HeapFree(GetProcessHeap(),0,data16);
748 ERR("Unmapping unmapped msg %d\n",msg);
753 LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2, BOOL bFrom32) {
755 WINE_HIC *whic = GlobalLock16(hic);
759 #define XX(x) case x: TRACE("(0x%08lx,"#x",0x%08lx,0x%08lx,%d)\n",(DWORD)hic,lParam1,lParam2,bFrom32?32:16);break;
774 XX(ICM_GETDEFAULTQUALITY);
781 XX(ICM_COMPRESS_FRAMES_INFO);
782 XX(ICM_COMPRESS_GET_FORMAT);
783 XX(ICM_COMPRESS_GET_SIZE);
784 XX(ICM_COMPRESS_QUERY);
785 XX(ICM_COMPRESS_BEGIN);
787 XX(ICM_COMPRESS_END);
788 XX(ICM_DECOMPRESS_GET_FORMAT);
789 XX(ICM_DECOMPRESS_QUERY);
790 XX(ICM_DECOMPRESS_BEGIN);
792 XX(ICM_DECOMPRESS_END);
793 XX(ICM_DECOMPRESS_SET_PALETTE);
794 XX(ICM_DECOMPRESS_GET_PALETTE);
797 XX(ICM_DRAW_GET_PALETTE);
801 XX(ICM_DRAW_GETTIME);
804 XX(ICM_DRAW_SETTIME);
805 XX(ICM_DRAW_REALIZE);
807 XX(ICM_DRAW_RENDERBUFFER);
808 XX(ICM_DRAW_START_PLAY);
809 XX(ICM_DRAW_STOP_PLAY);
810 XX(ICM_DRAW_SUGGESTFORMAT);
811 XX(ICM_DRAW_CHANGEPALETTE);
812 XX(ICM_GETBUFFERSWANTED);
813 XX(ICM_GETDEFAULTKEYFRAMERATE);
814 XX(ICM_DECOMPRESSEX_BEGIN);
815 XX(ICM_DECOMPRESSEX_QUERY);
816 XX(ICM_DECOMPRESSEX);
817 XX(ICM_DECOMPRESSEX_END);
818 XX(ICM_SET_STATUS_PROC);
820 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,%i) unknown message\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,bFrom32?32:16);
825 if (whic->driverproc) { /* IC is a function */
826 bDrv32 = whic->private;
828 bDrv32 = ((GetDriverFlags(whic->hdrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) == WINE_GDF_EXIST);
833 data16 = MSVIDEO_MapMsg16To32(msg,&lParam1,&lParam2);
836 ERR("Can't do 32->16 mappings\n");
842 if (whic->driverproc) {
844 ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
846 ret = MSVIDEO_CallTo16_long_lwwll((FARPROC16)whic->driverproc,whic->hdrv,hic,msg,lParam1,lParam2);
849 ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
853 MSVIDEO_UnmapMsg16To32(msg,data16,&lParam1,&lParam2);
858 TRACE(" -> 0x%08lx\n",ret);
862 /***********************************************************************
863 * ICSendMessage [MSVFW.40]
865 LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2) {
866 return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,TRUE);
869 LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lParam2) {
870 return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,FALSE);
873 LRESULT VFWAPIV ICMessage16(void) {
884 hic = VA_ARG16(valist, HIC16);
885 msg = VA_ARG16(valist, UINT16);
886 cb = VA_ARG16(valist, UINT16);
888 lpData = SEGPTR_ALLOC(cb);
890 TRACE("0x%08lx, %u, %u, ...)\n",(DWORD)hic,msg,cb);
892 for(i=0;i<cb/sizeof(WORD);i++) {
893 lpData[i] = VA_ARG16(valist, WORD);
897 ret = ICSendMessage16(hic, msg, (DWORD)(SEGPTR_GET(lpData)), (DWORD)cb);
903 /***********************************************************************
904 * ICDrawBegin [MSVFW.28]
906 DWORD VFWAPIV ICDrawBegin(
908 DWORD dwFlags,/* flags */
909 HPALETTE hpal, /* palette to draw with */
910 HWND hwnd, /* window to draw to */
911 HDC hdc, /* HDC to draw to */
912 INT xDst, /* destination rectangle */
916 LPBITMAPINFOHEADER lpbi, /* format of frame to draw */
917 INT xSrc, /* source rectangle */
921 DWORD dwRate, /* frames/second = (dwRate/dwScale) */
926 TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
927 (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
928 lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
930 icdb.dwFlags = dwFlags;
943 icdb.dwRate = dwRate;
944 icdb.dwScale = dwScale;
945 return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD)&icdb,sizeof(icdb));
948 DWORD VFWAPIV ICDrawBegin16(
950 DWORD dwFlags,/* flags */
951 HPALETTE16 hpal, /* palette to draw with */
952 HWND16 hwnd, /* window to draw to */
953 HDC16 hdc, /* HDC to draw to */
954 INT16 xDst, /* destination rectangle */
958 LPBITMAPINFOHEADER /*SEGPTR*/ lpbi, /* format of frame to draw */
959 INT16 xSrc, /* source rectangle */
963 DWORD dwRate, /* frames/second = (dwRate/dwScale) */
967 ICDRAWBEGIN16* icdb = SEGPTR_NEW(ICDRAWBEGIN16); /* SEGPTR for mapper to deal with */
969 TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
970 (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
971 lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
973 icdb->dwFlags = dwFlags;
981 icdb->lpbi = lpbi; /* Keep this as SEGPTR for the mapping code to deal with */
986 icdb->dwRate = dwRate;
987 icdb->dwScale = dwScale;
989 ret = (DWORD)ICSendMessage16(hic,ICM_DRAW_BEGIN,(DWORD)SEGPTR_GET(icdb),sizeof(ICDRAWBEGIN16));
994 /***********************************************************************
997 DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
1000 TRACE("(0x%09lx,%ld,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
1002 icd.dwFlags = dwFlags;
1003 icd.lpFormat = lpFormat;
1004 icd.lpData = lpData;
1005 icd.cbData = cbData;
1008 return ICSendMessage(hic,ICM_DRAW,(DWORD)&icd,sizeof(icd));
1011 DWORD VFWAPIV ICDraw16(HIC16 hic, DWORD dwFlags, LPVOID /*SEGPTR*/ lpFormat,
1012 LPVOID /*SEGPTR*/ lpData, DWORD cbData, LONG lTime) {
1014 ICDRAW* icd = SEGPTR_NEW(ICDRAW); /* SEGPTR for mapper to deal with */
1016 TRACE("(0x%08lx,0x%08lx,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
1017 icd->dwFlags = dwFlags;
1018 icd->lpFormat = lpFormat;
1019 icd->lpData = lpData;
1020 icd->cbData = cbData;
1023 return ICSendMessage16(hic,ICM_DRAW,(DWORD)SEGPTR_GET(icd),sizeof(ICDRAW));
1026 /***********************************************************************
1027 * ICClose [MSVFW.22]
1029 LRESULT WINAPI ICClose(HIC hic) {
1030 WINE_HIC *whic = GlobalLock16(hic);
1031 TRACE("(0x%08lx)\n",(DWORD)hic);
1032 if (whic->driverproc) {
1033 ICSendMessage16(hic,DRV_CLOSE,0,0);
1034 ICSendMessage16(hic,DRV_DISABLE,0,0);
1035 ICSendMessage16(hic,DRV_FREE,0,0);
1037 CloseDriver(whic->hdrv,0,0);
1040 GlobalUnlock16(hic);
1045 LRESULT WINAPI ICClose16(HIC16 hic) {
1046 return ICClose(hic);
1049 /***********************************************************************
1050 * MCIWndCreateA [MSVFW.44 & MSVFW.45]
1052 HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance,
1053 DWORD dwStyle,LPCSTR szFile)
1055 FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
1059 /***********************************************************************
1060 * MCIWndCreateW [MSVFW.46]
1062 HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance,
1063 DWORD dwStyle,LPCWSTR szFile)
1065 FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));