Added parser template and made AVISplitter use it.
[wine] / dlls / msvideo / msvideo_main.c
1 /*
2  * Copyright 1998 Marcus Meissner
3  * Copyright 2000 Bradley Baetz
4  * Copyright 2003 Michael Günnewig
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * FIXME: This all assumes 32 bit codecs
21  *              Win95 appears to prefer 32 bit codecs, even from 16 bit code.
22  *              There is the ICOpenFunction16 to worry about still, though.
23  *      
24  * TODO
25  *      - no thread safety
26  */
27
28 #include <stdio.h>
29 #include <string.h>
30
31 #include "msvideo_private.h"
32 #include "winnls.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "winreg.h"
36
37 #include "windowsx.h"
38
39 #include "wine/debug.h"
40
41 /* Drivers32 settings */
42 #define HKLM_DRIVERS32 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
45
46 static inline const char *wine_dbgstr_fcc( DWORD fcc )
47 {
48     return wine_dbg_sprintf("%c%c%c%c", 
49                             LOBYTE(LOWORD(fcc)), HIBYTE(LOWORD(fcc)),
50                             LOBYTE(HIWORD(fcc)), HIBYTE(HIWORD(fcc)));
51 }
52
53 LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM) = NULL;
54
55 static WINE_HIC*        MSVIDEO_FirstHic /* = NULL */;
56
57 typedef struct _reg_driver reg_driver;
58 struct _reg_driver
59 {
60     DWORD       fccType;
61     DWORD       fccHandler;
62     DRIVERPROC  proc;
63     LPWSTR      name;
64     reg_driver* next;
65 };
66
67 static reg_driver* reg_driver_list = NULL;
68
69 /* This one is a macro such that it works for both ASCII and Unicode */
70 #define fourcc_to_string(str, fcc) do { \
71         (str)[0] = LOBYTE(LOWORD(fcc)); \
72         (str)[1] = HIBYTE(LOWORD(fcc)); \
73         (str)[2] = LOBYTE(HIWORD(fcc)); \
74         (str)[3] = HIBYTE(HIWORD(fcc)); \
75         } while(0)
76
77 HMODULE MSVFW32_hModule;
78
79 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
80 {
81     TRACE("%p,%lx,%p\n", hinst, reason, reserved);
82
83     switch(reason)
84     {
85         case DLL_PROCESS_ATTACH:
86             DisableThreadLibraryCalls(hinst);
87             MSVFW32_hModule = (HMODULE)hinst;
88             break;
89     }
90     return TRUE;
91 }
92
93 static int compare_fourcc(DWORD fcc1, DWORD fcc2)
94 {
95   char fcc_str1[4];
96   char fcc_str2[4];
97   fourcc_to_string(fcc_str1, fcc1);
98   fourcc_to_string(fcc_str2, fcc2);
99   return strncasecmp(fcc_str1, fcc_str2, 4);
100 }
101
102 typedef BOOL (*enum_handler_t)(const char*, int, void*);
103
104 static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
105 {
106     CHAR buf[2048], fccTypeStr[5], *s;
107     DWORD i, cnt = 0, bufLen, lRet;
108     BOOL result = FALSE;
109     FILETIME lastWrite;
110     HKEY hKey;
111
112     fourcc_to_string(fccTypeStr, fccType);
113     fccTypeStr[4] = '.';
114
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) 
118     {
119         RegQueryInfoKeyA( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
120         for (i = 0; i < cnt; i++) 
121         {
122             bufLen = sizeof(buf) / sizeof(buf[0]);
123             lRet = RegEnumKeyExA(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
124             if (lRet != ERROR_SUCCESS) continue;
125             if (strncasecmp(buf, fccTypeStr, 5) || buf[9] != '=') continue;
126             if ((result = handler(buf, i, param))) break;
127         }
128         RegCloseKey( hKey );
129     }
130     if (result) return result;
131
132     /* if that didn't work, go through the values in system.ini */
133     if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini")) 
134     {
135         for (s = buf; *s; cnt++, s += strlen(s) + 1)
136         {
137             if (strncasecmp(s, fccTypeStr, 5) || s[9] != '=') continue;
138             if ((result = handler(s, cnt, param))) break;
139         }
140     }
141
142     return result;
143 }
144
145 /******************************************************************
146  *              MSVIDEO_GetHicPtr
147  *
148  *
149  */
150 WINE_HIC*   MSVIDEO_GetHicPtr(HIC hic)
151 {
152     WINE_HIC*   whic;
153
154     for (whic = MSVIDEO_FirstHic; whic && whic->hic != hic; whic = whic->next);
155     return whic;
156 }
157
158 /***********************************************************************
159  *              VideoForWindowsVersion          [MSVFW32.2]
160  *              VideoForWindowsVersion          [MSVIDEO.2]
161  * Returns the version in major.minor form.
162  * In Windows95 this returns 0x040003b6 (4.950)
163  */
164 DWORD WINAPI VideoForWindowsVersion(void) 
165 {
166     return 0x040003B6; /* 4.950 */
167 }
168
169 static BOOL ICInfo_enum_handler(const char *drv, int nr, void *param)
170 {
171     ICINFO *lpicinfo = (ICINFO *)param;
172     DWORD fccHandler = mmioStringToFOURCCA(drv + 5, 0);
173
174     /* exact match of fccHandler or nth driver found */
175     if ((lpicinfo->fccHandler != nr) && (lpicinfo->fccHandler != fccHandler))
176         return FALSE;
177
178     lpicinfo->fccType = mmioStringToFOURCCA(drv, 0);
179     lpicinfo->fccHandler = fccHandler;
180     lpicinfo->dwFlags = 0;
181     lpicinfo->dwVersion = 0;
182     lpicinfo->dwVersionICM = 0x104;
183     lpicinfo->szName[0] = 0;
184     lpicinfo->szDescription[0] = 0;
185     MultiByteToWideChar(CP_ACP, 0, drv + 10, -1, lpicinfo->szDriver, 
186                         sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
187
188     return TRUE;
189 }
190
191 /***********************************************************************
192  *              ICInfo                          [MSVFW32.@]
193  * Get information about an installable compressor. Return TRUE if there
194  * is one.
195  *
196  * PARAMS
197  *   fccType     [I] type of compressor (e.g. 'vidc')
198  *   fccHandler  [I] real fcc for handler or <n>th compressor
199  *   lpicinfo    [O] information about compressor
200  */
201 BOOL VFWAPI ICInfo( DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo)
202 {
203     TRACE("(%s,%s/%08lx,%p)\n", 
204           wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), fccHandler, lpicinfo);
205
206     lpicinfo->fccHandler = fccHandler;
207     return enum_drivers(fccType, ICInfo_enum_handler, lpicinfo);
208 }
209
210 static DWORD IC_HandleRef = 1;
211
212 /***********************************************************************
213  *              ICInstall                       [MSVFW32.@]
214  */
215 BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags) 
216 {
217     reg_driver* driver;
218     unsigned len;
219
220     TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
221
222     /* Check if a driver is already registered */
223     for (driver = reg_driver_list; driver; driver = driver->next)
224     {
225         if (!compare_fourcc(fccType, driver->fccType) &&
226             !compare_fourcc(fccHandler, driver->fccHandler))
227             break;
228     }
229     if (driver) return FALSE;
230
231     /* Register the driver */
232     driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(reg_driver));
233     if (!driver) goto oom;
234     driver->fccType = fccType;
235     driver->fccHandler = fccHandler;
236
237     switch(wFlags)
238     {
239     case ICINSTALL_FUNCTION:
240         driver->proc = (DRIVERPROC)lParam;
241         driver->name = NULL;
242         break;
243     case ICINSTALL_DRIVER:
244         driver->proc = NULL;
245         len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0);
246         driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
247         if (!driver->name) goto oom;
248         MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len);
249         break;
250     default:
251         ERR("Invalid flags!\n");
252         HeapFree(GetProcessHeap(), 0, driver);
253         return FALSE;
254    }
255
256    /* Insert our driver in the list*/
257    driver->next = reg_driver_list;
258    reg_driver_list = driver;
259     
260    return TRUE;
261  oom:
262    HeapFree(GetProcessHeap(), 0, driver);
263    return FALSE;
264 }
265
266 /***********************************************************************
267  *              ICRemove                        [MSVFW32.@]
268  */
269 BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) 
270 {
271     reg_driver** pdriver;
272     
273     TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
274
275     /* Check if a driver is already registered */
276     for (pdriver = &reg_driver_list; *pdriver; pdriver = &(*pdriver)->next)
277     {
278         if (!compare_fourcc(fccType, (*pdriver)->fccType) &&
279             !compare_fourcc(fccHandler, (*pdriver)->fccHandler))
280             break;
281     }
282     if (!*pdriver)
283         return FALSE;
284
285     /* Remove the driver from the list */
286     *pdriver = (*pdriver)->next;
287     HeapFree(GetProcessHeap(), 0, (*pdriver)->name);
288     HeapFree(GetProcessHeap(), 0, *pdriver);
289     
290     return TRUE;  
291 }
292
293
294 /***********************************************************************
295  *              ICOpen                          [MSVFW32.@]
296  * Opens an installable compressor. Return special handle.
297  */
298 HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) 
299 {
300     WCHAR               codecname[10];
301     ICOPEN              icopen;
302     HDRVR               hdrv;
303     WINE_HIC*           whic;
304     BOOL                bIs16;
305     static const WCHAR  drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'};
306     reg_driver*         driver;
307
308     TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
309
310     /* Check if there is a registered driver that matches */
311     driver = reg_driver_list;
312     while(driver)
313         if (!compare_fourcc(fccType, driver->fccType) &&
314             !compare_fourcc(fccHandler, driver->fccHandler))
315             break;
316         else
317             driver = driver->next;
318
319     if (driver && driver->proc)
320         /* The driver has been registered at runtime with its driverproc */
321         return MSVIDEO_OpenFunction(fccType, fccHandler, wMode, (DRIVERPROC)driver->proc, (DWORD)NULL);
322   
323     /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
324      * same layout as ICOPEN
325      */
326     icopen.dwSize               = sizeof(ICOPEN);
327     icopen.fccType              = fccType;
328     icopen.fccHandler           = fccHandler;
329     icopen.dwVersion            = 0x00001000; /* FIXME */
330     icopen.dwFlags              = wMode;
331     icopen.dwError              = 0;
332     icopen.pV1Reserved          = NULL;
333     icopen.pV2Reserved          = NULL;
334     icopen.dnDevNode            = 0; /* FIXME */
335         
336     if (!driver) {
337         /* The driver is registered in the registry */
338         fourcc_to_string(codecname, fccType);
339         codecname[4] = '.';
340         fourcc_to_string(codecname + 5, fccHandler);
341         codecname[9] = '\0';
342
343         hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
344         if (!hdrv) 
345         {
346             if (fccType == streamtypeVIDEO) 
347             {
348                 codecname[0] = 'v';
349                 codecname[1] = 'i';
350                 codecname[2] = 'd';
351                 codecname[3] = 'c';
352
353                 fccType = ICTYPE_VIDEO;
354                 hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
355             }
356             if (!hdrv)
357                 return 0;
358         }
359     } else {
360         /* The driver has been registered at runtime with its name */
361         hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
362         if (!hdrv) 
363             return 0; 
364     }
365     bIs16 = GetDriverFlags(hdrv) & 0x10000000; /* undocumented flag: WINE_GDF_16BIT */
366
367     if (bIs16 && !pFnCallTo16)
368     {
369         FIXME("Got a 16 bit driver, but no 16 bit support in msvfw\n");
370         return 0;
371     }
372     whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
373     if (!whic)
374     {
375         CloseDriver(hdrv, 0, 0);
376         return FALSE;
377     }
378     whic->hdrv          = hdrv;
379     /* FIXME: is the signature the real one ? */
380     whic->driverproc    = bIs16 ? (DRIVERPROC)pFnCallTo16 : NULL;
381     whic->driverproc16  = 0;
382     whic->type          = fccType;
383     whic->handler       = fccHandler;
384     while (MSVIDEO_GetHicPtr(HIC_32(IC_HandleRef)) != NULL) IC_HandleRef++;
385     whic->hic           = HIC_32(IC_HandleRef++);
386     whic->next          = MSVIDEO_FirstHic;
387     MSVIDEO_FirstHic = whic;
388
389     TRACE("=> %p\n", whic->hic);
390     return whic->hic;
391 }
392
393 /***********************************************************************
394  *              MSVIDEO_OpenFunction
395  */
396 HIC MSVIDEO_OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, 
397                          DRIVERPROC lpfnHandler, DWORD lpfnHandler16) 
398 {
399     ICOPEN      icopen;
400     WINE_HIC*   whic;
401
402     TRACE("(%s,%s,%d,%p,%08lx)\n", 
403           wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode, lpfnHandler, lpfnHandler16);
404
405     icopen.dwSize               = sizeof(ICOPEN);
406     icopen.fccType              = fccType;
407     icopen.fccHandler           = fccHandler;
408     icopen.dwVersion            = 0x00001000; /* FIXME */
409     icopen.dwFlags              = wMode;
410     icopen.dwError              = 0;
411     icopen.pV1Reserved          = NULL;
412     icopen.pV2Reserved          = NULL;
413     icopen.dnDevNode            = 0; /* FIXME */
414
415     whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
416     if (!whic) return 0;
417
418     whic->driverproc   = lpfnHandler;
419     whic->driverproc16 = lpfnHandler16;
420     while (MSVIDEO_GetHicPtr(HIC_32(IC_HandleRef)) != NULL) IC_HandleRef++;
421     whic->hic          = HIC_32(IC_HandleRef++);
422     whic->next         = MSVIDEO_FirstHic;
423     MSVIDEO_FirstHic = whic;
424
425     /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
426     /* What if the function is used more than once? */
427
428     if (MSVIDEO_SendMessage(whic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) 
429     {
430         WARN("DRV_LOAD failed for hic %p\n", whic->hic);
431         MSVIDEO_FirstHic = whic->next;
432         HeapFree(GetProcessHeap(), 0, whic);
433         return 0;
434     }
435     /* return value is not checked */
436     MSVIDEO_SendMessage(whic, DRV_ENABLE, 0L, 0L);
437
438     whic->driverId = (DWORD)MSVIDEO_SendMessage(whic, DRV_OPEN, 0, (DWORD)&icopen);
439     /* FIXME: What should we put here? */
440     whic->hdrv = NULL;
441     
442     if (whic->driverId == 0) 
443     {
444         WARN("DRV_OPEN failed for hic %p\n", whic->hic);
445         MSVIDEO_FirstHic = whic->next;
446         HeapFree(GetProcessHeap(), 0, whic);
447         return 0;
448     }
449
450     TRACE("=> %p\n", whic->hic);
451     return whic->hic;
452 }
453
454 /***********************************************************************
455  *              ICOpenFunction                  [MSVFW32.@]
456  */
457 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler) 
458 {
459     return MSVIDEO_OpenFunction(fccType, fccHandler, wMode, (DRIVERPROC)lpfnHandler, 0);
460 }
461
462 /***********************************************************************
463  *              ICGetInfo                       [MSVFW32.@]
464  */
465 LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb) 
466 {
467     LRESULT     ret;
468     WINE_HIC*   whic = MSVIDEO_GetHicPtr(hic);
469
470     TRACE("(%p,%p,%ld)\n", hic, picinfo, cb);
471
472     whic = MSVIDEO_GetHicPtr(hic);
473     if (!whic) return ICERR_BADHANDLE;
474     if (!picinfo) return MMSYSERR_INVALPARAM;
475
476     /* (WS) The field szDriver should be initialized because the driver 
477      * is not obliged and often will not do it. Some applications, like
478      * VirtualDub, rely on this field and will occasionally crash if it
479      * goes unitialized.
480      */
481     if (cb >= sizeof(ICINFO)) picinfo->szDriver[0] = '\0';
482
483     ret = ICSendMessage(hic, ICM_GETINFO, (DWORD)picinfo, cb);
484
485     /* (WS) When szDriver was not supplied by the driver itself, apparently 
486      * Windows will set its value equal to the driver file name. This can
487      * be obtained from the registry as we do here.
488      */
489     if (cb >= sizeof(ICINFO) && picinfo->szDriver[0] == 0)
490     {
491         ICINFO  ii;
492
493         memset(&ii, 0, sizeof(ii));
494         ii.dwSize = sizeof(ii);
495         ICInfo(picinfo->fccType, picinfo->fccHandler, &ii);
496         lstrcpyW(picinfo->szDriver, ii.szDriver);
497     }
498
499     TRACE("     -> 0x%08lx\n", ret);
500     return ret;
501 }
502
503 typedef struct {
504     DWORD fccType;
505     DWORD fccHandler;
506     LPBITMAPINFOHEADER lpbiIn;
507     LPBITMAPINFOHEADER lpbiOut;
508     WORD wMode;
509     DWORD querymsg;
510     HIC hic;
511 } driver_info_t;
512
513 static HIC try_driver(driver_info_t *info)
514 {
515     HIC   hic;
516
517     if ((hic = ICOpen(info->fccType, info->fccHandler, info->wMode))) 
518     {
519         if (!ICSendMessage(hic, info->querymsg, (DWORD)info->lpbiIn, (DWORD)info->lpbiOut))
520             return hic;
521         ICClose(hic);
522     }
523     return 0;
524 }
525
526 static BOOL ICLocate_enum_handler(const char *drv, int nr, void *param)
527 {
528     driver_info_t *info = (driver_info_t *)param;
529     info->fccHandler = mmioStringToFOURCCA(drv + 5, 0);
530     info->hic = try_driver(info);
531     return info->hic != 0;
532 }
533
534 /***********************************************************************
535  *              ICLocate                        [MSVFW32.@]
536  */
537 HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
538                     LPBITMAPINFOHEADER lpbiOut, WORD wMode)
539 {
540     driver_info_t info;
541
542     TRACE("(%s,%s,%p,%p,0x%04x)\n", 
543           wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
544
545     info.fccType = fccType;
546     info.fccHandler = fccHandler;
547     info.lpbiIn = lpbiIn;
548     info.lpbiOut = lpbiOut;
549     info.wMode = wMode;
550
551     switch (wMode) 
552     {
553     case ICMODE_FASTCOMPRESS:
554     case ICMODE_COMPRESS:
555         info.querymsg = ICM_COMPRESS_QUERY;
556         break;
557     case ICMODE_FASTDECOMPRESS:
558     case ICMODE_DECOMPRESS:
559         info.querymsg = ICM_DECOMPRESS_QUERY;
560         break;
561     case ICMODE_DRAW:
562         info.querymsg = ICM_DRAW_QUERY;
563         break;
564     default:
565         WARN("Unknown mode (%d)\n", wMode);
566         return 0;
567     }
568
569     /* Easy case: handler/type match, we just fire a query and return */
570     info.hic = try_driver(&info);
571     /* If it didn't work, try each driver in turn. 32 bit codecs only. */
572     /* FIXME: Move this to an init routine? */
573     if (!info.hic) enum_drivers(fccType, ICLocate_enum_handler, &info);
574
575     if (info.hic) 
576     {
577         TRACE("=> %p\n", info.hic);
578         return info.hic;
579     }
580
581     if (fccType == streamtypeVIDEO) 
582         return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode);
583     
584     WARN("(%s,%s,%p,%p,0x%04x) not found!\n",
585          wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
586     return 0;
587 }
588
589 /***********************************************************************
590  *              ICGetDisplayFormat                      [MSVFW32.@]
591  */
592 HIC VFWAPI ICGetDisplayFormat(
593         HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
594         INT depth,INT dx,INT dy)
595 {
596         HIC     tmphic = hic;
597
598         TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic,lpbiIn,lpbiOut,depth,dx,dy);
599
600         if (!tmphic) {
601                 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
602                 if (!tmphic)
603                         return tmphic;
604         }
605         if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
606                 dy = dx = 0; /* no resize needed */
607
608         /* Can we decompress it ? */
609         if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
610                 goto errout; /* no, sorry */
611
612         ICDecompressGetFormat(tmphic,lpbiIn,lpbiOut);
613
614         if (lpbiOut->biCompression != 0) {
615            FIXME("Ooch, how come decompressor outputs compressed data (%ld)??\n",
616                          lpbiOut->biCompression);
617         }
618         if (lpbiOut->biSize < sizeof(*lpbiOut)) {
619            FIXME("Ooch, size of output BIH is too small (%ld)\n",
620                          lpbiOut->biSize);
621            lpbiOut->biSize = sizeof(*lpbiOut);
622         }
623         if (!depth) {
624                 HDC     hdc;
625
626                 hdc = GetDC(0);
627                 depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
628                 ReleaseDC(0,hdc);
629                 if (depth==15)  depth = 16;
630                 if (depth<8)    depth =  8;
631         }
632         if (lpbiIn->biBitCount == 8)
633                 depth = 8;
634
635         TRACE("=> %p\n", tmphic);
636         return tmphic;
637 errout:
638         if (hic!=tmphic)
639                 ICClose(tmphic);
640
641         TRACE("=> 0\n");
642         return 0;
643 }
644
645 /***********************************************************************
646  *              ICCompress                      [MSVFW32.@]
647  */
648 DWORD VFWAPIV
649 ICCompress(
650         HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
651         LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
652         LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
653         LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
654 {
655         ICCOMPRESS      iccmp;
656
657         TRACE("(%p,%ld,%p,%p,%p,%p,...)\n",hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
658
659         iccmp.dwFlags           = dwFlags;
660
661         iccmp.lpbiOutput        = lpbiOutput;
662         iccmp.lpOutput          = lpData;
663         iccmp.lpbiInput         = lpbiInput;
664         iccmp.lpInput           = lpBits;
665
666         iccmp.lpckid            = lpckid;
667         iccmp.lpdwFlags         = lpdwFlags;
668         iccmp.lFrameNum         = lFrameNum;
669         iccmp.dwFrameSize       = dwFrameSize;
670         iccmp.dwQuality         = dwQuality;
671         iccmp.lpbiPrev          = lpbiPrev;
672         iccmp.lpPrev            = lpPrev;
673         return ICSendMessage(hic,ICM_COMPRESS,(DWORD)&iccmp,sizeof(iccmp));
674 }
675
676 /***********************************************************************
677  *              ICDecompress                    [MSVFW32.@]
678  */
679 DWORD VFWAPIV  ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
680                                 LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
681 {
682         ICDECOMPRESS    icd;
683         DWORD ret;
684
685         TRACE("(%p,%ld,%p,%p,%p,%p)\n",hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
686
687         TRACE("lpBits[0] == %lx\n",((LPDWORD)lpBits)[0]);
688
689         icd.dwFlags     = dwFlags;
690         icd.lpbiInput   = lpbiFormat;
691         icd.lpInput     = lpData;
692
693         icd.lpbiOutput  = lpbi;
694         icd.lpOutput    = lpBits;
695         icd.ckid        = 0;
696         ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
697
698         TRACE("lpBits[0] == %lx\n",((LPDWORD)lpBits)[0]);
699
700         TRACE("-> %ld\n",ret);
701
702         return ret;
703 }
704
705 /***********************************************************************
706  *              ICCompressorChoose   [MSVFW32.@]
707  */
708 BOOL VFWAPI ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn,
709                                LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle)
710 {
711   FIXME("(%p,0x%X,%p,%p,%p,%s),stub!\n",hwnd,uiFlags,pvIn,lpData,pc,lpszTitle);
712
713   if (pc == NULL || pc->cbSize != sizeof(COMPVARS))
714     return FALSE;
715
716   if ((pc->dwFlags & ICMF_COMPVARS_VALID) == 0) {
717     pc->dwFlags   = 0;
718     pc->fccType   = pc->fccHandler = 0;
719     pc->hic       = NULL;
720     pc->lpbiOut   = NULL;
721     pc->lpBitsOut = pc->lpBitsPrev = pc->lpState = NULL;
722     pc->lQ        = ICQUALITY_DEFAULT;
723     pc->lKey      = -1;
724     pc->lDataRate = 300; /* kB */
725     pc->lpState   = NULL;
726     pc->cbState   = 0;
727   }
728   if (pc->fccType == 0)
729     pc->fccType = ICTYPE_VIDEO;
730
731   /* FIXME */
732   
733   return FALSE;
734 }
735
736
737 /***********************************************************************
738  *              ICCompressorFree   [MSVFW32.@]
739  */
740 void VFWAPI ICCompressorFree(PCOMPVARS pc)
741 {
742   TRACE("(%p)\n",pc);
743
744   if (pc != NULL && pc->cbSize == sizeof(COMPVARS)) {
745     if (pc->hic != NULL) {
746       ICClose(pc->hic);
747       pc->hic = NULL;
748     }
749     if (pc->lpbiOut != NULL) {
750       GlobalFreePtr(pc->lpbiOut);
751       pc->lpbiOut = NULL;
752     }
753     if (pc->lpBitsOut != NULL) {
754       GlobalFreePtr(pc->lpBitsOut);
755       pc->lpBitsOut = NULL;
756     }
757     if (pc->lpBitsPrev != NULL) {
758       GlobalFreePtr(pc->lpBitsPrev);
759       pc->lpBitsPrev = NULL;
760     }
761     if (pc->lpState != NULL) {
762       GlobalFreePtr(pc->lpBitsPrev);
763       pc->lpState = NULL;
764     }
765     pc->dwFlags = 0;
766   }
767 }
768
769
770 /******************************************************************
771  *              MSVIDEO_SendMessage
772  *
773  *
774  */
775 LRESULT MSVIDEO_SendMessage(WINE_HIC* whic, UINT msg, DWORD lParam1, DWORD lParam2)
776 {
777     LRESULT     ret;
778     
779 #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break;
780     
781     switch (msg) {
782         /* DRV_* */
783         XX(DRV_LOAD);
784         XX(DRV_ENABLE);
785         XX(DRV_OPEN);
786         XX(DRV_CLOSE);
787         XX(DRV_DISABLE);
788         XX(DRV_FREE);
789         /* ICM_RESERVED+X */
790         XX(ICM_ABOUT);
791         XX(ICM_CONFIGURE);
792         XX(ICM_GET);
793         XX(ICM_GETINFO);
794         XX(ICM_GETDEFAULTQUALITY);
795         XX(ICM_GETQUALITY);
796         XX(ICM_GETSTATE);
797         XX(ICM_SETQUALITY);
798         XX(ICM_SET);
799         XX(ICM_SETSTATE);
800         /* ICM_USER+X */
801         XX(ICM_COMPRESS_FRAMES_INFO);
802         XX(ICM_COMPRESS_GET_FORMAT);
803         XX(ICM_COMPRESS_GET_SIZE);
804         XX(ICM_COMPRESS_QUERY);
805         XX(ICM_COMPRESS_BEGIN);
806         XX(ICM_COMPRESS);
807         XX(ICM_COMPRESS_END);
808         XX(ICM_DECOMPRESS_GET_FORMAT);
809         XX(ICM_DECOMPRESS_QUERY);
810         XX(ICM_DECOMPRESS_BEGIN);
811         XX(ICM_DECOMPRESS);
812         XX(ICM_DECOMPRESS_END);
813         XX(ICM_DECOMPRESS_SET_PALETTE);
814         XX(ICM_DECOMPRESS_GET_PALETTE);
815         XX(ICM_DRAW_QUERY);
816         XX(ICM_DRAW_BEGIN);
817         XX(ICM_DRAW_GET_PALETTE);
818         XX(ICM_DRAW_START);
819         XX(ICM_DRAW_STOP);
820         XX(ICM_DRAW_END);
821         XX(ICM_DRAW_GETTIME);
822         XX(ICM_DRAW);
823         XX(ICM_DRAW_WINDOW);
824         XX(ICM_DRAW_SETTIME);
825         XX(ICM_DRAW_REALIZE);
826         XX(ICM_DRAW_FLUSH);
827         XX(ICM_DRAW_RENDERBUFFER);
828         XX(ICM_DRAW_START_PLAY);
829         XX(ICM_DRAW_STOP_PLAY);
830         XX(ICM_DRAW_SUGGESTFORMAT);
831         XX(ICM_DRAW_CHANGEPALETTE);
832         XX(ICM_GETBUFFERSWANTED);
833         XX(ICM_GETDEFAULTKEYFRAMERATE);
834         XX(ICM_DECOMPRESSEX_BEGIN);
835         XX(ICM_DECOMPRESSEX_QUERY);
836         XX(ICM_DECOMPRESSEX);
837         XX(ICM_DECOMPRESSEX_END);
838         XX(ICM_SET_STATUS_PROC);
839     default:
840         FIXME("(%p,0x%08lx,0x%08lx,0x%08lx) unknown message\n",whic,(DWORD)msg,lParam1,lParam2);
841     }
842     
843 #undef XX
844     
845     if (whic->driverproc) {
846         /* dwDriverId parameter is the value returned by the DRV_OPEN */
847         ret = whic->driverproc(whic->driverId, whic->hdrv, msg, lParam1, lParam2);
848     } else {
849         ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2);
850     }
851
852     TRACE("     -> 0x%08lx\n", ret);
853     return ret;
854 }
855
856 /***********************************************************************
857  *              ICSendMessage                   [MSVFW32.@]
858  */
859 LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2) 
860 {
861     WINE_HIC*   whic = MSVIDEO_GetHicPtr(hic);
862
863     if (!whic) return ICERR_BADHANDLE;
864     return MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
865 }
866
867 /***********************************************************************
868  *              ICDrawBegin             [MSVFW32.@]
869  */
870 DWORD VFWAPIV ICDrawBegin(
871         HIC                hic,     /* [in] */
872         DWORD              dwFlags, /* [in] flags */
873         HPALETTE           hpal,    /* [in] palette to draw with */
874         HWND               hwnd,    /* [in] window to draw to */
875         HDC                hdc,     /* [in] HDC to draw to */
876         INT                xDst,    /* [in] destination rectangle */
877         INT                yDst,    /* [in] */
878         INT                dxDst,   /* [in] */
879         INT                dyDst,   /* [in] */
880         LPBITMAPINFOHEADER lpbi,    /* [in] format of frame to draw */
881         INT                xSrc,    /* [in] source rectangle */
882         INT                ySrc,    /* [in] */
883         INT                dxSrc,   /* [in] */
884         INT                dySrc,   /* [in] */
885         DWORD              dwRate,  /* [in] frames/second = (dwRate/dwScale) */
886         DWORD              dwScale) /* [in] */
887 {
888
889         ICDRAWBEGIN     icdb;
890
891         TRACE("(%p,%ld,%p,%p,%p,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
892                   hic, dwFlags, hpal, hwnd, hdc, xDst, yDst, dxDst, dyDst,
893                   lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
894
895         icdb.dwFlags = dwFlags;
896         icdb.hpal = hpal;
897         icdb.hwnd = hwnd;
898         icdb.hdc = hdc;
899         icdb.xDst = xDst;
900         icdb.yDst = yDst;
901         icdb.dxDst = dxDst;
902         icdb.dyDst = dyDst;
903         icdb.lpbi = lpbi;
904         icdb.xSrc = xSrc;
905         icdb.ySrc = ySrc;
906         icdb.dxSrc = dxSrc;
907         icdb.dySrc = dySrc;
908         icdb.dwRate = dwRate;
909         icdb.dwScale = dwScale;
910         return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD)&icdb,sizeof(icdb));
911 }
912
913 /***********************************************************************
914  *              ICDraw                  [MSVFW32.@]
915  */
916 DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
917         ICDRAW  icd;
918
919         TRACE("(%p,%ld,%p,%p,%ld,%ld)\n",hic,dwFlags,lpFormat,lpData,cbData,lTime);
920
921         icd.dwFlags = dwFlags;
922         icd.lpFormat = lpFormat;
923         icd.lpData = lpData;
924         icd.cbData = cbData;
925         icd.lTime = lTime;
926
927         return ICSendMessage(hic,ICM_DRAW,(DWORD)&icd,sizeof(icd));
928 }
929
930 /***********************************************************************
931  *              ICClose                 [MSVFW32.@]
932  */
933 LRESULT WINAPI ICClose(HIC hic)
934 {
935     WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
936     WINE_HIC** p;
937
938     TRACE("(%p)\n",hic);
939
940     if (!whic) return ICERR_BADHANDLE;
941
942     if (whic->driverproc) 
943     {
944         MSVIDEO_SendMessage(whic, DRV_CLOSE, 0, 0);
945         MSVIDEO_SendMessage(whic, DRV_DISABLE, 0, 0);
946         MSVIDEO_SendMessage(whic, DRV_FREE, 0, 0);
947     }
948     else
949     {
950         CloseDriver(whic->hdrv, 0, 0);
951     }
952
953     /* remove whic from list */
954     for (p = &MSVIDEO_FirstHic; *p != NULL; p = &((*p)->next))
955     {
956         if ((*p) == whic)
957         {
958             *p = whic->next;
959             break;
960         }
961     }
962
963     HeapFree(GetProcessHeap(), 0, whic);
964     return 0;
965 }
966
967
968
969 /***********************************************************************
970  *              ICImageCompress [MSVFW32.@]
971  */
972 HANDLE VFWAPI ICImageCompress(
973         HIC hic, UINT uiFlags,
974         LPBITMAPINFO lpbiIn, LPVOID lpBits,
975         LPBITMAPINFO lpbiOut, LONG lQuality,
976         LONG* plSize)
977 {
978         FIXME("(%p,%08x,%p,%p,%p,%ld,%p)\n",
979                 hic, uiFlags, lpbiIn, lpBits, lpbiOut, lQuality, plSize);
980
981         return NULL;
982 }
983
984 /***********************************************************************
985  *              ICImageDecompress       [MSVFW32.@]
986  */
987
988 HANDLE VFWAPI ICImageDecompress(
989         HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn,
990         LPVOID lpBits, LPBITMAPINFO lpbiOut)
991 {
992         HGLOBAL hMem = NULL;
993         BYTE*   pMem = NULL;
994         BOOL    bReleaseIC = FALSE;
995         BYTE*   pHdr = NULL;
996         ULONG   cbHdr = 0;
997         BOOL    bSucceeded = FALSE;
998         BOOL    bInDecompress = FALSE;
999         DWORD   biSizeImage;
1000
1001         TRACE("(%p,%08x,%p,%p,%p)\n",
1002                 hic, uiFlags, lpbiIn, lpBits, lpbiOut);
1003
1004         if ( hic == NULL )
1005         {
1006                 hic = ICDecompressOpen( ICTYPE_VIDEO, 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL );
1007                 if ( hic == NULL )
1008                 {
1009                         WARN("no handler\n" );
1010                         goto err;
1011                 }
1012                 bReleaseIC = TRUE;
1013         }
1014         if ( uiFlags != 0 )
1015         {
1016                 FIXME( "unknown flag %08x\n", uiFlags );
1017                 goto err;
1018         }
1019         if ( lpbiIn == NULL || lpBits == NULL )
1020         {
1021                 WARN("invalid argument\n");
1022                 goto err;
1023         }
1024
1025         if ( lpbiOut != NULL )
1026         {
1027                 if ( lpbiOut->bmiHeader.biSize != sizeof(BITMAPINFOHEADER) )
1028                         goto err;
1029                 cbHdr = sizeof(BITMAPINFOHEADER);
1030                 if ( lpbiOut->bmiHeader.biCompression == 3 )
1031                         cbHdr += sizeof(DWORD)*3;
1032                 else
1033                 if ( lpbiOut->bmiHeader.biBitCount <= 8 )
1034                 {
1035                         if ( lpbiOut->bmiHeader.biClrUsed == 0 )
1036                                 cbHdr += sizeof(RGBQUAD) * (1<<lpbiOut->bmiHeader.biBitCount);
1037                         else
1038                                 cbHdr += sizeof(RGBQUAD) * lpbiOut->bmiHeader.biClrUsed;
1039                 }
1040         }
1041         else
1042         {
1043                 TRACE( "get format\n" );
1044
1045                 cbHdr = ICDecompressGetFormatSize(hic,lpbiIn);
1046                 if ( cbHdr < sizeof(BITMAPINFOHEADER) )
1047                         goto err;
1048                 pHdr = (BYTE*)HeapAlloc(GetProcessHeap(),0,cbHdr+sizeof(RGBQUAD)*256);
1049                 if ( pHdr == NULL )
1050                         goto err;
1051                 ZeroMemory( pHdr, cbHdr+sizeof(RGBQUAD)*256 );
1052                 if ( ICDecompressGetFormat( hic, lpbiIn, (BITMAPINFO*)pHdr ) != ICERR_OK )
1053                         goto err;
1054                 lpbiOut = (BITMAPINFO*)pHdr;
1055                 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1056                          ICDecompressGetPalette( hic, lpbiIn, lpbiOut ) != ICERR_OK &&
1057                          lpbiIn->bmiHeader.biBitCount == lpbiOut->bmiHeader.biBitCount )
1058                 {
1059                         if ( lpbiIn->bmiHeader.biClrUsed == 0 )
1060                                 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*(1<<lpbiOut->bmiHeader.biBitCount) );
1061                         else
1062                                 memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*lpbiIn->bmiHeader.biClrUsed );
1063                 }
1064                 if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1065                          lpbiOut->bmiHeader.biClrUsed == 0 )
1066                         lpbiOut->bmiHeader.biClrUsed = 1<<lpbiOut->bmiHeader.biBitCount;
1067
1068                 lpbiOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1069                 cbHdr = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*lpbiOut->bmiHeader.biClrUsed;
1070         }
1071
1072         biSizeImage = lpbiOut->bmiHeader.biSizeImage;
1073         if ( biSizeImage == 0 )
1074                 biSizeImage = ((((lpbiOut->bmiHeader.biWidth * lpbiOut->bmiHeader.biBitCount + 7) >> 3) + 3) & (~3)) * abs(lpbiOut->bmiHeader.biHeight);
1075
1076         TRACE( "call ICDecompressBegin\n" );
1077
1078         if ( ICDecompressBegin( hic, lpbiIn, lpbiOut ) != ICERR_OK )
1079                 goto err;
1080         bInDecompress = TRUE;
1081
1082         TRACE( "cbHdr %ld, biSizeImage %ld\n", cbHdr, biSizeImage );
1083
1084         hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, cbHdr + biSizeImage );
1085         if ( hMem == NULL )
1086         {
1087                 WARN( "out of memory\n" );
1088                 goto err;
1089         }
1090         pMem = (BYTE*)GlobalLock( hMem );
1091         if ( pMem == NULL )
1092                 goto err;
1093         memcpy( pMem, lpbiOut, cbHdr );
1094
1095         TRACE( "call ICDecompress\n" );
1096         if ( ICDecompress( hic, 0, &lpbiIn->bmiHeader, lpBits, &lpbiOut->bmiHeader, pMem+cbHdr ) != ICERR_OK )
1097                 goto err;
1098
1099         bSucceeded = TRUE;
1100 err:
1101         if ( bInDecompress )
1102                 ICDecompressEnd( hic );
1103         if ( bReleaseIC )
1104                 ICClose(hic);
1105         HeapFree(GetProcessHeap(),0,pHdr);
1106         if ( pMem != NULL )
1107                 GlobalUnlock( hMem );
1108         if ( !bSucceeded && hMem != NULL )
1109         {
1110                 GlobalFree(hMem); hMem = NULL;
1111         }
1112
1113         return (HANDLE)hMem;
1114 }
1115
1116 /***********************************************************************
1117  *      ICSeqCompressFrame   [MSVFW32.@]
1118  */
1119 LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL *pfKey, LONG *plSize)
1120 {
1121     FIXME("(%p, 0x%08x, %p, %p, %p), stub!\n", pc, uiFlags, lpBits, pfKey, plSize);
1122     return NULL;
1123 }
1124
1125 /***********************************************************************
1126  *      ICSeqCompressFrameEnd   [MSVFW32.@]
1127  */
1128 void VFWAPI ICSeqCompressFrameEnd(PCOMPVARS pc)
1129 {
1130     FIXME("(%p), stub!\n", pc);
1131 }
1132
1133 /***********************************************************************
1134  *      ICSeqCompressFrameEnd   [MSVFW32.@]
1135  */
1136 BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn)
1137 {
1138     FIXME("(%p, %p), stub!\n", pc, lpbiIn);
1139     return TRUE;
1140 }
1141
1142 /***********************************************************************
1143  *      GetFileNamePreview   [MSVFW32.@]
1144  */
1145 static BOOL GetFileNamePreview(LPVOID lpofn,BOOL bSave,BOOL bUnicode)
1146 {
1147   CHAR    szFunctionName[20];
1148   BOOL    (*fnGetFileName)(LPVOID);
1149   HMODULE hComdlg32;
1150   BOOL    ret;
1151
1152   FIXME("(%p,%d,%d), semi-stub!\n",lpofn,bSave,bUnicode);
1153
1154   lstrcpyA(szFunctionName, (bSave ? "GetSaveFileName" : "GetOpenFileName"));
1155   lstrcatA(szFunctionName, (bUnicode ? "W" : "A"));
1156
1157   hComdlg32 = LoadLibraryA("COMDLG32.DLL");
1158   if (hComdlg32 == NULL)
1159     return FALSE;
1160
1161   fnGetFileName = (LPVOID)GetProcAddress(hComdlg32, szFunctionName);
1162   if (fnGetFileName == NULL)
1163     return FALSE;
1164
1165   /* FIXME: need to add OFN_ENABLEHOOK and our own handler */
1166   ret = fnGetFileName(lpofn);
1167
1168   FreeLibrary(hComdlg32);
1169   return ret;
1170 }
1171
1172 /***********************************************************************
1173  *              GetOpenFileNamePreviewA [MSVFW32.@]
1174  */
1175 BOOL WINAPI GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn)
1176 {
1177   FIXME("(%p), semi-stub!\n", lpofn);
1178
1179   return GetFileNamePreview(lpofn, FALSE, FALSE);
1180 }
1181
1182 /***********************************************************************
1183  *              GetOpenFileNamePreviewW [MSVFW32.@]
1184  */
1185 BOOL WINAPI GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn)
1186 {
1187   FIXME("(%p), semi-stub!\n", lpofn);
1188
1189   return GetFileNamePreview(lpofn, FALSE, TRUE);
1190 }
1191
1192 /***********************************************************************
1193  *              GetSaveFileNamePreviewA [MSVFW32.@]
1194  */
1195 BOOL WINAPI GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn)
1196 {
1197   FIXME("(%p), semi-stub!\n", lpofn);
1198
1199   return GetFileNamePreview(lpofn, TRUE, FALSE);
1200 }
1201
1202 /***********************************************************************
1203  *              GetSaveFileNamePreviewW [MSVFW32.@]
1204  */
1205 BOOL WINAPI GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn)
1206 {
1207   FIXME("(%p), semi-stub!\n", lpofn);
1208
1209   return GetFileNamePreview(lpofn, TRUE, TRUE);
1210 }