Allow to display all builtin Wine video codecs in ICCompressorChoose

Dmitry Timoshkov dmitry at baikal.ru
Thu Nov 24 08:21:26 CST 2005


Hello,

this patch allows to display all builtin Wine video codecs in
the ICCompressorChoose dialog's combobox.

What we really miss now is the lack of the compression support in iccvid
and msvidc32 codecs.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    - Add support for ICM_GETINFO in iccvid codec (based on msrle32)
    - Add support for ICM_GETINFO in msvidc32 codec (based on msrle32)
    - Fix several bugs in msrle32 preventing it to load
    - Remove a hack in ICOpen compensating a bug in msrle32.
    - Use MSVFW32_hModule directly in ICCompressorChoose, and avoid
      a convoluted GWLP_HINSTANCE hack.

diff -up cvs/hq/wine/dlls/iccvid/iccvid.c wine/dlls/iccvid/iccvid.c
--- cvs/hq/wine/dlls/iccvid/iccvid.c	2005-06-21 16:39:57.000000000 +0900
+++ wine/dlls/iccvid/iccvid.c	2005-11-24 22:07:07.000000000 +0800
@@ -47,13 +47,15 @@
 #include "winuser.h"
 #include "commdlg.h"
 #include "vfw.h"
-
 #include "mmsystem.h"
+#include "iccvid_private.h"
 
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(iccvid);
 
+static HINSTANCE ICCVID_hModule;
+
 #define ICCVID_MAGIC mmioFOURCC('c', 'v', 'i', 'd')
 
 #define DBUG    0
@@ -910,8 +912,27 @@ static LRESULT ICCVID_Close( ICCVID_Info
     return 1;
 }
 
+static LRESULT ICCVID_GetInfo( ICCVID_Info *info, ICINFO *icinfo, DWORD dwSize )
+{
+    if (!icinfo) return sizeof(ICINFO);
+    if (dwSize < sizeof(ICINFO)) return 0;
+
+    icinfo->dwSize = sizeof(ICINFO);
+    icinfo->fccType = ICTYPE_VIDEO;
+    icinfo->fccHandler = info ? info->dwMagic : ICCVID_MAGIC;
+    icinfo->dwFlags = 0;
+    icinfo->dwVersion = 0x00010000; /* Version 1.0 build 0 */
+    icinfo->dwVersionICM = 0x01040000; /* Version 1.4 build 0 */
+
+    LoadStringW(ICCVID_hModule, IDS_NAME, icinfo->szName, sizeof(icinfo->szName)/sizeof(WCHAR));
+    LoadStringW(ICCVID_hModule, IDS_DESCRIPTION, icinfo->szDescription, sizeof(icinfo->szDescription)/sizeof(WCHAR));
+    /* msvfw32 will fill icinfo->szDriver for us */
+
+    return sizeof(ICINFO);
+}
+
 LRESULT WINAPI ICCVID_DriverProc( DWORD dwDriverId, HDRVR hdrvr, UINT msg,
-                                  LONG lParam1, LONG lParam2)
+                                  LPARAM lParam1, LPARAM lParam2)
 {
     ICCVID_Info *info = (ICCVID_Info *) dwDriverId;
 
@@ -939,6 +960,9 @@ LRESULT WINAPI ICCVID_DriverProc( DWORD 
         }
         return (LRESULT) info;
 
+    case ICM_GETINFO:
+        return ICCVID_GetInfo( info, (ICINFO *)lParam1, (DWORD)lParam2 );
+
     case ICM_DECOMPRESS_QUERY:
         return ICCVID_DecompressQuery( info, (LPBITMAPINFO) lParam1,
                                        (LPBITMAPINFO) lParam2 );
@@ -963,3 +987,20 @@ LRESULT WINAPI ICCVID_DriverProc( DWORD 
     }
     return 0;
 }
