2 * Copyright 1998 Marcus Meissner
12 #include "wine/winestring.h"
14 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(msvideo)
18 /***********************************************************************
19 * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
20 * Returns the version in major.minor form.
21 * In Windows95 this returns 0x040003b6 (4.950)
24 VideoForWindowsVersion(void) {
25 return 0x040003B6; /* 4.950 */
28 /***********************************************************************
29 * VideoCapDriverDescAndVer [MSVIDEO.22]
32 VideoCapDriverDescAndVer(WORD nr,LPVOID buf1,WORD buf1len,LPVOID buf2,WORD buf2len) {
33 FIXME("(%d,%p,%d,%p,%d), stub!\n",nr,buf1,buf1len,buf2,buf2len);
37 /* system.ini: [drivers] */
39 /***********************************************************************
41 * Get information about an installable compressor. Return TRUE if there
46 DWORD fccType, /* [in] type of compressor ('vidc') */
47 DWORD fccHandler, /* [in] <n>th compressor */
48 ICINFO *lpicinfo /* [out] information about compressor */
50 char type[5],buf[2000];
52 memcpy(type,&fccType,4);type[4]=0;
53 TRACE("(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
54 /* does OpenDriver/CloseDriver */
55 lpicinfo->dwSize = sizeof(ICINFO);
56 lpicinfo->fccType = fccType;
57 lpicinfo->dwFlags = 0;
58 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
61 if (!lstrncmpiA(type,s,4)) {
63 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
67 s=s+lstrlenA(s)+1; /* either next char or \0 */
73 /***********************************************************************
75 * Opens an installable compressor. Return special handle.
78 ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
79 char type[5],handler[5],codecname[20];
84 memcpy(type,&fccType,4);type[4]=0;
85 memcpy(handler,&fccHandler,4);handler[4]=0;
86 TRACE("(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
87 sprintf(codecname,"%s.%s",type,handler);
89 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
90 * same layout as ICOPEN
92 icopen.fccType = fccType;
93 icopen.fccHandler = fccHandler;
94 icopen.dwSize = sizeof(ICOPEN);
95 icopen.dwFlags = wMode;
96 /* FIXME: do we need to fill out the rest too? */
97 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
99 if (!strcasecmp(type,"vids")) {
100 sprintf(codecname,"vidc.%s",handler);
101 fccType = mmioFOURCC('v','i','d','c');
103 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
107 whic = HeapAlloc(GetProcessHeap(),0,sizeof(WINE_HIC));
109 whic->driverproc= NULL;
110 whic->private = ICSendMessage((HIC)whic,DRV_OPEN,0,(LPARAM)&icopen);
114 /***********************************************************************
115 * ICOpenFunction [MSVFW.38]
117 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
118 FARPROC lpfnHandler) {
119 char type[5],handler[5];
123 memcpy(type,&fccType,4);type[4]=0;
124 memcpy(handler,&fccHandler,4);handler[4]=0;
125 FIXME("(%s,%s,%d,%p), stub!\n",type,handler,wMode,lpfnHandler);
126 hic = ICOpen(fccType,fccHandler,wMode);
129 whic = (WINE_HIC*)hic;
130 whic->driverproc = lpfnHandler;
135 /***********************************************************************
136 * ICGetInfo [MSVFW.30]
139 ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
142 TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
143 ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
144 TRACE(" -> 0x%08lx\n",ret);
148 /***********************************************************************
149 * ICLocate [MSVFW.35]
153 DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
154 LPBITMAPINFOHEADER lpbiOut, WORD wMode
156 char type[5],handler[5];
161 case ICMODE_FASTCOMPRESS:
162 case ICMODE_COMPRESS:
163 querymsg = ICM_COMPRESS_QUERY;
165 case ICMODE_DECOMPRESS:
166 case ICMODE_FASTDECOMPRESS:
167 querymsg = ICM_DECOMPRESS_QUERY;
170 querymsg = ICM_DRAW_QUERY;
173 FIXME("Unknown mode (%d)\n",wMode);
177 /* Easy case: handler/type match, we just fire a query and return */
178 hic = ICOpen(fccType,fccHandler,wMode);
180 if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
184 type[4]='\0';memcpy(type,&fccType,4);
185 handler[4]='\0';memcpy(handler,&fccHandler,4);
186 if (fccType==streamtypeVIDEO) {
187 hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
191 FIXME("(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode);
195 /***********************************************************************
196 * ICGetDisplayFormat [MSVFW.29]
198 HIC VFWAPI ICGetDisplayFormat(
199 HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
200 INT depth,INT dx,INT dy
205 FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
207 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
211 if ((dy == lpbiIn->biHeight) || (dx == lpbiIn->biWidth))
212 dy = dx = 0; /* no resize needed */
213 /* Can we decompress it ? */
214 lres = ICDecompressQuery(tmphic,lpbiIn,NULL);
216 goto errout; /* no, sorry */
217 ICDecompressGetFormat(hic,lpbiIn,lpbiOut);
219 lpbiOut->biCompression = 0;
220 lpbiOut->biSize = sizeof(*lpbiOut);
225 depth = GetDeviceCaps(hdc,12)*GetDeviceCaps(hdc,14);
227 if (depth==15) depth = 16;
228 if (depth<8) depth = 8;
229 /* more constraints and tests */
231 if (lpbiIn->biBitCount == 8)
241 /***********************************************************************
242 * ICCompress [MSVFW.23]
246 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
247 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
248 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
249 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev
253 iccmp.dwFlags = dwFlags;
255 iccmp.lpbiOutput = lpbiOutput;
256 iccmp.lpOutput = lpData;
257 iccmp.lpbiInput = lpbiInput;
258 iccmp.lpInput = lpBits;
260 iccmp.lpckid = lpckid;
261 iccmp.lpdwFlags = lpdwFlags;
262 iccmp.lFrameNum = lFrameNum;
263 iccmp.dwFrameSize = dwFrameSize;
264 iccmp.dwQuality = dwQuality;
265 iccmp.lpbiPrev = lpbiPrev;
266 iccmp.lpPrev = lpPrev;
267 return ICSendMessage(hic,ICM_COMPRESS,(LPARAM)&iccmp,sizeof(iccmp));
270 /***********************************************************************
271 * ICDecompress [MSVFW.26]
274 ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits) {
277 icd.dwFlags = dwFlags;
278 icd.lpbiInput = lpbiFormat;
279 icd.lpInput = lpData;
281 icd.lpbiOutput = lpbi;
282 icd.lpOutput = lpBits;
284 return ICSendMessage(hic,ICM_DECOMPRESS,(LPARAM)&icd,sizeof(icd));
287 /***********************************************************************
288 * ICSendMessage [MSVFW.40]
291 ICSendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2) {
293 WINE_HIC *whic = (WINE_HIC*)hic;
295 #define XX(x) case x: TRACE("(0x%08lx,"#x",0x%08lx,0x%08lx)\n",(DWORD)hic,lParam1,lParam2);break;
300 XX(ICM_COMPRESS_FRAMES_INFO)
301 XX(ICM_COMPRESS_GET_FORMAT)
302 XX(ICM_COMPRESS_GET_SIZE)
303 XX(ICM_COMPRESS_QUERY)
304 XX(ICM_COMPRESS_BEGIN)
307 XX(ICM_DECOMPRESS_GET_FORMAT)
308 XX(ICM_DECOMPRESS_QUERY)
309 XX(ICM_DECOMPRESS_BEGIN)
311 XX(ICM_DECOMPRESS_END)
312 XX(ICM_DECOMPRESS_SET_PALETTE)
313 XX(ICM_DECOMPRESS_GET_PALETTE)
316 XX(ICM_DRAW_GET_PALETTE)
326 XX(ICM_DRAW_RENDERBUFFER)
327 XX(ICM_DRAW_START_PLAY)
328 XX(ICM_DRAW_STOP_PLAY)
329 XX(ICM_DRAW_SUGGESTFORMAT)
330 XX(ICM_DRAW_CHANGEPALETTE)
331 XX(ICM_GETBUFFERSWANTED)
332 XX(ICM_GETDEFAULTKEYFRAMERATE)
333 XX(ICM_DECOMPRESSEX_BEGIN)
334 XX(ICM_DECOMPRESSEX_QUERY)
336 XX(ICM_DECOMPRESSEX_END)
337 XX(ICM_SET_STATUS_PROC)
339 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx)\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2);
342 if (whic->driverproc) {
343 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx), calling %p\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,whic->driverproc);
344 ret = whic->driverproc(whic->hdrv,1,msg,lParam1,lParam2);
347 ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
348 TRACE(" -> 0x%08lx\n",ret);
352 /***********************************************************************
353 * ICDrawBegin [MSVFW.28]
355 DWORD VFWAPIV ICDrawBegin(
357 DWORD dwFlags,/* flags */
358 HPALETTE hpal, /* palette to draw with */
359 HWND hwnd, /* window to draw to */
360 HDC hdc, /* HDC to draw to */
361 INT xDst, /* destination rectangle */
365 LPBITMAPINFOHEADER lpbi, /* format of frame to draw */
366 INT xSrc, /* source rectangle */
370 DWORD dwRate, /* frames/second = (dwRate/dwScale) */
374 icdb.dwFlags = dwFlags;
387 icdb.dwRate = dwRate;
388 icdb.dwScale = dwScale;
389 return ICSendMessage(hic,ICM_DRAW_BEGIN,(LPARAM)&icdb,sizeof(icdb));
392 /***********************************************************************
395 DWORD VFWAPIV ICDraw(
396 HIC hic,DWORD dwFlags,LPVOID lpFormat,LPVOID lpData,DWORD cbData,
401 icd.dwFlags = dwFlags;
402 icd.lpFormat = lpFormat;
406 return ICSendMessage(hic,ICM_DRAW,(LPARAM)&icd,sizeof(icd));
409 /***********************************************************************
412 LRESULT WINAPI ICClose(HIC hic) {
413 WINE_HIC *whic = (WINE_HIC*)hic;
414 TRACE("(%d).\n",hic);
415 /* FIXME: correct? */
416 CloseDriver(whic->hdrv,0,0);
417 HeapFree(GetProcessHeap(),0,whic);
421 /***********************************************************************
422 * DrawDibOpen [MSVFW.10]
425 DrawDibOpen( void ) {
430 /***********************************************************************
431 * DrawDibClose [MSVFW.5]
434 DrawDibClose( HDRAWDIB hDib ) {
439 /***********************************************************************
440 * DrawDibBegin [MSVFW.3]
442 BOOL VFWAPI DrawDibBegin(HDRAWDIB hdd,
446 LPBITMAPINFOHEADER lpbi,
450 FIXME("(%d,0x%lx,%d,%d,%p,%d,%d,0x%08lx), stub!\n",
451 hdd,(DWORD)hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,(DWORD)wFlags
457 /***********************************************************************
458 * DrawDibSetPalette [MSVFW.13]
461 DrawDibSetPalette(HDRAWDIB hdd, HPALETTE hpal) {
462 FIXME("(%d,%d),stub!\n",hdd,hpal);
466 /***********************************************************************
467 * DrawDibRealize [MSVFW.12]
469 UINT VFWAPI DrawDibRealize(HDRAWDIB hdd, HDC hdc, BOOL fBackground) {
470 FIXME("(0x%08lx,0x%08lx,%d),stub!\n",(DWORD)hdd,(DWORD)hdc,fBackground);
474 /***********************************************************************
475 * MCIWndCreate [MSVFW.44]
477 HWND VFWAPIV MCIWndCreate (HWND hwndParent, HINSTANCE hInstance,
478 DWORD dwStyle,LPVOID szFile)
479 { FIXME("%x %x %lx %p\n",hwndParent, hInstance, dwStyle, szFile);
483 /***********************************************************************
484 * MCIWndCreateA [MSVFW.45]
486 HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance,
487 DWORD dwStyle,LPCSTR szFile)
488 { FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
492 /***********************************************************************
493 * MCIWndCreateW [MSVFW.46]
495 HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance,
496 DWORD dwStyle,LPCWSTR szFile)
497 { FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));