2 * Copyright 1998 Marcus Meissner
3 * Copyright 2000 Bradley Baetz
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * FIXME: This all assumes 32 bit codecs
20 * Win95 appears to prefer 32 bit codecs, even from 16 bit code.
21 * There is the ICOpenFunction16 to worry about still, though.
35 #include "wine/winbase16.h"
36 #include "wine/debug.h"
37 #include "stackframe.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
41 /* ### start build ### */
42 extern LONG CALLBACK MSVIDEO_CallTo16_long_lwwll(FARPROC16,LONG,WORD,WORD,LONG,LONG);
43 /* ### stop build ### */
45 LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2);
46 void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID lpv, LPDWORD lParam1, LPDWORD lParam2);
47 LRESULT MSVIDEO_SendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2, BOOL bFrom32);
49 #define HDRVR_16(h32) (LOWORD(h32))
52 /***********************************************************************
53 * VideoForWindowsVersion [MSVFW32.2]
54 * VideoForWindowsVersion [MSVIDEO.2]
55 * Returns the version in major.minor form.
56 * In Windows95 this returns 0x040003b6 (4.950)
58 DWORD WINAPI VideoForWindowsVersion(void) {
59 return 0x040003B6; /* 4.950 */
62 /***********************************************************************
63 * VideoCapDriverDescAndVer [MSVIDEO.22]
65 DWORD WINAPI VideoCapDriverDescAndVer(
66 WORD nr,LPSTR buf1,WORD buf1len,LPSTR buf2,WORD buf2len
72 char *s,buf[2000],fn[260];
76 TRACE("(%d,%p,%d,%p,%d)\n",nr,buf1,buf1len,buf2,buf2len);
77 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,sizeof(buf),"system.ini")) {
80 if (!strncasecmp(s,"vid",3)) {
85 s=s+strlen(s)+1; /* either next char or \0 */
88 return 20; /* hmm, out of entries even if we don't have any */
90 FIXME("No more VID* entries found\n");
93 GetPrivateProfileStringA("drivers32",s,NULL,fn,sizeof(fn),"system.ini");
94 infosize = GetFileVersionInfoSizeA(fn,&verhandle);
96 TRACE("%s has no fileversioninfo.\n",fn);
99 infobuf = HeapAlloc(GetProcessHeap(),0,infosize);
100 if (GetFileVersionInfoA(fn,verhandle,infosize,infobuf)) {
102 /* Yes, two space behind : */
103 /* FIXME: test for buflen */
104 sprintf(vbuf,"Version: %d.%d.%d.%d\n",
105 ((WORD*)infobuf)[0x0f],
106 ((WORD*)infobuf)[0x0e],
107 ((WORD*)infobuf)[0x11],
108 ((WORD*)infobuf)[0x10]
110 TRACE("version of %s is %s\n",fn,vbuf);
111 strncpy(buf2,vbuf,buf2len);
113 TRACE("GetFileVersionInfoA failed for %s.\n",fn);
114 strncpy(buf2,fn,buf2len); /* msvideo.dll appears to copy fn*/
116 /* FIXME: language problem? */
117 if (VerQueryValueA( infobuf,
118 "\\StringFileInfo\\040904E4\\FileDescription",
122 TRACE("VQA returned %s\n",(LPCSTR)subblock);
123 strncpy(buf1,subblock,buf1len);
125 TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
126 strncpy(buf1,fn,buf1len); /* msvideo.dll appears to copy fn*/
128 HeapFree(GetProcessHeap(),0,infobuf);
132 /* system.ini: [drivers] */
134 /***********************************************************************
136 * Get information about an installable compressor. Return TRUE if there
140 DWORD fccType, /* [in] type of compressor ('vidc') */
141 DWORD fccHandler, /* [in] <n>th compressor */
142 ICINFO *lpicinfo) /* [out] information about compressor */
144 char type[5],buf[2000];
146 memcpy(type,&fccType,4);type[4]=0;
147 TRACE("(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
148 /* does OpenDriver/CloseDriver */
149 lpicinfo->dwSize = sizeof(ICINFO);
150 lpicinfo->fccType = fccType;
151 lpicinfo->dwFlags = 0;
152 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
155 if (!strncasecmp(type,s,4)) {
157 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
161 s=s+strlen(s)+1; /* either next char or \0 */
167 /***********************************************************************
168 * ICInfo [MSVIDEO.200]
170 BOOL16 VFWAPI ICInfo16(
171 DWORD fccType, /* [in] */
172 DWORD fccHandler, /* [in] */
173 ICINFO16 *lpicinfo) /* [in/out] NOTE: SEGPTR */
177 DWORD lParam = (DWORD)lpicinfo;
178 DWORD size = ((ICINFO*)(MapSL((SEGPTR)lpicinfo)))->dwSize;
180 /* Use the mapping functions to map the ICINFO structure */
181 lpv = MSVIDEO_MapMsg16To32(ICM_GETINFO,&lParam,&size);
183 ret = ICInfo(fccType,fccHandler,(ICINFO*)lParam);
185 MSVIDEO_UnmapMsg16To32(ICM_GETINFO,lpv,&lParam,&size);
190 /***********************************************************************
192 * Opens an installable compressor. Return special handle.
194 HIC VFWAPI ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
195 char type[5],handler[5],codecname[20];
201 memcpy(type,&fccType,4);type[4]=0;
202 memcpy(handler,&fccHandler,4);handler[4]=0;
203 TRACE("(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
205 sprintf(codecname,"%s.%s",type,handler);
207 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
208 * same layout as ICOPEN
210 icopen.fccType = fccType;
211 icopen.fccHandler = fccHandler;
212 icopen.dwSize = sizeof(ICOPEN);
213 icopen.dwFlags = wMode;
214 /* FIXME: do we need to fill out the rest too? */
215 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
217 if (!strcasecmp(type,"vids")) {
218 sprintf(codecname,"vidc.%s",handler);
219 fccType = mmioFOURCC('v','i','d','c');
221 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
225 /* The handle should be a valid 16-bit handle as well */
226 hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
227 whic = (WINE_HIC*)GlobalLock16(hic);
229 whic->driverproc= NULL;
232 TRACE("=> 0x%08lx\n",(DWORD)hic);
236 HIC MSVIDEO_OpenFunc(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler, BOOL bFrom32) {
237 char type[5],handler[5],codecname[20];
243 memcpy(type,&fccType,4);type[4]=0;
244 memcpy(handler,&fccHandler,4);handler[4]=0;
245 TRACE("(%s,%s,%d,%p,%d)\n",type,handler,wMode,lpfnHandler,bFrom32?32:16);
247 icopen.fccType = fccType;
248 icopen.fccHandler = fccHandler;
249 icopen.dwSize = sizeof(ICOPEN);
250 icopen.dwFlags = wMode;
252 sprintf(codecname,"%s.%s",type,handler);
254 hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
257 whic = GlobalLock16(hic);
258 whic->driverproc = lpfnHandler;
260 whic->private = bFrom32;
262 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
263 /* What if the function is used more than once? */
265 if (MSVIDEO_SendMessage(hic,DRV_LOAD,0L,0L,bFrom32) != DRV_SUCCESS) {
266 WARN("DRV_LOAD failed for hic 0x%08lx\n",(DWORD)hic);
270 /* return value is not checked */
271 MSVIDEO_SendMessage(hic,DRV_ENABLE,0L,0L,bFrom32);
273 seg_icopen = MapLS( &icopen );
274 whic->hdrv = (HDRVR)MSVIDEO_SendMessage(hic,DRV_OPEN,0,seg_icopen,FALSE);
275 UnMapLS( seg_icopen );
276 if (whic->hdrv == 0) {
277 WARN("DRV_OPEN failed for hic 0x%08lx\n",(DWORD)hic);
283 TRACE("=> 0x%08lx\n",(DWORD)hic);
287 /***********************************************************************
288 * ICOpenFunction [MSVFW32.@]
290 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler) {
291 return MSVIDEO_OpenFunc(fccType,fccHandler,wMode,lpfnHandler,TRUE);
294 /***********************************************************************
295 * ICOpenFunction [MSVIDEO.206]
297 HIC16 VFWAPI ICOpenFunction16(DWORD fccType, DWORD fccHandler, UINT16 wMode, FARPROC16 lpfnHandler)
299 return MSVIDEO_OpenFunc(fccType, fccHandler, wMode, (FARPROC)lpfnHandler,FALSE);
302 /***********************************************************************
303 * ICGetInfo [MSVFW32.@]
305 LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
308 TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
309 ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
310 TRACE(" -> 0x%08lx\n",ret);
314 /***********************************************************************
315 * ICLocate [MSVFW32.@]
318 DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
319 LPBITMAPINFOHEADER lpbiOut, WORD wMode)
321 char type[5],handler[5];
326 type[4]=0;memcpy(type,&fccType,4);
327 handler[4]=0;memcpy(handler,&fccHandler,4);
329 TRACE("(%s,%s,%p,%p,0x%04x)\n", type, handler, lpbiIn, lpbiOut, wMode);
332 case ICMODE_FASTCOMPRESS:
333 case ICMODE_COMPRESS:
334 querymsg = ICM_COMPRESS_QUERY;
336 case ICMODE_FASTDECOMPRESS:
337 case ICMODE_DECOMPRESS:
338 querymsg = ICM_DECOMPRESS_QUERY;
341 querymsg = ICM_DRAW_QUERY;
344 WARN("Unknown mode (%d)\n",wMode);
348 /* Easy case: handler/type match, we just fire a query and return */
349 hic = ICOpen(fccType,fccHandler,wMode);
351 if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
356 type[4]='.';memcpy(type,&fccType,4);
357 handler[4]='.';memcpy(handler,&fccHandler,4);
359 /* Now try each driver in turn. 32 bit codecs only. */
360 /* FIXME: Move this to an init routine? */
362 pszBuffer = (LPSTR)HeapAlloc(GetProcessHeap(),0,1024);
363 if (GetPrivateProfileSectionA("drivers32",pszBuffer,1024,"system.ini")) {
366 if (!strncasecmp(type,s,5)) {
368 while (*s2 != '\0' && *s2 != '.') s2++;
372 h = ICOpen(fccType,*(DWORD*)s2,wMode);
374 if (!ICSendMessage(h,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
383 HeapFree(GetProcessHeap(),0,pszBuffer);
385 if (fccType==streamtypeVIDEO) {
386 hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
391 type[4] = handler[4] = '\0';
392 WARN("(%.4s,%.4s,%p,%p,0x%04x) not found!\n",type,handler,lpbiIn,lpbiOut,wMode);
396 /***********************************************************************
397 * ICGetDisplayFormat [MSVFW32.@]
399 HIC VFWAPI ICGetDisplayFormat(
400 HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
401 INT depth,INT dx,INT dy)
405 FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
407 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
411 if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
412 dy = dx = 0; /* no resize needed */
414 /* Can we decompress it ? */
415 if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
416 goto errout; /* no, sorry */
418 ICDecompressGetFormat(tmphic,lpbiIn,lpbiOut);
420 if (lpbiOut->biCompression != 0) {
421 FIXME("Ooch, how come decompressor outputs compressed data (%ld)??\n",
422 lpbiOut->biCompression);
424 if (lpbiOut->biSize < sizeof(*lpbiOut)) {
425 FIXME("Ooch, size of output BIH is too small (%ld)\n",
427 lpbiOut->biSize = sizeof(*lpbiOut);
433 depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
435 if (depth==15) depth = 16;
436 if (depth<8) depth = 8;
438 if (lpbiIn->biBitCount == 8)
441 TRACE("=> 0x%08lx\n",(DWORD)tmphic);
451 /***********************************************************************
452 * ICCompress [MSVFW32.@]
456 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
457 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
458 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
459 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
463 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
465 iccmp.dwFlags = dwFlags;
467 iccmp.lpbiOutput = lpbiOutput;
468 iccmp.lpOutput = lpData;
469 iccmp.lpbiInput = lpbiInput;
470 iccmp.lpInput = lpBits;
472 iccmp.lpckid = lpckid;
473 iccmp.lpdwFlags = lpdwFlags;
474 iccmp.lFrameNum = lFrameNum;
475 iccmp.dwFrameSize = dwFrameSize;
476 iccmp.dwQuality = dwQuality;
477 iccmp.lpbiPrev = lpbiPrev;
478 iccmp.lpPrev = lpPrev;
479 return ICSendMessage(hic,ICM_COMPRESS,(DWORD)&iccmp,sizeof(iccmp));
482 /***********************************************************************
483 * ICDecompress [MSVFW32.@]
485 DWORD VFWAPIV ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
486 LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
491 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
493 TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
495 icd.dwFlags = dwFlags;
496 icd.lpbiInput = lpbiFormat;
497 icd.lpInput = lpData;
499 icd.lpbiOutput = lpbi;
500 icd.lpOutput = lpBits;
502 ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
504 TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
506 TRACE("-> %ld\n",ret);
511 #define COPY(x,y) (x->y = x##16->y);
512 #define COPYPTR(x,y) (x->y = MapSL((SEGPTR)x##16->y));
514 LPVOID MSVIDEO_MapICDEX16To32(LPDWORD lParam) {
517 ICDECOMPRESSEX *icdx = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESSEX));
518 ICDECOMPRESSEX16 *icdx16 = MapSL(*lParam);
522 COPYPTR(icdx,lpbiSrc);
524 COPYPTR(icdx,lpbiDst);
535 *lParam = (DWORD)(icdx);
539 LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2) {
542 TRACE("Mapping %d\n",msg);
552 case ICM_COMPRESS_END:
553 case ICM_DECOMPRESS_END:
554 case ICM_DECOMPRESSEX_END:
556 case ICM_DRAW_START_PLAY:
557 case ICM_DRAW_STOP_PLAY:
558 case ICM_DRAW_REALIZE:
559 case ICM_DRAW_RENDERBUFFER:
563 case ICM_GETDEFAULTQUALITY:
566 case ICM_DRAW_WINDOW:
567 case ICM_GETBUFFERSWANTED:
568 *lParam1 = (DWORD)MapSL(*lParam1);
572 ICINFO *ici = HeapAlloc(GetProcessHeap(),0,sizeof(ICINFO));
575 ici16 = MapSL(*lParam1);
578 ici->dwSize = sizeof(ICINFO);
580 COPY(ici,fccHandler);
583 COPY(ici,dwVersionICM);
584 MultiByteToWideChar( CP_ACP, 0, ici16->szName, -1, ici->szName, 16 );
585 MultiByteToWideChar( CP_ACP, 0, ici16->szDescription, -1, ici->szDescription, 128 );
586 MultiByteToWideChar( CP_ACP, 0, ici16->szDriver, -1, ici->szDriver, 128 );
587 *lParam1 = (DWORD)(ici);
588 *lParam2 = sizeof(ICINFO);
593 ICCOMPRESS *icc = HeapAlloc(GetProcessHeap(),0,sizeof(ICCOMPRESS));
596 icc16 = MapSL(*lParam1);
600 COPYPTR(icc,lpbiOutput);
601 COPYPTR(icc,lpOutput);
602 COPYPTR(icc,lpbiInput);
603 COPYPTR(icc,lpInput);
605 COPYPTR(icc,lpdwFlags);
607 COPY(icc,dwFrameSize);
609 COPYPTR(icc,lpbiPrev);
612 *lParam1 = (DWORD)(icc);
613 *lParam2 = sizeof(ICCOMPRESS);
618 ICDECOMPRESS *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESS));
619 ICDECOMPRESS *icd16; /* Same structure except for the pointers */
621 icd16 = MapSL(*lParam1);
625 COPYPTR(icd,lpbiInput);
626 COPYPTR(icd,lpInput);
627 COPYPTR(icd,lpbiOutput);
628 COPYPTR(icd,lpOutput);
631 *lParam1 = (DWORD)(icd);
632 *lParam2 = sizeof(ICDECOMPRESS);
635 case ICM_COMPRESS_BEGIN:
636 case ICM_COMPRESS_GET_FORMAT:
637 case ICM_COMPRESS_GET_SIZE:
638 case ICM_COMPRESS_QUERY:
639 case ICM_DECOMPRESS_GET_FORMAT:
640 case ICM_DECOMPRESS_QUERY:
641 case ICM_DECOMPRESS_BEGIN:
642 case ICM_DECOMPRESS_SET_PALETTE:
643 case ICM_DECOMPRESS_GET_PALETTE:
644 *lParam1 = (DWORD)MapSL(*lParam1);
645 *lParam2 = (DWORD)MapSL(*lParam2);
647 case ICM_DECOMPRESSEX_QUERY:
648 if ((*lParam2 != sizeof(ICDECOMPRESSEX16)) && (*lParam2 != 0))
649 WARN("*lParam2 has unknown value %p\n",(ICDECOMPRESSEX16*)*lParam2);
650 /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
651 * This is because of ICMessage(). Special case it?
653 LPVOID* addr = HeapAlloc(GetProcessHeap(),0,2*sizeof(LPVOID));
654 addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
656 addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
663 case ICM_DECOMPRESSEX_BEGIN:
664 case ICM_DECOMPRESSEX:
665 ret = MSVIDEO_MapICDEX16To32(lParam1);
666 *lParam2 = sizeof(ICDECOMPRESSEX);
670 ICDRAWBEGIN *icdb = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWBEGIN));
671 ICDRAWBEGIN16 *icdb16 = MapSL(*lParam1);
675 icdb->hpal = HPALETTE_32(icdb16->hpal);
676 icdb->hwnd = HWND_32(icdb16->hwnd);
690 *lParam1 = (DWORD)(icdb);
691 *lParam2 = sizeof(ICDRAWBEGIN);
694 case ICM_DRAW_SUGGESTFORMAT:
696 ICDRAWSUGGEST *icds = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWSUGGEST));
697 ICDRAWSUGGEST16 *icds16 = MapSL(*lParam1);
702 COPYPTR(icds,lpbiIn);
703 COPYPTR(icds,lpbiSuggest);
708 COPY(icds,hicDecompressor);
710 *lParam1 = (DWORD)(icds);
711 *lParam2 = sizeof(ICDRAWSUGGEST);
716 ICDRAW *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAW));
717 ICDRAW *icd16 = MapSL(*lParam1);
721 COPYPTR(icd,lpFormat);
726 *lParam1 = (DWORD)(icd);
727 *lParam2 = sizeof(ICDRAW);
734 FIXME("%d is not yet handled. Expect a crash.\n",msg);
742 void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID data16, LPDWORD lParam1, LPDWORD lParam2) {
743 TRACE("Unmapping %d\n",msg);
745 #define UNCOPY(x,y) (x##16->y = x->y);
750 ICINFO *ici = (ICINFO*)(*lParam1);
751 ICINFO16 *ici16 = (ICINFO16*)data16;
754 UNCOPY(ici,fccHandler);
756 UNCOPY(ici,dwVersion);
757 UNCOPY(ici,dwVersionICM);
758 WideCharToMultiByte( CP_ACP, 0, ici->szName, -1, ici16->szName,
759 sizeof(ici16->szName), NULL, NULL );
760 ici16->szName[sizeof(ici16->szName)-1] = 0;
761 WideCharToMultiByte( CP_ACP, 0, ici->szDescription, -1, ici16->szDescription,
762 sizeof(ici16->szDescription), NULL, NULL );
763 ici16->szDescription[sizeof(ici16->szDescription)-1] = 0;
764 /* This just gives garbage for some reason - BB
765 lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/
767 HeapFree(GetProcessHeap(),0,ici);
770 case ICM_DECOMPRESS_QUERY:
773 HeapFree(GetProcessHeap(),0,x[0]);
775 HeapFree(GetProcessHeap(),0,x[1]);
780 case ICM_DECOMPRESSEX_QUERY:
781 case ICM_DECOMPRESSEX_BEGIN:
782 case ICM_DECOMPRESSEX:
784 case ICM_DRAW_SUGGESTFORMAT:
786 HeapFree(GetProcessHeap(),0,data16);
789 ERR("Unmapping unmapped msg %d\n",msg);
794 LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2, BOOL bFrom32) {
796 WINE_HIC *whic = GlobalLock16(hic);
800 #define XX(x) case x: TRACE("(0x%08lx,"#x",0x%08lx,0x%08lx,%d)\n",(DWORD)hic,lParam1,lParam2,bFrom32?32:16);break;
815 XX(ICM_GETDEFAULTQUALITY);
822 XX(ICM_COMPRESS_FRAMES_INFO);
823 XX(ICM_COMPRESS_GET_FORMAT);
824 XX(ICM_COMPRESS_GET_SIZE);
825 XX(ICM_COMPRESS_QUERY);
826 XX(ICM_COMPRESS_BEGIN);
828 XX(ICM_COMPRESS_END);
829 XX(ICM_DECOMPRESS_GET_FORMAT);
830 XX(ICM_DECOMPRESS_QUERY);
831 XX(ICM_DECOMPRESS_BEGIN);
833 XX(ICM_DECOMPRESS_END);
834 XX(ICM_DECOMPRESS_SET_PALETTE);
835 XX(ICM_DECOMPRESS_GET_PALETTE);
838 XX(ICM_DRAW_GET_PALETTE);
842 XX(ICM_DRAW_GETTIME);
845 XX(ICM_DRAW_SETTIME);
846 XX(ICM_DRAW_REALIZE);
848 XX(ICM_DRAW_RENDERBUFFER);
849 XX(ICM_DRAW_START_PLAY);
850 XX(ICM_DRAW_STOP_PLAY);
851 XX(ICM_DRAW_SUGGESTFORMAT);
852 XX(ICM_DRAW_CHANGEPALETTE);
853 XX(ICM_GETBUFFERSWANTED);
854 XX(ICM_GETDEFAULTKEYFRAMERATE);
855 XX(ICM_DECOMPRESSEX_BEGIN);
856 XX(ICM_DECOMPRESSEX_QUERY);
857 XX(ICM_DECOMPRESSEX);
858 XX(ICM_DECOMPRESSEX_END);
859 XX(ICM_SET_STATUS_PROC);
861 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,%i) unknown message\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,bFrom32?32:16);
866 if (!whic) return ICERR_BADHANDLE;
868 if (whic->driverproc) { /* IC is a function */
869 bDrv32 = whic->private;
871 bDrv32 = ((GetDriverFlags(whic->hdrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) == WINE_GDF_EXIST);
876 data16 = MSVIDEO_MapMsg16To32(msg,&lParam1,&lParam2);
879 ERR("Can't do 32->16 mappings\n");
885 if (whic->driverproc) {
887 ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
889 ret = MSVIDEO_CallTo16_long_lwwll((FARPROC16)whic->driverproc,HDRVR_16(whic->hdrv),hic,msg,lParam1,lParam2);
892 ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
896 MSVIDEO_UnmapMsg16To32(msg,data16,&lParam1,&lParam2);
901 TRACE(" -> 0x%08lx\n",ret);
905 /***********************************************************************
906 * ICSendMessage [MSVFW32.@]
908 LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2) {
909 return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,TRUE);
912 /***********************************************************************
913 * ICSendMessage [MSVIDEO.205]
915 LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lParam2) {
916 return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,FALSE);
919 /***********************************************************************
920 * ICDrawBegin [MSVFW32.@]
922 DWORD VFWAPIV ICDrawBegin(
924 DWORD dwFlags, /* [in] flags */
925 HPALETTE hpal, /* [in] palette to draw with */
926 HWND hwnd, /* [in] window to draw to */
927 HDC hdc, /* [in] HDC to draw to */
928 INT xDst, /* [in] destination rectangle */
930 INT dxDst, /* [in] */
931 INT dyDst, /* [in] */
932 LPBITMAPINFOHEADER lpbi, /* [in] format of frame to draw */
933 INT xSrc, /* [in] source rectangle */
935 INT dxSrc, /* [in] */
936 INT dySrc, /* [in] */
937 DWORD dwRate, /* [in] frames/second = (dwRate/dwScale) */
938 DWORD dwScale) /* [in] */
943 TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
944 (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
945 lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
947 icdb.dwFlags = dwFlags;
960 icdb.dwRate = dwRate;
961 icdb.dwScale = dwScale;
962 return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD)&icdb,sizeof(icdb));
965 /***********************************************************************
968 DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
971 TRACE("(0x%09lx,%ld,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
973 icd.dwFlags = dwFlags;
974 icd.lpFormat = lpFormat;
979 return ICSendMessage(hic,ICM_DRAW,(DWORD)&icd,sizeof(icd));
982 /***********************************************************************
983 * ICClose [MSVFW32.@]
985 LRESULT WINAPI ICClose(HIC hic) {
986 WINE_HIC *whic = GlobalLock16(hic);
987 TRACE("(0x%08lx)\n",(DWORD)hic);
988 if (whic->driverproc) {
989 ICSendMessage(hic,DRV_CLOSE,0,0);
990 ICSendMessage(hic,DRV_DISABLE,0,0);
991 ICSendMessage(hic,DRV_FREE,0,0);
993 CloseDriver(whic->hdrv,0,0);
1003 /***********************************************************************
1004 * ICImageCompress [MSVFW32.@]
1006 HANDLE VFWAPI ICImageCompress(
1007 HIC hic, UINT uiFlags,
1008 LPBITMAPINFO lpbiIn, LPVOID lpBits,
1009 LPBITMAPINFO lpbiOut, LONG lQuality,
1012 FIXME("(%08x,%08x,%p,%p,%p,%ld,%p)\n",
1013 hic, uiFlags, lpbiIn, lpBits, lpbiOut, lQuality, plSize);
1015 return (HANDLE)NULL;
1018 /***********************************************************************
1019 * ICImageDecompress [MSVFW32.@]
1022 HANDLE VFWAPI ICImageDecompress(
1023 HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn,
1024 LPVOID lpBits, LPBITMAPINFO lpbiOut)
1026 HGLOBAL hMem = (HGLOBAL)NULL;
1028 BOOL bReleaseIC = FALSE;
1031 BOOL bSucceeded = FALSE;
1032 BOOL bInDecompress = FALSE;
1035 TRACE("(%08x,%08x,%p,%p,%p)\n",
1036 hic, uiFlags, lpbiIn, lpBits, lpbiOut);
1038 if ( hic == (HIC)NULL )
1040 hic = ICDecompressOpen( mmioFOURCC('V','I','D','C'), 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL );
1041 if ( hic == (HIC)NULL )
1043 WARN("no handler\n" );
1050 FIXME( "unknown flag %08x\n", uiFlags );
1053 if ( lpbiIn == NULL || lpBits == NULL )
1055 WARN("invalid argument\n");
1059 if ( lpbiOut != NULL )
1061 if ( lpbiOut->bmiHeader.biSize != sizeof(BITMAPINFOHEADER) )
1063 cbHdr = sizeof(BITMAPINFOHEADER);
1064 if ( lpbiOut->bmiHeader.biCompression == 3 )
1065 cbHdr += sizeof(DWORD)*3;
1067 if ( lpbiOut->bmiHeader.biBitCount <= 8 )
1069 if ( lpbiOut->bmiHeader.biClrUsed == 0 )
1070 cbHdr += sizeof(RGBQUAD) * (1<<lpbiOut->bmiHeader.biBitCount);
1072 cbHdr += sizeof(RGBQUAD) * lpbiOut->bmiHeader.biClrUsed;
1077 TRACE( "get format\n" );
1079 cbHdr = ICDecompressGetFormatSize(hic,lpbiIn);
1080 if ( cbHdr < sizeof(BITMAPINFOHEADER) )
1082 pHdr = (BYTE*)HeapAlloc(GetProcessHeap(),0,cbHdr+sizeof(RGBQUAD)*256);
1085 ZeroMemory( pHdr, cbHdr+sizeof(RGBQUAD)*256 );
1086 if ( ICDecompressGetFormat( hic, lpbiIn, (BITMAPINFO*)pHdr ) != ICERR_OK )
1088 lpbiOut = (BITMAPINFO*)pHdr;
1089 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1090 ICDecompressGetPalette( hic, lpbiIn, lpbiOut ) != ICERR_OK &&
1091 lpbiIn->bmiHeader.biBitCount == lpbiOut->bmiHeader.biBitCount )
1093 if ( lpbiIn->bmiHeader.biClrUsed == 0 )
1094 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*(1<<lpbiOut->bmiHeader.biBitCount) );
1096 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*lpbiIn->bmiHeader.biClrUsed );
1098 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1099 lpbiOut->bmiHeader.biClrUsed == 0 )
1100 lpbiOut->bmiHeader.biClrUsed = 1<<lpbiOut->bmiHeader.biBitCount;
1102 lpbiOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1103 cbHdr = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*lpbiOut->bmiHeader.biClrUsed;
1106 biSizeImage = lpbiOut->bmiHeader.biSizeImage;
1107 if ( biSizeImage == 0 )
1108 biSizeImage = ((((lpbiOut->bmiHeader.biWidth * lpbiOut->bmiHeader.biBitCount + 7) >> 3) + 3) & (~3)) * abs(lpbiOut->bmiHeader.biHeight);
1110 TRACE( "call ICDecompressBegin\n" );
1112 if ( ICDecompressBegin( hic, lpbiIn, lpbiOut ) != ICERR_OK )
1114 bInDecompress = TRUE;
1116 TRACE( "cbHdr %ld, biSizeImage %ld\n", cbHdr, biSizeImage );
1118 hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, cbHdr + biSizeImage );
1119 if ( hMem == (HGLOBAL)NULL )
1121 WARN( "out of memory\n" );
1124 pMem = (BYTE*)GlobalLock( hMem );
1127 memcpy( pMem, lpbiOut, cbHdr );
1129 TRACE( "call ICDecompress\n" );
1130 if ( ICDecompress( hic, 0, &lpbiIn->bmiHeader, lpBits, &lpbiOut->bmiHeader, pMem+cbHdr ) != ICERR_OK )
1135 if ( bInDecompress )
1136 ICDecompressEnd( hic );
1140 HeapFree(GetProcessHeap(),0,pHdr);
1142 GlobalUnlock( hMem );
1143 if ( !bSucceeded && hMem != (HGLOBAL)NULL )
1145 GlobalFree(hMem); hMem = (HGLOBAL)NULL;
1148 return (HANDLE)hMem;