+
+BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
+{
+    TRACE("(%p,%ld,%p)\n", hModule, dwReason, lpReserved);
+
+    switch (dwReason)
+    {
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(hModule);
+        ICCVID_hModule = hModule;
+        break;
+
+    case DLL_PROCESS_DETACH:
+        break;
+    }
+    return TRUE;
+}
diff -up /dev/null wine/dlls/iccvid/iccvid_En.rc
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/iccvid/iccvid_En.rc	2005-11-24 21:40:27.000000000 +0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE DISCARDABLE
+{
+    IDS_NAME "Cinepak Video codec"
+    IDS_DESCRIPTION "Cinepak Video codec"
+}
diff -up /dev/null wine/dlls/iccvid/iccvid_private.h
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/iccvid/iccvid_private.h	2005-11-24 21:50:33.000000000 +0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __ICCVID_PRIVATE_H
+#define __ICCVID_PRIVATE_H
+
+#define IDS_NAME        100
+#define IDS_DESCRIPTION 101
+
+#endif /* __ICCVID_PRIVATE_H */
diff -up cvs/hq/wine/dlls/iccvid/Makefile.in wine/dlls/iccvid/Makefile.in
--- cvs/hq/wine/dlls/iccvid/Makefile.in	2005-08-22 11:43:26.000000000 +0900
+++ wine/dlls/iccvid/Makefile.in	2005-11-24 21:43:29.000000000 +0800
@@ -3,11 +3,13 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = iccvid.dll
-IMPORTS   = kernel32
+IMPORTS   = kernel32 user32
 
 C_SRCS = \
 	iccvid.c
 
+RC_SRCS = rsrc.rc
+
 @MAKE_DLL_RULES@
 
 ### Dependencies:
diff -up /dev/null wine/dlls/iccvid/rsrc.rc
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/iccvid/rsrc.rc	2005-11-24 21:37:52.000000000 +0800
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windef.h"
+#include "iccvid_private.h"
+
+#include "iccvid_En.rc"
diff -up cvs/hq/wine/dlls/msrle32/msrle32.c wine/dlls/msrle32/msrle32.c
--- cvs/hq/wine/dlls/msrle32/msrle32.c	2005-09-13 15:09:28.000000000 +0900
+++ wine/dlls/msrle32/msrle32.c	2005-11-24 21:46:50.000000000 +0800
@@ -58,7 +58,6 @@ inline WORD Intensity(RGBQUAD clr)
 /* utility functions */
 static BOOL    isSupportedDIB(LPCBITMAPINFOHEADER lpbi);
 static BOOL    isSupportedMRLE(LPCBITMAPINFOHEADER lpbi);
-static void    LoadWideString(UINT id, LPWSTR str, INT len);
 static BYTE    MSRLE32_GetNearestPaletteIndex(UINT count, const RGBQUAD *clrs, RGBQUAD clr);
 
 /* compression functions */
