- made ICInfo closer to Windows behavior (i.e. no longer opens the

driver)
- fixed most endianess related bugs in fourCC handling
- added debug function for printing fourCC:s
- internal function fixes and speed-up
This commit is contained in:
Eric Pouech 2003-01-30 00:16:35 +00:00 committed by Alexandre Julliard
parent 8b429f766d
commit 766ea910b9
3 changed files with 124 additions and 95 deletions

View File

@ -740,7 +740,7 @@ LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lPara
/* map the message for a 32 bit infrastructure, and pass it along */ /* map the message for a 32 bit infrastructure, and pass it along */
void* data16 = MSVIDEO_MapMsg16To32(msg, &lParam1, &lParam2); void* data16 = MSVIDEO_MapMsg16To32(msg, &lParam1, &lParam2);
ret = MSVIDEO_SendMessage(HIC_32(hic), msg, lParam1, lParam2); ret = MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
if (data16) if (data16)
MSVIDEO_UnmapMsg16To32(msg, data16, &lParam1, &lParam2); MSVIDEO_UnmapMsg16To32(msg, data16, &lParam1, &lParam2);
} }

View File

@ -22,7 +22,6 @@
* *
* TODO * TODO
* - no thread safety * - no thread safety
* - the four CC comparisons are wrong on big endian machines
*/ */
#include <stdio.h> #include <stdio.h>
@ -37,6 +36,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvideo); WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
static inline const char *wine_dbgstr_fcc( DWORD fcc )
{
return wine_dbg_sprintf("%c%c%c%c",
LOBYTE(LOWORD(fcc)), HIBYTE(LOWORD(fcc)),
LOBYTE(HIWORD(fcc)), HIBYTE(HIWORD(fcc)));
}
LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM) = NULL; LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM) = NULL;
static WINE_HIC* MSVIDEO_FirstHic /* = NULL */; static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
@ -74,51 +80,48 @@ DWORD WINAPI VideoForWindowsVersion(void)
*/ */
BOOL VFWAPI ICInfo( BOOL VFWAPI ICInfo(
DWORD fccType, /* [in] type of compressor ('vidc') */ DWORD fccType, /* [in] type of compressor ('vidc') */
DWORD fccHandler, /* [in] <n>th compressor */ DWORD fccHandler, /* [in] real fcc for handler or <n>th compressor */
ICINFO *lpicinfo) /* [out] information about compressor */ ICINFO *lpicinfo) /* [out] information about compressor */
{ {
char buf[2000]; char buf[2000];
TRACE("(%.4s,%.4s,%p)\n", (char*)&fccType, (char*)&fccHandler, lpicinfo); TRACE("(%s,%s/%08lx,%p)\n",
wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), fccHandler, lpicinfo);
if (GetPrivateProfileStringA("drivers32", NULL, NULL, buf, sizeof(buf), "system.ini")) if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini"))
{ {
char *s = buf; char fccTypeStr[4];
while (*s) char fccHandlerStr[4];
char* s;
fccTypeStr[0] = LOBYTE(LOWORD(fccType));
fccTypeStr[1] = HIBYTE(LOWORD(fccType));
fccTypeStr[2] = LOBYTE(HIWORD(fccType));
fccTypeStr[3] = HIBYTE(HIWORD(fccType));
fccHandlerStr[0] = LOBYTE(LOWORD(fccHandler));
fccHandlerStr[1] = HIBYTE(LOWORD(fccHandler));
fccHandlerStr[2] = LOBYTE(HIWORD(fccHandler));
fccHandlerStr[3] = HIBYTE(HIWORD(fccHandler));
for (s = buf; *s; s += strlen(s) + 1)
{ {
/* (WS) I'm commenting out this test because GetPrivateProfileString if (!strncasecmp(fccTypeStr, s, 4) && s[4] == '.' && s[9] == '=' &&
* will return only a list of keys without their values. I'm curious (!fccHandler-- || !strncasecmp(fccHandlerStr, s + 5, 4)))
* to understand how the codecs ever got listed since it seems
* obvious they can't be found this way.
*/
if (!strncasecmp((char*)&fccType, s, 4) && s[4] == '.' /* && s[9] == '=' */ )
{ {
if (!fccHandler--) /* exact match of fccHandler or nth driver found ?? */
{ lpicinfo->fccType = fccType;
HIC hic; lpicinfo->fccHandler = mmioStringToFOURCCA(s + 5, 0);
lpicinfo->dwFlags = 0;
lpicinfo->fccHandler = mmioStringToFOURCCA(s + 5, 0); lpicinfo->dwVersion = 0;
hic = ICOpen(fccType, lpicinfo->fccHandler, ICMODE_QUERY); lpicinfo->dwVersionICM = 0x104;
if (hic) lpicinfo->szName[0] = 0;
{ lpicinfo->szDescription[0] = 0;
/* (WS) Some incompatible codecs can make wine crash MultiByteToWideChar(CP_ACP, 0, s + 10, -1,
* right here. It would be nice if we could protect lpicinfo->szDriver,
* wine and simply ignore such codecs. sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
*/ return TRUE;
ICGetInfo(hic, lpicinfo, lpicinfo->dwSize);
ICClose(hic);
return TRUE;
}
/* (WS) I'm removing this return because I think it's
* better to keep going down the list of codecs rather
* than stopping short at the first one that will not
* open.
* return FALSE; */
fccHandler++;
}
} }
s += strlen(s) + 1; /* either next char or \0 */
} }
} }
return FALSE; return FALSE;
@ -132,15 +135,24 @@ static DWORD IC_HandleRef = 1;
*/ */
HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
{ {
char codecname[20]; char codecname[10];
ICOPEN icopen; ICOPEN icopen;
HDRVR hdrv; HDRVR hdrv;
WINE_HIC* whic; WINE_HIC* whic;
BOOL bIs16; BOOL bIs16;
TRACE("(%.4s,%.4s,0x%08lx)\n", (char*)&fccType, (char*)&fccHandler, (DWORD)wMode); TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
sprintf(codecname, "%.4s.%.4s", (char*)&fccType, (char*)&fccHandler); codecname[0] = LOBYTE(LOWORD(fccType));
codecname[1] = HIBYTE(LOWORD(fccType));
codecname[2] = LOBYTE(HIWORD(fccType));
codecname[3] = HIBYTE(HIWORD(fccType));
codecname[4] = '.';
codecname[5] = LOBYTE(LOWORD(fccHandler));
codecname[6] = HIBYTE(LOWORD(fccHandler));
codecname[7] = LOBYTE(HIWORD(fccHandler));
codecname[8] = HIBYTE(HIWORD(fccHandler));
codecname[9] = '\0';
/* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
* same layout as ICOPEN * same layout as ICOPEN
@ -160,7 +172,11 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
{ {
if (fccType == streamtypeVIDEO) if (fccType == streamtypeVIDEO)
{ {
sprintf(codecname, "vidc.%.4s", (char*)&fccHandler); codecname[0] = 'v';
codecname[1] = 'i';
codecname[2] = 'd';
codecname[3] = 'c';
fccType = ICTYPE_VIDEO; fccType = ICTYPE_VIDEO;
hdrv = OpenDriverA(codecname, "drivers32", (LPARAM)&icopen); hdrv = OpenDriverA(codecname, "drivers32", (LPARAM)&icopen);
} }
@ -204,8 +220,8 @@ HIC MSVIDEO_OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
ICOPEN icopen; ICOPEN icopen;
WINE_HIC* whic; WINE_HIC* whic;
TRACE("(%.4s,%.4s,%d,%p,%08lx)\n", TRACE("(%s,%s,%d,%p,%08lx)\n",
(char*)&fccType, (char*)&fccHandler, wMode, lpfnHandler, lpfnHandler16); wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode, lpfnHandler, lpfnHandler16);
icopen.dwSize = sizeof(ICOPEN); icopen.dwSize = sizeof(ICOPEN);
icopen.fccType = fccType; icopen.fccType = fccType;
@ -230,7 +246,7 @@ HIC MSVIDEO_OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
/* Now try opening/loading the driver. Taken from DRIVER_AddToList */ /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
/* What if the function is used more than once? */ /* What if the function is used more than once? */
if (MSVIDEO_SendMessage(whic->hic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) if (MSVIDEO_SendMessage(whic, DRV_LOAD, 0L, 0L) != DRV_SUCCESS)
{ {
WARN("DRV_LOAD failed for hic %p\n", whic->hic); WARN("DRV_LOAD failed for hic %p\n", whic->hic);
MSVIDEO_FirstHic = whic->next; MSVIDEO_FirstHic = whic->next;
@ -238,9 +254,9 @@ HIC MSVIDEO_OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
return 0; return 0;
} }
/* return value is not checked */ /* return value is not checked */
MSVIDEO_SendMessage(whic->hic, DRV_ENABLE, 0L, 0L); MSVIDEO_SendMessage(whic, DRV_ENABLE, 0L, 0L);
whic->hdrv = (HDRVR)MSVIDEO_SendMessage(whic->hic, DRV_OPEN, 0, (DWORD)&icopen); whic->hdrv = (HDRVR)MSVIDEO_SendMessage(whic, DRV_OPEN, 0, (DWORD)&icopen);
if (whic->hdrv == 0) if (whic->hdrv == 0)
{ {
@ -265,36 +281,42 @@ HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC l
/*********************************************************************** /***********************************************************************
* ICGetInfo [MSVFW32.@] * ICGetInfo [MSVFW32.@]
*/ */
LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) { LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
LRESULT ret; {
char codecname[10]; LRESULT ret;
char szDriver[128]; WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
TRACE("(%p,%p,%ld)\n",hic,picinfo,cb); TRACE("(%p,%p,%ld)\n", hic, picinfo, cb);
/* (WS) The field szDriver should be initialized because the driver whic = MSVIDEO_GetHicPtr(hic);
* is not obliged and often will not do it. Some applications, like if (!whic) return ICERR_BADHANDLE;
* VirtualDub, rely on this field and will occasionally crash if it if (!picinfo) return MMSYSERR_INVALPARAM;
* goes unitialized.
*/
if (picinfo && cb >= sizeof(ICINFO))
picinfo->szDriver[0] = 0; /* At first, set it to an empty string */
ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb); /* (WS) The field szDriver should be initialized because the driver
* is not obliged and often will not do it. Some applications, like
* VirtualDub, rely on this field and will occasionally crash if it
* goes unitialized.
*/
if (cb >= sizeof(ICINFO)) picinfo->szDriver[0] = '\0';
/* (WS) When szDriver was not supplied by the driver itself, apparently ret = ICSendMessage(hic, ICM_GETINFO, (DWORD)picinfo, cb);
* Windows will set its value equal to the driver file name. This can
* be obtained from the registry as we do here.
*/
if (picinfo && cb >= sizeof(ICINFO))
if (picinfo->szDriver[0] == 0) { /* was szDriver not supplied? */
sprintf(codecname, "vidc.%.4s", (char*)&(picinfo->fccHandler));
GetPrivateProfileStringA("drivers32", codecname, "", szDriver, sizeof(szDriver), "system.ini");
MultiByteToWideChar(CP_ACP, 0, szDriver, -1, picinfo->szDriver, sizeof(picinfo->szDriver)/sizeof(WCHAR));
}
TRACE(" -> 0x%08lx\n",ret); /* (WS) When szDriver was not supplied by the driver itself, apparently
return ret; * Windows will set its value equal to the driver file name. This can
* be obtained from the registry as we do here.
*/
if (cb >= sizeof(ICINFO) && picinfo->szDriver[0] == 0)
{
ICINFO ii;
memset(&ii, 0, sizeof(ii));
ii.dwSize = sizeof(ii);
ICInfo(picinfo->fccType, picinfo->fccHandler, &ii);
lstrcpyW(picinfo->szDriver, ii.szDriver);
}
TRACE(" -> 0x%08lx\n", ret);
return ret;
} }
/*********************************************************************** /***********************************************************************
@ -307,8 +329,8 @@ HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
DWORD querymsg; DWORD querymsg;
LPSTR pszBuffer; LPSTR pszBuffer;
TRACE("(%.4s,%.4s,%p,%p,0x%04x)\n", TRACE("(%s,%s,%p,%p,0x%04x)\n",
(char*)&fccType, (char*)&fccHandler, lpbiIn, lpbiOut, wMode); wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
switch (wMode) switch (wMode)
{ {
@ -347,15 +369,21 @@ HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
if (GetPrivateProfileSectionA("drivers32", pszBuffer, 1024, "system.ini")) if (GetPrivateProfileSectionA("drivers32", pszBuffer, 1024, "system.ini"))
{ {
char* s = pszBuffer; char* s = pszBuffer;
char fcc[4];
while (*s) while (*s)
{ {
if (!strncasecmp((char*)&fccType, s, 4) && s[4] == '.' && s[9] == '=') fcc[0] = LOBYTE(LOWORD(fccType));
fcc[1] = HIBYTE(LOWORD(fccType));
fcc[2] = LOBYTE(HIWORD(fccType));
fcc[3] = HIBYTE(HIWORD(fccType));
if (!strncasecmp(fcc, s, 4) && s[4] == '.' && s[9] == '=')
{ {
char *s2 = s; char *s2 = s;
while (*s2 != '\0' && *s2 != '.') s2++; while (*s2 != '\0' && *s2 != '.') s2++;
if (*s2++) if (*s2++)
{ {
hic = ICOpen(fccType, *(DWORD*)s2, wMode); hic = ICOpen(fccType, mmioStringToFOURCCA(s2, 0), wMode);
if (hic) if (hic)
{ {
if (!ICSendMessage(hic, querymsg, (DWORD)lpbiIn, (DWORD)lpbiOut)) if (!ICSendMessage(hic, querymsg, (DWORD)lpbiIn, (DWORD)lpbiOut))
@ -376,8 +404,8 @@ HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
if (fccType == streamtypeVIDEO) if (fccType == streamtypeVIDEO)
return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode); return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode);
WARN("(%.4s,%.4s,%p,%p,0x%04x) not found!\n", WARN("(%s,%s,%p,%p,0x%04x) not found!\n",
(char*)&fccType, (char*)&fccHandler, lpbiIn, lpbiOut, wMode); wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode);
return 0; return 0;
} }
@ -478,7 +506,7 @@ DWORD VFWAPIV ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
TRACE("(%p,%ld,%p,%p,%p,%p)\n",hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits); TRACE("(%p,%ld,%p,%p,%p,%p)\n",hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]); TRACE("lpBits[0] == %lx\n",((LPDWORD)lpBits)[0]);
icd.dwFlags = dwFlags; icd.dwFlags = dwFlags;
icd.lpbiInput = lpbiFormat; icd.lpbiInput = lpbiFormat;
@ -489,7 +517,7 @@ DWORD VFWAPIV ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
icd.ckid = 0; icd.ckid = 0;
ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS)); ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]); TRACE("lpBits[0] == %lx\n",((LPDWORD)lpBits)[0]);
TRACE("-> %ld\n",ret); TRACE("-> %ld\n",ret);
@ -522,12 +550,11 @@ void VFWAPI ICCompressorFree(PCOMPVARS pc)
* *
* *
*/ */
LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2) LRESULT MSVIDEO_SendMessage(WINE_HIC* whic, UINT msg, DWORD lParam1, DWORD lParam2)
{ {
LRESULT ret; LRESULT ret;
WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
#define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",hic,lParam1,lParam2);break; #define XX(x) case x: TRACE("(%p,"#x",0x%08lx,0x%08lx)\n",whic,lParam1,lParam2); break;
switch (msg) { switch (msg) {
/* DRV_* */ /* DRV_* */
@ -588,15 +615,13 @@ LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2)
XX(ICM_DECOMPRESSEX_END); XX(ICM_DECOMPRESSEX_END);
XX(ICM_SET_STATUS_PROC); XX(ICM_SET_STATUS_PROC);
default: default:
FIXME("(%p,0x%08lx,0x%08lx,0x%08lx) unknown message\n",hic,(DWORD)msg,lParam1,lParam2); FIXME("(%p,0x%08lx,0x%08lx,0x%08lx) unknown message\n",whic,(DWORD)msg,lParam1,lParam2);
} }
#undef XX #undef XX
if (!whic) return ICERR_BADHANDLE;
if (whic->driverproc) { if (whic->driverproc) {
ret = whic->driverproc((DWORD)hic, whic->hdrv, msg, lParam1, lParam2); ret = whic->driverproc((DWORD)whic->hic, whic->hdrv, msg, lParam1, lParam2);
} else { } else {
ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2); ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2);
} }
@ -608,8 +633,12 @@ LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2)
/*********************************************************************** /***********************************************************************
* ICSendMessage [MSVFW32.@] * ICSendMessage [MSVFW32.@]
*/ */
LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2) { LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2)
return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2); {
WINE_HIC* whic = MSVIDEO_GetHicPtr(hic);
if (!whic) return ICERR_BADHANDLE;
return MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
} }
/*********************************************************************** /***********************************************************************
@ -689,9 +718,9 @@ LRESULT WINAPI ICClose(HIC hic)
if (whic->driverproc) if (whic->driverproc)
{ {
MSVIDEO_SendMessage(hic, DRV_CLOSE, 0, 0); MSVIDEO_SendMessage(whic, DRV_CLOSE, 0, 0);
MSVIDEO_SendMessage(hic, DRV_DISABLE, 0, 0); MSVIDEO_SendMessage(whic, DRV_DISABLE, 0, 0);
MSVIDEO_SendMessage(hic, DRV_FREE, 0, 0); MSVIDEO_SendMessage(whic, DRV_FREE, 0, 0);
} }
else else
{ {
@ -751,7 +780,7 @@ HANDLE VFWAPI ICImageDecompress(
if ( hic == NULL ) if ( hic == NULL )
{ {
hic = ICDecompressOpen( mmioFOURCC('V','I','D','C'), 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL ); hic = ICDecompressOpen( ICTYPE_VIDEO, 0, &lpbiIn->bmiHeader, (lpbiOut != NULL) ? &lpbiOut->bmiHeader : NULL );
if ( hic == NULL ) if ( hic == NULL )
{ {
WARN("no handler\n" ); WARN("no handler\n" );

View File

@ -43,7 +43,7 @@ typedef struct tagWINE_HIC {
} WINE_HIC; } WINE_HIC;
HIC MSVIDEO_OpenFunction(DWORD, DWORD, UINT, DRIVERPROC, DWORD); HIC MSVIDEO_OpenFunction(DWORD, DWORD, UINT, DRIVERPROC, DWORD);
LRESULT MSVIDEO_SendMessage(HIC, UINT, DWORD, DWORD); LRESULT MSVIDEO_SendMessage(WINE_HIC*, UINT, DWORD, DWORD);
WINE_HIC* MSVIDEO_GetHicPtr(HIC); WINE_HIC* MSVIDEO_GetHicPtr(HIC);
extern LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM); extern LRESULT (CALLBACK *pFnCallTo16)(HDRVR, HIC, UINT, LPARAM, LPARAM);