ReactOS  0.4.14-dev-49-gfb4591c
msvideo_main.c
Go to the documentation of this file.
1 /*
2  * Copyright 1998 Marcus Meissner
3  * Copyright 2000 Bradley Baetz
4  * Copyright 2003 Michael G├╝nnewig
5  * Copyright 2005 Dmitry Timoshkov
6  *
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.
11  *
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.
16  *
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
20  *
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.
24  *
25  * TODO
26  * - no thread safety
27  */
28 
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <string.h>
32 
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winreg.h"
36 #include "winnls.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39 #include "commdlg.h"
40 #include "vfw.h"
41 #include "msvideo_private.h"
42 #include "wine/debug.h"
43 
44 /* Drivers32 settings */
45 #define HKLM_DRIVERS32 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
46 
48 
49 /* This one is a macro in order to work for both ASCII and Unicode */
50 #define fourcc_to_string(str, fcc) do { \
51  (str)[0] = LOBYTE(LOWORD(fcc)); \
52  (str)[1] = HIBYTE(LOWORD(fcc)); \
53  (str)[2] = LOBYTE(HIWORD(fcc)); \
54  (str)[3] = HIBYTE(HIWORD(fcc)); \
55  } while(0)
56 
57 static inline const char *wine_dbgstr_fcc( DWORD fcc )
58 {
59  char fcc_str[5];
60  fourcc_to_string(fcc_str, fcc);
61  fcc_str[4] = '\0';
62  /* Last byte may be ' ' in some cases like "DIB " */
63  if (isalnum(fcc_str[0]) && isalnum(fcc_str[1]) && isalnum(fcc_str[2])
64  && (isalnum(fcc_str[3]) || isspace(fcc_str[3])))
65  return wine_dbg_sprintf("%s", fcc_str);
66  return wine_dbg_sprintf("0x%08x", fcc);
67 }
68 
69 static const char *wine_dbgstr_icerr( int ret )
70 {
71  const char *str;
72  if (ret <= ICERR_CUSTOM)
73  return wine_dbg_sprintf("ICERR_CUSTOM (%d)", ret);
74 #define XX(x) case (x): str = #x; break
75  switch (ret)
76  {
77  XX(ICERR_OK);
91  XX(ICERR_ABORT);
92  XX(ICERR_ERROR);
95  default: str = wine_dbg_sprintf("UNKNOWN (%d)", ret);
96  }
97 #undef XX
98  return str;
99 }
100 
101 static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
102 
103 typedef struct _reg_driver reg_driver;
105 {
111 };
112 
114 
116 
118 {
119  TRACE("%p,%x,%p\n", hinst, reason, reserved);
120 
121  switch(reason)
122  {
123  case DLL_PROCESS_ATTACH:
126  break;
127  }
128  return TRUE;
129 }
130 
131 /******************************************************************
132  * MSVIDEO_SendMessage
133  *
134  *
135  */
137 {
138  LRESULT ret;
139 
140 #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break
141 
142  switch (msg) {
143  /* DRV_* */
144  XX(DRV_LOAD);
145  XX(DRV_ENABLE);
146  XX(DRV_OPEN);
147  XX(DRV_CLOSE);
148  XX(DRV_DISABLE);
149  XX(DRV_FREE);
150  /* ICM_RESERVED+X */
151  XX(ICM_ABOUT);
152  XX(ICM_CONFIGURE);
153  XX(ICM_GET);
154  XX(ICM_GETINFO);
157  XX(ICM_GETSTATE);
159  XX(ICM_SET);
160  XX(ICM_SETSTATE);
161  /* ICM_USER+X */
167  XX(ICM_COMPRESS);
180  XX(ICM_DRAW_STOP);
181  XX(ICM_DRAW_END);
183  XX(ICM_DRAW);
200  default:
201  FIXME("(%p,0x%08x,0x%08lx,0x%08lx) unknown message\n",whic,msg,lParam1,lParam2);
202  }
203 
204 #undef XX
205 
206  if (whic->driverproc) {
207  /* dwDriverId parameter is the value returned by the DRV_OPEN */
208  ret = whic->driverproc(whic->driverId, whic->hdrv, msg, lParam1, lParam2);
209  } else {
210  ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2);
211  }
212 
213  TRACE(" -> %s\n", wine_dbgstr_icerr(ret));
214  return ret;
215 }
216 
217 static int compare_fourcc(DWORD fcc1, DWORD fcc2)
218 {
219  char fcc_str1[4];
220  char fcc_str2[4];
221  fourcc_to_string(fcc_str1, fcc1);
222  fourcc_to_string(fcc_str2, fcc2);
223  return strncasecmp(fcc_str1, fcc_str2, 4);
224 }
225 
227 {
228  DWORD ret = width * depth;
229  ret = (ret + 7) / 8; /* divide by byte size, rounding up */
230  ret = (ret + 3) & ~3; /* align to 4 bytes */
231  ret *= abs(height);
232  return ret;
233 }
234 
235 typedef BOOL (*enum_handler_t)(const char *name, const char *driver, unsigned int index, void *param);
236 
238 {
239  char fccTypeStr[4];
240  char name_buf[10];
241  char buf[2048];
242 
243  DWORD i, cnt = 0, lRet;
244  BOOL result = FALSE;
245  HKEY hKey;
246 
247  fourcc_to_string(fccTypeStr, fccType);
248 
249  /* first, go through the registry entries */
251  if (lRet == ERROR_SUCCESS)
252  {
253  i = 0;
254  for (;;)
255  {
256  DWORD name_len = 10, driver_len = 128;
257  lRet = RegEnumValueA(hKey, i++, name_buf, &name_len, 0, 0, (BYTE *)buf, &driver_len);
258  if (lRet == ERROR_NO_MORE_ITEMS) break;
259  if (name_len != 9 || name_buf[4] != '.') continue;
260  if (fccType && strncasecmp(name_buf, fccTypeStr, 4)) continue;
261  if ((result = handler(name_buf, buf, cnt++, param))) break;
262  }
263  RegCloseKey( hKey );
264  }
265  if (result) return result;
266 
267  /* if that didn't work, go through the values in system.ini */
268  if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini"))
269  {
270  char *s;
271  for (s = buf; *s; s += strlen(s) + 1)
272  {
273  if (s[4] != '.' || s[9] != '=') continue;
274  if (fccType && strncasecmp(s, fccTypeStr, 4)) continue;
275  if ((result = handler(s, s + 10, cnt++, param))) break;
276  }
277  }
278 
279  return result;
280 }
281 
282 /******************************************************************
283  * MSVIDEO_GetHicPtr
284  *
285  *
286  */
287 static WINE_HIC* MSVIDEO_GetHicPtr(HIC hic)
288 {
289  WINE_HIC* whic;
290 
291  for (whic = MSVIDEO_FirstHic; whic && whic->hic != hic; whic = whic->next);
292  return whic;
293 }
294 
295 /***********************************************************************
296  * VideoForWindowsVersion [MSVFW32.2]
297  * VideoForWindowsVersion [MSVIDEO.2]
298  * Returns the version in major.minor form.
299  * In Windows95 this returns 0x040003b6 (4.950)
300  */
302 {
303  return 0x040003B6; /* 4.950 */
304 }
305 
306 static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
307 {
308  ICINFO *lpicinfo = param;
309  DWORD fccType = mmioStringToFOURCCA(name, 0);
310  DWORD fccHandler = mmioStringToFOURCCA(name + 5, 0);
311 
312  if (lpicinfo->fccHandler != nr && compare_fourcc(lpicinfo->fccHandler, fccHandler))
313  return FALSE;
314 
315  lpicinfo->fccType = fccType;
316  lpicinfo->fccHandler = fccHandler;
317  lpicinfo->dwFlags = 0;
318  lpicinfo->dwVersion = 0;
319  lpicinfo->dwVersionICM = ICVERSION;
320  lpicinfo->szName[0] = 0;
321  lpicinfo->szDescription[0] = 0;
322  MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver, ARRAY_SIZE(lpicinfo->szDriver));
323 
324  return TRUE;
325 }
326 
327 /***********************************************************************
328  * ICInfo [MSVFW32.@]
329  * Get information about an installable compressor. Return TRUE if there
330  * is one.
331  *
332  * PARAMS
333  * fccType [I] type of compressor (e.g. 'vidc')
334  * fccHandler [I] real fcc for handler or <n>th compressor
335  * lpicinfo [O] information about compressor
336  */
337 BOOL VFWAPI ICInfo( DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo)
338 {
339  TRACE("(%s,%s,%p)\n",
340  wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpicinfo);
341 
342  lpicinfo->fccType = fccType;
343  lpicinfo->fccHandler = fccHandler;
344  return enum_drivers(fccType, ICInfo_enum_handler, lpicinfo);
345 }
346 
347 static DWORD IC_HandleRef = 1;
348 
349 /***********************************************************************
350  * ICInstall [MSVFW32.@]
351  */
352 BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags)
353 {
355  unsigned len;
356 
357  TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
358 
359  /* Check if a driver is already registered */
360  for (driver = reg_driver_list; driver; driver = driver->next)
361  {
362  if (!compare_fourcc(fccType, driver->fccType) &&
363  !compare_fourcc(fccHandler, driver->fccHandler))
364  break;
365  }
366  if (driver) return FALSE;
367 
368  /* Register the driver */
370  if (!driver) goto oom;
371  driver->fccType = fccType;
372  driver->fccHandler = fccHandler;
373 
374  switch(wFlags)
375  {
376  case ICINSTALL_FUNCTION:
377  driver->proc = (DRIVERPROC)lParam;
378  driver->name = NULL;
379  break;
380  case ICINSTALL_DRIVER:
381  driver->proc = NULL;
382  len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0);
383  driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
384  if (!driver->name) goto oom;
385  MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len);
386  break;
387  default:
388  ERR("Invalid flags!\n");
390  return FALSE;
391  }
392 
393  /* Insert our driver in the list*/
394  driver->next = reg_driver_list;
396 
397  return TRUE;
398 oom:
400  return FALSE;
401 }
402 
403 /***********************************************************************
404  * ICRemove [MSVFW32.@]
405  */
406 BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags)
407 {
408  reg_driver** pdriver;
409  reg_driver* drv;
410 
411  TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
412 
413  /* Check if a driver is already registered */
414  for (pdriver = &reg_driver_list; *pdriver; pdriver = &(*pdriver)->next)
415  {
416  if (!compare_fourcc(fccType, (*pdriver)->fccType) &&
417  !compare_fourcc(fccHandler, (*pdriver)->fccHandler))
418  break;
419  }
420  if (!*pdriver)
421  return FALSE;
422 
423  /* Remove the driver from the list */
424  drv = *pdriver;
425  *pdriver = (*pdriver)->next;
426  HeapFree(GetProcessHeap(), 0, drv->name);
427  HeapFree(GetProcessHeap(), 0, drv);
428 
429  return TRUE;
430 }
431 
432 
433 /***********************************************************************
434  * ICOpen [MSVFW32.@]
435  * Opens an installable compressor. Return special handle.
436  */
437 HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
438 {
439  WCHAR codecname[10];
440  ICOPEN icopen;
441  HDRVR hdrv;
442  WINE_HIC* whic;
443  static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'};
445 
446  TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
447 
448  if (!fccHandler) /* No specific handler, return the first valid for wMode */
449  {
450  HIC local;
451  ICINFO info;
452  DWORD loop = 0;
453  info.dwSize = sizeof(info);
454  while(ICInfo(fccType, loop++, &info))
455  {
456  /* Ensure fccHandler is not 0x0 because we will recurse on ICOpen */
457  if(!info.fccHandler)
458  continue;
459  local = ICOpen(fccType, info.fccHandler, wMode);
460  if (local != 0)
461  {
462  TRACE("Returning %s as default handler for %s\n",
463  wine_dbgstr_fcc(info.fccHandler), wine_dbgstr_fcc(fccType));
464  return local;
465  }
466  }
467  }
468 
469  /* Check if there is a registered driver that matches */
471  while(driver)
472  if (!compare_fourcc(fccType, driver->fccType) &&
473  !compare_fourcc(fccHandler, driver->fccHandler)) {
474  fccType = driver->fccType;
475  fccHandler = driver->fccHandler;
476  break;
477  } else
478  driver = driver->next;
479 
480  if (driver && driver->proc)
481  /* The driver has been registered at runtime with its driverproc */
482  return ICOpenFunction(fccType, fccHandler, wMode, driver->proc);
483 
484  /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
485  * same layout as ICOPEN
486  */
487  icopen.dwSize = sizeof(ICOPEN);
488  icopen.fccType = fccType;
489  icopen.fccHandler = fccHandler;
490  icopen.dwVersion = 0x00001000; /* FIXME */
491  icopen.dwFlags = wMode;
492  icopen.dwError = 0;
493  icopen.pV1Reserved = NULL;
494  icopen.pV2Reserved = NULL;
495  icopen.dnDevNode = 0; /* FIXME */
496 
497  if (!driver) {
498  /* normalize to lower case as in 'vidc' */
499  ((char*)&fccType)[0] = tolower(((char*)&fccType)[0]);
500  ((char*)&fccType)[1] = tolower(((char*)&fccType)[1]);
501  ((char*)&fccType)[2] = tolower(((char*)&fccType)[2]);
502  ((char*)&fccType)[3] = tolower(((char*)&fccType)[3]);
503  icopen.fccType = fccType;
504  /* Seek the driver in the registry */
505  fourcc_to_string(codecname, fccType);
506  codecname[4] = '.';
507  fourcc_to_string(codecname + 5, fccHandler);
508  codecname[9] = '\0';
509 
510  hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
511  if (!hdrv)
512  return 0;
513  } else {
514  /* The driver has been registered at runtime with its name */
515  hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
516  if (!hdrv)
517  return 0;
518  }
519 
520  whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
521  if (!whic)
522  {
523  CloseDriver(hdrv, 0, 0);
524  return FALSE;
525  }
526  whic->hdrv = hdrv;
527  whic->driverproc = NULL;
528  whic->type = fccType;
529  whic->handler = fccHandler;
531  whic->hic = (HIC)(ULONG_PTR)IC_HandleRef++;
532  whic->next = MSVIDEO_FirstHic;
533  MSVIDEO_FirstHic = whic;
534 
535  TRACE("=> %p\n", whic->hic);
536  return whic->hic;
537 }
538 
539 /***********************************************************************
540  * ICOpenFunction [MSVFW32.@]
541  */
542 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPROC lpfnHandler)
543 {
544  ICOPEN icopen;
545  WINE_HIC* whic;
546 
547  TRACE("(%s,%s,%d,%p)\n",
548  wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode, lpfnHandler);
549 
550  icopen.dwSize = sizeof(ICOPEN);
551  icopen.fccType = fccType;
552  icopen.fccHandler = fccHandler;
553  icopen.dwVersion = ICVERSION;
554  icopen.dwFlags = wMode;
555  icopen.dwError = 0;
556  icopen.pV1Reserved = NULL;
557  icopen.pV2Reserved = NULL;
558  icopen.dnDevNode = 0; /* FIXME */
559 
560  whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC));
561  if (!whic) return 0;
562 
563  whic->driverproc = lpfnHandler;
565  whic->hic = (HIC)(ULONG_PTR)IC_HandleRef++;
566  whic->next = MSVIDEO_FirstHic;
567  MSVIDEO_FirstHic = whic;
568 
569  /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
570  /* What if the function is used more than once? */
571 
572  if (MSVIDEO_SendMessage(whic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS)
573  {
574  WARN("DRV_LOAD failed for hic %p\n", whic->hic);
575  MSVIDEO_FirstHic = whic->next;
576  HeapFree(GetProcessHeap(), 0, whic);
577  return 0;
578  }
579  /* return value is not checked */
580  MSVIDEO_SendMessage(whic, DRV_ENABLE, 0L, 0L);
581 
582  whic->driverId = (DWORD)MSVIDEO_SendMessage(whic, DRV_OPEN, 0, (DWORD_PTR)&icopen);
583  /* FIXME: What should we put here? */
584  whic->hdrv = NULL;
585 
586  if (whic->driverId == 0)
587  {
588  WARN("DRV_OPEN failed for hic %p\n", whic->hic);
589  MSVIDEO_FirstHic = whic->next;
590  HeapFree(GetProcessHeap(), 0, whic);
591  return 0;
592  }
593 
594  TRACE("=> %p\n", whic->hic);
595  return whic->hic;
596 }
597 
598 /***********************************************************************
599  * ICGetInfo [MSVFW32.@]
600  */
601 LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
602 {
603  LRESULT ret;
604  WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
605 
606  TRACE("(%p,%p,%d)\n", hic, picinfo, cb);
607 
608  if (!whic) return ICERR_BADHANDLE;
609  if (!picinfo) return MMSYSERR_INVALPARAM;
610 
611  /* (WS) The field szDriver should be initialized because the driver
612  * is not obliged and often will not do it. Some applications, like
613  * VirtualDub, rely on this field and will occasionally crash if it
614  * goes uninitialized.
615  */
616  if (cb >= sizeof(ICINFO)) picinfo->szDriver[0] = '\0';
617 
618  ret = ICSendMessage(hic, ICM_GETINFO, (DWORD_PTR)picinfo, cb);
619 
620  /* (WS) When szDriver was not supplied by the driver itself, apparently
621  * Windows will set its value equal to the driver file name. This can
622  * be obtained from the registry as we do here.
623  */
624  if (cb >= sizeof(ICINFO) && picinfo->szDriver[0] == 0)
625  {
626  ICINFO ii;
627 
628  memset(&ii, 0, sizeof(ii));
629  ii.dwSize = sizeof(ii);
630  ICInfo(picinfo->fccType, picinfo->fccHandler, &ii);
631  lstrcpyW(picinfo->szDriver, ii.szDriver);
632  }
633 
634  return ret;
635 }
636 
637 typedef struct {
644  HIC hic;
645 } driver_info_t;
646 
648 {
649  HIC hic;
650 
651  if ((hic = ICOpen(info->fccType, info->fccHandler, info->wMode)))
652  {
653  if (!ICSendMessage(hic, info->querymsg, (DWORD_PTR)info->lpbiIn, (DWORD_PTR)info->lpbiOut))
654  return hic;
655  ICClose(hic);
656  }
657  return 0;
658 }
659 
660 static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
661 {
663  info->fccHandler = mmioStringToFOURCCA(name + 5, 0);
664  info->hic = try_driver(info);
665  return info->hic != 0;
666 }
667 
668 /***********************************************************************
669  * ICLocate [MSVFW32.@]
670  */
671 HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
672  LPBITMAPINFOHEADER lpbiOut, WORD wMode)
673 {
675 
676  TRACE("(%s,%s,%p,%p,0x%04x)\n",
677  wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
678 
679  info.fccType = fccType;
680  info.fccHandler = fccHandler;
681  info.lpbiIn = lpbiIn;
682  info.lpbiOut = lpbiOut;
683  info.wMode = wMode;
684 
685  switch (wMode)
686  {
687  case ICMODE_FASTCOMPRESS:
688  case ICMODE_COMPRESS:
689  info.querymsg = ICM_COMPRESS_QUERY;
690  break;
692  case ICMODE_DECOMPRESS:
693  info.querymsg = ICM_DECOMPRESS_QUERY;
694  break;
695  case ICMODE_DRAW:
696  info.querymsg = ICM_DRAW_QUERY;
697  break;
698  default:
699  WARN("Unknown mode (%d)\n", wMode);
700  return 0;
701  }
702 
703  /* Easy case: handler/type match, we just fire a query and return */
704  info.hic = try_driver(&info);
705  /* If it didn't work, try each driver in turn. 32 bit codecs only. */
706  /* FIXME: Move this to an init routine? */
707  if (!info.hic) enum_drivers(fccType, ICLocate_enum_handler, &info);
708 
709  if (info.hic)
710  {
711  TRACE("=> %p\n", info.hic);
712  return info.hic;
713  }
714 
715  if (fccType == streamtypeVIDEO)
716  return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode);
717 
718  ERR("Required media codec '%s %s' not found!\n",
719  wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler));
720  return 0;
721 }
722 
723 /***********************************************************************
724  * ICGetDisplayFormat [MSVFW32.@]
725  */
727  int depth, int width, int height)
728 {
729  HIC tmphic = hic;
730 
731  TRACE("(%p, %p, %p, %d, %d, %d)\n", hic, in, out, depth, width, height);
732 
733  if (!tmphic)
734  {
736  if (!tmphic)
737  return NULL;
738  }
739 
740  if (ICDecompressQuery(tmphic, in, NULL))
741  goto err;
742 
743  if (width <= 0 || height <= 0)
744  {
745  width = in->biWidth;
746  height = in->biHeight;
747  }
748 
749  if (!depth)
750  depth = 32;
751 
752  *out = *in;
753  out->biSize = sizeof(*out);
754  out->biWidth = width;
755  out->biHeight = height;
756  out->biCompression = BI_RGB;
757  out->biSizeImage = get_size_image(width, height, depth);
758 
759  /* first try the given depth */
760  out->biBitCount = depth;
761  out->biSizeImage = get_size_image(width, height, out->biBitCount);
762  if (!ICDecompressQuery(tmphic, in, out))
763  {
764  if (depth == 8)
765  ICDecompressGetPalette(tmphic, in, out);
766  return tmphic;
767  }
768 
769  /* then try 16, both with BI_RGB and BI_BITFIELDS */
770  if (depth <= 16)
771  {
772  out->biBitCount = 16;
773  out->biSizeImage = get_size_image(width, height, out->biBitCount);
774  if (!ICDecompressQuery(tmphic, in, out))
775  return tmphic;
776 
777  out->biCompression = BI_BITFIELDS;
778  if (!ICDecompressQuery(tmphic, in, out))
779  return tmphic;
780  out->biCompression = BI_RGB;
781  }
782 
783  /* then try 24 */
784  if (depth <= 24)
785  {
786  out->biBitCount = 24;
787  out->biSizeImage = get_size_image(width, height, out->biBitCount);
788  if (!ICDecompressQuery(tmphic, in, out))
789  return tmphic;
790  }
791 
792  /* then try 32 */
793  if (depth <= 32)
794  {
795  out->biBitCount = 32;
796  out->biSizeImage = get_size_image(width, height, out->biBitCount);
797  if (!ICDecompressQuery(tmphic, in, out))
798  return tmphic;
799  }
800 
801  /* as a last resort, try 32 bpp with the original width and height */
802  out->biWidth = in->biWidth;
803  out->biHeight = in->biHeight;
804  out->biBitCount = 32;
805  out->biSizeImage = get_size_image(out->biWidth, out->biHeight, out->biBitCount);
806  if (!ICDecompressQuery(tmphic, in, out))
807  return tmphic;
808 
809  /* finally, ask the compressor for its default output format */
811  return tmphic;
812 
813 err:
814  if (hic != tmphic)
815  ICClose(tmphic);
816 
817  return NULL;
818 }
819 
820 /***********************************************************************
821  * ICCompress [MSVFW32.@]
822  */
825  HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
826  LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
827  LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
828  LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
829 {
830  ICCOMPRESS iccmp;
831 
832  TRACE("(%p,%d,%p,%p,%p,%p,...)\n",hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
833 
834  iccmp.dwFlags = dwFlags;
835 
836  iccmp.lpbiOutput = lpbiOutput;
837  iccmp.lpOutput = lpData;
838  iccmp.lpbiInput = lpbiInput;
839  iccmp.lpInput = lpBits;
840 
841  iccmp.lpckid = lpckid;
842  iccmp.lpdwFlags = lpdwFlags;
843  iccmp.lFrameNum = lFrameNum;
844  iccmp.dwFrameSize = dwFrameSize;
845  iccmp.dwQuality = dwQuality;
846  iccmp.lpbiPrev = lpbiPrev;
847  iccmp.lpPrev = lpPrev;
848  return ICSendMessage(hic,ICM_COMPRESS,(DWORD_PTR)&iccmp,sizeof(iccmp));
849 }
850 
851 /***********************************************************************
852  * ICDecompress [MSVFW32.@]
853  */
855  LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
856 {
857  ICDECOMPRESS icd;
858  DWORD ret;
859 
860  TRACE("(%p,%d,%p,%p,%p,%p)\n",hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
861 
862  icd.dwFlags = dwFlags;
863  icd.lpbiInput = lpbiFormat;
864  icd.lpInput = lpData;
865 
866  icd.lpbiOutput = lpbi;
867  icd.lpOutput = lpBits;
868  icd.ckid = 0;
870 
871  return ret;
872 }
873 
874 
876 {
880 };
881 
883 {
884  HIC hic;
886 };
887 
888 static BOOL enum_compressors(HWND list, COMPVARS *pcv, BOOL enum_all)
889 {
890  UINT id, total = 0;
891  ICINFO icinfo;
892 
893  id = 0;
894 
895  while (ICInfo(pcv->fccType, id, &icinfo))
896  {
897  struct codec_info *ic;
898  DWORD idx;
899  HIC hic;
900 
901  id++;
902 
904 
905  if (hic)
906  {
907  /* for unknown reason fccHandler reported by the driver
908  * doesn't always work, use the one returned by ICInfo instead.
909  */
910  DWORD fccHandler = icinfo.fccHandler;
911 
912  if (!enum_all && pcv->lpbiIn)
913  {
914  if (ICCompressQuery(hic, pcv->lpbiIn, NULL) != ICERR_OK)
915  {
916  TRACE("fccHandler %s doesn't support input DIB format %d\n",
918  ICClose(hic);
919  continue;
920  }
921  }
922 
923  ICGetInfo(hic, &icinfo, sizeof(icinfo));
924  icinfo.fccHandler = fccHandler;
925 
927 
928  ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info));
929  ic->icinfo = icinfo;
930  ic->hic = hic;
932  }
933  total++;
934  }
935 
936  return total != 0;
937 }
938 
940 {
941  switch (msg)
942  {
943  case WM_INITDIALOG:
944  {
945  struct codec_info *ic;
946  WCHAR buf[128];
947  struct choose_compressor *choose_comp = (struct choose_compressor *)lparam;
948 
950 
951  /* FIXME */
952  choose_comp->flags &= ~(ICMF_CHOOSE_DATARATE | ICMF_CHOOSE_KEYFRAME);
953 
954  if (choose_comp->title)
955  SetWindowTextA(hdlg, choose_comp->title);
956 
957  if (!(choose_comp->flags & ICMF_CHOOSE_DATARATE))
958  {
962  }
963 
964  if (!(choose_comp->flags & ICMF_CHOOSE_KEYFRAME))
965  {
969  }
970 
971  /* FIXME */
974 
975  /*if (!(choose_comp->flags & ICMF_CHOOSE_PREVIEW))
976  ShowWindow(GetDlgItem(hdlg, IDC_PREVIEW), SW_HIDE);*/
977 
980 
981  ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info));
984  ic->hic = 0;
986 
987  enum_compressors(GetDlgItem(hdlg, IDC_COMP_LIST), &choose_comp->cv, choose_comp->flags & ICMF_CHOOSE_ALLCOMPRESSORS);
988 
991 
992  SetWindowLongPtrW(hdlg, DWLP_USER, (ULONG_PTR)choose_comp);
993  break;
994  }
995 
996  case WM_COMMAND:
997  switch (LOWORD(wparam))
998  {
999  case IDC_COMP_LIST:
1000  {
1001  INT cur_sel;
1002  struct codec_info *ic;
1003  BOOL can_configure = FALSE, can_about = FALSE;
1004  struct choose_compressor *choose_comp;
1005 
1007  break;
1008 
1009  choose_comp = (struct choose_compressor *)GetWindowLongPtrW(hdlg, DWLP_USER);
1010 
1011  cur_sel = SendMessageW((HWND)lparam, CB_GETCURSEL, 0, 0);
1012 
1013  ic = (struct codec_info *)SendMessageW((HWND)lparam, CB_GETITEMDATA, cur_sel, 0);
1014  if (ic && ic->hic)
1015  {
1016  if (ICQueryConfigure(ic->hic) == DRVCNF_OK)
1017  can_configure = TRUE;
1018  if (ICQueryAbout(ic->hic) == DRVCNF_OK)
1019  can_about = TRUE;
1020  }
1021  EnableWindow(GetDlgItem(hdlg, IDC_CONFIGURE), can_configure);
1022  EnableWindow(GetDlgItem(hdlg, IDC_ABOUT), can_about);
1023 
1024  if (choose_comp->flags & ICMF_CHOOSE_DATARATE)
1025  {
1026  /* FIXME */
1027  }
1028  if (choose_comp->flags & ICMF_CHOOSE_KEYFRAME)
1029  {
1030  /* FIXME */
1031  }
1032 
1033  break;
1034  }
1035 
1036  case IDC_CONFIGURE:
1037  case IDC_ABOUT:
1038  {
1039  HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
1040  INT cur_sel;
1041  struct codec_info *ic;
1042 
1043  if (HIWORD(wparam) != BN_CLICKED)
1044  break;
1045 
1046  cur_sel = SendMessageW(list, CB_GETCURSEL, 0, 0);
1047 
1048  ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, cur_sel, 0);
1049  if (ic && ic->hic)
1050  {
1051  if (LOWORD(wparam) == IDC_CONFIGURE)
1052  ICConfigure(ic->hic, hdlg);
1053  else
1054  ICAbout(ic->hic, hdlg);
1055  }
1056 
1057  break;
1058  }
1059 
1060  case IDOK:
1061  {
1062  HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
1063  INT cur_sel;
1064  struct codec_info *ic;
1065 
1066  if (HIWORD(wparam) != BN_CLICKED)
1067  break;
1068 
1069  cur_sel = SendMessageW(list, CB_GETCURSEL, 0, 0);
1070  ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, cur_sel, 0);
1071  if (ic)
1072  {
1073  struct choose_compressor *choose_comp = (struct choose_compressor *)GetWindowLongPtrW(hdlg, DWLP_USER);
1074 
1075  choose_comp->cv.hic = ic->hic;
1076  choose_comp->cv.fccType = ic->icinfo.fccType;
1077  choose_comp->cv.fccHandler = ic->icinfo.fccHandler;
1078  /* FIXME: fill everything else */
1079 
1080  /* prevent closing the codec handle below */
1081  ic->hic = 0;
1082  }
1083  }
1084  /* fall through */
1085  case IDCANCEL:
1086  {
1087  HWND list = GetDlgItem(hdlg, IDC_COMP_LIST);
1088  INT idx = 0;
1089 
1090  if (HIWORD(wparam) != BN_CLICKED)
1091  break;
1092 
1093  while (1)
1094  {
1095  struct codec_info *ic;
1096 
1097  ic = (struct codec_info *)SendMessageW(list, CB_GETITEMDATA, idx++, 0);
1098 
1099  if (!ic || (LONG_PTR)ic == CB_ERR) break;
1100 
1101  if (ic->hic) ICClose(ic->hic);
1102  HeapFree(GetProcessHeap(), 0, ic);
1103  }
1104 
1105  EndDialog(hdlg, LOWORD(wparam) == IDOK);
1106  break;
1107  }
1108 
1109  default:
1110  break;
1111  }
1112  break;
1113 
1114  default:
1115  break;
1116  }
1117 
1118  return FALSE;
1119 }
1120 
1121 /***********************************************************************
1122  * ICCompressorChoose [MSVFW32.@]
1123  */
1125  LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle)
1126 {
1127  struct choose_compressor choose_comp;
1128  BOOL ret;
1129 
1130  TRACE("(%p,%08x,%p,%p,%p,%s)\n", hwnd, uiFlags, pvIn, lpData, pc, lpszTitle);
1131 
1132  if (!pc || pc->cbSize != sizeof(COMPVARS))
1133  return FALSE;
1134 
1135  if (!(pc->dwFlags & ICMF_COMPVARS_VALID))
1136  {
1137  pc->dwFlags = 0;
1138  pc->fccType = pc->fccHandler = 0;
1139  pc->hic = NULL;
1140  pc->lpbiIn = NULL;
1141  pc->lpbiOut = NULL;
1142  pc->lpBitsOut = pc->lpBitsPrev = pc->lpState = NULL;
1143  pc->lQ = ICQUALITY_DEFAULT;
1144  pc->lKey = -1;
1145  pc->lDataRate = 300; /* kB */
1146  pc->lpState = NULL;
1147  pc->cbState = 0;
1148  }
1149  if (pc->fccType == 0)
1150  pc->fccType = ICTYPE_VIDEO;
1151 
1152  choose_comp.cv = *pc;
1153  choose_comp.flags = uiFlags;
1154  choose_comp.title = lpszTitle;
1155 
1157  icm_choose_compressor_dlgproc, (LPARAM)&choose_comp);
1158 
1159  if (ret)
1160  {
1161  *pc = choose_comp.cv;
1163  }
1164 
1165  return ret;
1166 }
1167 
1168 
1169 /***********************************************************************
1170  * ICCompressorFree [MSVFW32.@]
1171  */
1173 {
1174  TRACE("(%p)\n",pc);
1175 
1176  if (pc != NULL && pc->cbSize == sizeof(COMPVARS)) {
1177  if (pc->hic != NULL) {
1178  ICClose(pc->hic);
1179  pc->hic = NULL;
1180  }
1181  HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1182  pc->lpbiIn = NULL;
1183  HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
1184  pc->lpBitsOut = NULL;
1185  HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1186  pc->lpBitsPrev = NULL;
1187  HeapFree(GetProcessHeap(), 0, pc->lpState);
1188  pc->lpState = NULL;
1189  pc->dwFlags = 0;
1190  }
1191 }
1192 
1193 /***********************************************************************
1194  * ICSendMessage [MSVFW32.@]
1195  */
1197 {
1198  WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
1199 
1200  if (!whic) return ICERR_BADHANDLE;
1201  return MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
1202 }
1203 
1204 /***********************************************************************
1205  * ICDrawBegin [MSVFW32.@]
1206  */
1208  HIC hic, /* [in] */
1209  DWORD dwFlags, /* [in] flags */
1210  HPALETTE hpal, /* [in] palette to draw with */
1211  HWND hwnd, /* [in] window to draw to */
1212  HDC hdc, /* [in] HDC to draw to */
1213  INT xDst, /* [in] destination rectangle */
1214  INT yDst, /* [in] */
1215  INT dxDst, /* [in] */
1216  INT dyDst, /* [in] */
1217  LPBITMAPINFOHEADER lpbi, /* [in] format of frame to draw */
1218  INT xSrc, /* [in] source rectangle */
1219  INT ySrc, /* [in] */
1220  INT dxSrc, /* [in] */
1221  INT dySrc, /* [in] */
1222  DWORD dwRate, /* [in] frames/second = (dwRate/dwScale) */
1223  DWORD dwScale) /* [in] */
1224 {
1225 
1226  ICDRAWBEGIN icdb;
1227 
1228  TRACE("(%p,%d,%p,%p,%p,%u,%u,%u,%u,%p,%u,%u,%u,%u,%d,%d)\n",
1229  hic, dwFlags, hpal, hwnd, hdc, xDst, yDst, dxDst, dyDst,
1230  lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
1231 
1232  icdb.dwFlags = dwFlags;
1233  icdb.hpal = hpal;
1234  icdb.hwnd = hwnd;
1235  icdb.hdc = hdc;
1236  icdb.xDst = xDst;
1237  icdb.yDst = yDst;
1238  icdb.dxDst = dxDst;
1239  icdb.dyDst = dyDst;
1240  icdb.lpbi = lpbi;
1241  icdb.xSrc = xSrc;
1242  icdb.ySrc = ySrc;
1243  icdb.dxSrc = dxSrc;
1244  icdb.dySrc = dySrc;
1245  icdb.dwRate = dwRate;
1246  icdb.dwScale = dwScale;
1247  return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD_PTR)&icdb,sizeof(icdb));
1248 }
1249 
1250 /***********************************************************************
1251  * ICDraw [MSVFW32.@]
1252  */
1253 DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
1254  ICDRAW icd;
1255 
1256  TRACE("(%p,%d,%p,%p,%d,%d)\n",hic,dwFlags,lpFormat,lpData,cbData,lTime);
1257 
1258  icd.dwFlags = dwFlags;
1259  icd.lpFormat = lpFormat;
1260  icd.lpData = lpData;
1261  icd.cbData = cbData;
1262  icd.lTime = lTime;
1263 
1264  return ICSendMessage(hic,ICM_DRAW,(DWORD_PTR)&icd,sizeof(icd));
1265 }
1266 
1267 /***********************************************************************
1268  * ICClose [MSVFW32.@]
1269  */
1271 {
1272  WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
1273  WINE_HIC** p;
1274 
1275  TRACE("(%p)\n",hic);
1276 
1277  if (!whic) return ICERR_BADHANDLE;
1278 
1279  if (whic->driverproc)
1280  {
1281  MSVIDEO_SendMessage(whic, DRV_CLOSE, 0, 0);
1282  MSVIDEO_SendMessage(whic, DRV_DISABLE, 0, 0);
1283  MSVIDEO_SendMessage(whic, DRV_FREE, 0, 0);
1284  }
1285  else
1286  {
1287  CloseDriver(whic->hdrv, 0, 0);
1288  }
1289 
1290  /* remove whic from list */
1291  for (p = &MSVIDEO_FirstHic; *p != NULL; p = &((*p)->next))
1292  {
1293  if ((*p) == whic)
1294  {
1295  *p = whic->next;
1296  break;
1297  }
1298  }
1299 
1300  HeapFree(GetProcessHeap(), 0, whic);
1301  return 0;
1302 }
1303 
1304 
1305 
1306 /***********************************************************************
1307  * ICImageCompress [MSVFW32.@]
1308  */
1310  HIC hic, UINT uiFlags,
1311  LPBITMAPINFO lpbiIn, LPVOID lpBits,
1312  LPBITMAPINFO lpbiOut, LONG lQuality,
1313  LONG* plSize)
1314 {
1315  FIXME("(%p,%08x,%p,%p,%p,%d,%p)\n",
1316  hic, uiFlags, lpbiIn, lpBits, lpbiOut, lQuality, plSize);
1317 
1318  return NULL;
1319 }
1320 
1321 /***********************************************************************
1322  * ICImageDecompress [MSVFW32.@]
1323  */
1324 
1326  HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn,
1327  LPVOID lpBits, LPBITMAPINFO lpbiOut)
1328 {
1329  HGLOBAL hMem = NULL;
1330  BYTE* pMem = NULL;
1331  BOOL bReleaseIC = FALSE;
1332  BYTE* pHdr = NULL;
1333  ULONG cbHdr = 0;
1334  BOOL bSucceeded = FALSE;
1335  BOOL bInDecompress = FALSE;
1336  DWORD biSizeImage;
1337 
1338  TRACE("(%p,%08x,%p,%p,%p)\n",
1339  hic, uiFlags, lpbiIn, lpBits, lpbiOut);
1340 
1341  if ( hic == NULL )
1342  {
1343  hic = ICDecompressOpen( ICTYPE_VIDEO, 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL );
1344  if ( hic == NULL )
1345  {
1346  WARN("no handler\n" );
1347  goto err;
1348  }
1349  bReleaseIC = TRUE;
1350  }
1351  if ( uiFlags != 0 )
1352  {
1353  FIXME( "unknown flag %08x\n", uiFlags );
1354  goto err;
1355  }
1356  if ( lpbiIn == NULL || lpBits == NULL )
1357  {
1358  WARN("invalid argument\n");
1359  goto err;
1360  }
1361 
1362  if ( lpbiOut != NULL )
1363  {
1364  if ( lpbiOut->bmiHeader.biSize != sizeof(BITMAPINFOHEADER) )
1365  goto err;
1366  cbHdr = sizeof(BITMAPINFOHEADER);
1367  if ( lpbiOut->bmiHeader.biCompression == 3 )
1368  cbHdr += sizeof(DWORD)*3;
1369  else
1370  if ( lpbiOut->bmiHeader.biBitCount <= 8 )
1371  {
1372  if ( lpbiOut->bmiHeader.biClrUsed == 0 )
1373  cbHdr += sizeof(RGBQUAD) * (1<<lpbiOut->bmiHeader.biBitCount);
1374  else
1375  cbHdr += sizeof(RGBQUAD) * lpbiOut->bmiHeader.biClrUsed;
1376  }
1377  }
1378  else
1379  {
1380  TRACE( "get format\n" );
1381 
1382  cbHdr = ICDecompressGetFormatSize(hic,lpbiIn);
1383  if ( cbHdr < sizeof(BITMAPINFOHEADER) )
1384  goto err;
1385  pHdr = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,cbHdr+sizeof(RGBQUAD)*256);
1386  if ( pHdr == NULL )
1387  goto err;
1388  if ( ICDecompressGetFormat( hic, lpbiIn, pHdr ) != ICERR_OK )
1389  goto err;
1390  lpbiOut = (BITMAPINFO*)pHdr;
1391  if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1392  ICDecompressGetPalette( hic, lpbiIn, lpbiOut ) != ICERR_OK &&
1393  lpbiIn->bmiHeader.biBitCount == lpbiOut->bmiHeader.biBitCount )
1394  {
1395  if ( lpbiIn->bmiHeader.biClrUsed == 0 )
1396  memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*(1<<lpbiOut->bmiHeader.biBitCount) );
1397  else
1398  memcpy( lpbiOut->bmiColors, lpbiIn->bmiColors, sizeof(RGBQUAD)*lpbiIn->bmiHeader.biClrUsed );
1399  }
1400  if ( lpbiOut->bmiHeader.biBitCount <= 8 &&
1401  lpbiOut->bmiHeader.biClrUsed == 0 )
1402  lpbiOut->bmiHeader.biClrUsed = 1<<lpbiOut->bmiHeader.biBitCount;
1403 
1404  lpbiOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1405  cbHdr = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*lpbiOut->bmiHeader.biClrUsed;
1406  }
1407 
1408  biSizeImage = lpbiOut->bmiHeader.biSizeImage;
1409  if ( biSizeImage == 0 )
1410  biSizeImage = get_size_image(lpbiOut->bmiHeader.biWidth, lpbiOut->bmiHeader.biHeight, lpbiOut->bmiHeader.biBitCount);
1411 
1412  TRACE( "call ICDecompressBegin\n" );
1413 
1414  if ( ICDecompressBegin( hic, lpbiIn, lpbiOut ) != ICERR_OK )
1415  goto err;
1416  bInDecompress = TRUE;
1417 
1418  TRACE( "cbHdr %d, biSizeImage %d\n", cbHdr, biSizeImage );
1419 
1420  hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, cbHdr + biSizeImage );
1421  if ( hMem == NULL )
1422  {
1423  WARN( "out of memory\n" );
1424  goto err;
1425  }
1426  pMem = GlobalLock( hMem );
1427  if ( pMem == NULL )
1428  goto err;
1429  memcpy( pMem, lpbiOut, cbHdr );
1430 
1431  TRACE( "call ICDecompress\n" );
1432  if ( ICDecompress( hic, 0, &lpbiIn->bmiHeader, lpBits, &lpbiOut->bmiHeader, pMem+cbHdr ) != ICERR_OK )
1433  goto err;
1434 
1435  bSucceeded = TRUE;
1436 err:
1437  if ( bInDecompress )
1438  ICDecompressEnd( hic );
1439  if ( bReleaseIC )
1440  ICClose(hic);
1441  HeapFree(GetProcessHeap(),0,pHdr);
1442  if ( pMem != NULL )
1443  GlobalUnlock( hMem );
1444  if ( !bSucceeded && hMem != NULL )
1445  {
1446  GlobalFree(hMem); hMem = NULL;
1447  }
1448 
1449  return hMem;
1450 }
1451 
1452 /***********************************************************************
1453  * ICSeqCompressFrame [MSVFW32.@]
1454  */
1455 LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL *pfKey, LONG *plSize)
1456 {
1457  ICCOMPRESS* icComp = pc->lpState;
1458  DWORD ret;
1459  TRACE("(%p, 0x%08x, %p, %p, %p)\n", pc, uiFlags, lpBits, pfKey, plSize);
1460 
1461  if (pc->cbState != sizeof(ICCOMPRESS))
1462  {
1463  ERR("Invalid cbState %i\n", pc->cbState);
1464  return NULL;
1465  }
1466 
1467  if (!pc->lKeyCount++)
1468  icComp->dwFlags = ICCOMPRESS_KEYFRAME;
1469  else
1470  {
1471  if (pc->lKey && pc->lKeyCount == (pc->lKey - 1))
1472  /* No key frames if pc->lKey == 0 */
1473  pc->lKeyCount = 0;
1474  icComp->dwFlags = 0;
1475  }
1476 
1477  icComp->lpInput = lpBits;
1478  icComp->lFrameNum = pc->lFrame++;
1479  icComp->lpOutput = pc->lpBitsOut;
1480  icComp->lpPrev = pc->lpBitsPrev;
1481  ret = ICSendMessage(pc->hic, ICM_COMPRESS, (DWORD_PTR)icComp, sizeof(*icComp));
1482 
1483  if (ret == ICERR_OK)
1484  {
1485  LPVOID oldprev, oldout;
1486 
1487  if (icComp->dwFlags & AVIIF_KEYFRAME)
1488  {
1489  pc->lKeyCount = 1;
1490  *pfKey = TRUE;
1491  TRACE("Key frame\n");
1492  }
1493  else
1494  *pfKey = FALSE;
1495 
1496  *plSize = icComp->lpbiOutput->biSizeImage;
1497 
1498  /* We shift Prev and Out, so we don't have to allocate and release memory */
1499  oldprev = pc->lpBitsPrev;
1500  oldout = pc->lpBitsOut;
1501  pc->lpBitsPrev = oldout;
1502  pc->lpBitsOut = oldprev;
1503 
1504  TRACE("returning: %p, compressed frame size %u\n", icComp->lpOutput, *plSize);
1505  return icComp->lpOutput;
1506  }
1507  return NULL;
1508 }
1509 
1510 static void clear_compvars(PCOMPVARS pc)
1511 {
1512  HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
1513  HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
1514  HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
1515  HeapFree(GetProcessHeap(), 0, pc->lpState);
1516  pc->lpbiIn = pc->lpBitsPrev = pc->lpBitsOut = pc->lpState = NULL;
1517  if (pc->dwFlags & 0x80000000)
1518  {
1519  HeapFree(GetProcessHeap(), 0, pc->lpbiOut);
1520  pc->lpbiOut = NULL;
1521  pc->dwFlags &= ~0x80000000;
1522  }
1523 }
1524 
1525 /***********************************************************************
1526  * ICSeqCompressFrameEnd [MSVFW32.@]
1527  */
1529 {
1530  TRACE("(%p)\n", pc);
1531  ICSendMessage(pc->hic, ICM_COMPRESS_END, 0, 0);
1532  clear_compvars(pc);
1533 }
1534 
1535 /***********************************************************************
1536  * ICSeqCompressFrameStart [MSVFW32.@]
1537  */
1539 {
1540  /* I'm ignoring bmiColors as I don't know what to do with it,
1541  * it doesn't appear to be used though
1542  */
1543  DWORD ret;
1544  ICCOMPRESS* icComp;
1545  pc->lpbiIn = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFO));
1546  if (!pc->lpbiIn)
1547  return FALSE;
1548 
1549  *pc->lpbiIn = *lpbiIn;
1550 
1551  pc->lpState = HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS)
1552  + sizeof(*icComp->lpckid) + sizeof(*icComp->lpdwFlags));
1553  if (!pc->lpState)
1554  goto error;
1555 
1556  pc->cbState = sizeof(ICCOMPRESS);
1557 
1558  if (!pc->lpbiOut)
1559  {
1560  /* Ask compressor for needed header size */
1562  (DWORD_PTR)pc->lpbiIn, 0);
1563  if (size <= 0)
1564  goto error;
1565 
1567  if (!pc->lpbiOut)
1568  goto error;
1569  /* Flag to show that we allocated lpbiOut for proper cleanup */
1570  pc->dwFlags |= 0x80000000;
1571 
1573  (DWORD_PTR)pc->lpbiIn, (DWORD_PTR)pc->lpbiOut);
1574  if (ret != ICERR_OK)
1575  {
1576  ERR("Could not get output format from compressor\n");
1577  goto error;
1578  }
1579  if (!pc->lpbiOut->bmiHeader.biSizeImage)
1580  {
1581  /* If we can't know the output frame size for sure at least allocate
1582  * the same size of the input frame and also at least 8Kb to be sure
1583  * that poor compressors will have enough memory to work if the input
1584  * frame is too small.
1585  */
1587  ERR("Bad codec! Invalid output frame size, guessing from input\n");
1588  }
1589  }
1590 
1591  TRACE("Input: %ux%u, fcc %s, bpp %u, size %u\n",
1596  TRACE("Output: %ux%u, fcc %s, bpp %u, size %u\n",
1601 
1602  /* Buffer for compressed frame data */
1604  if (!pc->lpBitsOut)
1605  goto error;
1606 
1607  /* Buffer for previous compressed frame data */
1609  if (!pc->lpBitsPrev)
1610  goto error;
1611 
1612  TRACE("Compvars:\n"
1613  "\tsize: %i\n"
1614  "\tflags: 0x%x\n"
1615  "\thic: %p\n"
1616  "\ttype: %s\n"
1617  "\thandler: %s\n"
1618  "\tin/out: %p/%p\n"
1619  "\tkey/data/quality: %i/%i/%i\n",
1620  pc->cbSize, pc->dwFlags, pc->hic, wine_dbgstr_fcc(pc->fccType),
1621  wine_dbgstr_fcc(pc->fccHandler), pc->lpbiIn, pc->lpbiOut, pc->lKey,
1622  pc->lDataRate, pc->lQ);
1623 
1625  if (ret == ICERR_OK)
1626  {
1627  icComp = pc->lpState;
1628  /* Initialise some variables */
1629  pc->lFrame = 0; pc->lKeyCount = 0;
1630 
1631  icComp->lpbiOutput = &pc->lpbiOut->bmiHeader;
1632  icComp->lpbiInput = &pc->lpbiIn->bmiHeader;
1633  icComp->lpckid = (DWORD *)(icComp + 1);
1634  *icComp->lpckid = 0;
1635  icComp->lpdwFlags = (DWORD *)((char *)(icComp + 1) + sizeof(*icComp->lpckid));
1636  *icComp->lpdwFlags = 0;
1637  icComp->dwFrameSize = 0;
1638  icComp->dwQuality = pc->lQ;
1639  icComp->lpbiPrev = &pc->lpbiIn->bmiHeader;
1640  return TRUE;
1641  }
1642 error:
1643  clear_compvars(pc);
1644  return FALSE;
1645 }
1646 
1647 /***********************************************************************
1648  * GetFileNamePreview [MSVFW32.@]
1649  */
1650 static BOOL GetFileNamePreview(LPVOID lpofn,BOOL bSave,BOOL bUnicode)
1651 {
1652  CHAR szFunctionName[20];
1653  BOOL (*fnGetFileName)(LPVOID);
1654  HMODULE hComdlg32;
1655  BOOL ret;
1656 
1657  FIXME("(%p,%d,%d), semi-stub!\n",lpofn,bSave,bUnicode);
1658 
1659  lstrcpyA(szFunctionName, (bSave ? "GetSaveFileName" : "GetOpenFileName"));
1660  lstrcatA(szFunctionName, (bUnicode ? "W" : "A"));
1661 
1662  hComdlg32 = LoadLibraryA("COMDLG32.DLL");
1663  if (hComdlg32 == NULL)
1664  return FALSE;
1665 
1666  fnGetFileName = (LPVOID)GetProcAddress(hComdlg32, szFunctionName);
1667  if (fnGetFileName == NULL)
1668  {
1669  FreeLibrary(hComdlg32);
1670  return FALSE;
1671  }
1672 
1673  /* FIXME: need to add OFN_ENABLEHOOK and our own handler */
1674  ret = fnGetFileName(lpofn);
1675 
1676  FreeLibrary(hComdlg32);
1677  return ret;
1678 }
1679 
1680 /***********************************************************************
1681  * GetOpenFileNamePreviewA [MSVFW32.@]
1682  */
1684 {
1685  FIXME("(%p), semi-stub!\n", lpofn);
1686 
1687  return GetFileNamePreview(lpofn, FALSE, FALSE);
1688 }
1689 
1690 /***********************************************************************
1691  * GetOpenFileNamePreviewW [MSVFW32.@]
1692  */
1694 {
1695  FIXME("(%p), semi-stub!\n", lpofn);
1696 
1697  return GetFileNamePreview(lpofn, FALSE, TRUE);
1698 }
1699 
1700 /***********************************************************************
1701  * GetSaveFileNamePreviewA [MSVFW32.@]
1702  */
1704 {
1705  FIXME("(%p), semi-stub!\n", lpofn);
1706 
1707  return GetFileNamePreview(lpofn, TRUE, FALSE);
1708 }
1709 
1710 /***********************************************************************
1711  * GetSaveFileNamePreviewW [MSVFW32.@]
1712  */
1714 {
1715  FIXME("(%p), semi-stub!\n", lpofn);
1716 
1717  return GetFileNamePreview(lpofn, TRUE, TRUE);
1718 }
#define ICM_DECOMPRESSEX_QUERY
Definition: vfw.h:139
INT yDst
Definition: vfw.h:700
LRESULT(CALLBACK * DRIVERPROC)(DWORD_PTR, HDRVR, UINT, LPARAM, LPARAM)
Definition: mmsystem.h:1001
#define DRV_DISABLE
Definition: mmsystem.h:123
#define ICM_DECOMPRESSEX_BEGIN
Definition: vfw.h:138
#define CBN_SETFOCUS
Definition: winuser.h:1964
#define abs(i)
Definition: fconv.c:206
#define ICDecompressEnd(hic)
Definition: vfw.h:404
#define ICMF_CHOOSE_ALLCOMPRESSORS
Definition: vfw.h:851
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:131
#define CB_SETITEMDATA
Definition: winuser.h:1948
#define ICM_GETQUALITY
Definition: vfw.h:89
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD dwVersion
Definition: vfw.h:285
GLint GLint GLsizei width
Definition: gl.h:1546
#define isspace(c)
Definition: acclib.h:69
#define max(a, b)
Definition: svc.c:63
static LRESULT MSVIDEO_SendMessage(WINE_HIC *whic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2)
Definition: msvideo_main.c:136
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
Definition: msvideo_main.c:437
LPBITMAPINFOHEADER lpbiInput
Definition: vfw.h:176
#define IDOK
Definition: winuser.h:824
DWORD cbData
Definition: vfw.h:722
#define ICM_DRAW_START
Definition: vfw.h:117
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define ICM_COMPRESS_BEGIN
Definition: vfw.h:102
static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
Definition: msvideo_main.c:306
LONG lKeyCount
Definition: vfw.h:831
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
#define ICM_ABOUT
Definition: vfw.h:85
#define ICVERSION
Definition: vfw.h:45
DWORD dwSize
Definition: vfw.h:281
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ICM_GET
Definition: vfw.h:93
LPBITMAPINFOHEADER lpbi
Definition: vfw.h:703
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
DWORD dwFlags
Definition: vfw.h:284
ULONG nr
Definition: thread.c:7
#define ICCOMPRESS_KEYFRAME
Definition: vfw.h:170
DWORD dnDevNode
Definition: vfw.h:166
#define ICDecompressQuery(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:377
LRESULT dwError
Definition: vfw.h:163
#define ICM_DECOMPRESS_SET_PALETTE
Definition: vfw.h:111
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
LPVOID lpFormat
Definition: vfw.h:720
LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2)
#define SW_HIDE
Definition: winuser.h:762
#define CP_ACP
Definition: compat.h:99
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define CB_GETITEMDATA
Definition: winuser.h:1932
char CHAR
Definition: xmlstorage.h:175
#define ICM_GETDEFAULTQUALITY
Definition: vfw.h:88
#define WARN(fmt,...)
Definition: debug.h:111
static const char * wine_dbgstr_icerr(int ret)
Definition: msvideo_main.c:69
#define ICM_DECOMPRESSEX_END
Definition: vfw.h:141
struct tagWINE_HIC * next
static HDC
Definition: imagelist.c:92
LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:462
#define CALLBACK
Definition: compat.h:27
LPBITMAPINFOHEADER lpbiInput
Definition: vfw.h:335
#define AVIIF_KEYFRAME
Definition: aviriff.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HWND hwnd
Definition: vfw.h:697
#define IDC_KEYFRAME
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
static reg_driver * reg_driver_list
Definition: msvideo_main.c:113
#define DRV_CLOSE
Definition: mmsystem.h:122
HWND WINAPI SetFocus(_In_opt_ HWND)
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define ICMF_COMPVARS_VALID
Definition: vfw.h:836
DWORD fccHandler
Definition: msvideo_main.c:107
DRIVERPROC driverproc
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4730
static WINE_HIC * MSVIDEO_FirstHic
Definition: msvideo_main.c:101
#define ICERR_OK
Definition: vfw.h:50
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define ICDecompressGetFormat(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:383
int32_t INT_PTR
Definition: typedefs.h:62
#define DRVCNF_OK
Definition: mmsystem.h:134
DWORD fccType
Definition: vfw.h:159
_Check_return_ _CRTIMP int __cdecl isalnum(_In_ int _C)
HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
Definition: driver.c:400
char * LPSTR
Definition: xmlstorage.h:182
DWORD dwSize
Definition: vfw.h:158
DWORD ckid
Definition: vfw.h:339
BOOL VFWAPI ICInfo(DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo)
Definition: msvideo_main.c:337
#define BOOL
Definition: nt_native.h:43
#define ICERR_MEMORY
Definition: vfw.h:58
#define ICM_COMPRESS_QUERY
Definition: vfw.h:101
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD dwRate
Definition: vfw.h:708
#define CB_GETCURSEL
Definition: winuser.h:1925
#define ICM_GETINFO
Definition: vfw.h:82
WCHAR szDriver[128]
Definition: vfw.h:292
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define IDC_QUALITY_SCROLL
HMODULE MSVFW32_hModule
Definition: msvideo_main.c:115
#define ICMODE_FASTDECOMPRESS
Definition: vfw.h:270
LPDWORD lpdwFlags
Definition: vfw.h:179
HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPROC lpfnHandler)
Definition: msvideo_main.c:542
DWORD fccHandler
Definition: vfw.h:283
#define ICERR_DONTDRAW
Definition: vfw.h:51
DWORD VFWAPIV ICDrawBegin(HIC hic, DWORD dwFlags, HPALETTE hpal, HWND hwnd, HDC hdc, INT xDst, INT yDst, INT dxDst, INT dyDst, LPBITMAPINFOHEADER lpbi, INT xSrc, INT ySrc, INT dxSrc, INT dySrc, DWORD dwRate, DWORD dwScale)
#define DRV_OPEN
Definition: mmsystem.h:121
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
INT dxDst
Definition: vfw.h:701
#define ICERR_ABORT
Definition: vfw.h:65
LONG lTime
Definition: vfw.h:723
HDC hdc
Definition: vfw.h:698
#define comptypeDIB
Definition: vfw.h:147
#define ICM_DECOMPRESS_QUERY
Definition: vfw.h:107
DWORD dwFrameSize
Definition: vfw.h:181
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG lDataRate
Definition: vfw.h:829
static BOOL enum_compressors(HWND list, COMPVARS *pcv, BOOL enum_all)
Definition: msvideo_main.c:888
#define ICERR_CANTUPDATE
Definition: vfw.h:64
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LPBITMAPINFO lpbiIn
Definition: vfw.h:823
Definition: vfw.h:718
LPBITMAPINFOHEADER lpbiOutput
Definition: vfw.h:174
#define ICM_DRAW_WINDOW
Definition: vfw.h:122
LPBITMAPINFO lpbiOut
Definition: vfw.h:824
INT xSrc
Definition: vfw.h:704
DWORD VFWAPIV ICDecompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits)
Definition: msvideo_main.c:854
unsigned int BOOL
Definition: ntddk_ex.h:94
LRESULT WINAPI ICClose(HIC hic)
long LONG
Definition: pedump.c:60
#define ICQUALITY_DEFAULT
Definition: vfw.h:278
#define ICCompressQuery(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:224
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ICM_COMPRESS_FRAMES_INFO
Definition: vfw.h:143
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FIXME(fmt,...)
Definition: debug.h:110
DRIVERPROC proc
Definition: msvideo_main.c:108
#define HKLM_DRIVERS32
Definition: msvideo_main.c:45
DWORD biCompression
Definition: amvideo.idl:35
r reserved
Definition: btrfs.c:2893
#define ICMF_CHOOSE_DATARATE
Definition: vfw.h:849
#define ICM_SETSTATE
Definition: vfw.h:81
struct @1605::@1606 driver
unsigned int idx
Definition: utils.c:41
HANDLE VFWAPI ICImageCompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut, LONG lQuality, LONG *plSize)
#define CB_ADDSTRING
Definition: winuser.h:1918
const WCHAR * str
#define strncasecmp
Definition: fake.h:10
LPBITMAPINFOHEADER lpbiPrev
Definition: vfw.h:183
DWORD fccHandler
Definition: vfw.h:160
smooth NULL
Definition: ftsmooth.c:416
LPVOID lpBitsPrev
Definition: vfw.h:826
#define ICERR_INTERNAL
Definition: vfw.h:59
#define ICM_DRAW_QUERY
Definition: vfw.h:114
DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime)
#define ICM_GETSTATE
Definition: vfw.h:80
LONG_PTR LPARAM
Definition: windef.h:208
#define DRV_LOAD(x)
DWORD fccType
Definition: vfw.h:821
WINE_DEFAULT_DEBUG_CHANNEL(msvideo)
#define IDC_DATARATE
DWORD VFWAPIV ICCompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData, LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags, LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev)
Definition: msvideo_main.c:824
#define IDC_DATARATE_KB
#define ICM_DRAW_STOP_PLAY
Definition: vfw.h:129
const char * LPCSTR
Definition: xmlstorage.h:183
INT dyDst
Definition: vfw.h:702
#define ICERR_BADIMAGESIZE
Definition: vfw.h:68
WCHAR szDescription[128]
Definition: vfw.h:291
#define ICM_DRAW_BEGIN
Definition: vfw.h:115
#define ICM_DRAW_START_PLAY
Definition: vfw.h:128
DWORD WINAPI VideoForWindowsVersion(void)
Definition: msvideo_main.c:301
static void clear_compvars(PCOMPVARS pc)
#define CB_ERR
Definition: winuser.h:2410
#define ICINSTALL_FUNCTION
Definition: vfw.h:625
HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wMode)
Definition: msvideo_main.c:671
FOURCC WINAPI mmioStringToFOURCCA(LPCSTR sz, UINT uFlags)
Definition: mmio.c:1024
#define ICM_DRAW_SUGGESTFORMAT
Definition: vfw.h:131
BOOL WINAPI GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn)
struct tagRGBQUAD RGBQUAD
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
INT dxSrc
Definition: vfw.h:706
LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
Definition: msvideo_main.c:601
#define ICERR_BADFORMAT
Definition: vfw.h:57
#define TRACE(s)
Definition: solgame.cpp:4
#define ICERR_BADHANDLE
Definition: vfw.h:63
#define FreeLibrary(x)
Definition: compat.h:405
#define ICM_DRAW_SETTIME
Definition: vfw.h:123
GLsizeiptr size
Definition: glext.h:5919
#define IDC_COMP_LIST
Definition: resource.h:7
#define ICM_DRAW_FLUSH
Definition: vfw.h:125
DWORD dwFlags
Definition: vfw.h:695
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ICDecompressOpen(fccType, fccHandler, lpbiIn, lpbiOut)
Definition: vfw.h:535
#define ICMODE_DRAW
Definition: vfw.h:273
BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags)
Definition: msvideo_main.c:406
RGBQUAD bmiColors[1]
Definition: wingdi.h:1472
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ICM_DECOMPRESS_GET_PALETTE
Definition: vfw.h:112
__wchar_t WCHAR
Definition: xmlstorage.h:180
HIC hic
Definition: vfw.h:820
Definition: vfw.h:157
#define ICMODE_DECOMPRESS
Definition: vfw.h:269
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define ICDecompressGetPalette(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:392
LPBITMAPINFOHEADER lpbiIn
Definition: msvideo_main.c:640
#define ICERR_BADPARAM
Definition: vfw.h:61
static INT_PTR CALLBACK icm_choose_compressor_dlgproc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: msvideo_main.c:939
#define ICM_DECOMPRESS_GET_FORMAT
Definition: vfw.h:106
#define ICTYPE_VIDEO
Definition: mmreg.h:531
GLfloat param
Definition: glext.h:5796
#define WINAPI
Definition: msvc.h:8
HANDLE VFWAPI ICImageDecompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut)
#define ICM_DECOMPRESS_END
Definition: vfw.h:110
#define ICINSTALL_DRIVER
Definition: vfw.h:626
static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void *param)
Definition: msvideo_main.c:237
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD fccType
Definition: vfw.h:282
#define ICERR_BADBITDEPTH
Definition: vfw.h:67
DWORD biSizeImage
Definition: amvideo.idl:36
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
INT ySrc
Definition: vfw.h:705
LONG lQ
Definition: vfw.h:830
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DRV_FREE
Definition: mmsystem.h:124
#define ICQueryConfigure(hic)
Definition: vfw.h:320
LPVOID lpBitsOut
Definition: vfw.h:825
static DWORD cb
Definition: integrity.c:41
#define LPVOID
Definition: nt_native.h:45
#define ICM_DRAW_REALIZE
Definition: vfw.h:124
#define IDS_FULLFRAMES
#define ICMODE_FASTCOMPRESS
Definition: vfw.h:272
WCHAR szName[16]
Definition: vfw.h:290
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
DWORD dwFlags
Definition: vfw.h:334
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#define ICM_COMPRESS
Definition: vfw.h:103
LPBITMAPINFOHEADER lpbiOut
Definition: msvideo_main.c:641
#define VFWAPIV
Definition: vfw.h:27
#define ICQueryAbout(hic)
Definition: vfw.h:313
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
int ret
#define ICM_GETBUFFERSWANTED
Definition: vfw.h:134
#define ICAbout(hic, hwnd)
Definition: vfw.h:316
#define ICERR_STOPDRAWING
Definition: vfw.h:54
static HIC try_driver(driver_info_t *info)
Definition: msvideo_main.c:647
#define ICERR_UNSUPPORTED
Definition: vfw.h:56
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL WINAPI GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn)
#define ICM_SETQUALITY
Definition: vfw.h:90
LONG lKey
Definition: vfw.h:828
HDC hdc
Definition: main.c:9
#define ICM_DECOMPRESS
Definition: vfw.h:109
#define DWLP_USER
Definition: winuser.h:866
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ICDecompressGetFormatSize(hic, lpbi)
Definition: vfw.h:389
static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
Definition: msvideo_main.c:660
DWORD dwScale
Definition: vfw.h:709
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
Definition: msvideo_main.c:117
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
static DWORD IC_HandleRef
Definition: msvideo_main.c:347
GLdouble s
Definition: gl.h:2039
Definition: _list.h:228
static const char * wine_dbgstr_fcc(DWORD fcc)
Definition: msvideo_main.c:57
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define CB_SETCURSEL
Definition: winuser.h:1943
#define err(...)
#define WM_COMMAND
Definition: winuser.h:1722
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define ICM_DECOMPRESS_BEGIN
Definition: vfw.h:108
LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL *pfKey, LONG *plSize)
DWORD fccHandler
Definition: vfw.h:822
LPVOID lpState
Definition: vfw.h:832
#define ICDecompressBegin(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:371
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ICM_SET_STATUS_PROC
Definition: vfw.h:144
#define ICConfigure(hic, hwnd)
Definition: vfw.h:323
static BOOL GetFileNamePreview(LPVOID lpofn, BOOL bSave, BOOL bUnicode)
#define DRV_ENABLE
Definition: mmsystem.h:120
#define ICERR_BADFLAGS
Definition: vfw.h:60
HIC VFWAPI ICGetDisplayFormat(HIC hic, BITMAPINFOHEADER *in, BITMAPINFOHEADER *out, int depth, int width, int height)
Definition: msvideo_main.c:726
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
DWORD dwFlags
Definition: vfw.h:162
#define ICM_COMPRESS_GET_FORMAT
Definition: vfw.h:99
#define local
Definition: zutil.h:30
#define streamtypeVIDEO
Definition: aviriff.h:92
#define ICMF_CHOOSE_KEYFRAME
Definition: vfw.h:848
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
#define ERR(fmt,...)
Definition: debug.h:109
Definition: vfw.h:280
#define DRV_SUCCESS
Definition: mmsystem.h:18
#define VFWAPI
Definition: vfw.h:26
#define ICMODE_COMPRESS
Definition: vfw.h:268
reg_driver * next
Definition: msvideo_main.c:110
BOOL WINAPI GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn)
#define ICERR_NEWPALETTE
Definition: vfw.h:52
void VFWAPI ICCompressorFree(PCOMPVARS pc)
#define ICERR_CUSTOM
Definition: vfw.h:70
BOOL WINAPI GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn)
#define IDC_KEYFRAME_FRAMES
ICINFO icinfo
Definition: msvideo_main.c:885
GLuint in
Definition: glext.h:9616
#define lstrcpyW
Definition: compat.h:406
#define fourcc_to_string(str, fcc)
Definition: msvideo_main.c:50
LPBITMAPINFOHEADER lpbiOutput
Definition: vfw.h:337
#define ICERR_ERROR
Definition: vfw.h:66
#define ICM_COMPRESS_END
Definition: vfw.h:104
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
HPALETTE hpal
Definition: vfw.h:696
#define ARRAY_SIZE(a)
Definition: main.h:24
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ICM_DRAW_STOP
Definition: vfw.h:118
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
DWORD dwFlags
Definition: vfw.h:719
#define IDC_DATARATE_CHECKBOX
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
LONG cbSize
Definition: vfw.h:818
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CBN_SELCHANGE
Definition: winuser.h:1961
BOOL(* enum_handler_t)(const char *name, const char *driver, unsigned int index, void *param)
Definition: msvideo_main.c:235
LONG lFrameNum
Definition: vfw.h:180
LONG cbState
Definition: vfw.h:833
#define MultiByteToWideChar
Definition: compat.h:100
#define msg(x)
Definition: auth_time.c:54
void VFWAPI ICSeqCompressFrameEnd(PCOMPVARS pc)
Definition: name.c:36
uint32_t * LPDWORD
Definition: typedefs.h:57
LPVOID pV1Reserved
Definition: vfw.h:164
BOOL VFWAPI ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn, LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle)
#define IDC_ABOUT
LPVOID pV2Reserved
Definition: vfw.h:165
#define ICM_DRAW_RENDERBUFFER
Definition: vfw.h:126
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
static HINSTANCE hinst
Definition: edit.c:551
static int compare_fourcc(DWORD fcc1, DWORD fcc2)
Definition: msvideo_main.c:217
#define ICERR_BADSIZE
Definition: vfw.h:62
#define GetProcAddress(x, y)
Definition: compat.h:410
#define SetWindowLongPtrW
Definition: winuser.h:5247
DWORD dwFlags
Definition: vfw.h:819
Definition: vfw.h:817
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
#define ICM_DECOMPRESSEX
Definition: vfw.h:140
DWORD dwFlags
Definition: vfw.h:173
LPDWORD lpckid
Definition: vfw.h:178
GLfloat GLfloat p
Definition: glext.h:8902
DWORD dwVersionICM
Definition: vfw.h:286
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define ICM_DRAW
Definition: vfw.h:121
#define IDC_KEYFRAME_CHECKBOX
LONG_PTR LRESULT
Definition: windef.h:209
#define IDC_QUALITY_TXT
BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags)
Definition: msvideo_main.c:352
#define ICERR_GOTOKEYFRAME
Definition: vfw.h:53
LPVOID lpData
Definition: vfw.h:721
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
static WINE_HIC * MSVIDEO_GetHicPtr(HIC hic)
Definition: msvideo_main.c:287
int tolower(int c)
Definition: utclib.c:902
#define ICM_GETDEFAULTKEYFRAMERATE
Definition: vfw.h:136
#define ICM_DRAW_END
Definition: vfw.h:119
#define ICM_CONFIGURE
Definition: vfw.h:84
#define WM_INITDIALOG
Definition: winuser.h:1721
#define BI_RGB
Definition: precomp.h:34
#define XX(x)
LPARAM lParam
Definition: combotst.c:139
DWORD dwQuality
Definition: vfw.h:182
#define LOWORD(l)
Definition: pedump.c:82
#define ICM_DRAW_GETTIME
Definition: vfw.h:120
#define HeapFree(x, y, z)
Definition: compat.h:394
#define GMEM_MOVEABLE
Definition: winbase.h:291
#define GMEM_ZEROINIT
Definition: winbase.h:303
static DWORD get_size_image(LONG width, LONG height, WORD depth)
Definition: msvideo_main.c:226
#define IDC_CONFIGURE
Definition: resource.h:28
#define ICM_DRAW_GET_PALETTE
Definition: vfw.h:116
static UINT WPARAM wparam
Definition: combo.c:716
#define ICM_SET
Definition: vfw.h:92
#define ICM_CHOOSE_COMPRESSOR
INT dySrc
Definition: vfw.h:707
INT WINAPI GetPrivateProfileSectionA(LPCSTR section, LPSTR buffer, DWORD len, LPCSTR filename)
Definition: profile.c:1381
#define ICM_COMPRESS_GET_SIZE
Definition: vfw.h:100
DWORD dwVersion
Definition: vfw.h:161
#define ICM_DRAW_CHANGEPALETTE
Definition: vfw.h:132
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
INT xDst
Definition: vfw.h:699
LONG lFrame
Definition: vfw.h:827
GLuint const GLchar * name
Definition: glext.h:6031