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 static WINE_HIC
* MSVIDEO_FirstHic
/* = NULL */;
58 typedef struct _reg_driver reg_driver
;
68 static reg_driver
* reg_driver_list
= NULL
;
70 /* This one is a macro such that it works for both ASCII and Unicode */
71 #define fourcc_to_string(str, fcc) do { \
72 (str)[0] = LOBYTE(LOWORD(fcc)); \
73 (str)[1] = HIBYTE(LOWORD(fcc)); \
74 (str)[2] = LOBYTE(HIWORD(fcc)); \
75 (str)[3] = HIBYTE(HIWORD(fcc)); \
78 HMODULE MSVFW32_hModule
;
80 BOOL WINAPI
DllMain( HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
82 TRACE("%p,%x,%p\n", hinst
, reason
, reserved
);
86 case DLL_PROCESS_ATTACH
:
87 DisableThreadLibraryCalls(hinst
);
88 MSVFW32_hModule
= hinst
;
94 static int compare_fourcc(DWORD fcc1
, DWORD fcc2
)
98 fourcc_to_string(fcc_str1
, fcc1
);
99 fourcc_to_string(fcc_str2
, fcc2
);
100 return strncasecmp(fcc_str1
, fcc_str2
, 4);
103 typedef BOOL (*enum_handler_t
)(const char*, unsigned int, void*);
105 static BOOL
enum_drivers(DWORD fccType
, enum_handler_t handler
, void* param
)
107 CHAR buf
[2048], fccTypeStr
[5], *s
;
108 DWORD i
, cnt
= 0, lRet
;
112 fourcc_to_string(fccTypeStr
, fccType
);
115 /* first, go through the registry entries */
116 lRet
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, HKLM_DRIVERS32
, 0, KEY_QUERY_VALUE
, &hKey
);
117 if (lRet
== ERROR_SUCCESS
)
119 DWORD name
, data
, type
;
124 data
= sizeof buf
- name
;
125 lRet
= RegEnumValueA(hKey
, i
++, buf
, &name
, 0, &type
, (LPBYTE
)(buf
+name
), &data
);
126 if (lRet
== ERROR_NO_MORE_ITEMS
) break;
127 if (lRet
!= ERROR_SUCCESS
) continue;
128 if (name
!= 9 || strncasecmp(buf
, fccTypeStr
, 5)) 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
, unsigned int nr
, void *param
)
176 ICINFO
*lpicinfo
= 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 ICOpenFunction(fccType
, fccHandler
, wMode
, driver
->proc
);
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 */
363 FIXME("Got a 16 bit driver, but no 16 bit support in msvfw\n");
364 CloseDriver(hdrv
, 0, 0);
367 whic
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC
));
370 CloseDriver(hdrv
, 0, 0);
374 whic
->driverproc
= NULL
;
375 whic
->type
= fccType
;
376 whic
->handler
= fccHandler
;
377 while (MSVIDEO_GetHicPtr((HIC
)(ULONG_PTR
)IC_HandleRef
) != NULL
) IC_HandleRef
++;
378 whic
->hic
= (HIC
)(ULONG_PTR
)IC_HandleRef
++;
379 whic
->next
= MSVIDEO_FirstHic
;
380 MSVIDEO_FirstHic
= whic
;
382 TRACE("=> %p\n", whic
->hic
);
386 /***********************************************************************
387 * ICOpenFunction [MSVFW32.@]
389 HIC VFWAPI
ICOpenFunction(DWORD fccType
, DWORD fccHandler
, UINT wMode
, FARPROC lpfnHandler
)
394 TRACE("(%s,%s,%d,%p)\n",
395 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), wMode
, lpfnHandler
);
397 icopen
.dwSize
= sizeof(ICOPEN
);
398 icopen
.fccType
= fccType
;
399 icopen
.fccHandler
= fccHandler
;
400 icopen
.dwVersion
= ICVERSION
;
401 icopen
.dwFlags
= wMode
;
403 icopen
.pV1Reserved
= NULL
;
404 icopen
.pV2Reserved
= NULL
;
405 icopen
.dnDevNode
= 0; /* FIXME */
407 whic
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC
));
410 whic
->driverproc
= lpfnHandler
;
411 while (MSVIDEO_GetHicPtr((HIC
)(ULONG_PTR
)IC_HandleRef
) != NULL
) IC_HandleRef
++;
412 whic
->hic
= (HIC
)(ULONG_PTR
)IC_HandleRef
++;
413 whic
->next
= MSVIDEO_FirstHic
;
414 MSVIDEO_FirstHic
= whic
;
416 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
417 /* What if the function is used more than once? */
419 if (MSVIDEO_SendMessage(whic
, DRV_LOAD
, 0L, 0L) != DRV_SUCCESS
)
421 WARN("DRV_LOAD failed for hic %p\n", whic
->hic
);
422 MSVIDEO_FirstHic
= whic
->next
;
423 HeapFree(GetProcessHeap(), 0, whic
);
426 /* return value is not checked */
427 MSVIDEO_SendMessage(whic
, DRV_ENABLE
, 0L, 0L);
429 whic
->driverId
= (DWORD
)MSVIDEO_SendMessage(whic
, DRV_OPEN
, 0, (DWORD_PTR
)&icopen
);
430 /* FIXME: What should we put here? */
433 if (whic
->driverId
== 0)
435 WARN("DRV_OPEN failed for hic %p\n", whic
->hic
);
436 MSVIDEO_FirstHic
= whic
->next
;
437 HeapFree(GetProcessHeap(), 0, whic
);
441 TRACE("=> %p\n", whic
->hic
);
445 /***********************************************************************
446 * ICGetInfo [MSVFW32.@]
448 LRESULT VFWAPI
ICGetInfo(HIC hic
, ICINFO
*picinfo
, DWORD cb
)
451 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
453 TRACE("(%p,%p,%d)\n", hic
, picinfo
, cb
);
455 whic
= MSVIDEO_GetHicPtr(hic
);
456 if (!whic
) return ICERR_BADHANDLE
;
457 if (!picinfo
) return MMSYSERR_INVALPARAM
;
459 /* (WS) The field szDriver should be initialized because the driver
460 * is not obliged and often will not do it. Some applications, like
461 * VirtualDub, rely on this field and will occasionally crash if it
462 * goes uninitialized.
464 if (cb
>= sizeof(ICINFO
)) picinfo
->szDriver
[0] = '\0';
466 ret
= ICSendMessage(hic
, ICM_GETINFO
, (DWORD_PTR
)picinfo
, cb
);
468 /* (WS) When szDriver was not supplied by the driver itself, apparently
469 * Windows will set its value equal to the driver file name. This can
470 * be obtained from the registry as we do here.
472 if (cb
>= sizeof(ICINFO
) && picinfo
->szDriver
[0] == 0)
476 memset(&ii
, 0, sizeof(ii
));
477 ii
.dwSize
= sizeof(ii
);
478 ICInfo(picinfo
->fccType
, picinfo
->fccHandler
, &ii
);
479 lstrcpyW(picinfo
->szDriver
, ii
.szDriver
);
482 TRACE(" -> 0x%08lx\n", ret
);
489 LPBITMAPINFOHEADER lpbiIn
;
490 LPBITMAPINFOHEADER lpbiOut
;
496 static HIC
try_driver(driver_info_t
*info
)
500 if ((hic
= ICOpen(info
->fccType
, info
->fccHandler
, info
->wMode
)))
502 if (!ICSendMessage(hic
, info
->querymsg
, (DWORD_PTR
)info
->lpbiIn
, (DWORD_PTR
)info
->lpbiOut
))
509 static BOOL
ICLocate_enum_handler(const char *drv
, unsigned int nr
, void *param
)
511 driver_info_t
*info
= param
;
512 info
->fccHandler
= mmioStringToFOURCCA(drv
+ 5, 0);
513 info
->hic
= try_driver(info
);
514 return info
->hic
!= 0;
517 /***********************************************************************
518 * ICLocate [MSVFW32.@]
520 HIC VFWAPI
ICLocate(DWORD fccType
, DWORD fccHandler
, LPBITMAPINFOHEADER lpbiIn
,
521 LPBITMAPINFOHEADER lpbiOut
, WORD wMode
)
525 TRACE("(%s,%s,%p,%p,0x%04x)\n",
526 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), lpbiIn
, lpbiOut
, wMode
);
528 info
.fccType
= fccType
;
529 info
.fccHandler
= fccHandler
;
530 info
.lpbiIn
= lpbiIn
;
531 info
.lpbiOut
= lpbiOut
;
536 case ICMODE_FASTCOMPRESS
:
537 case ICMODE_COMPRESS
:
538 info
.querymsg
= ICM_COMPRESS_QUERY
;
540 case ICMODE_FASTDECOMPRESS
:
541 case ICMODE_DECOMPRESS
:
542 info
.querymsg
= ICM_DECOMPRESS_QUERY
;
545 info
.querymsg
= ICM_DRAW_QUERY
;
548 WARN("Unknown mode (%d)\n", wMode
);
552 /* Easy case: handler/type match, we just fire a query and return */
553 info
.hic
= try_driver(&info
);
554 /* If it didn't work, try each driver in turn. 32 bit codecs only. */
555 /* FIXME: Move this to an init routine? */
556 if (!info
.hic
) enum_drivers(fccType
, ICLocate_enum_handler
, &info
);
560 TRACE("=> %p\n", info
.hic
);
564 if (fccType
== streamtypeVIDEO
)
565 return ICLocate(ICTYPE_VIDEO
, fccHandler
, lpbiIn
, lpbiOut
, wMode
);
567 WARN("(%s,%s,%p,%p,0x%04x) not found!\n",
568 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), lpbiIn
, lpbiOut
, wMode
);
572 /***********************************************************************
573 * ICGetDisplayFormat [MSVFW32.@]
575 HIC VFWAPI
ICGetDisplayFormat(
576 HIC hic
,LPBITMAPINFOHEADER lpbiIn
,LPBITMAPINFOHEADER lpbiOut
,
577 INT depth
,INT dx
,INT dy
)
581 TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic
,lpbiIn
,lpbiOut
,depth
,dx
,dy
);
584 tmphic
=ICLocate(ICTYPE_VIDEO
,0,lpbiIn
,NULL
,ICMODE_DECOMPRESS
);
588 if ((dy
== lpbiIn
->biHeight
) && (dx
== lpbiIn
->biWidth
))
589 dy
= dx
= 0; /* no resize needed */
591 /* Can we decompress it ? */
592 if (ICDecompressQuery(tmphic
,lpbiIn
,NULL
) != 0)
593 goto errout
; /* no, sorry */
595 ICSendMessage(tmphic
, ICM_DECOMPRESS_GET_FORMAT
, (DWORD_PTR
)lpbiIn
, (DWORD_PTR
)lpbiOut
);
597 if (lpbiOut
->biCompression
!= 0) {
598 FIXME("Ooch, how come decompressor outputs compressed data (%d)??\n",
599 lpbiOut
->biCompression
);
601 if (lpbiOut
->biSize
< sizeof(*lpbiOut
)) {
602 FIXME("Ooch, size of output BIH is too small (%d)\n",
604 lpbiOut
->biSize
= sizeof(*lpbiOut
);
610 depth
= GetDeviceCaps(hdc
,BITSPIXEL
)*GetDeviceCaps(hdc
,PLANES
);
612 if (depth
==15) depth
= 16;
613 if (depth
<8) depth
= 8;
615 if (lpbiIn
->biBitCount
== 8)
618 TRACE("=> %p\n", tmphic
);
628 /***********************************************************************
629 * ICCompress [MSVFW32.@]
633 HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiOutput
,LPVOID lpData
,
634 LPBITMAPINFOHEADER lpbiInput
,LPVOID lpBits
,LPDWORD lpckid
,
635 LPDWORD lpdwFlags
,LONG lFrameNum
,DWORD dwFrameSize
,DWORD dwQuality
,
636 LPBITMAPINFOHEADER lpbiPrev
,LPVOID lpPrev
)
640 TRACE("(%p,%d,%p,%p,%p,%p,...)\n",hic
,dwFlags
,lpbiOutput
,lpData
,lpbiInput
,lpBits
);
642 iccmp
.dwFlags
= dwFlags
;
644 iccmp
.lpbiOutput
= lpbiOutput
;
645 iccmp
.lpOutput
= lpData
;
646 iccmp
.lpbiInput
= lpbiInput
;
647 iccmp
.lpInput
= lpBits
;
649 iccmp
.lpckid
= lpckid
;
650 iccmp
.lpdwFlags
= lpdwFlags
;
651 iccmp
.lFrameNum
= lFrameNum
;
652 iccmp
.dwFrameSize
= dwFrameSize
;
653 iccmp
.dwQuality
= dwQuality
;
654 iccmp
.lpbiPrev
= lpbiPrev
;
655 iccmp
.lpPrev
= lpPrev
;
656 return ICSendMessage(hic
,ICM_COMPRESS
,(DWORD_PTR
)&iccmp
,sizeof(iccmp
));
659 /***********************************************************************
660 * ICDecompress [MSVFW32.@]
662 DWORD VFWAPIV
ICDecompress(HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiFormat
,
663 LPVOID lpData
,LPBITMAPINFOHEADER lpbi
,LPVOID lpBits
)
668 TRACE("(%p,%d,%p,%p,%p,%p)\n",hic
,dwFlags
,lpbiFormat
,lpData
,lpbi
,lpBits
);
670 icd
.dwFlags
= dwFlags
;
671 icd
.lpbiInput
= lpbiFormat
;
672 icd
.lpInput
= lpData
;
674 icd
.lpbiOutput
= lpbi
;
675 icd
.lpOutput
= lpBits
;
677 ret
= ICSendMessage(hic
,ICM_DECOMPRESS
,(DWORD_PTR
)&icd
,sizeof(ICDECOMPRESS
));
679 TRACE("-> %d\n",ret
);
685 struct choose_compressor
698 static BOOL
enum_compressors(HWND list
, COMPVARS
*pcv
, BOOL enum_all
)
705 while (ICInfo(pcv
->fccType
, id
, &icinfo
))
707 struct codec_info
*ic
;
713 hic
= ICOpen(icinfo
.fccType
, icinfo
.fccHandler
, ICMODE_COMPRESS
);
717 /* for unknown reason fccHandler reported by the driver
718 * doesn't always work, use the one returned by ICInfo instead.
720 DWORD fccHandler
= icinfo
.fccHandler
;
722 if (!enum_all
&& pcv
->lpbiIn
)
724 if (ICCompressQuery(hic
, pcv
->lpbiIn
, NULL
) != ICERR_OK
)
726 TRACE("fccHandler %s doesn't support input DIB format %d\n",
727 wine_dbgstr_fcc(icinfo
.fccHandler
), pcv
->lpbiIn
->bmiHeader
.biCompression
);
733 ICGetInfo(hic
, &icinfo
, sizeof(icinfo
));
734 icinfo
.fccHandler
= fccHandler
;
736 idx
= SendMessageW(list
, CB_ADDSTRING
, 0, (LPARAM
)icinfo
.szDescription
);
738 ic
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info
));
741 SendMessageW(list
, CB_SETITEMDATA
, idx
, (LPARAM
)ic
);
749 static INT_PTR CALLBACK
icm_choose_compressor_dlgproc(HWND hdlg
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
755 struct codec_info
*ic
;
757 struct choose_compressor
*choose_comp
= (struct choose_compressor
*)lparam
;
759 SetWindowLongPtrW(hdlg
, DWLP_USER
, lparam
);
762 choose_comp
->flags
&= ~(ICMF_CHOOSE_DATARATE
| ICMF_CHOOSE_KEYFRAME
);
764 if (choose_comp
->title
)
765 SetWindowTextA(hdlg
, choose_comp
->title
);
767 if (!(choose_comp
->flags
& ICMF_CHOOSE_DATARATE
))
769 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE_CHECKBOX
), SW_HIDE
);
770 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE
), SW_HIDE
);
771 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE_KB
), SW_HIDE
);
774 if (!(choose_comp
->flags
& ICMF_CHOOSE_KEYFRAME
))
776 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME_CHECKBOX
), SW_HIDE
);
777 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME
), SW_HIDE
);
778 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME_FRAMES
), SW_HIDE
);
782 EnableWindow(GetDlgItem(hdlg
, IDC_QUALITY_SCROLL
), FALSE
);
783 EnableWindow(GetDlgItem(hdlg
, IDC_QUALITY_TXT
), FALSE
);
785 /*if (!(choose_comp->flags & ICMF_CHOOSE_PREVIEW))
786 ShowWindow(GetDlgItem(hdlg, IDC_PREVIEW), SW_HIDE);*/
788 LoadStringW(MSVFW32_hModule
, IDS_FULLFRAMES
, buf
, 128);
789 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_ADDSTRING
, 0, (LPARAM
)buf
);
791 ic
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info
));
792 ic
->icinfo
.fccType
= streamtypeVIDEO
;
793 ic
->icinfo
.fccHandler
= comptypeDIB
;
795 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_SETITEMDATA
, 0, (LPARAM
)ic
);
797 enum_compressors(GetDlgItem(hdlg
, IDC_COMP_LIST
), &choose_comp
->cv
, choose_comp
->flags
& ICMF_CHOOSE_ALLCOMPRESSORS
);
799 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_SETCURSEL
, 0, 0);
800 SetFocus(GetDlgItem(hdlg
, IDC_COMP_LIST
));
802 SetWindowLongPtrW(hdlg
, DWLP_USER
, (ULONG_PTR
)choose_comp
);
807 switch (LOWORD(wparam
))
812 struct codec_info
*ic
;
813 BOOL can_configure
= FALSE
, can_about
= FALSE
;
814 struct choose_compressor
*choose_comp
;
816 if (HIWORD(wparam
) != CBN_SELCHANGE
&& HIWORD(wparam
) != CBN_SETFOCUS
)
819 choose_comp
= (struct choose_compressor
*)GetWindowLongPtrW(hdlg
, DWLP_USER
);
821 cur_sel
= SendMessageW((HWND
)lparam
, CB_GETCURSEL
, 0, 0);
823 ic
= (struct codec_info
*)SendMessageW((HWND
)lparam
, CB_GETITEMDATA
, cur_sel
, 0);
826 if (ICQueryConfigure(ic
->hic
) == DRVCNF_OK
)
827 can_configure
= TRUE
;
828 if (ICQueryAbout(ic
->hic
) == DRVCNF_OK
)
831 EnableWindow(GetDlgItem(hdlg
, IDC_CONFIGURE
), can_configure
);
832 EnableWindow(GetDlgItem(hdlg
, IDC_ABOUT
), can_about
);
834 if (choose_comp
->flags
& ICMF_CHOOSE_DATARATE
)
838 if (choose_comp
->flags
& ICMF_CHOOSE_KEYFRAME
)
849 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
851 struct codec_info
*ic
;
853 if (HIWORD(wparam
) != BN_CLICKED
)
856 cur_sel
= SendMessageW(list
, CB_GETCURSEL
, 0, 0);
858 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, cur_sel
, 0);
861 if (LOWORD(wparam
) == IDC_CONFIGURE
)
862 ICConfigure(ic
->hic
, hdlg
);
864 ICAbout(ic
->hic
, hdlg
);
872 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
874 struct codec_info
*ic
;
876 if (HIWORD(wparam
) != BN_CLICKED
)
879 cur_sel
= SendMessageW(list
, CB_GETCURSEL
, 0, 0);
880 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, cur_sel
, 0);
883 struct choose_compressor
*choose_comp
= (struct choose_compressor
*)GetWindowLongPtrW(hdlg
, DWLP_USER
);
885 choose_comp
->cv
.hic
= ic
->hic
;
886 choose_comp
->cv
.fccType
= ic
->icinfo
.fccType
;
887 choose_comp
->cv
.fccHandler
= ic
->icinfo
.fccHandler
;
888 /* FIXME: fill everything else */
890 /* prevent closing the codec handle below */
897 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
900 if (HIWORD(wparam
) != BN_CLICKED
)
905 struct codec_info
*ic
;
907 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, idx
++, 0);
909 if (!ic
|| (LONG_PTR
)ic
== CB_ERR
) break;
911 if (ic
->hic
) ICClose(ic
->hic
);
912 HeapFree(GetProcessHeap(), 0, ic
);
915 EndDialog(hdlg
, LOWORD(wparam
) == IDOK
);
931 /***********************************************************************
932 * ICCompressorChoose [MSVFW32.@]
934 BOOL VFWAPI
ICCompressorChoose(HWND hwnd
, UINT uiFlags
, LPVOID pvIn
,
935 LPVOID lpData
, PCOMPVARS pc
, LPSTR lpszTitle
)
937 struct choose_compressor choose_comp
;
940 TRACE("(%p,%08x,%p,%p,%p,%s)\n", hwnd
, uiFlags
, pvIn
, lpData
, pc
, lpszTitle
);
942 if (!pc
|| pc
->cbSize
!= sizeof(COMPVARS
))
945 if (!(pc
->dwFlags
& ICMF_COMPVARS_VALID
))
948 pc
->fccType
= pc
->fccHandler
= 0;
952 pc
->lpBitsOut
= pc
->lpBitsPrev
= pc
->lpState
= NULL
;
953 pc
->lQ
= ICQUALITY_DEFAULT
;
955 pc
->lDataRate
= 300; /* kB */
959 if (pc
->fccType
== 0)
960 pc
->fccType
= ICTYPE_VIDEO
;
962 choose_comp
.cv
= *pc
;
963 choose_comp
.flags
= uiFlags
;
964 choose_comp
.title
= lpszTitle
;
966 ret
= DialogBoxParamW(MSVFW32_hModule
, MAKEINTRESOURCEW(ICM_CHOOSE_COMPRESSOR
), hwnd
,
967 icm_choose_compressor_dlgproc
, (LPARAM
)&choose_comp
);
971 *pc
= choose_comp
.cv
;
972 pc
->dwFlags
|= ICMF_COMPVARS_VALID
;
979 /***********************************************************************
980 * ICCompressorFree [MSVFW32.@]
982 void VFWAPI
ICCompressorFree(PCOMPVARS pc
)
986 if (pc
!= NULL
&& pc
->cbSize
== sizeof(COMPVARS
)) {
987 if (pc
->hic
!= NULL
) {
991 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
993 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
994 pc
->lpBitsOut
= NULL
;
995 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
996 pc
->lpBitsPrev
= NULL
;
997 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1004 /******************************************************************
1005 * MSVIDEO_SendMessage
1009 LRESULT
MSVIDEO_SendMessage(WINE_HIC
* whic
, UINT msg
, DWORD_PTR lParam1
, DWORD_PTR lParam2
)
1013 #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break
1023 /* ICM_RESERVED+X */
1028 XX(ICM_GETDEFAULTQUALITY
);
1035 XX(ICM_COMPRESS_FRAMES_INFO
);
1036 XX(ICM_COMPRESS_GET_FORMAT
);
1037 XX(ICM_COMPRESS_GET_SIZE
);
1038 XX(ICM_COMPRESS_QUERY
);
1039 XX(ICM_COMPRESS_BEGIN
);
1041 XX(ICM_COMPRESS_END
);
1042 XX(ICM_DECOMPRESS_GET_FORMAT
);
1043 XX(ICM_DECOMPRESS_QUERY
);
1044 XX(ICM_DECOMPRESS_BEGIN
);
1046 XX(ICM_DECOMPRESS_END
);
1047 XX(ICM_DECOMPRESS_SET_PALETTE
);
1048 XX(ICM_DECOMPRESS_GET_PALETTE
);
1051 XX(ICM_DRAW_GET_PALETTE
);
1055 XX(ICM_DRAW_GETTIME
);
1057 XX(ICM_DRAW_WINDOW
);
1058 XX(ICM_DRAW_SETTIME
);
1059 XX(ICM_DRAW_REALIZE
);
1061 XX(ICM_DRAW_RENDERBUFFER
);
1062 XX(ICM_DRAW_START_PLAY
);
1063 XX(ICM_DRAW_STOP_PLAY
);
1064 XX(ICM_DRAW_SUGGESTFORMAT
);
1065 XX(ICM_DRAW_CHANGEPALETTE
);
1066 XX(ICM_GETBUFFERSWANTED
);
1067 XX(ICM_GETDEFAULTKEYFRAMERATE
);
1068 XX(ICM_DECOMPRESSEX_BEGIN
);
1069 XX(ICM_DECOMPRESSEX_QUERY
);
1070 XX(ICM_DECOMPRESSEX
);
1071 XX(ICM_DECOMPRESSEX_END
);
1072 XX(ICM_SET_STATUS_PROC
);
1074 FIXME("(%p,0x%08x,0x%08lx,0x%08lx) unknown message\n",whic
,msg
,lParam1
,lParam2
);
1079 if (whic
->driverproc
) {
1080 /* dwDriverId parameter is the value returned by the DRV_OPEN */
1081 ret
= whic
->driverproc(whic
->driverId
, whic
->hdrv
, msg
, lParam1
, lParam2
);
1083 ret
= SendDriverMessage(whic
->hdrv
, msg
, lParam1
, lParam2
);
1086 TRACE(" -> 0x%08lx\n", ret
);
1090 /***********************************************************************
1091 * ICSendMessage [MSVFW32.@]
1093 LRESULT VFWAPI
ICSendMessage(HIC hic
, UINT msg
, DWORD_PTR lParam1
, DWORD_PTR lParam2
)
1095 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
1097 if (!whic
) return ICERR_BADHANDLE
;
1098 return MSVIDEO_SendMessage(whic
, msg
, lParam1
, lParam2
);
1101 /***********************************************************************
1102 * ICDrawBegin [MSVFW32.@]
1104 DWORD VFWAPIV
ICDrawBegin(
1106 DWORD dwFlags
, /* [in] flags */
1107 HPALETTE hpal
, /* [in] palette to draw with */
1108 HWND hwnd
, /* [in] window to draw to */
1109 HDC hdc
, /* [in] HDC to draw to */
1110 INT xDst
, /* [in] destination rectangle */
1111 INT yDst
, /* [in] */
1112 INT dxDst
, /* [in] */
1113 INT dyDst
, /* [in] */
1114 LPBITMAPINFOHEADER lpbi
, /* [in] format of frame to draw */
1115 INT xSrc
, /* [in] source rectangle */
1116 INT ySrc
, /* [in] */
1117 INT dxSrc
, /* [in] */
1118 INT dySrc
, /* [in] */
1119 DWORD dwRate
, /* [in] frames/second = (dwRate/dwScale) */
1120 DWORD dwScale
) /* [in] */
1125 TRACE("(%p,%d,%p,%p,%p,%u,%u,%u,%u,%p,%u,%u,%u,%u,%d,%d)\n",
1126 hic
, dwFlags
, hpal
, hwnd
, hdc
, xDst
, yDst
, dxDst
, dyDst
,
1127 lpbi
, xSrc
, ySrc
, dxSrc
, dySrc
, dwRate
, dwScale
);
1129 icdb
.dwFlags
= dwFlags
;
1142 icdb
.dwRate
= dwRate
;
1143 icdb
.dwScale
= dwScale
;
1144 return ICSendMessage(hic
,ICM_DRAW_BEGIN
,(DWORD_PTR
)&icdb
,sizeof(icdb
));
1147 /***********************************************************************
1148 * ICDraw [MSVFW32.@]
1150 DWORD VFWAPIV
ICDraw(HIC hic
, DWORD dwFlags
, LPVOID lpFormat
, LPVOID lpData
, DWORD cbData
, LONG lTime
) {
1153 TRACE("(%p,%d,%p,%p,%d,%d)\n",hic
,dwFlags
,lpFormat
,lpData
,cbData
,lTime
);
1155 icd
.dwFlags
= dwFlags
;
1156 icd
.lpFormat
= lpFormat
;
1157 icd
.lpData
= lpData
;
1158 icd
.cbData
= cbData
;
1161 return ICSendMessage(hic
,ICM_DRAW
,(DWORD_PTR
)&icd
,sizeof(icd
));
1164 /***********************************************************************
1165 * ICClose [MSVFW32.@]
1167 LRESULT WINAPI
ICClose(HIC hic
)
1169 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
1172 TRACE("(%p)\n",hic
);
1174 if (!whic
) return ICERR_BADHANDLE
;
1176 if (whic
->driverproc
)
1178 MSVIDEO_SendMessage(whic
, DRV_CLOSE
, 0, 0);
1179 MSVIDEO_SendMessage(whic
, DRV_DISABLE
, 0, 0);
1180 MSVIDEO_SendMessage(whic
, DRV_FREE
, 0, 0);
1184 CloseDriver(whic
->hdrv
, 0, 0);
1187 /* remove whic from list */
1188 for (p
= &MSVIDEO_FirstHic
; *p
!= NULL
; p
= &((*p
)->next
))
1197 HeapFree(GetProcessHeap(), 0, whic
);
1203 /***********************************************************************
1204 * ICImageCompress [MSVFW32.@]
1206 HANDLE VFWAPI
ICImageCompress(
1207 HIC hic
, UINT uiFlags
,
1208 LPBITMAPINFO lpbiIn
, LPVOID lpBits
,
1209 LPBITMAPINFO lpbiOut
, LONG lQuality
,
1212 FIXME("(%p,%08x,%p,%p,%p,%d,%p)\n",
1213 hic
, uiFlags
, lpbiIn
, lpBits
, lpbiOut
, lQuality
, plSize
);
1218 /***********************************************************************
1219 * ICImageDecompress [MSVFW32.@]
1222 HANDLE VFWAPI
ICImageDecompress(
1223 HIC hic
, UINT uiFlags
, LPBITMAPINFO lpbiIn
,
1224 LPVOID lpBits
, LPBITMAPINFO lpbiOut
)
1226 HGLOBAL hMem
= NULL
;
1228 BOOL bReleaseIC
= FALSE
;
1231 BOOL bSucceeded
= FALSE
;
1232 BOOL bInDecompress
= FALSE
;
1235 TRACE("(%p,%08x,%p,%p,%p)\n",
1236 hic
, uiFlags
, lpbiIn
, lpBits
, lpbiOut
);
1240 hic
= ICDecompressOpen( ICTYPE_VIDEO
, 0, &lpbiIn
->bmiHeader
, (lpbiOut
!= NULL
) ? &lpbiOut
->bmiHeader
: NULL
);
1243 WARN("no handler\n" );
1250 FIXME( "unknown flag %08x\n", uiFlags
);
1253 if ( lpbiIn
== NULL
|| lpBits
== NULL
)
1255 WARN("invalid argument\n");
1259 if ( lpbiOut
!= NULL
)
1261 if ( lpbiOut
->bmiHeader
.biSize
!= sizeof(BITMAPINFOHEADER
) )
1263 cbHdr
= sizeof(BITMAPINFOHEADER
);
1264 if ( lpbiOut
->bmiHeader
.biCompression
== 3 )
1265 cbHdr
+= sizeof(DWORD
)*3;
1267 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 )
1269 if ( lpbiOut
->bmiHeader
.biClrUsed
== 0 )
1270 cbHdr
+= sizeof(RGBQUAD
) * (1<<lpbiOut
->bmiHeader
.biBitCount
);
1272 cbHdr
+= sizeof(RGBQUAD
) * lpbiOut
->bmiHeader
.biClrUsed
;
1277 TRACE( "get format\n" );
1279 cbHdr
= ICDecompressGetFormatSize(hic
,lpbiIn
);
1280 if ( cbHdr
< sizeof(BITMAPINFOHEADER
) )
1282 pHdr
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,cbHdr
+sizeof(RGBQUAD
)*256);
1285 if ( ICDecompressGetFormat( hic
, lpbiIn
, pHdr
) != ICERR_OK
)
1287 lpbiOut
= (BITMAPINFO
*)pHdr
;
1288 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 &&
1289 ICDecompressGetPalette( hic
, lpbiIn
, lpbiOut
) != ICERR_OK
&&
1290 lpbiIn
->bmiHeader
.biBitCount
== lpbiOut
->bmiHeader
.biBitCount
)
1292 if ( lpbiIn
->bmiHeader
.biClrUsed
== 0 )
1293 memcpy( lpbiOut
->bmiColors
, lpbiIn
->bmiColors
, sizeof(RGBQUAD
)*(1<<lpbiOut
->bmiHeader
.biBitCount
) );
1295 memcpy( lpbiOut
->bmiColors
, lpbiIn
->bmiColors
, sizeof(RGBQUAD
)*lpbiIn
->bmiHeader
.biClrUsed
);
1297 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 &&
1298 lpbiOut
->bmiHeader
.biClrUsed
== 0 )
1299 lpbiOut
->bmiHeader
.biClrUsed
= 1<<lpbiOut
->bmiHeader
.biBitCount
;
1301 lpbiOut
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1302 cbHdr
= sizeof(BITMAPINFOHEADER
) + sizeof(RGBQUAD
)*lpbiOut
->bmiHeader
.biClrUsed
;
1305 biSizeImage
= lpbiOut
->bmiHeader
.biSizeImage
;
1306 if ( biSizeImage
== 0 )
1307 biSizeImage
= ((((lpbiOut
->bmiHeader
.biWidth
* lpbiOut
->bmiHeader
.biBitCount
+ 7) >> 3) + 3) & (~3)) * abs(lpbiOut
->bmiHeader
.biHeight
);
1309 TRACE( "call ICDecompressBegin\n" );
1311 if ( ICDecompressBegin( hic
, lpbiIn
, lpbiOut
) != ICERR_OK
)
1313 bInDecompress
= TRUE
;
1315 TRACE( "cbHdr %d, biSizeImage %d\n", cbHdr
, biSizeImage
);
1317 hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_ZEROINIT
, cbHdr
+ biSizeImage
);
1320 WARN( "out of memory\n" );
1323 pMem
= GlobalLock( hMem
);
1326 memcpy( pMem
, lpbiOut
, cbHdr
);
1328 TRACE( "call ICDecompress\n" );
1329 if ( ICDecompress( hic
, 0, &lpbiIn
->bmiHeader
, lpBits
, &lpbiOut
->bmiHeader
, pMem
+cbHdr
) != ICERR_OK
)
1334 if ( bInDecompress
)
1335 ICDecompressEnd( hic
);
1338 HeapFree(GetProcessHeap(),0,pHdr
);
1340 GlobalUnlock( hMem
);
1341 if ( !bSucceeded
&& hMem
!= NULL
)
1343 GlobalFree(hMem
); hMem
= NULL
;
1349 /***********************************************************************
1350 * ICSeqCompressFrame [MSVFW32.@]
1352 LPVOID VFWAPI
ICSeqCompressFrame(PCOMPVARS pc
, UINT uiFlags
, LPVOID lpBits
, BOOL
*pfKey
, LONG
*plSize
)
1354 ICCOMPRESS
* icComp
= pc
->lpState
;
1356 TRACE("(%p, 0x%08x, %p, %p, %p)\n", pc
, uiFlags
, lpBits
, pfKey
, plSize
);
1358 if (pc
->cbState
!= sizeof(ICCOMPRESS
))
1360 ERR("Invalid cbState %i\n", pc
->cbState
);
1364 if (!pc
->lKeyCount
++)
1365 icComp
->dwFlags
= ICCOMPRESS_KEYFRAME
;
1368 if (pc
->lKey
&& pc
->lKeyCount
== (pc
->lKey
- 1))
1369 /* No key frames if pc->lKey == 0 */
1371 icComp
->dwFlags
= 0;
1374 icComp
->lpInput
= lpBits
;
1375 icComp
->lFrameNum
= pc
->lFrame
++;
1376 icComp
->lpOutput
= pc
->lpBitsOut
;
1377 icComp
->lpPrev
= pc
->lpBitsPrev
;
1378 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS
, (DWORD_PTR
)icComp
, sizeof(icComp
));
1380 if (icComp
->dwFlags
& AVIIF_KEYFRAME
)
1384 TRACE("Key frame\n");
1389 *plSize
= icComp
->lpbiOutput
->biSizeImage
;
1390 TRACE(" -- 0x%08x\n", ret
);
1391 if (ret
== ICERR_OK
)
1393 LPVOID oldprev
, oldout
;
1394 /* We shift Prev and Out, so we don't have to allocate and release memory */
1395 oldprev
= pc
->lpBitsPrev
;
1396 oldout
= pc
->lpBitsOut
;
1397 pc
->lpBitsPrev
= oldout
;
1398 pc
->lpBitsOut
= oldprev
;
1400 TRACE("returning: %p\n", icComp
->lpOutput
);
1401 return icComp
->lpOutput
;
1406 /***********************************************************************
1407 * ICSeqCompressFrameEnd [MSVFW32.@]
1409 void VFWAPI
ICSeqCompressFrameEnd(PCOMPVARS pc
)
1412 TRACE("(%p)\n", pc
);
1413 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS_END
, 0, 0);
1414 TRACE(" -- %x\n", ret
);
1415 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1416 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1417 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
1418 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1419 pc
->lpbiIn
= pc
->lpBitsPrev
= pc
->lpBitsOut
= pc
->lpState
= NULL
;
1422 /***********************************************************************
1423 * ICSeqCompressFrameStart [MSVFW32.@]
1425 BOOL VFWAPI
ICSeqCompressFrameStart(PCOMPVARS pc
, LPBITMAPINFO lpbiIn
)
1427 /* I'm ignoring bmiColors as I don't know what to do with it,
1428 * it doesn't appear to be used though
1431 pc
->lpbiIn
= HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFO
));
1435 *pc
->lpbiIn
= *lpbiIn
;
1436 pc
->lpBitsPrev
= HeapAlloc(GetProcessHeap(), 0, pc
->lpbiIn
->bmiHeader
.biSizeImage
);
1437 if (!pc
->lpBitsPrev
)
1439 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1443 pc
->lpState
= HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS
));
1446 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1447 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1450 pc
->cbState
= sizeof(ICCOMPRESS
);
1452 pc
->lpBitsOut
= HeapAlloc(GetProcessHeap(), 0, pc
->lpbiOut
->bmiHeader
.biSizeImage
);
1455 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1456 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1457 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1468 "key/data/quality: %i/%i/%i\n",
1469 pc
->cbSize
, pc
->dwFlags
, pc
->hic
, pc
->fccType
, pc
->fccHandler
,
1470 pc
->lpbiIn
, pc
->lpbiOut
, pc
->lKey
, pc
->lDataRate
, pc
->lQ
);
1472 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS_BEGIN
, (DWORD_PTR
)pc
->lpbiIn
, (DWORD_PTR
)pc
->lpbiOut
);
1473 TRACE(" -- %x\n", ret
);
1474 if (ret
== ICERR_OK
)
1476 ICCOMPRESS
* icComp
= pc
->lpState
;
1477 /* Initialise some variables */
1478 pc
->lFrame
= 0; pc
->lKeyCount
= 0;
1480 icComp
->lpbiOutput
= &pc
->lpbiOut
->bmiHeader
;
1481 icComp
->lpbiInput
= &pc
->lpbiIn
->bmiHeader
;
1482 icComp
->lpckid
= NULL
;
1483 icComp
->dwFrameSize
= 0;
1484 icComp
->dwQuality
= pc
->lQ
;
1485 icComp
->lpbiPrev
= &pc
->lpbiIn
->bmiHeader
;
1488 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1489 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1490 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1491 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
1492 pc
->lpBitsPrev
= pc
->lpbiIn
= pc
->lpState
= pc
->lpBitsOut
= NULL
;
1496 /***********************************************************************
1497 * GetFileNamePreview [MSVFW32.@]
1499 static BOOL
GetFileNamePreview(LPVOID lpofn
,BOOL bSave
,BOOL bUnicode
)
1501 CHAR szFunctionName
[20];
1502 BOOL (*fnGetFileName
)(LPVOID
);
1506 FIXME("(%p,%d,%d), semi-stub!\n",lpofn
,bSave
,bUnicode
);
1508 lstrcpyA(szFunctionName
, (bSave
? "GetSaveFileName" : "GetOpenFileName"));
1509 lstrcatA(szFunctionName
, (bUnicode
? "W" : "A"));
1511 hComdlg32
= LoadLibraryA("COMDLG32.DLL");
1512 if (hComdlg32
== NULL
)
1515 fnGetFileName
= (LPVOID
)GetProcAddress(hComdlg32
, szFunctionName
);
1516 if (fnGetFileName
== NULL
)
1519 /* FIXME: need to add OFN_ENABLEHOOK and our own handler */
1520 ret
= fnGetFileName(lpofn
);
1522 FreeLibrary(hComdlg32
);
1526 /***********************************************************************
1527 * GetOpenFileNamePreviewA [MSVFW32.@]
1529 BOOL WINAPI
GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn
)
1531 FIXME("(%p), semi-stub!\n", lpofn
);
1533 return GetFileNamePreview(lpofn
, FALSE
, FALSE
);
1536 /***********************************************************************
1537 * GetOpenFileNamePreviewW [MSVFW32.@]
1539 BOOL WINAPI
GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn
)
1541 FIXME("(%p), semi-stub!\n", lpofn
);
1543 return GetFileNamePreview(lpofn
, FALSE
, TRUE
);
1546 /***********************************************************************
1547 * GetSaveFileNamePreviewA [MSVFW32.@]
1549 BOOL WINAPI
GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn
)
1551 FIXME("(%p), semi-stub!\n", lpofn
);
1553 return GetFileNamePreview(lpofn
, TRUE
, FALSE
);
1556 /***********************************************************************
1557 * GetSaveFileNamePreviewW [MSVFW32.@]
1559 BOOL WINAPI
GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn
)
1561 FIXME("(%p), semi-stub!\n", lpofn
);
1563 return GetFileNamePreview(lpofn
, TRUE
, TRUE
);