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 in order to work 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 /******************************************************************
99 static LRESULT
MSVIDEO_SendMessage(WINE_HIC
* whic
, UINT msg
, DWORD_PTR lParam1
, DWORD_PTR lParam2
)
103 #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break
118 XX(ICM_GETDEFAULTQUALITY
);
125 XX(ICM_COMPRESS_FRAMES_INFO
);
126 XX(ICM_COMPRESS_GET_FORMAT
);
127 XX(ICM_COMPRESS_GET_SIZE
);
128 XX(ICM_COMPRESS_QUERY
);
129 XX(ICM_COMPRESS_BEGIN
);
131 XX(ICM_COMPRESS_END
);
132 XX(ICM_DECOMPRESS_GET_FORMAT
);
133 XX(ICM_DECOMPRESS_QUERY
);
134 XX(ICM_DECOMPRESS_BEGIN
);
136 XX(ICM_DECOMPRESS_END
);
137 XX(ICM_DECOMPRESS_SET_PALETTE
);
138 XX(ICM_DECOMPRESS_GET_PALETTE
);
141 XX(ICM_DRAW_GET_PALETTE
);
145 XX(ICM_DRAW_GETTIME
);
148 XX(ICM_DRAW_SETTIME
);
149 XX(ICM_DRAW_REALIZE
);
151 XX(ICM_DRAW_RENDERBUFFER
);
152 XX(ICM_DRAW_START_PLAY
);
153 XX(ICM_DRAW_STOP_PLAY
);
154 XX(ICM_DRAW_SUGGESTFORMAT
);
155 XX(ICM_DRAW_CHANGEPALETTE
);
156 XX(ICM_GETBUFFERSWANTED
);
157 XX(ICM_GETDEFAULTKEYFRAMERATE
);
158 XX(ICM_DECOMPRESSEX_BEGIN
);
159 XX(ICM_DECOMPRESSEX_QUERY
);
160 XX(ICM_DECOMPRESSEX
);
161 XX(ICM_DECOMPRESSEX_END
);
162 XX(ICM_SET_STATUS_PROC
);
164 FIXME("(%p,0x%08x,0x%08lx,0x%08lx) unknown message\n",whic
,msg
,lParam1
,lParam2
);
169 if (whic
->driverproc
) {
170 /* dwDriverId parameter is the value returned by the DRV_OPEN */
171 ret
= whic
->driverproc(whic
->driverId
, whic
->hdrv
, msg
, lParam1
, lParam2
);
173 ret
= SendDriverMessage(whic
->hdrv
, msg
, lParam1
, lParam2
);
176 TRACE(" -> 0x%08lx\n", ret
);
180 static int compare_fourcc(DWORD fcc1
, DWORD fcc2
)
184 fourcc_to_string(fcc_str1
, fcc1
);
185 fourcc_to_string(fcc_str2
, fcc2
);
186 return strncasecmp(fcc_str1
, fcc_str2
, 4);
189 typedef BOOL (*enum_handler_t
)(const char*, unsigned int, void*);
191 static BOOL
enum_drivers(DWORD fccType
, enum_handler_t handler
, void* param
)
193 CHAR buf
[2048], fccTypeStr
[5], *s
;
194 DWORD i
, cnt
= 0, lRet
;
198 fourcc_to_string(fccTypeStr
, fccType
);
201 /* first, go through the registry entries */
202 lRet
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, HKLM_DRIVERS32
, 0, KEY_QUERY_VALUE
, &hKey
);
203 if (lRet
== ERROR_SUCCESS
)
205 DWORD name
, data
, type
;
210 data
= sizeof buf
- name
;
211 lRet
= RegEnumValueA(hKey
, i
++, buf
, &name
, 0, &type
, (LPBYTE
)(buf
+name
), &data
);
212 if (lRet
== ERROR_NO_MORE_ITEMS
) break;
213 if (lRet
!= ERROR_SUCCESS
) continue;
214 if (name
!= 9 || strncasecmp(buf
, fccTypeStr
, 5)) continue;
216 if ((result
= handler(buf
, cnt
++, param
))) break;
220 if (result
) return result
;
222 /* if that didn't work, go through the values in system.ini */
223 if (GetPrivateProfileSectionA("drivers32", buf
, sizeof(buf
), "system.ini"))
225 for (s
= buf
; *s
; s
+= strlen(s
) + 1)
227 TRACE("got %s\n", s
);
228 if (strncasecmp(s
, fccTypeStr
, 5) || s
[9] != '=') continue;
229 if ((result
= handler(s
, cnt
++, param
))) break;
236 /******************************************************************
241 static WINE_HIC
* MSVIDEO_GetHicPtr(HIC hic
)
245 for (whic
= MSVIDEO_FirstHic
; whic
&& whic
->hic
!= hic
; whic
= whic
->next
);
249 /***********************************************************************
250 * VideoForWindowsVersion [MSVFW32.2]
251 * VideoForWindowsVersion [MSVIDEO.2]
252 * Returns the version in major.minor form.
253 * In Windows95 this returns 0x040003b6 (4.950)
255 DWORD WINAPI
VideoForWindowsVersion(void)
257 return 0x040003B6; /* 4.950 */
260 static BOOL
ICInfo_enum_handler(const char *drv
, unsigned int nr
, void *param
)
262 ICINFO
*lpicinfo
= param
;
263 DWORD fccHandler
= mmioStringToFOURCCA(drv
+ 5, 0);
265 /* exact match of fccHandler or nth driver found */
266 if ((lpicinfo
->fccHandler
!= nr
) && (lpicinfo
->fccHandler
!= fccHandler
))
269 lpicinfo
->fccHandler
= fccHandler
;
270 lpicinfo
->dwFlags
= 0;
271 lpicinfo
->dwVersion
= 0;
272 lpicinfo
->dwVersionICM
= ICVERSION
;
273 lpicinfo
->szName
[0] = 0;
274 lpicinfo
->szDescription
[0] = 0;
275 MultiByteToWideChar(CP_ACP
, 0, drv
+ 10, -1, lpicinfo
->szDriver
,
276 sizeof(lpicinfo
->szDriver
)/sizeof(WCHAR
));
281 /***********************************************************************
283 * Get information about an installable compressor. Return TRUE if there
287 * fccType [I] type of compressor (e.g. 'vidc')
288 * fccHandler [I] real fcc for handler or <n>th compressor
289 * lpicinfo [O] information about compressor
291 BOOL VFWAPI
ICInfo( DWORD fccType
, DWORD fccHandler
, ICINFO
*lpicinfo
)
293 TRACE("(%s,%s/%08x,%p)\n",
294 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), fccHandler
, lpicinfo
);
296 lpicinfo
->fccType
= fccType
;
297 lpicinfo
->fccHandler
= fccHandler
;
298 return enum_drivers(fccType
, ICInfo_enum_handler
, lpicinfo
);
301 static DWORD IC_HandleRef
= 1;
303 /***********************************************************************
304 * ICInstall [MSVFW32.@]
306 BOOL VFWAPI
ICInstall(DWORD fccType
, DWORD fccHandler
, LPARAM lParam
, LPSTR szDesc
, UINT wFlags
)
311 TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), (void*)lParam
, szDesc
, wFlags
);
313 /* Check if a driver is already registered */
314 for (driver
= reg_driver_list
; driver
; driver
= driver
->next
)
316 if (!compare_fourcc(fccType
, driver
->fccType
) &&
317 !compare_fourcc(fccHandler
, driver
->fccHandler
))
320 if (driver
) return FALSE
;
322 /* Register the driver */
323 driver
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(reg_driver
));
324 if (!driver
) goto oom
;
325 driver
->fccType
= fccType
;
326 driver
->fccHandler
= fccHandler
;
330 case ICINSTALL_FUNCTION
:
331 driver
->proc
= (DRIVERPROC
)lParam
;
334 case ICINSTALL_DRIVER
:
336 len
= MultiByteToWideChar(CP_ACP
, 0, (char*)lParam
, -1, NULL
, 0);
337 driver
->name
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
338 if (!driver
->name
) goto oom
;
339 MultiByteToWideChar(CP_ACP
, 0, (char*)lParam
, -1, driver
->name
, len
);
342 ERR("Invalid flags!\n");
343 HeapFree(GetProcessHeap(), 0, driver
);
347 /* Insert our driver in the list*/
348 driver
->next
= reg_driver_list
;
349 reg_driver_list
= driver
;
353 HeapFree(GetProcessHeap(), 0, driver
);
357 /***********************************************************************
358 * ICRemove [MSVFW32.@]
360 BOOL VFWAPI
ICRemove(DWORD fccType
, DWORD fccHandler
, UINT wFlags
)
362 reg_driver
** pdriver
;
365 TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), wFlags
);
367 /* Check if a driver is already registered */
368 for (pdriver
= ®_driver_list
; *pdriver
; pdriver
= &(*pdriver
)->next
)
370 if (!compare_fourcc(fccType
, (*pdriver
)->fccType
) &&
371 !compare_fourcc(fccHandler
, (*pdriver
)->fccHandler
))
377 /* Remove the driver from the list */
379 *pdriver
= (*pdriver
)->next
;
380 HeapFree(GetProcessHeap(), 0, drv
->name
);
381 HeapFree(GetProcessHeap(), 0, drv
);
387 /***********************************************************************
389 * Opens an installable compressor. Return special handle.
391 HIC VFWAPI
ICOpen(DWORD fccType
, DWORD fccHandler
, UINT wMode
)
397 static const WCHAR drv32W
[] = {'d','r','i','v','e','r','s','3','2','\0'};
400 TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), wMode
);
402 /* Check if there is a registered driver that matches */
403 driver
= reg_driver_list
;
405 if (!compare_fourcc(fccType
, driver
->fccType
) &&
406 !compare_fourcc(fccHandler
, driver
->fccHandler
)) {
407 fccType
= driver
->fccType
;
408 fccHandler
= driver
->fccHandler
;
411 driver
= driver
->next
;
413 if (driver
&& driver
->proc
)
414 /* The driver has been registered at runtime with its driverproc */
415 return ICOpenFunction(fccType
, fccHandler
, wMode
, driver
->proc
);
417 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
418 * same layout as ICOPEN
420 icopen
.dwSize
= sizeof(ICOPEN
);
421 icopen
.fccType
= fccType
;
422 icopen
.fccHandler
= fccHandler
;
423 icopen
.dwVersion
= 0x00001000; /* FIXME */
424 icopen
.dwFlags
= wMode
;
426 icopen
.pV1Reserved
= NULL
;
427 icopen
.pV2Reserved
= NULL
;
428 icopen
.dnDevNode
= 0; /* FIXME */
431 /* normalize to lower case as in 'vidc' */
432 ((char*)&fccType
)[0] = tolower(((char*)&fccType
)[0]);
433 ((char*)&fccType
)[1] = tolower(((char*)&fccType
)[1]);
434 ((char*)&fccType
)[2] = tolower(((char*)&fccType
)[2]);
435 ((char*)&fccType
)[3] = tolower(((char*)&fccType
)[3]);
436 icopen
.fccType
= fccType
;
437 /* Seek the driver in the registry */
438 fourcc_to_string(codecname
, fccType
);
440 fourcc_to_string(codecname
+ 5, fccHandler
);
443 hdrv
= OpenDriver(codecname
, drv32W
, (LPARAM
)&icopen
);
447 /* The driver has been registered at runtime with its name */
448 hdrv
= OpenDriver(driver
->name
, NULL
, (LPARAM
)&icopen
);
453 whic
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC
));
456 CloseDriver(hdrv
, 0, 0);
460 whic
->driverproc
= NULL
;
461 whic
->type
= fccType
;
462 whic
->handler
= fccHandler
;
463 while (MSVIDEO_GetHicPtr((HIC
)(ULONG_PTR
)IC_HandleRef
) != NULL
) IC_HandleRef
++;
464 whic
->hic
= (HIC
)(ULONG_PTR
)IC_HandleRef
++;
465 whic
->next
= MSVIDEO_FirstHic
;
466 MSVIDEO_FirstHic
= whic
;
468 TRACE("=> %p\n", whic
->hic
);
472 /***********************************************************************
473 * ICOpenFunction [MSVFW32.@]
475 HIC VFWAPI
ICOpenFunction(DWORD fccType
, DWORD fccHandler
, UINT wMode
, DRIVERPROC lpfnHandler
)
480 TRACE("(%s,%s,%d,%p)\n",
481 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), wMode
, lpfnHandler
);
483 icopen
.dwSize
= sizeof(ICOPEN
);
484 icopen
.fccType
= fccType
;
485 icopen
.fccHandler
= fccHandler
;
486 icopen
.dwVersion
= ICVERSION
;
487 icopen
.dwFlags
= wMode
;
489 icopen
.pV1Reserved
= NULL
;
490 icopen
.pV2Reserved
= NULL
;
491 icopen
.dnDevNode
= 0; /* FIXME */
493 whic
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC
));
496 whic
->driverproc
= lpfnHandler
;
497 while (MSVIDEO_GetHicPtr((HIC
)(ULONG_PTR
)IC_HandleRef
) != NULL
) IC_HandleRef
++;
498 whic
->hic
= (HIC
)(ULONG_PTR
)IC_HandleRef
++;
499 whic
->next
= MSVIDEO_FirstHic
;
500 MSVIDEO_FirstHic
= whic
;
502 /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
503 /* What if the function is used more than once? */
505 if (MSVIDEO_SendMessage(whic
, DRV_LOAD
, 0L, 0L) != DRV_SUCCESS
)
507 WARN("DRV_LOAD failed for hic %p\n", whic
->hic
);
508 MSVIDEO_FirstHic
= whic
->next
;
509 HeapFree(GetProcessHeap(), 0, whic
);
512 /* return value is not checked */
513 MSVIDEO_SendMessage(whic
, DRV_ENABLE
, 0L, 0L);
515 whic
->driverId
= (DWORD
)MSVIDEO_SendMessage(whic
, DRV_OPEN
, 0, (DWORD_PTR
)&icopen
);
516 /* FIXME: What should we put here? */
519 if (whic
->driverId
== 0)
521 WARN("DRV_OPEN failed for hic %p\n", whic
->hic
);
522 MSVIDEO_FirstHic
= whic
->next
;
523 HeapFree(GetProcessHeap(), 0, whic
);
527 TRACE("=> %p\n", whic
->hic
);
531 /***********************************************************************
532 * ICGetInfo [MSVFW32.@]
534 LRESULT VFWAPI
ICGetInfo(HIC hic
, ICINFO
*picinfo
, DWORD cb
)
537 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
539 TRACE("(%p,%p,%d)\n", hic
, picinfo
, cb
);
541 if (!whic
) return ICERR_BADHANDLE
;
542 if (!picinfo
) return MMSYSERR_INVALPARAM
;
544 /* (WS) The field szDriver should be initialized because the driver
545 * is not obliged and often will not do it. Some applications, like
546 * VirtualDub, rely on this field and will occasionally crash if it
547 * goes uninitialized.
549 if (cb
>= sizeof(ICINFO
)) picinfo
->szDriver
[0] = '\0';
551 ret
= ICSendMessage(hic
, ICM_GETINFO
, (DWORD_PTR
)picinfo
, cb
);
553 /* (WS) When szDriver was not supplied by the driver itself, apparently
554 * Windows will set its value equal to the driver file name. This can
555 * be obtained from the registry as we do here.
557 if (cb
>= sizeof(ICINFO
) && picinfo
->szDriver
[0] == 0)
561 memset(&ii
, 0, sizeof(ii
));
562 ii
.dwSize
= sizeof(ii
);
563 ICInfo(picinfo
->fccType
, picinfo
->fccHandler
, &ii
);
564 lstrcpyW(picinfo
->szDriver
, ii
.szDriver
);
567 TRACE(" -> 0x%08lx\n", ret
);
574 LPBITMAPINFOHEADER lpbiIn
;
575 LPBITMAPINFOHEADER lpbiOut
;
581 static HIC
try_driver(driver_info_t
*info
)
585 if ((hic
= ICOpen(info
->fccType
, info
->fccHandler
, info
->wMode
)))
587 if (!ICSendMessage(hic
, info
->querymsg
, (DWORD_PTR
)info
->lpbiIn
, (DWORD_PTR
)info
->lpbiOut
))
594 static BOOL
ICLocate_enum_handler(const char *drv
, unsigned int nr
, void *param
)
596 driver_info_t
*info
= param
;
597 info
->fccHandler
= mmioStringToFOURCCA(drv
+ 5, 0);
598 info
->hic
= try_driver(info
);
599 return info
->hic
!= 0;
602 /***********************************************************************
603 * ICLocate [MSVFW32.@]
605 HIC VFWAPI
ICLocate(DWORD fccType
, DWORD fccHandler
, LPBITMAPINFOHEADER lpbiIn
,
606 LPBITMAPINFOHEADER lpbiOut
, WORD wMode
)
610 TRACE("(%s,%s,%p,%p,0x%04x)\n",
611 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), lpbiIn
, lpbiOut
, wMode
);
613 info
.fccType
= fccType
;
614 info
.fccHandler
= fccHandler
;
615 info
.lpbiIn
= lpbiIn
;
616 info
.lpbiOut
= lpbiOut
;
621 case ICMODE_FASTCOMPRESS
:
622 case ICMODE_COMPRESS
:
623 info
.querymsg
= ICM_COMPRESS_QUERY
;
625 case ICMODE_FASTDECOMPRESS
:
626 case ICMODE_DECOMPRESS
:
627 info
.querymsg
= ICM_DECOMPRESS_QUERY
;
630 info
.querymsg
= ICM_DRAW_QUERY
;
633 WARN("Unknown mode (%d)\n", wMode
);
637 /* Easy case: handler/type match, we just fire a query and return */
638 info
.hic
= try_driver(&info
);
639 /* If it didn't work, try each driver in turn. 32 bit codecs only. */
640 /* FIXME: Move this to an init routine? */
641 if (!info
.hic
) enum_drivers(fccType
, ICLocate_enum_handler
, &info
);
645 TRACE("=> %p\n", info
.hic
);
649 if (fccType
== streamtypeVIDEO
)
650 return ICLocate(ICTYPE_VIDEO
, fccHandler
, lpbiIn
, lpbiOut
, wMode
);
652 WARN("(%s,%s,%p,%p,0x%04x) not found!\n",
653 wine_dbgstr_fcc(fccType
), wine_dbgstr_fcc(fccHandler
), lpbiIn
, lpbiOut
, wMode
);
657 /***********************************************************************
658 * ICGetDisplayFormat [MSVFW32.@]
660 HIC VFWAPI
ICGetDisplayFormat(
661 HIC hic
,LPBITMAPINFOHEADER lpbiIn
,LPBITMAPINFOHEADER lpbiOut
,
662 INT depth
,INT dx
,INT dy
)
666 TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic
,lpbiIn
,lpbiOut
,depth
,dx
,dy
);
669 tmphic
=ICLocate(ICTYPE_VIDEO
,0,lpbiIn
,NULL
,ICMODE_DECOMPRESS
);
673 if ((dy
== lpbiIn
->biHeight
) && (dx
== lpbiIn
->biWidth
))
674 dy
= dx
= 0; /* no resize needed */
676 /* Can we decompress it ? */
677 if (ICDecompressQuery(tmphic
,lpbiIn
,NULL
) != 0)
678 goto errout
; /* no, sorry */
680 ICSendMessage(tmphic
, ICM_DECOMPRESS_GET_FORMAT
, (DWORD_PTR
)lpbiIn
, (DWORD_PTR
)lpbiOut
);
682 if (lpbiOut
->biCompression
!= 0) {
683 FIXME("Ooch, how come decompressor outputs compressed data (%d)??\n",
684 lpbiOut
->biCompression
);
686 if (lpbiOut
->biSize
< sizeof(*lpbiOut
)) {
687 FIXME("Ooch, size of output BIH is too small (%d)\n",
689 lpbiOut
->biSize
= sizeof(*lpbiOut
);
695 depth
= GetDeviceCaps(hdc
,BITSPIXEL
)*GetDeviceCaps(hdc
,PLANES
);
697 if (depth
==15) depth
= 16;
698 if (depth
<8) depth
= 8;
700 if (lpbiIn
->biBitCount
== 8)
703 TRACE("=> %p\n", tmphic
);
713 /***********************************************************************
714 * ICCompress [MSVFW32.@]
718 HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiOutput
,LPVOID lpData
,
719 LPBITMAPINFOHEADER lpbiInput
,LPVOID lpBits
,LPDWORD lpckid
,
720 LPDWORD lpdwFlags
,LONG lFrameNum
,DWORD dwFrameSize
,DWORD dwQuality
,
721 LPBITMAPINFOHEADER lpbiPrev
,LPVOID lpPrev
)
725 TRACE("(%p,%d,%p,%p,%p,%p,...)\n",hic
,dwFlags
,lpbiOutput
,lpData
,lpbiInput
,lpBits
);
727 iccmp
.dwFlags
= dwFlags
;
729 iccmp
.lpbiOutput
= lpbiOutput
;
730 iccmp
.lpOutput
= lpData
;
731 iccmp
.lpbiInput
= lpbiInput
;
732 iccmp
.lpInput
= lpBits
;
734 iccmp
.lpckid
= lpckid
;
735 iccmp
.lpdwFlags
= lpdwFlags
;
736 iccmp
.lFrameNum
= lFrameNum
;
737 iccmp
.dwFrameSize
= dwFrameSize
;
738 iccmp
.dwQuality
= dwQuality
;
739 iccmp
.lpbiPrev
= lpbiPrev
;
740 iccmp
.lpPrev
= lpPrev
;
741 return ICSendMessage(hic
,ICM_COMPRESS
,(DWORD_PTR
)&iccmp
,sizeof(iccmp
));
744 /***********************************************************************
745 * ICDecompress [MSVFW32.@]
747 DWORD VFWAPIV
ICDecompress(HIC hic
,DWORD dwFlags
,LPBITMAPINFOHEADER lpbiFormat
,
748 LPVOID lpData
,LPBITMAPINFOHEADER lpbi
,LPVOID lpBits
)
753 TRACE("(%p,%d,%p,%p,%p,%p)\n",hic
,dwFlags
,lpbiFormat
,lpData
,lpbi
,lpBits
);
755 icd
.dwFlags
= dwFlags
;
756 icd
.lpbiInput
= lpbiFormat
;
757 icd
.lpInput
= lpData
;
759 icd
.lpbiOutput
= lpbi
;
760 icd
.lpOutput
= lpBits
;
762 ret
= ICSendMessage(hic
,ICM_DECOMPRESS
,(DWORD_PTR
)&icd
,sizeof(ICDECOMPRESS
));
764 TRACE("-> %d\n",ret
);
770 struct choose_compressor
783 static BOOL
enum_compressors(HWND list
, COMPVARS
*pcv
, BOOL enum_all
)
790 while (ICInfo(pcv
->fccType
, id
, &icinfo
))
792 struct codec_info
*ic
;
798 hic
= ICOpen(icinfo
.fccType
, icinfo
.fccHandler
, ICMODE_COMPRESS
);
802 /* for unknown reason fccHandler reported by the driver
803 * doesn't always work, use the one returned by ICInfo instead.
805 DWORD fccHandler
= icinfo
.fccHandler
;
807 if (!enum_all
&& pcv
->lpbiIn
)
809 if (ICCompressQuery(hic
, pcv
->lpbiIn
, NULL
) != ICERR_OK
)
811 TRACE("fccHandler %s doesn't support input DIB format %d\n",
812 wine_dbgstr_fcc(icinfo
.fccHandler
), pcv
->lpbiIn
->bmiHeader
.biCompression
);
818 ICGetInfo(hic
, &icinfo
, sizeof(icinfo
));
819 icinfo
.fccHandler
= fccHandler
;
821 idx
= SendMessageW(list
, CB_ADDSTRING
, 0, (LPARAM
)icinfo
.szDescription
);
823 ic
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info
));
826 SendMessageW(list
, CB_SETITEMDATA
, idx
, (LPARAM
)ic
);
834 static INT_PTR CALLBACK
icm_choose_compressor_dlgproc(HWND hdlg
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
840 struct codec_info
*ic
;
842 struct choose_compressor
*choose_comp
= (struct choose_compressor
*)lparam
;
844 SetWindowLongPtrW(hdlg
, DWLP_USER
, lparam
);
847 choose_comp
->flags
&= ~(ICMF_CHOOSE_DATARATE
| ICMF_CHOOSE_KEYFRAME
);
849 if (choose_comp
->title
)
850 SetWindowTextA(hdlg
, choose_comp
->title
);
852 if (!(choose_comp
->flags
& ICMF_CHOOSE_DATARATE
))
854 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE_CHECKBOX
), SW_HIDE
);
855 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE
), SW_HIDE
);
856 ShowWindow(GetDlgItem(hdlg
, IDC_DATARATE_KB
), SW_HIDE
);
859 if (!(choose_comp
->flags
& ICMF_CHOOSE_KEYFRAME
))
861 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME_CHECKBOX
), SW_HIDE
);
862 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME
), SW_HIDE
);
863 ShowWindow(GetDlgItem(hdlg
, IDC_KEYFRAME_FRAMES
), SW_HIDE
);
867 EnableWindow(GetDlgItem(hdlg
, IDC_QUALITY_SCROLL
), FALSE
);
868 EnableWindow(GetDlgItem(hdlg
, IDC_QUALITY_TXT
), FALSE
);
870 /*if (!(choose_comp->flags & ICMF_CHOOSE_PREVIEW))
871 ShowWindow(GetDlgItem(hdlg, IDC_PREVIEW), SW_HIDE);*/
873 LoadStringW(MSVFW32_hModule
, IDS_FULLFRAMES
, buf
, 128);
874 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_ADDSTRING
, 0, (LPARAM
)buf
);
876 ic
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info
));
877 ic
->icinfo
.fccType
= streamtypeVIDEO
;
878 ic
->icinfo
.fccHandler
= comptypeDIB
;
880 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_SETITEMDATA
, 0, (LPARAM
)ic
);
882 enum_compressors(GetDlgItem(hdlg
, IDC_COMP_LIST
), &choose_comp
->cv
, choose_comp
->flags
& ICMF_CHOOSE_ALLCOMPRESSORS
);
884 SendDlgItemMessageW(hdlg
, IDC_COMP_LIST
, CB_SETCURSEL
, 0, 0);
885 SetFocus(GetDlgItem(hdlg
, IDC_COMP_LIST
));
887 SetWindowLongPtrW(hdlg
, DWLP_USER
, (ULONG_PTR
)choose_comp
);
892 switch (LOWORD(wparam
))
897 struct codec_info
*ic
;
898 BOOL can_configure
= FALSE
, can_about
= FALSE
;
899 struct choose_compressor
*choose_comp
;
901 if (HIWORD(wparam
) != CBN_SELCHANGE
&& HIWORD(wparam
) != CBN_SETFOCUS
)
904 choose_comp
= (struct choose_compressor
*)GetWindowLongPtrW(hdlg
, DWLP_USER
);
906 cur_sel
= SendMessageW((HWND
)lparam
, CB_GETCURSEL
, 0, 0);
908 ic
= (struct codec_info
*)SendMessageW((HWND
)lparam
, CB_GETITEMDATA
, cur_sel
, 0);
911 if (ICQueryConfigure(ic
->hic
) == DRVCNF_OK
)
912 can_configure
= TRUE
;
913 if (ICQueryAbout(ic
->hic
) == DRVCNF_OK
)
916 EnableWindow(GetDlgItem(hdlg
, IDC_CONFIGURE
), can_configure
);
917 EnableWindow(GetDlgItem(hdlg
, IDC_ABOUT
), can_about
);
919 if (choose_comp
->flags
& ICMF_CHOOSE_DATARATE
)
923 if (choose_comp
->flags
& ICMF_CHOOSE_KEYFRAME
)
934 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
936 struct codec_info
*ic
;
938 if (HIWORD(wparam
) != BN_CLICKED
)
941 cur_sel
= SendMessageW(list
, CB_GETCURSEL
, 0, 0);
943 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, cur_sel
, 0);
946 if (LOWORD(wparam
) == IDC_CONFIGURE
)
947 ICConfigure(ic
->hic
, hdlg
);
949 ICAbout(ic
->hic
, hdlg
);
957 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
959 struct codec_info
*ic
;
961 if (HIWORD(wparam
) != BN_CLICKED
)
964 cur_sel
= SendMessageW(list
, CB_GETCURSEL
, 0, 0);
965 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, cur_sel
, 0);
968 struct choose_compressor
*choose_comp
= (struct choose_compressor
*)GetWindowLongPtrW(hdlg
, DWLP_USER
);
970 choose_comp
->cv
.hic
= ic
->hic
;
971 choose_comp
->cv
.fccType
= ic
->icinfo
.fccType
;
972 choose_comp
->cv
.fccHandler
= ic
->icinfo
.fccHandler
;
973 /* FIXME: fill everything else */
975 /* prevent closing the codec handle below */
982 HWND list
= GetDlgItem(hdlg
, IDC_COMP_LIST
);
985 if (HIWORD(wparam
) != BN_CLICKED
)
990 struct codec_info
*ic
;
992 ic
= (struct codec_info
*)SendMessageW(list
, CB_GETITEMDATA
, idx
++, 0);
994 if (!ic
|| (LONG_PTR
)ic
== CB_ERR
) break;
996 if (ic
->hic
) ICClose(ic
->hic
);
997 HeapFree(GetProcessHeap(), 0, ic
);
1000 EndDialog(hdlg
, LOWORD(wparam
) == IDOK
);
1016 /***********************************************************************
1017 * ICCompressorChoose [MSVFW32.@]
1019 BOOL VFWAPI
ICCompressorChoose(HWND hwnd
, UINT uiFlags
, LPVOID pvIn
,
1020 LPVOID lpData
, PCOMPVARS pc
, LPSTR lpszTitle
)
1022 struct choose_compressor choose_comp
;
1025 TRACE("(%p,%08x,%p,%p,%p,%s)\n", hwnd
, uiFlags
, pvIn
, lpData
, pc
, lpszTitle
);
1027 if (!pc
|| pc
->cbSize
!= sizeof(COMPVARS
))
1030 if (!(pc
->dwFlags
& ICMF_COMPVARS_VALID
))
1033 pc
->fccType
= pc
->fccHandler
= 0;
1037 pc
->lpBitsOut
= pc
->lpBitsPrev
= pc
->lpState
= NULL
;
1038 pc
->lQ
= ICQUALITY_DEFAULT
;
1040 pc
->lDataRate
= 300; /* kB */
1044 if (pc
->fccType
== 0)
1045 pc
->fccType
= ICTYPE_VIDEO
;
1047 choose_comp
.cv
= *pc
;
1048 choose_comp
.flags
= uiFlags
;
1049 choose_comp
.title
= lpszTitle
;
1051 ret
= DialogBoxParamW(MSVFW32_hModule
, MAKEINTRESOURCEW(ICM_CHOOSE_COMPRESSOR
), hwnd
,
1052 icm_choose_compressor_dlgproc
, (LPARAM
)&choose_comp
);
1056 *pc
= choose_comp
.cv
;
1057 pc
->dwFlags
|= ICMF_COMPVARS_VALID
;
1064 /***********************************************************************
1065 * ICCompressorFree [MSVFW32.@]
1067 void VFWAPI
ICCompressorFree(PCOMPVARS pc
)
1071 if (pc
!= NULL
&& pc
->cbSize
== sizeof(COMPVARS
)) {
1072 if (pc
->hic
!= NULL
) {
1076 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1078 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
1079 pc
->lpBitsOut
= NULL
;
1080 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1081 pc
->lpBitsPrev
= NULL
;
1082 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1088 /***********************************************************************
1089 * ICSendMessage [MSVFW32.@]
1091 LRESULT VFWAPI
ICSendMessage(HIC hic
, UINT msg
, DWORD_PTR lParam1
, DWORD_PTR lParam2
)
1093 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
1095 if (!whic
) return ICERR_BADHANDLE
;
1096 return MSVIDEO_SendMessage(whic
, msg
, lParam1
, lParam2
);
1099 /***********************************************************************
1100 * ICDrawBegin [MSVFW32.@]
1102 DWORD VFWAPIV
ICDrawBegin(
1104 DWORD dwFlags
, /* [in] flags */
1105 HPALETTE hpal
, /* [in] palette to draw with */
1106 HWND hwnd
, /* [in] window to draw to */
1107 HDC hdc
, /* [in] HDC to draw to */
1108 INT xDst
, /* [in] destination rectangle */
1109 INT yDst
, /* [in] */
1110 INT dxDst
, /* [in] */
1111 INT dyDst
, /* [in] */
1112 LPBITMAPINFOHEADER lpbi
, /* [in] format of frame to draw */
1113 INT xSrc
, /* [in] source rectangle */
1114 INT ySrc
, /* [in] */
1115 INT dxSrc
, /* [in] */
1116 INT dySrc
, /* [in] */
1117 DWORD dwRate
, /* [in] frames/second = (dwRate/dwScale) */
1118 DWORD dwScale
) /* [in] */
1123 TRACE("(%p,%d,%p,%p,%p,%u,%u,%u,%u,%p,%u,%u,%u,%u,%d,%d)\n",
1124 hic
, dwFlags
, hpal
, hwnd
, hdc
, xDst
, yDst
, dxDst
, dyDst
,
1125 lpbi
, xSrc
, ySrc
, dxSrc
, dySrc
, dwRate
, dwScale
);
1127 icdb
.dwFlags
= dwFlags
;
1140 icdb
.dwRate
= dwRate
;
1141 icdb
.dwScale
= dwScale
;
1142 return ICSendMessage(hic
,ICM_DRAW_BEGIN
,(DWORD_PTR
)&icdb
,sizeof(icdb
));
1145 /***********************************************************************
1146 * ICDraw [MSVFW32.@]
1148 DWORD VFWAPIV
ICDraw(HIC hic
, DWORD dwFlags
, LPVOID lpFormat
, LPVOID lpData
, DWORD cbData
, LONG lTime
) {
1151 TRACE("(%p,%d,%p,%p,%d,%d)\n",hic
,dwFlags
,lpFormat
,lpData
,cbData
,lTime
);
1153 icd
.dwFlags
= dwFlags
;
1154 icd
.lpFormat
= lpFormat
;
1155 icd
.lpData
= lpData
;
1156 icd
.cbData
= cbData
;
1159 return ICSendMessage(hic
,ICM_DRAW
,(DWORD_PTR
)&icd
,sizeof(icd
));
1162 /***********************************************************************
1163 * ICClose [MSVFW32.@]
1165 LRESULT WINAPI
ICClose(HIC hic
)
1167 WINE_HIC
* whic
= MSVIDEO_GetHicPtr(hic
);
1170 TRACE("(%p)\n",hic
);
1172 if (!whic
) return ICERR_BADHANDLE
;
1174 if (whic
->driverproc
)
1176 MSVIDEO_SendMessage(whic
, DRV_CLOSE
, 0, 0);
1177 MSVIDEO_SendMessage(whic
, DRV_DISABLE
, 0, 0);
1178 MSVIDEO_SendMessage(whic
, DRV_FREE
, 0, 0);
1182 CloseDriver(whic
->hdrv
, 0, 0);
1185 /* remove whic from list */
1186 for (p
= &MSVIDEO_FirstHic
; *p
!= NULL
; p
= &((*p
)->next
))
1195 HeapFree(GetProcessHeap(), 0, whic
);
1201 /***********************************************************************
1202 * ICImageCompress [MSVFW32.@]
1204 HANDLE VFWAPI
ICImageCompress(
1205 HIC hic
, UINT uiFlags
,
1206 LPBITMAPINFO lpbiIn
, LPVOID lpBits
,
1207 LPBITMAPINFO lpbiOut
, LONG lQuality
,
1210 FIXME("(%p,%08x,%p,%p,%p,%d,%p)\n",
1211 hic
, uiFlags
, lpbiIn
, lpBits
, lpbiOut
, lQuality
, plSize
);
1216 /***********************************************************************
1217 * ICImageDecompress [MSVFW32.@]
1220 HANDLE VFWAPI
ICImageDecompress(
1221 HIC hic
, UINT uiFlags
, LPBITMAPINFO lpbiIn
,
1222 LPVOID lpBits
, LPBITMAPINFO lpbiOut
)
1224 HGLOBAL hMem
= NULL
;
1226 BOOL bReleaseIC
= FALSE
;
1229 BOOL bSucceeded
= FALSE
;
1230 BOOL bInDecompress
= FALSE
;
1233 TRACE("(%p,%08x,%p,%p,%p)\n",
1234 hic
, uiFlags
, lpbiIn
, lpBits
, lpbiOut
);
1238 hic
= ICDecompressOpen( ICTYPE_VIDEO
, 0, &lpbiIn
->bmiHeader
, (lpbiOut
!= NULL
) ? &lpbiOut
->bmiHeader
: NULL
);
1241 WARN("no handler\n" );
1248 FIXME( "unknown flag %08x\n", uiFlags
);
1251 if ( lpbiIn
== NULL
|| lpBits
== NULL
)
1253 WARN("invalid argument\n");
1257 if ( lpbiOut
!= NULL
)
1259 if ( lpbiOut
->bmiHeader
.biSize
!= sizeof(BITMAPINFOHEADER
) )
1261 cbHdr
= sizeof(BITMAPINFOHEADER
);
1262 if ( lpbiOut
->bmiHeader
.biCompression
== 3 )
1263 cbHdr
+= sizeof(DWORD
)*3;
1265 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 )
1267 if ( lpbiOut
->bmiHeader
.biClrUsed
== 0 )
1268 cbHdr
+= sizeof(RGBQUAD
) * (1<<lpbiOut
->bmiHeader
.biBitCount
);
1270 cbHdr
+= sizeof(RGBQUAD
) * lpbiOut
->bmiHeader
.biClrUsed
;
1275 TRACE( "get format\n" );
1277 cbHdr
= ICDecompressGetFormatSize(hic
,lpbiIn
);
1278 if ( cbHdr
< sizeof(BITMAPINFOHEADER
) )
1280 pHdr
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,cbHdr
+sizeof(RGBQUAD
)*256);
1283 if ( ICDecompressGetFormat( hic
, lpbiIn
, pHdr
) != ICERR_OK
)
1285 lpbiOut
= (BITMAPINFO
*)pHdr
;
1286 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 &&
1287 ICDecompressGetPalette( hic
, lpbiIn
, lpbiOut
) != ICERR_OK
&&
1288 lpbiIn
->bmiHeader
.biBitCount
== lpbiOut
->bmiHeader
.biBitCount
)
1290 if ( lpbiIn
->bmiHeader
.biClrUsed
== 0 )
1291 memcpy( lpbiOut
->bmiColors
, lpbiIn
->bmiColors
, sizeof(RGBQUAD
)*(1<<lpbiOut
->bmiHeader
.biBitCount
) );
1293 memcpy( lpbiOut
->bmiColors
, lpbiIn
->bmiColors
, sizeof(RGBQUAD
)*lpbiIn
->bmiHeader
.biClrUsed
);
1295 if ( lpbiOut
->bmiHeader
.biBitCount
<= 8 &&
1296 lpbiOut
->bmiHeader
.biClrUsed
== 0 )
1297 lpbiOut
->bmiHeader
.biClrUsed
= 1<<lpbiOut
->bmiHeader
.biBitCount
;
1299 lpbiOut
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1300 cbHdr
= sizeof(BITMAPINFOHEADER
) + sizeof(RGBQUAD
)*lpbiOut
->bmiHeader
.biClrUsed
;
1303 biSizeImage
= lpbiOut
->bmiHeader
.biSizeImage
;
1304 if ( biSizeImage
== 0 )
1305 biSizeImage
= ((((lpbiOut
->bmiHeader
.biWidth
* lpbiOut
->bmiHeader
.biBitCount
+ 7) >> 3) + 3) & (~3)) * abs(lpbiOut
->bmiHeader
.biHeight
);
1307 TRACE( "call ICDecompressBegin\n" );
1309 if ( ICDecompressBegin( hic
, lpbiIn
, lpbiOut
) != ICERR_OK
)
1311 bInDecompress
= TRUE
;
1313 TRACE( "cbHdr %d, biSizeImage %d\n", cbHdr
, biSizeImage
);
1315 hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_ZEROINIT
, cbHdr
+ biSizeImage
);
1318 WARN( "out of memory\n" );
1321 pMem
= GlobalLock( hMem
);
1324 memcpy( pMem
, lpbiOut
, cbHdr
);
1326 TRACE( "call ICDecompress\n" );
1327 if ( ICDecompress( hic
, 0, &lpbiIn
->bmiHeader
, lpBits
, &lpbiOut
->bmiHeader
, pMem
+cbHdr
) != ICERR_OK
)
1332 if ( bInDecompress
)
1333 ICDecompressEnd( hic
);
1336 HeapFree(GetProcessHeap(),0,pHdr
);
1338 GlobalUnlock( hMem
);
1339 if ( !bSucceeded
&& hMem
!= NULL
)
1341 GlobalFree(hMem
); hMem
= NULL
;
1347 /***********************************************************************
1348 * ICSeqCompressFrame [MSVFW32.@]
1350 LPVOID VFWAPI
ICSeqCompressFrame(PCOMPVARS pc
, UINT uiFlags
, LPVOID lpBits
, BOOL
*pfKey
, LONG
*plSize
)
1352 ICCOMPRESS
* icComp
= pc
->lpState
;
1354 TRACE("(%p, 0x%08x, %p, %p, %p)\n", pc
, uiFlags
, lpBits
, pfKey
, plSize
);
1356 if (pc
->cbState
!= sizeof(ICCOMPRESS
))
1358 ERR("Invalid cbState %i\n", pc
->cbState
);
1362 if (!pc
->lKeyCount
++)
1363 icComp
->dwFlags
= ICCOMPRESS_KEYFRAME
;
1366 if (pc
->lKey
&& pc
->lKeyCount
== (pc
->lKey
- 1))
1367 /* No key frames if pc->lKey == 0 */
1369 icComp
->dwFlags
= 0;
1372 icComp
->lpInput
= lpBits
;
1373 icComp
->lFrameNum
= pc
->lFrame
++;
1374 icComp
->lpOutput
= pc
->lpBitsOut
;
1375 icComp
->lpPrev
= pc
->lpBitsPrev
;
1376 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS
, (DWORD_PTR
)icComp
, sizeof(*icComp
));
1378 if (icComp
->dwFlags
& AVIIF_KEYFRAME
)
1382 TRACE("Key frame\n");
1387 *plSize
= icComp
->lpbiOutput
->biSizeImage
;
1388 TRACE(" -- 0x%08x\n", ret
);
1389 if (ret
== ICERR_OK
)
1391 LPVOID oldprev
, oldout
;
1392 /* We shift Prev and Out, so we don't have to allocate and release memory */
1393 oldprev
= pc
->lpBitsPrev
;
1394 oldout
= pc
->lpBitsOut
;
1395 pc
->lpBitsPrev
= oldout
;
1396 pc
->lpBitsOut
= oldprev
;
1398 TRACE("returning: %p\n", icComp
->lpOutput
);
1399 return icComp
->lpOutput
;
1404 /***********************************************************************
1405 * ICSeqCompressFrameEnd [MSVFW32.@]
1407 void VFWAPI
ICSeqCompressFrameEnd(PCOMPVARS pc
)
1410 TRACE("(%p)\n", pc
);
1411 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS_END
, 0, 0);
1412 TRACE(" -- %x\n", ret
);
1413 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1414 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1415 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
1416 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1417 pc
->lpbiIn
= pc
->lpBitsPrev
= pc
->lpBitsOut
= pc
->lpState
= NULL
;
1420 /***********************************************************************
1421 * ICSeqCompressFrameStart [MSVFW32.@]
1423 BOOL VFWAPI
ICSeqCompressFrameStart(PCOMPVARS pc
, LPBITMAPINFO lpbiIn
)
1425 /* I'm ignoring bmiColors as I don't know what to do with it,
1426 * it doesn't appear to be used though
1429 pc
->lpbiIn
= HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFO
));
1433 *pc
->lpbiIn
= *lpbiIn
;
1434 pc
->lpBitsPrev
= HeapAlloc(GetProcessHeap(), 0, pc
->lpbiIn
->bmiHeader
.biSizeImage
);
1435 if (!pc
->lpBitsPrev
)
1437 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1441 pc
->lpState
= HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS
));
1444 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1445 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1448 pc
->cbState
= sizeof(ICCOMPRESS
);
1450 pc
->lpBitsOut
= HeapAlloc(GetProcessHeap(), 0, pc
->lpbiOut
->bmiHeader
.biSizeImage
);
1453 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1454 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1455 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1466 "key/data/quality: %i/%i/%i\n",
1467 pc
->cbSize
, pc
->dwFlags
, pc
->hic
, pc
->fccType
, pc
->fccHandler
,
1468 pc
->lpbiIn
, pc
->lpbiOut
, pc
->lKey
, pc
->lDataRate
, pc
->lQ
);
1470 ret
= ICSendMessage(pc
->hic
, ICM_COMPRESS_BEGIN
, (DWORD_PTR
)pc
->lpbiIn
, (DWORD_PTR
)pc
->lpbiOut
);
1471 TRACE(" -- %x\n", ret
);
1472 if (ret
== ICERR_OK
)
1474 ICCOMPRESS
* icComp
= pc
->lpState
;
1475 /* Initialise some variables */
1476 pc
->lFrame
= 0; pc
->lKeyCount
= 0;
1478 icComp
->lpbiOutput
= &pc
->lpbiOut
->bmiHeader
;
1479 icComp
->lpbiInput
= &pc
->lpbiIn
->bmiHeader
;
1480 icComp
->lpckid
= NULL
;
1481 icComp
->dwFrameSize
= 0;
1482 icComp
->dwQuality
= pc
->lQ
;
1483 icComp
->lpbiPrev
= &pc
->lpbiIn
->bmiHeader
;
1486 HeapFree(GetProcessHeap(), 0, pc
->lpbiIn
);
1487 HeapFree(GetProcessHeap(), 0, pc
->lpBitsPrev
);
1488 HeapFree(GetProcessHeap(), 0, pc
->lpState
);
1489 HeapFree(GetProcessHeap(), 0, pc
->lpBitsOut
);
1490 pc
->lpBitsPrev
= pc
->lpbiIn
= pc
->lpState
= pc
->lpBitsOut
= NULL
;
1494 /***********************************************************************
1495 * GetFileNamePreview [MSVFW32.@]
1497 static BOOL
GetFileNamePreview(LPVOID lpofn
,BOOL bSave
,BOOL bUnicode
)
1499 CHAR szFunctionName
[20];
1500 BOOL (*fnGetFileName
)(LPVOID
);
1504 FIXME("(%p,%d,%d), semi-stub!\n",lpofn
,bSave
,bUnicode
);
1506 lstrcpyA(szFunctionName
, (bSave
? "GetSaveFileName" : "GetOpenFileName"));
1507 lstrcatA(szFunctionName
, (bUnicode
? "W" : "A"));
1509 hComdlg32
= LoadLibraryA("COMDLG32.DLL");
1510 if (hComdlg32
== NULL
)
1513 fnGetFileName
= (LPVOID
)GetProcAddress(hComdlg32
, szFunctionName
);
1514 if (fnGetFileName
== NULL
)
1516 FreeLibrary(hComdlg32
);
1520 /* FIXME: need to add OFN_ENABLEHOOK and our own handler */
1521 ret
= fnGetFileName(lpofn
);
1523 FreeLibrary(hComdlg32
);
1527 /***********************************************************************
1528 * GetOpenFileNamePreviewA [MSVFW32.@]
1530 BOOL WINAPI
GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn
)
1532 FIXME("(%p), semi-stub!\n", lpofn
);
1534 return GetFileNamePreview(lpofn
, FALSE
, FALSE
);
1537 /***********************************************************************
1538 * GetOpenFileNamePreviewW [MSVFW32.@]
1540 BOOL WINAPI
GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn
)
1542 FIXME("(%p), semi-stub!\n", lpofn
);
1544 return GetFileNamePreview(lpofn
, FALSE
, TRUE
);
1547 /***********************************************************************
1548 * GetSaveFileNamePreviewA [MSVFW32.@]
1550 BOOL WINAPI
GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn
)
1552 FIXME("(%p), semi-stub!\n", lpofn
);
1554 return GetFileNamePreview(lpofn
, TRUE
, FALSE
);
1557 /***********************************************************************
1558 * GetSaveFileNamePreviewW [MSVFW32.@]
1560 BOOL WINAPI
GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn
)
1562 FIXME("(%p), semi-stub!\n", lpofn
);
1564 return GetFileNamePreview(lpofn
, TRUE
, TRUE
);