@@ -98,14 +97,6 @@ static LRESULT DecompressGetPalette(Code
 
 /*****************************************************************************/
 
-static void LoadWideString(UINT id, LPWSTR str, INT len)
-{
-  char szTemp[80];
-
-  LoadStringA(MSRLE32_hModule, id, szTemp, sizeof(szTemp));
-  MultiByteToWideChar(CP_ACP, 0, szTemp, -1, str, len);
-}
-
 static BOOL isSupportedMRLE(LPCBITMAPINFOHEADER lpbi)
 {
   /* pre-conditions */
@@ -1113,9 +1104,6 @@ static CodecInfo* Open(LPICOPEN icinfo)
 	icinfo->fccHandler, (char*)&icinfo->fccHandler,
 	icinfo->dwVersion,icinfo->dwFlags);
 
-  if (icinfo->fccType != ICTYPE_VIDEO)
-    return NULL;
-
   switch (icinfo->fccHandler) {
   case FOURCC_RLE:
   case FOURCC_RLE4:
@@ -1176,14 +1164,14 @@ static LRESULT GetInfo(CodecInfo *pi, IC
     return 0;
 
   icinfo->dwSize       = sizeof(ICINFO);
-  icinfo->fccType      = streamtypeVIDEO;
+  icinfo->fccType      = ICTYPE_VIDEO;
   icinfo->fccHandler   = (pi != NULL ? pi->fccHandler : FOURCC_MRLE);
   icinfo->dwFlags      = VIDCF_QUALITY | VIDCF_TEMPORAL | VIDCF_CRUNCH | VIDCF_FASTTEMPORALC;
   icinfo->dwVersion    = MSRLE32_VERSION;
   icinfo->dwVersionICM = 0x01040000; /* Version 1.4 build 0 */
 
-  LoadWideString(IDS_NAME, icinfo->szName, sizeof(icinfo->szName));
-  LoadWideString(IDS_DESCRIPTION, icinfo->szDescription, sizeof(icinfo->szDescription));
+  LoadStringW(MSRLE32_hModule, IDS_NAME, icinfo->szName, sizeof(icinfo->szName)/sizeof(WCHAR));
+  LoadStringW(MSRLE32_hModule, IDS_DESCRIPTION, icinfo->szDescription, sizeof(icinfo->szDescription)/sizeof(WCHAR));
 
   return sizeof(ICINFO);
 }
@@ -1796,9 +1784,6 @@ LRESULT CALLBACK MSRLE32_DriverProc(DWOR
   case DRV_LOAD:
     return DRVCNF_OK;
   case DRV_OPEN:
-    if (lParam2 == 0)
-      return (LRESULT)0xFFFF0000;
-    else
       return (LRESULT)Open((ICOPEN*)lParam2);
   case DRV_CLOSE:
     if (dwDrvID != 0xFFFF0000 && (LPVOID)dwDrvID != NULL)
@@ -1910,7 +1895,7 @@ BOOL WINAPI DllMain(HINSTANCE hModule, D
 
   case DLL_PROCESS_DETACH:
     break;
-  };
+  }
 
   return TRUE;
 }
diff -up cvs/hq/wine/dlls/msvidc32/Makefile.in wine/dlls/msvidc32/Makefile.in
--- cvs/hq/wine/dlls/msvidc32/Makefile.in	2005-08-22 11:43:30.000000000 +0900
+++ wine/dlls/msvidc32/Makefile.in	2005-11-24 20:11:15.000000000 +0800
@@ -3,11 +3,13 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msvidc32.dll
-IMPORTS   = kernel32
+IMPORTS   = kernel32 user32
 
 C_SRCS = \
 	msvideo1.c
 
+RC_SRCS = rsrc.rc
+
 @MAKE_DLL_RULES@
 
 ### Dependencies:
diff -up /dev/null wine/dlls/msvidc32/msvidc32_En.rc
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/msvidc32/msvidc32_En.rc	2005-11-24 21:36:52.000000000 +0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE DISCARDABLE
+{
+    IDS_NAME "WINE-MS-CRAM"
+    IDS_DESCRIPTION "Wine Video 1 video codec"
+}
diff -up /dev/null wine/dlls/msvidc32/msvidc32_private.h
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/msvidc32/msvidc32_private.h	2005-11-24 21:34:02.000000000 +0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __MSVIDC32_PRIVATE_H
+#define __MSVIDC32_PRIVATE_H
+
+#define IDS_NAME        100
+#define IDS_DESCRIPTION 101
+
+#endif /* __MSVIDC32_PRIVATE_H */
diff -up cvs/hq/wine/dlls/msvidc32/msvideo1.c wine/dlls/msvidc32/msvideo1.c
--- cvs/hq/wine/dlls/msvidc32/msvideo1.c	2005-07-07 18:13:16.000000000 +0900
+++ wine/dlls/msvidc32/msvideo1.c	2005-11-24 21:42:55.000000000 +0800
@@ -31,20 +31,22 @@
  * if it's present, then the data is PAL8; RGB555 otherwise.
  */
 
-#include <stdarg.h> 
+#include <stdarg.h>
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h" 
 #include "commdlg.h"
 #include "vfw.h"
- 
 #include "mmsystem.h"
+#include "msvidc32_private.h"
  
 #include "wine/debug.h"
  
 WINE_DEFAULT_DEBUG_CHANNEL(msvidc32); 
 
+static HINSTANCE MSVIDC32_hModule;
+
 #define CRAM_MAGIC mmioFOURCC('C', 'R', 'A', 'M')
 #define MSVC_MAGIC mmioFOURCC('M', 'S', 'V', 'C')
 #define WHAM_MAGIC mmioFOURCC('W', 'H', 'A', 'M')
@@ -454,16 +456,35 @@ static LRESULT CRAM_DecompressEx( Msvide
     return ICERR_OK;
 }
 
+static LRESULT CRAM_GetInfo( Msvideo1Context *info, ICINFO *icinfo, DWORD dwSize )
+{
+    if (!icinfo) return sizeof(ICINFO);
+    if (dwSize < sizeof(ICINFO)) return 0;
+
+    icinfo->dwSize = sizeof(ICINFO);
+    icinfo->fccType = ICTYPE_VIDEO;
+    icinfo->fccHandler = info ? info->dwMagic : CRAM_MAGIC;
+    icinfo->dwFlags = 0;
+    icinfo->dwVersion = 0x00010000; /* Version 1.0 build 0 */
+    icinfo->dwVersionICM = 0x01040000; /* Version 1.4 build 0 */
+
+    LoadStringW(MSVIDC32_hModule, IDS_NAME, icinfo->szName, sizeof(icinfo->szName)/sizeof(WCHAR));
+    LoadStringW(MSVIDC32_hModule, IDS_DESCRIPTION, icinfo->szDescription, sizeof(icinfo->szDescription)/sizeof(WCHAR));
+    /* msvfw32 will fill icinfo->szDriver for us */
+
+    return sizeof(ICINFO);
+}
+
 /***********************************************************************
  *		DriverProc (MSVIDC32.@)
  */
 LRESULT WINAPI CRAM_DriverProc( DWORD dwDriverId, HDRVR hdrvr, UINT msg,
-                                  LONG lParam1, LONG lParam2)
+                                LPARAM lParam1, LPARAM lParam2 )
 {
     Msvideo1Context *info = (Msvideo1Context *) dwDriverId;
     LRESULT r = 0;
 
-    TRACE("%ld %p %d %ld %ld\n", dwDriverId, hdrvr, msg, lParam1, lParam2);
+    TRACE("%ld %p %04x %08lx %08lx\n", dwDriverId, hdrvr, msg, lParam1, lParam2);
 
     switch( msg )
     {
@@ -486,6 +507,10 @@ LRESULT WINAPI CRAM_DriverProc( DWORD dw
         r = (LRESULT) info;
         break;
 
+    case ICM_GETINFO:
+        r = CRAM_GetInfo( info, (ICINFO *)lParam1, (DWORD)lParam2 );
+        break;
+
     case ICM_DECOMPRESS_QUERY:
         r = CRAM_DecompressQuery( info, (LPBITMAPINFO) lParam1,
                                        (LPBITMAPINFO) lParam2 );
@@ -535,3 +560,20 @@ LRESULT WINAPI CRAM_DriverProc( DWORD dw
 
     return r;
 }
+
+BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
+{
+    TRACE("(%p,%ld,%p)\n", hModule, dwReason, lpReserved);
+
+    switch (dwReason)
+    {
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(hModule);
+        MSVIDC32_hModule = hModule;
+        break;
+
+    case DLL_PROCESS_DETACH:
+        break;
+    }
+    return TRUE;
+}
diff -up /dev/null wine/dlls/msvidc32/rsrc.rc
--- /dev/null	2005-11-25 00:48:07.312883000 +0800
+++ wine/dlls/msvidc32/rsrc.rc	2005-11-24 21:34:11.000000000 +0800
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2005 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windef.h"
+#include "msvidc32_private.h"
+
+#include "msvidc32_En.rc"
diff -up cvs/hq/wine/dlls/msvideo/msvideo_main.c wine/dlls/msvideo/msvideo_main.c
--- cvs/hq/wine/dlls/msvideo/msvideo_main.c	2005-11-24 16:53:06.000000000 +0800
+++ wine/dlls/msvideo/msvideo_main.c	2005-11-24 21:13:54.000000000 +0800
@@ -139,6 +139,7 @@ static BOOL enum_drivers(DWORD fccType, 
     {
 	for (s = buf; *s; s += strlen(s) + 1)
 	{
+            TRACE("got %s\n", s);
 	    if (strncasecmp(s, fccTypeStr, 5) || s[9] != '=') continue;
 	    if ((result = handler(s, cnt++, param))) break;
 	}
@@ -349,20 +350,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD f
 
         hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
         if (!hdrv) 
-        {
-            if (fccType == streamtypeVIDEO) 
-            {
-		codecname[0] = 'v';
-		codecname[1] = 'i';
-		codecname[2] = 'd';
-		codecname[3] = 'c';
-
-		fccType = ICTYPE_VIDEO;
-                hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
-	    }
-            if (!hdrv)
-                return 0;
-	}
+            return 0;
     } else {
         /* The driver has been registered at runtime with its name */
         hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
@@ -767,8 +755,7 @@ static INT_PTR CALLBACK icm_choose_compr
         if (choose_comp->title)
             SetWindowTextA(hdlg, choose_comp->title);
 
-        LoadStringW((HINSTANCE)GetWindowLongPtrW(hdlg, GWLP_HINSTANCE),
-                    IDS_FULLFRAMES, buf, 128);
+        LoadStringW(MSVFW32_hModule, IDS_FULLFRAMES, buf, 128);
         SendDlgItemMessageW(hdlg, IDC_COMP_LIST, CB_ADDSTRING, 0, (LPARAM)buf);
 
         enum_compressors(GetDlgItem(hdlg, IDC_COMP_LIST));






More information about the wine-patches mailing list