2 * Copyright 1998 Marcus Meissner
3 * Copyright 2000 Bradley Baetz
4 * Copyright 2003 Michael Günnewig
5 * Copyright 2005 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * FIXME: This all assumes 32 bit codecs
22 * Win95 appears to prefer 32 bit codecs, even from 16 bit code.
23 * There is the ICOpenFunction16 to worry about still, though.
41 #include "msvideo_private.h"
42 #include "wine/debug.h"
44 /* Drivers32 settings */
45 #define HKLM_DRIVERS32 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
47 WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
49 static inline const char *wine_dbgstr_fcc( DWORD fcc )
51 return wine_dbg_sprintf("%c%c%c%c",
52 LOBYTE(LOWORD(fcc)), HIBYTE(LOWORD(fcc)),
53 LOBYTE(HIWORD(fcc)), HIBYTE(HIWORD(fcc)));
56 LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM) = NULL;
58 static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
60 typedef struct _reg_driver reg_driver;
70 static reg_driver* reg_driver_list = NULL;
72 /* This one is a macro such that it works for both ASCII and Unicode */
73 #define fourcc_to_string(str, fcc) do { \
74 (str)[0] = LOBYTE(LOWORD(fcc)); \
75 (str)[1] = HIBYTE(LOWORD(fcc)); \
76 (str)[2] = LOBYTE(HIWORD(fcc)); \
77 (str)[3] = HIBYTE(HIWORD(fcc)); \
80 HMODULE MSVFW32_hModule;
82 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
84 TRACE("%p,%x,%p\n", hinst, reason, reserved);
88 case DLL_PROCESS_ATTACH:
89 DisableThreadLibraryCalls(hinst);
90 MSVFW32_hModule = (HMODULE)hinst;
96 static int compare_fourcc(DWORD fcc1, DWORD fcc2)
100 fourcc_to_string(fcc_str1, fcc1);
101 fourcc_to_string(fcc_str2, fcc2);
102 return strncasecmp(fcc_str1, fcc_str2, 4);
105 typedef BOOL (*enum_handler_t)(const char*, int, void*);
107 static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
109 CHAR buf[2048], fccTypeStr[5], *s;
110 DWORD i, cnt = 0, bufLen, lRet;
115 fourcc_to_string(fccTypeStr, fccType);
118 /* first, go through the registry entries */
119 lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
120 if (lRet == ERROR_SUCCESS)
123 RegQueryInfoKeyA( hKey, 0, 0, 0, &numkeys, 0, 0, 0, 0, 0, 0, 0);
124 for (i = 0; i < numkeys; i++)
126 bufLen = sizeof(buf) / sizeof(buf[0]);
127 lRet = RegEnumKeyExA(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
128 if (lRet != ERROR_SUCCESS) continue;
129 if (strncasecmp(buf, fccTypeStr, 5) || buf[9] != '=') continue;
130 if ((result = handler(buf, cnt++, param))) break;
134 if (result) return result;
136 /* if that didn't work, go through the values in system.ini */
137 if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini"))
139 for (s = buf; *s; s += strlen(s) + 1)
141 TRACE("got %s\n", s);
142 if (strncasecmp(s, fccTypeStr, 5) || s[9] != '=') continue;
143 if ((result = handler(s, cnt++, param))) break;
150 /******************************************************************
155 WINE_HIC* MSVIDEO_GetHicPtr(HIC hic)
159 for (whic = MSVIDEO_FirstHic; whic && whic->hic != hic; whic = whic->next);
163 /***********************************************************************
164 * VideoForWindowsVersion [MSVFW32.2]
165 * VideoForWindowsVersion [MSVIDEO.2]
166 * Returns the version in major.minor form.
167 * In Windows95 this returns 0x040003b6 (4.950)
169 DWORD WINAPI VideoForWindowsVersion(void)
171 return 0x040003B6; /* 4.950 */
174 static BOOL ICInfo_enum_handler(const char *drv, int nr, void *param)
176 ICINFO *lpicinfo = (ICINFO *)param;
177 DWORD fccHandler = mmioStringToFOURCCA(drv + 5, 0);
179 /* exact match of fccHandler or nth driver found */
180 if ((lpicinfo->fccHandler != nr) && (lpicinfo->fccHandler != fccHandler))
183 lpicinfo->fccHandler = fccHandler;
184 lpicinfo->dwFlags = 0;
185 lpicinfo->dwVersion = 0;
186 lpicinfo->dwVersionICM = ICVERSION;
187 lpicinfo->szName[0] = 0;
188 lpicinfo->szDescription[0] = 0;
189 MultiByteToWideChar(CP_ACP, 0, drv + 10, -1, lpicinfo->szDriver,
190 sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
195 /***********************************************************************
197 * Get information about an installable compressor. Return TRUE if there
201 * fccType [I] type of compressor (e.g. 'vidc')
202 * fccHandler [I] real fcc for handler or <n>th compressor
203 * lpicinfo [O] information about compressor
205 BOOL VFWAPI ICInfo( DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo)
207 TRACE("(%s,%s/%08x,%p)\n",
208 wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), fccHandler, lpicinfo);
210 lpicinfo->fccType = fccType;
211 lpicinfo->fccHandler = fccHandler;
212 return enum_drivers(fccType, ICInfo_enum_handler, lpicinfo);
215 static DWORD IC_HandleRef = 1;
217 /***********************************************************************
218 * ICInstall [MSVFW32.@]
220 BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags)
225 TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
227 /* Check if a driver is already registered */
228 for (driver = reg_driver_list; driver; driver = driver->next)
230 if (!compare_fourcc(fccType, driver->fccType) &&
231 !compare_fourcc(fccHandler, driver->fccHandler))
234 if (driver) return FALSE;
236 /* Register the driver */
237 driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(reg_driver));
238 if (!driver) goto oom;
239 driver->fccType = fccType;
240 driver->fccHandler = fccHandler;
244 case ICINSTALL_FUNCTION:
245 driver->proc = (DRIVERPROC)lParam;
248 case ICINSTALL_DRIVER:
250 len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0);
251 driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
252 if (!driver->name) goto oom;
253 MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len);
256 ERR("Invalid flags!\n");
257 HeapFree(GetProcessHeap(), 0, driver);
261 /* Insert our driver in the list*/
262 driver->next = reg_driver_list;
263 reg_driver_list = driver;
267 HeapFree(GetProcessHeap(), 0, driver);
271 /***********************************************************************
272 * ICRemove [MSVFW32.@]
274 BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags)
276 reg_driver** pdriver;
279 TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
281 /* Check if a driver is already registered */
282 for (pdriver = ®_driver_list; *pdriver; pdriver = &(*pdriver)->next)
284 if (!compare_fourcc(fccType, (*pdriver)->fccType) &&
285 !compare_fourcc(fccHandler, (*pdriver)->fccHandler))
291 /* Remove the driver from the list */
293 *pdriver = (*pdriver)->next;
294 HeapFree(GetProcessHeap(), 0, drv->name);
295 HeapFree(GetProcessHeap(), 0, drv);
301 /***********************************************************************
303 * Opens an installable compressor. Return special handle.
305 HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
312 static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'};
315 TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
317 /* Check if there is a registered driver that matches */
318 driver = reg_driver_list;
320 if (!compare_fourcc(fccType, driver->fccType) &&
321 !compare_fourcc(fccHandler, driver->fccHandler))
324 driver = driver->next;
326 if (driver && driver->proc)
327 /* The driver has been registered at runtime with its driverproc */
328 return MSVIDEO_OpenFunction(fccType, fccHandler, wMode, (DRIVERPROC)driver->proc, (DWORD)NULL);
330 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
331 * same layout as ICOPEN
333 icopen.dwSize = sizeof(ICOPEN);
334 icopen.fccType = fccType;
335 icopen.fccHandler = fccHandler;
336 icopen.dwVersion = 0x00001000; /* FIXME */
337 icopen.dwFlags = wMode;
339 icopen.pV1Reserved = NULL;
340 icopen.pV2Reserved = NULL;
341 icopen.dnDevNode = 0; /* FIXME */
344 /* The driver is registered in the registry */
345 fourcc_to_string(codecname, fccType);
347 fourcc_to_string(codecname + 5, fccHandler);
350 hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
354 /* The driver has been registered at runtime with its name */
355 hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
359 bIs16 = GetDriverFlags(hdrv) & 0x10000000; /* undocumented flag: WINE_GDF_16BIT */
361 if (bIs16 && !pFnCallTo16)
363 FIXME("Got a 16 bit driver, but no 16 bit support in msvfw\n");
366 whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
369 CloseDriver(hdrv, 0, 0);
373 /* FIXME: is the signature the real one ? */
374 whic->driverproc = bIs16 ? (DRIVERPROC)pFnCallTo16 : NULL;
375 whic->driverproc16 = 0;
376 whic->type = fccType;
377 whic->handler = fccHandler;
378 while (MSVIDEO_GetHicPtr(HIC_32(IC_HandleRef)) != NULL) IC_HandleRef++;
379 whic->hic = HIC_32(IC_HandleRef++);
380 whic->next = MSVIDEO_FirstHic;
381 MSVIDEO_FirstHic = whic;
383 TRACE("=> %p\n", whic->hic);
387 /***********************************************************************
388 * MSVIDEO_OpenFunction
390 HIC MSVIDEO_OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
391 DRIVERPROC lpfnHandler, DWORD lpfnHandler16)
396 TRACE("(%s,%s,%d,%p,%08x)\n",
397 wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode, lpfnHandler, lpfnHandler16);
399 icopen.dwSize = sizeof(ICOPEN);
400 icopen.fccType = fccType;
401 icopen.fccHandler = fccHandler;
402 icopen.dwVersion = ICVERSION;
403 icopen.dwFlags = wMode;
405 icopen.pV1Reserved = NULL;
406 icopen.pV2Reserved = NULL;
407 icopen.dnDevNode = 0; /* FIXME */
409 whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
412 whic->driverproc = lpfnHandler;
413 whic->driverproc16 = lpfnHandler16;
414 while (MSVIDEO_GetHicPtr(HIC_32(IC_HandleRef)) != NULL) IC_HandleRef++;
415 whic->hic = HIC_32(IC_HandleRef++);
416 whic->next = MSVIDEO_FirstHic;
417 MSVIDEO_FirstHic = whic;
419 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
420 /* What if the function is used more than once? */
422 if (MSVIDEO_SendMessage(whic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS)
424 WARN("DRV_LOAD failed for hic %p\n", whic->hic);
425 MSVIDEO_FirstHic = whic->next;
426 HeapFree(GetProcessHeap(), 0, whic);
429 /* return value is not checked */
430 MSVIDEO_SendMessage(whic, DRV_ENABLE, 0L, 0L);
432 whic->driverId = (DWORD)MSVIDEO_SendMessage(whic, DRV_OPEN, 0, (DWORD_PTR)&icopen);
433 /* FIXME: What should we put here? */
436 if (whic->driverId == 0)
438 WARN("DRV_OPEN failed for hic %p\n", whic->hic);
439 MSVIDEO_FirstHic = whic->next;
440 HeapFree(GetProcessHeap(), 0, whic);
444 TRACE("=> %p\n", whic->hic);
448 /***********************************************************************
449 * ICOpenFunction [MSVFW32.@]
451 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler)
453 return MSVIDEO_OpenFunction(fccType, fccHandler, wMode, (DRIVERPROC)lpfnHandler, 0);
456 /***********************************************************************
457 * ICGetInfo [MSVFW32.@]
459 LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
462 WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
464 TRACE("(%p,%p,%d)\n", hic, picinfo, cb);
466 whic = MSVIDEO_GetHicPtr(hic);
467 if (!whic) return ICERR_BADHANDLE;
468 if (!picinfo) return MMSYSERR_INVALPARAM;
470 /* (WS) The field szDriver should be initialized because the driver
471 * is not obliged and often will not do it. Some applications, like
472 * VirtualDub, rely on this field and will occasionally crash if it
473 * goes uninitialized.
475 if (cb >= sizeof(ICINFO)) picinfo->szDriver[0] = '\0';
477 ret = ICSendMessage(hic, ICM_GETINFO, (DWORD_PTR)picinfo, cb);
479 /* (WS) When szDriver was not supplied by the driver itself, apparently
480 * Windows will set its value equal to the driver file name. This can
481 * be obtained from the registry as we do here.
483 if (cb >= sizeof(ICINFO) && picinfo->szDriver[0] == 0)
487 memset(&ii, 0, sizeof(ii));
488 ii.dwSize = sizeof(ii);
489 ICInfo(picinfo->fccType, picinfo->fccHandler, &ii);
490 lstrcpyW(picinfo->szDriver, ii.szDriver);
493 TRACE(" -> 0x%08lx\n", ret);
500 LPBITMAPINFOHEADER lpbiIn;
501 LPBITMAPINFOHEADER lpbiOut;
507 static HIC try_driver(driver_info_t *info)
511 if ((hic = ICOpen(info->fccType, info->fccHandler, info->wMode)))
513 if (!ICSendMessage(hic, info->querymsg, (DWORD_PTR)info->lpbiIn, (DWORD_PTR)info->lpbiOut))
520 static BOOL ICLocate_enum_handler(const char *drv, int nr, void *param)
522 driver_info_t *info = (driver_info_t *)param;
523 info->fccHandler = mmioStringToFOURCCA(drv + 5, 0);
524 info->hic = try_driver(info);
525 return info->hic != 0;
528 /***********************************************************************
529 * ICLocate [MSVFW32.@]
531 HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
532 LPBITMAPINFOHEADER lpbiOut, WORD wMode)
536 TRACE("(%s,%s,%p,%p,0x%04x)\n",
537 wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
539 info.fccType = fccType;
540 info.fccHandler = fccHandler;
541 info.lpbiIn = lpbiIn;
542 info.lpbiOut = lpbiOut;
547 case ICMODE_FASTCOMPRESS:
548 case ICMODE_COMPRESS:
549 info.querymsg = ICM_COMPRESS_QUERY;
551 case ICMODE_FASTDECOMPRESS:
552 case ICMODE_DECOMPRESS:
553 info.querymsg = ICM_DECOMPRESS_QUERY;
556 info.querymsg = ICM_DRAW_QUERY;
559 WARN("Unknown mode (%d)\n", wMode);
563 /* Easy case: handler/type match, we just fire a query and return */
564 info.hic = try_driver(&info);
565 /* If it didn't work, try each driver in turn. 32 bit codecs only. */
566 /* FIXME: Move this to an init routine? */
567 if (!info.hic) enum_drivers(fccType, ICLocate_enum_handler, &info);
571 TRACE("=> %p\n", info.hic);
575 if (fccType == streamtypeVIDEO)
576 return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode);
578 WARN("(%s,%s,%p,%p,0x%04x) not found!\n",
579 wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
583 /***********************************************************************
584 * ICGetDisplayFormat [MSVFW32.@]
586 HIC VFWAPI ICGetDisplayFormat(
587 HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
588 INT depth,INT dx,INT dy)
592 TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic,lpbiIn,lpbiOut,depth,dx,dy);
595 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
599 if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
600 dy = dx = 0; /* no resize needed */
602 /* Can we decompress it ? */
603 if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
604 goto errout; /* no, sorry */
606 ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn, (DWORD_PTR)lpbiOut);
608 if (lpbiOut->biCompression != 0) {
609 FIXME("Ooch, how come decompressor outputs compressed data (%d)??\n",
610 lpbiOut->biCompression);
612 if (lpbiOut->biSize < sizeof(*lpbiOut)) {
613 FIXME("Ooch, size of output BIH is too small (%d)\n",
615 lpbiOut->biSize = sizeof(*lpbiOut);
621 depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
623 if (depth==15) depth = 16;
624 if (depth<8) depth = 8;
626 if (lpbiIn->biBitCount == 8)
629 TRACE("=> %p\n", tmphic);
639 /***********************************************************************
640 * ICCompress [MSVFW32.@]
644 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
645 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
646 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
647 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
651 TRACE("(%p,%d,%p,%p,%p,%p,...)\n",hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
653 iccmp.dwFlags = dwFlags;
655 iccmp.lpbiOutput = lpbiOutput;
656 iccmp.lpOutput = lpData;
657 iccmp.lpbiInput = lpbiInput;
658 iccmp.lpInput = lpBits;
660 iccmp.lpckid = lpckid;
661 iccmp.lpdwFlags = lpdwFlags;
662 iccmp.lFrameNum = lFrameNum;
663 iccmp.dwFrameSize = dwFrameSize;
664 iccmp.dwQuality = dwQuality;
665 iccmp.lpbiPrev = lpbiPrev;
666 iccmp.lpPrev = lpPrev;
667 return ICSendMessage(hic,ICM_COMPRESS,(DWORD_PTR)&iccmp,sizeof(iccmp));
670 /***********************************************************************
671 * ICDecompress [MSVFW32.@]
673 DWORD VFWAPIV ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
674 LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
679 TRACE("(%p,%d,%p,%p,%p,%p)\n",hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
681 TRACE("lpBits[0] == %x\n",((LPDWORD)lpBits)[0]);
683 icd.dwFlags = dwFlags;
684 icd.lpbiInput = lpbiFormat;
685 icd.lpInput = lpData;
687 icd.lpbiOutput = lpbi;
688 icd.lpOutput = lpBits;
690 ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD_PTR)&icd,sizeof(ICDECOMPRESS));
692 TRACE("lpBits[0] == %x\n",((LPDWORD)lpBits)[0]);
694 TRACE("-> %d\n",ret);
700 struct choose_compressor
713 static BOOL enum_compressors(HWND list, COMPVARS *pcv, BOOL enum_all)
720 while (ICInfo(pcv->fccType, id, &icinfo))
722 struct codec_info *ic;
728 hic = ICOpen(icinfo.fccType, icinfo.fccHandler, ICMODE_COMPRESS);
732 /* for unknown reason fccHandler reported by the driver
733 * doesn't always work, use the one returned by ICInfo instead.
735 DWORD fccHandler = icinfo.fccHandler;
737 if (!enum_all && pcv->lpbiIn)
739 if (ICCompressQuery(hic, pcv->lpbiIn, NULL) != ICERR_OK)
741 TRACE("fccHandler %s doesn't support input DIB format %d\n",
742 wine_dbgstr_fcc(icinfo.fccHandler), pcv->lpbiIn->bmiHeader.biCompression);
748 ICGetInfo(hic, &icinfo, sizeof(icinfo));
749 icinfo.fccHandler = fccHandler;
751 idx = SendMessageW(list, CB_ADDSTRING, 0, (LPARAM)icinfo.szDescription);
753 ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info));
754 memcpy(&ic->icinfo, &icinfo, sizeof(ICINFO));
756 SendMessageW(list, CB_SETITEMDATA, idx, (LPARAM)ic);
764 static INT_PTR CALLBACK icm_choose_compressor_dlgproc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
770 struct codec_info *ic;
772 struct choose_compressor *choose_comp = (struct choose_compressor *)lparam;
774 SetWindowLongPtrW(hdlg, DWLP_USER, lparam);
777 choose_comp->flags &= ~(ICMF_CHOOSE_DATARATE | ICMF_CHOOSE_KEYFRAME);
779 if (choose_comp->title)
780 SetWindowTextA(hdlg, choose_comp->title);
782 if (!(choose_comp->flags & ICMF_CHOOSE_DATARATE))
784 ShowWindow(GetDlgItem(hdlg, IDC_DATARATE_CHECKBOX), SW_HIDE);
785 ShowWindow(GetDlgItem(hdlg, IDC_DATARATE), SW_HIDE);
786 ShowWindow(GetDlgItem(hdlg, IDC_DATARATE_KB), SW_HIDE);
789 if (!(choose_comp->flags & ICMF_CHOOSE_KEYFRAME))
791 ShowWindow(GetDlgItem(hdlg, IDC_KEYFRAME_CHECKBOX), SW_HIDE);
792 ShowWindow(GetDlgItem(hdlg, IDC_KEYFRAME), SW_HIDE);
793 ShowWindow(GetDlgItem(hdlg, IDC_KEYFRAME_FRAMES), SW_HIDE);
797 EnableWindow(GetDlgItem(hdlg, IDC_QUALITY_SCROLL), FALSE);
798 EnableWindow(GetDlgItem(hdlg, IDC_QUALITY_TXT), FALSE);
800 /*if (!(choose_comp->flags & ICMF_CHOOSE_PREVIEW))
801 ShowWindow(GetDlgItem(hdlg, IDC_PREVIEW), SW_HIDE);*/
803 LoadStringW(MSVFW32_hModule, IDS_FULLFRAMES, buf, 128);
804 SendDlgItemMessageW(hdlg, IDC_COMP_LIST, CB_ADDSTRING, 0, (LPARAM)buf);
806 ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info));
807 ic->icinfo.fccType = streamtypeVIDEO;
808 ic->icinfo.fccHandler = comptypeDIB;
810 SendDlgItemMessageW(hdlg, IDC_COMP_LIST, CB_SETITEMDATA, 0, (LPARAM)ic);
812 enum_compressors(GetDlgItem(hdlg, IDC_COMP_LIST), &choose_comp->cv, choose_comp->flags & ICMF_CHOOSE_ALLCOMPRESSORS);
814 SendDlgItemMessageW(hdlg, IDC_COMP_LIST, CB_SETCURSEL, 0, 0);
815 SetFocus(GetDlgItem(hdlg, IDC_COMP_LIST));
817 SetWindowLongPtrW(hdlg, DWLP_USER, (ULONG_PTR)choose_comp);
822 switch (LOWORD(wparam))
827 struct codec_info *ic;
828 BOOL can_configure = FALSE, can_about = FALSE;
829 struct choose_compressor *choose_comp;
831 if (HIWORD(wparam) != CBN_SELCHANGE && HIWORD(wparam) != CBN_SETFOCUS)
834 choose_comp = (struct choose_compressor *)GetWindowLongPtrW(hdlg, DWLP_USER);
836 cur_sel = SendMessageW((HWND)lparam, CB_GETCURSEL, 0, 0);
838 ic = (struct codec_info *)SendMessageW((HWND)lparam, CB_GETITEMDATA, cur_sel, 0);
841 if (ICQueryConfigure(ic->hic) == DRVCNF_OK)
842 can_configure = TRUE;
843 if (ICQueryAbout(ic->hic) == DRVCNF_OK)
846 EnableWindow(GetDlgItem(hdlg, IDC_CONFIGURE), can_configure);
847 EnableWindow(GetDlgItem(hdlg, IDC_ABOUT), can_about);
849 if (choose_comp->flags & ICMF_CHOOSE_DATARATE)
853 if (choose_comp->flags & ICMF_CHOOSE_KEYFRAME)
864 HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
866 struct codec_info *ic;
868 if (HIWORD(wparam) != BN_CLICKED)
871 cur_sel = SendMessageW(list, CB_GETCURSEL, 0, 0);
873 ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, cur_sel, 0);
876 if (LOWORD(wparam) == IDC_CONFIGURE)
877 ICConfigure(ic->hic, hdlg);
879 ICAbout(ic->hic, hdlg);
887 HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
889 struct codec_info *ic;
891 if (HIWORD(wparam) != BN_CLICKED)
894 cur_sel = SendMessageW(list, CB_GETCURSEL, 0, 0);
895 ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, cur_sel, 0);
898 struct choose_compressor *choose_comp = (struct choose_compressor *)GetWindowLongPtrW(hdlg, DWLP_USER);
900 choose_comp->cv.hic = ic->hic;
901 choose_comp->cv.fccType = ic->icinfo.fccType;
902 choose_comp->cv.fccHandler = ic->icinfo.fccHandler;
903 /* FIXME: fill everything else */
905 /* prevent closing the codec handle below */
912 HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
915 if (HIWORD(wparam) != BN_CLICKED)
920 struct codec_info *ic;
922 ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, idx++, 0);
924 if (!ic || (LONG_PTR)ic == CB_ERR) break;
926 if (ic->hic) ICClose(ic->hic);
927 HeapFree(GetProcessHeap(), 0, ic);
930 EndDialog(hdlg, LOWORD(wparam) == IDOK);
946 /***********************************************************************
947 * ICCompressorChoose [MSVFW32.@]
949 BOOL VFWAPI ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn,
950 LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle)
952 struct choose_compressor choose_comp;
955 TRACE("(%p,%08x,%p,%p,%p,%s)\n", hwnd, uiFlags, pvIn, lpData, pc, lpszTitle);
957 if (!pc || pc->cbSize != sizeof(COMPVARS))
960 if (!(pc->dwFlags & ICMF_COMPVARS_VALID))
963 pc->fccType = pc->fccHandler = 0;
967 pc->lpBitsOut = pc->lpBitsPrev = pc->lpState = NULL;
968 pc->lQ = ICQUALITY_DEFAULT;
970 pc->lDataRate = 300; /* kB */
974 if (pc->fccType == 0)
975 pc->fccType = ICTYPE_VIDEO;
977 choose_comp.cv = *pc;
978 choose_comp.flags = uiFlags;
979 choose_comp.title = lpszTitle;
981 ret = DialogBoxParamW(MSVFW32_hModule, MAKEINTRESOURCEW(ICM_CHOOSE_COMPRESSOR), hwnd,
982 icm_choose_compressor_dlgproc, (LPARAM)&choose_comp);
986 *pc = choose_comp.cv;
987 pc->dwFlags |= ICMF_COMPVARS_VALID;
994 /***********************************************************************
995 * ICCompressorFree [MSVFW32.@]
997 void VFWAPI ICCompressorFree(PCOMPVARS pc)
1001 if (pc != NULL && pc->cbSize == sizeof(COMPVARS)) {
1002 if (pc->hic != NULL) {
1006 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1008 HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
1009 pc->lpBitsOut = NULL;
1010 HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1011 pc->lpBitsPrev = NULL;
1012 HeapFree(GetProcessHeap(), 0, pc->lpState);
1019 /******************************************************************
1020 * MSVIDEO_SendMessage
1024 LRESULT MSVIDEO_SendMessage(WINE_HIC* whic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2)
1028 #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break;
1038 /* ICM_RESERVED+X */
1043 XX(ICM_GETDEFAULTQUALITY);
1050 XX(ICM_COMPRESS_FRAMES_INFO);
1051 XX(ICM_COMPRESS_GET_FORMAT);
1052 XX(ICM_COMPRESS_GET_SIZE);
1053 XX(ICM_COMPRESS_QUERY);
1054 XX(ICM_COMPRESS_BEGIN);
1056 XX(ICM_COMPRESS_END);
1057 XX(ICM_DECOMPRESS_GET_FORMAT);
1058 XX(ICM_DECOMPRESS_QUERY);
1059 XX(ICM_DECOMPRESS_BEGIN);
1061 XX(ICM_DECOMPRESS_END);
1062 XX(ICM_DECOMPRESS_SET_PALETTE);
1063 XX(ICM_DECOMPRESS_GET_PALETTE);
1066 XX(ICM_DRAW_GET_PALETTE);
1070 XX(ICM_DRAW_GETTIME);
1072 XX(ICM_DRAW_WINDOW);
1073 XX(ICM_DRAW_SETTIME);
1074 XX(ICM_DRAW_REALIZE);
1076 XX(ICM_DRAW_RENDERBUFFER);
1077 XX(ICM_DRAW_START_PLAY);
1078 XX(ICM_DRAW_STOP_PLAY);
1079 XX(ICM_DRAW_SUGGESTFORMAT);
1080 XX(ICM_DRAW_CHANGEPALETTE);
1081 XX(ICM_GETBUFFERSWANTED);
1082 XX(ICM_GETDEFAULTKEYFRAMERATE);
1083 XX(ICM_DECOMPRESSEX_BEGIN);
1084 XX(ICM_DECOMPRESSEX_QUERY);
1085 XX(ICM_DECOMPRESSEX);
1086 XX(ICM_DECOMPRESSEX_END);
1087 XX(ICM_SET_STATUS_PROC);
1089 FIXME("(%p,0x%08x,0x%08lx,0x%08lx) unknown message\n",whic,(DWORD)msg,lParam1,lParam2);
1094 if (whic->driverproc) {
1095 /* dwDriverId parameter is the value returned by the DRV_OPEN */
1096 ret = whic->driverproc(whic->driverId, whic->hdrv, msg, lParam1, lParam2);
1098 ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2);
1101 TRACE(" -> 0x%08lx\n", ret);
1105 /***********************************************************************
1106 * ICSendMessage [MSVFW32.@]
1108 LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2)
1110 WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
1112 if (!whic) return ICERR_BADHANDLE;
1113 return MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
1116 /***********************************************************************
1117 * ICDrawBegin [MSVFW32.@]
1119 DWORD VFWAPIV ICDrawBegin(
1121 DWORD dwFlags, /* [in] flags */
1122 HPALETTE hpal, /* [in] palette to draw with */
1123 HWND hwnd, /* [in] window to draw to */
1124 HDC hdc, /* [in] HDC to draw to */
1125 INT xDst, /* [in] destination rectangle */
1126 INT yDst, /* [in] */
1127 INT dxDst, /* [in] */
1128 INT dyDst, /* [in] */
1129 LPBITMAPINFOHEADER lpbi, /* [in] format of frame to draw */
1130 INT xSrc, /* [in] source rectangle */
1131 INT ySrc, /* [in] */
1132 INT dxSrc, /* [in] */
1133 INT dySrc, /* [in] */
1134 DWORD dwRate, /* [in] frames/second = (dwRate/dwScale) */
1135 DWORD dwScale) /* [in] */
1140 TRACE("(%p,%d,%p,%p,%p,%u,%u,%u,%u,%p,%u,%u,%u,%u,%d,%d)\n",
1141 hic, dwFlags, hpal, hwnd, hdc, xDst, yDst, dxDst, dyDst,
1142 lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
1144 icdb.dwFlags = dwFlags;
1157 icdb.dwRate = dwRate;
1158 icdb.dwScale = dwScale;
1159 return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD_PTR)&icdb,sizeof(icdb));
1162 /***********************************************************************
1163 * ICDraw [MSVFW32.@]
1165 DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
1168 TRACE("(%p,%d,%p,%p,%d,%d)\n",hic,dwFlags,lpFormat,lpData,cbData,lTime);
1170 icd.dwFlags = dwFlags;
1171 icd.lpFormat = lpFormat;
1172 icd.lpData = lpData;
1173 icd.cbData = cbData;
1176 return ICSendMessage(hic,ICM_DRAW,(DWORD_PTR)&icd,sizeof(icd));
1179 /***********************************************************************
1180 * ICClose [MSVFW32.@]
1182 LRESULT WINAPI ICClose(HIC hic)
1184 WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
1187 TRACE("(%p)\n",hic);
1189 if (!whic) return ICERR_BADHANDLE;
1191 if (whic->driverproc)
1193 MSVIDEO_SendMessage(whic, DRV_CLOSE, 0, 0);
1194 MSVIDEO_SendMessage(whic, DRV_DISABLE, 0, 0);
1195 MSVIDEO_SendMessage(whic, DRV_FREE, 0, 0);
1199 CloseDriver(whic->hdrv, 0, 0);
1202 /* remove whic from list */
1203 for (p = &MSVIDEO_FirstHic; *p != NULL; p = &((*p)->next))
1212 HeapFree(GetProcessHeap(), 0, whic);
1218 /***********************************************************************
1219 * ICImageCompress [MSVFW32.@]
1221 HANDLE VFWAPI ICImageCompress(
1222 HIC hic, UINT uiFlags,
1223 LPBITMAPINFO lpbiIn, LPVOID lpBits,
1224 LPBITMAPINFO lpbiOut, LONG lQuality,
1227 FIXME("(%p,%08x,%p,%p,%p,%d,%p)\n",
1228 hic, uiFlags, lpbiIn, lpBits, lpbiOut, lQuality, plSize);
1233 /***********************************************************************
1234 * ICImageDecompress [MSVFW32.@]
1237 HANDLE VFWAPI ICImageDecompress(
1238 HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn,
1239 LPVOID lpBits, LPBITMAPINFO lpbiOut)
1241 HGLOBAL hMem = NULL;
1243 BOOL bReleaseIC = FALSE;
1246 BOOL bSucceeded = FALSE;
1247 BOOL bInDecompress = FALSE;
1250 TRACE("(%p,%08x,%p,%p,%p)\n",
1251 hic, uiFlags, lpbiIn, lpBits, lpbiOut);
1255 hic = ICDecompressOpen( ICTYPE_VIDEO, 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL );
1258 WARN("no handler\n" );
1265 FIXME( "unknown flag %08x\n", uiFlags );
1268 if ( lpbiIn == NULL || lpBits == NULL )
1270 WARN("invalid argument\n");
1274 if ( lpbiOut != NULL )
1276 if ( lpbiOut->bmiHeader.biSize != sizeof(BITMAPINFOHEADER) )
1278 cbHdr = sizeof(BITMAPINFOHEADER);
1279 if ( lpbiOut->bmiHeader.biCompression == 3 )
1280 cbHdr += sizeof(DWORD)*3;
1282 if ( lpbiOut->bmiHeader.biBitCount <= 8 )
1284 if ( lpbiOut->bmiHeader.biClrUsed == 0 )
1285 cbHdr += sizeof(RGBQUAD) * (1<<lpbiOut->bmiHeader.biBitCount);
1287 cbHdr += sizeof(RGBQUAD) * lpbiOut->bmiHeader.biClrUsed;
1292 TRACE( "get format\n" );
1294 cbHdr = ICDecompressGetFormatSize(hic,lpbiIn);
1295 if ( cbHdr < sizeof(BITMAPINFOHEADER) )
1297 pHdr = HeapAlloc(GetProcessHeap(),0,cbHdr+sizeof(RGBQUAD)*256);
1300 ZeroMemory( pHdr, cbHdr+sizeof(RGBQUAD)*256 );
1301 if ( ICDecompressGetFormat( hic, lpbiIn, (BITMAPINFO*)pHdr ) != ICERR_OK )
1303 lpbiOut = (BITMAPINFO*)pHdr;
1304 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1305 ICDecompressGetPalette( hic, lpbiIn, lpbiOut ) != ICERR_OK &&
1306 lpbiIn->bmiHeader.biBitCount == lpbiOut->bmiHeader.biBitCount )
1308 if ( lpbiIn->bmiHeader.biClrUsed == 0 )
1309 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*(1<<lpbiOut->bmiHeader.biBitCount) );
1311 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*lpbiIn->bmiHeader.biClrUsed );
1313 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1314 lpbiOut->bmiHeader.biClrUsed == 0 )
1315 lpbiOut->bmiHeader.biClrUsed = 1<<lpbiOut->bmiHeader.biBitCount;
1317 lpbiOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1318 cbHdr = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*lpbiOut->bmiHeader.biClrUsed;
1321 biSizeImage = lpbiOut->bmiHeader.biSizeImage;
1322 if ( biSizeImage == 0 )
1323 biSizeImage = ((((lpbiOut->bmiHeader.biWidth * lpbiOut->bmiHeader.biBitCount + 7) >> 3) + 3) & (~3)) * abs(lpbiOut->bmiHeader.biHeight);
1325 TRACE( "call ICDecompressBegin\n" );
1327 if ( ICDecompressBegin( hic, lpbiIn, lpbiOut ) != ICERR_OK )
1329 bInDecompress = TRUE;
1331 TRACE( "cbHdr %d, biSizeImage %d\n", cbHdr, biSizeImage );
1333 hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, cbHdr + biSizeImage );
1336 WARN( "out of memory\n" );
1339 pMem = (BYTE*)GlobalLock( hMem );
1342 memcpy( pMem, lpbiOut, cbHdr );
1344 TRACE( "call ICDecompress\n" );
1345 if ( ICDecompress( hic, 0, &lpbiIn->bmiHeader, lpBits, &lpbiOut->bmiHeader, pMem+cbHdr ) != ICERR_OK )
1350 if ( bInDecompress )
1351 ICDecompressEnd( hic );
1354 HeapFree(GetProcessHeap(),0,pHdr);
1356 GlobalUnlock( hMem );
1357 if ( !bSucceeded && hMem != NULL )
1359 GlobalFree(hMem); hMem = NULL;
1362 return (HANDLE)hMem;
1365 /***********************************************************************
1366 * ICSeqCompressFrame [MSVFW32.@]
1368 LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL *pfKey, LONG *plSize)
1370 ICCOMPRESS* icComp = (ICCOMPRESS *)pc->lpState;
1372 TRACE("(%p, 0x%08x, %p, %p, %p)\n", pc, uiFlags, lpBits, pfKey, plSize);
1374 if (pc->cbState != sizeof(ICCOMPRESS))
1376 ERR("Invalid cbState %i\n", pc->cbState);
1380 if (!pc->lKeyCount++)
1381 icComp->dwFlags = ICCOMPRESS_KEYFRAME;
1384 if (pc->lKey && pc->lKeyCount == (pc->lKey - 1))
1385 /* No key frames if pc->lKey == 0 */
1387 icComp->dwFlags = 0;
1390 icComp->lpInput = lpBits;
1391 icComp->lFrameNum = pc->lFrame++;
1392 icComp->lpOutput = pc->lpBitsOut;
1393 icComp->lpPrev = pc->lpBitsPrev;
1394 ret = ICSendMessage(pc->hic, ICM_COMPRESS, (DWORD_PTR)icComp, sizeof(icComp));
1396 if (icComp->dwFlags & AVIIF_KEYFRAME)
1400 TRACE("Key frame\n");
1405 *plSize = icComp->lpbiOutput->biSizeImage;
1406 TRACE(" -- 0x%08x\n", ret);
1407 if (ret == ICERR_OK)
1409 LPVOID oldprev, oldout;
1410 /* We shift Prev and Out, so we don't have to allocate and release memory */
1411 oldprev = pc->lpBitsPrev;
1412 oldout = pc->lpBitsOut;
1413 pc->lpBitsPrev = oldout;
1414 pc->lpBitsOut = oldprev;
1416 TRACE("returning: %p\n", icComp->lpOutput);
1417 return icComp->lpOutput;
1422 /***********************************************************************
1423 * ICSeqCompressFrameEnd [MSVFW32.@]
1425 void VFWAPI ICSeqCompressFrameEnd(PCOMPVARS pc)
1428 TRACE("(%p)\n", pc);
1429 ret = ICSendMessage(pc->hic, ICM_COMPRESS_END, 0, 0);
1430 TRACE(" -- %x\n", ret);
1431 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1432 HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1433 HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
1434 HeapFree(GetProcessHeap(), 0, pc->lpState);
1435 pc->lpbiIn = pc->lpBitsPrev = pc->lpBitsOut = pc->lpState = NULL;
1438 /***********************************************************************
1439 * ICSeqCompressFrameStart [MSVFW32.@]
1441 BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn)
1443 /* I'm ignoring bmiColors as I don't know what to do with it,
1444 * it doesn't appear to be used though
1447 pc->lpbiIn = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFO));
1451 memcpy(pc->lpbiIn, lpbiIn, sizeof(BITMAPINFO));
1452 pc->lpBitsPrev = HeapAlloc(GetProcessHeap(), 0, pc->lpbiIn->bmiHeader.biSizeImage);
1453 if (!pc->lpBitsPrev)
1455 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1459 pc->lpState = HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS));
1462 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1463 HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1466 pc->cbState = sizeof(ICCOMPRESS);
1468 pc->lpBitsOut = HeapAlloc(GetProcessHeap(), 0, pc->lpbiOut->bmiHeader.biSizeImage);
1471 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1472 HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1473 HeapFree(GetProcessHeap(), 0, pc->lpState);
1484 "key/data/quality: %i/%i/%i\n",
1485 pc->cbSize, pc->dwFlags, pc->hic, pc->fccType, pc->fccHandler,
1486 pc->lpbiIn, pc->lpbiOut, pc->lKey, pc->lDataRate, pc->lQ);
1488 ret = ICSendMessage(pc->hic, ICM_COMPRESS_BEGIN, (DWORD_PTR)pc->lpbiIn, (DWORD_PTR)pc->lpbiOut);
1489 TRACE(" -- %x\n", ret);
1490 if (ret == ICERR_OK)
1492 ICCOMPRESS* icComp = (ICCOMPRESS *)pc->lpState;
1493 /* Initialise some variables */
1494 pc->lFrame = 0; pc->lKeyCount = 0;
1496 icComp->lpbiOutput = &pc->lpbiOut->bmiHeader;
1497 icComp->lpbiInput = &pc->lpbiIn->bmiHeader;
1498 icComp->lpckid = NULL;
1499 icComp->dwFrameSize = 0;
1500 icComp->dwQuality = pc->lQ;
1501 icComp->lpbiPrev = &pc->lpbiIn->bmiHeader;
1504 HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1505 HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1506 HeapFree(GetProcessHeap(), 0, pc->lpState);
1507 HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
1508 pc->lpBitsPrev = pc->lpbiIn = pc->lpState = pc->lpBitsOut = NULL;
1512 /***********************************************************************
1513 * GetFileNamePreview [MSVFW32.@]
1515 static BOOL GetFileNamePreview(LPVOID lpofn,BOOL bSave,BOOL bUnicode)
1517 CHAR szFunctionName[20];
1518 BOOL (*fnGetFileName)(LPVOID);
1522 FIXME("(%p,%d,%d), semi-stub!\n",lpofn,bSave,bUnicode);
1524 lstrcpyA(szFunctionName, (bSave ? "GetSaveFileName" : "GetOpenFileName"));
1525 lstrcatA(szFunctionName, (bUnicode ? "W" : "A"));
1527 hComdlg32 = LoadLibraryA("COMDLG32.DLL");
1528 if (hComdlg32 == NULL)
1531 fnGetFileName = (LPVOID)GetProcAddress(hComdlg32, szFunctionName);
1532 if (fnGetFileName == NULL)
1535 /* FIXME: need to add OFN_ENABLEHOOK and our own handler */
1536 ret = fnGetFileName(lpofn);
1538 FreeLibrary(hComdlg32);
1542 /***********************************************************************
1543 * GetOpenFileNamePreviewA [MSVFW32.@]
1545 BOOL WINAPI GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn)
1547 FIXME("(%p), semi-stub!\n", lpofn);
1549 return GetFileNamePreview(lpofn, FALSE, FALSE);
1552 /***********************************************************************
1553 * GetOpenFileNamePreviewW [MSVFW32.@]
1555 BOOL WINAPI GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn)
1557 FIXME("(%p), semi-stub!\n", lpofn);
1559 return GetFileNamePreview(lpofn, FALSE, TRUE);
1562 /***********************************************************************
1563 * GetSaveFileNamePreviewA [MSVFW32.@]
1565 BOOL WINAPI GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn)
1567 FIXME("(%p), semi-stub!\n", lpofn);
1569 return GetFileNamePreview(lpofn, TRUE, FALSE);
1572 /***********************************************************************
1573 * GetSaveFileNamePreviewW [MSVFW32.@]
1575 BOOL WINAPI GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn)
1577 FIXME("(%p), semi-stub!\n", lpofn);
1579 return GetFileNamePreview(lpofn, TRUE, TRUE);