Zebediah Figura : msvfw32: Reimplement ICLocate() on top of ICInfo().

Alexandre Julliard julliard at winehq.org
Thu Mar 7 16:27:58 CST 2019


Module: wine
Branch: master
Commit: 07a1f8d9fe935bf27b323f60bed256779d2cf6b1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=07a1f8d9fe935bf27b323f60bed256779d2cf6b1

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Mar  6 21:10:20 2019 -0600

msvfw32: Reimplement ICLocate() on top of ICInfo().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvfw32/msvideo_main.c | 102 ++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 61 deletions(-)

diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 16238c2..43c9afc 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -623,89 +623,69 @@ LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
     return ret;
 }
 
-typedef struct {
-    DWORD fccType;
-    DWORD fccHandler;
-    LPBITMAPINFOHEADER lpbiIn;
-    LPBITMAPINFOHEADER lpbiOut;
-    WORD wMode;
-    DWORD querymsg;
-    HIC hic;
-} driver_info_t;
-
-static HIC try_driver(driver_info_t *info)
-{
-    HIC   hic;
-
-    if ((hic = ICOpen(info->fccType, info->fccHandler, info->wMode))) 
-    {
-	if (!ICSendMessage(hic, info->querymsg, (DWORD_PTR)info->lpbiIn, (DWORD_PTR)info->lpbiOut))
-	    return hic;
-	ICClose(hic);
-    }
-    return 0;
-}
-
-static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
-{
-    driver_info_t *info = param;
-    info->fccHandler = mmioStringToFOURCCA(name + 5, 0);
-    info->hic = try_driver(info);
-    return info->hic != 0;
-}
-
 /***********************************************************************
- *		ICLocate			[MSVFW32.@]
+ *              ICLocate                        [MSVFW32.@]
  */
-HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
-                    LPBITMAPINFOHEADER lpbiOut, WORD wMode)
+HIC VFWAPI ICLocate(DWORD type, DWORD handler, BITMAPINFOHEADER *in,
+        BITMAPINFOHEADER *out, WORD mode)
 {
-    driver_info_t info;
-
-    TRACE("(%s,%s,%p,%p,0x%04x)\n", 
-          wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
+    ICINFO info = {sizeof(info)};
+    UINT msg;
+    HIC hic;
+    DWORD i;
 
-    info.fccType = fccType;
-    info.fccHandler = fccHandler;
-    info.lpbiIn = lpbiIn;
-    info.lpbiOut = lpbiOut;
-    info.wMode = wMode;
+    TRACE("type %s, handler %s, in %p, out %p, mode %u.\n",
+            wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), in, out, mode);
 
-    switch (wMode) 
+    switch (mode)
     {
     case ICMODE_FASTCOMPRESS:
     case ICMODE_COMPRESS:
-        info.querymsg = ICM_COMPRESS_QUERY;
+        msg = ICM_COMPRESS_QUERY;
         break;
     case ICMODE_FASTDECOMPRESS:
     case ICMODE_DECOMPRESS:
-        info.querymsg = ICM_DECOMPRESS_QUERY;
+        msg = ICM_DECOMPRESS_QUERY;
         break;
     case ICMODE_DRAW:
-        info.querymsg = ICM_DRAW_QUERY;
+        msg = ICM_DRAW_QUERY;
         break;
     default:
-        WARN("Unknown mode (%d)\n", wMode);
+        FIXME("Unhandled mode %#x.\n", mode);
         return 0;
     }
 
-    /* Easy case: handler/type match, we just fire a query and return */
-    info.hic = try_driver(&info);
-    /* If it didn't work, try each driver in turn. 32 bit codecs only. */
-    /* FIXME: Move this to an init routine? */
-    if (!info.hic) enum_drivers(fccType, ICLocate_enum_handler, &info);
+    if ((hic = ICOpen(type, handler, mode)))
+    {
+        if (!ICSendMessage(hic, msg, (DWORD_PTR)in, (DWORD_PTR)out))
+        {
+            TRACE("Found codec %s.%s.\n", wine_dbgstr_fcc(type),
+                    wine_dbgstr_fcc(handler));
+            return hic;
+        }
+        ICClose(hic);
+    }
 
-    if (info.hic) 
+    for (i = 0; ICInfo(type, i, &info); ++i)
     {
-        TRACE("=> %p\n", info.hic);
-	return info.hic;
+        if ((hic = ICOpen(info.fccType, info.fccHandler, mode)))
+        {
+            if (!ICSendMessage(hic, msg, (DWORD_PTR)in, (DWORD_PTR)out))
+            {
+                TRACE("Found codec %s.%s.\n", wine_dbgstr_fcc(info.fccType),
+                        wine_dbgstr_fcc(info.fccHandler));
+                return hic;
+            }
+            ICClose(hic);
+        }
     }
 
-    if (fccType == streamtypeVIDEO) 
-        return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode);
-    
-    ERR("Required media codec '%s %s' not found!\n",
-         wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler));
+    if (type == streamtypeVIDEO)
+        return ICLocate(ICTYPE_VIDEO, handler, in, out, mode);
+
+    WARN("Could not find a driver for codec %s.%s.\n",
+            wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler));
+
     return 0;
 }
 




More information about the wine-cvs mailing list