--- trunk/xvidcore/vfw/src/driverproc.c 2004/04/02 21:29:21 1398 +++ trunk/xvidcore/vfw/src/driverproc.c 2008/11/30 16:38:31 1827 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: driverproc.c,v 1.3 2004-04-02 21:29:21 edgomez Exp $ + * $Id: driverproc.c,v 1.9 2008-11-30 16:36:44 Isibaar Exp $ * ****************************************************************************/ @@ -33,11 +33,12 @@ #include "status.h" #include "resource.h" +static int clean_dll_bindings(CODEC* codec); -BOOL WINAPI DllMain( - HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) +INT_PTR WINAPI DllMain( + HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved) { g_hInst = (HINSTANCE) hModule; return TRUE; @@ -59,7 +60,7 @@ case DRV_LOAD : case DRV_FREE : - return DRV_OK; + return DRVCNF_OK; case DRV_OPEN : DPRINTF("DRV_OPEN"); @@ -69,7 +70,7 @@ if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) { - return DRV_CANCEL; + return DRVCNF_CANCEL; } codec = malloc(sizeof(CODEC)); @@ -112,28 +113,30 @@ /* compress_end/decompress_end don't always get called */ compress_end(codec); decompress_end(codec); + clean_dll_bindings(codec); status_destroy_always(&codec->status); free(codec); - return DRV_OK; + return DRVCNF_OK; case DRV_DISABLE : case DRV_ENABLE : - return DRV_OK; + return DRVCNF_OK; case DRV_INSTALL : case DRV_REMOVE : - return DRV_OK; + return DRVCNF_OK; case DRV_QUERYCONFIGURE : case DRV_CONFIGURE : - return DRV_CANCEL; + return DRVCNF_CANCEL; /* info */ case ICM_GETINFO : DPRINTF("ICM_GETINFO"); - { + + if (lParam1 && lParam2 >= sizeof(ICINFO)) { ICINFO *icinfo = (ICINFO *)lParam1; icinfo->fccType = ICTYPE_VIDEO; @@ -144,6 +147,9 @@ VIDCF_COMPRESSFRAMES; icinfo->dwVersion = 0; +#if !defined(ICVERSION) +#define ICVERSION 0x0104 +#endif icinfo->dwVersionICM = ICVERSION; wcscpy(icinfo->szName, XVID_NAME_L); @@ -151,6 +157,8 @@ return lParam2; /* size of struct */ } + + return 0; /* error */ /* state control */ @@ -291,19 +299,43 @@ return ICERR_UNSUPPORTED; default: - return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); + if (uMsg < DRV_USER) + return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); + else + return ICERR_UNSUPPORTED; } } - void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow) { DWORD dwDriverId; - dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); + dwDriverId = (DWORD) DriverProc(0, 0, DRV_OPEN, 0, 0); if (dwDriverId != (DWORD)NULL) { - DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); + if (lstrcmpi(lpCmdLine, "about")==0) { + DriverProc(dwDriverId, 0, ICM_ABOUT, (LPARAM)GetDesktopWindow(), 0); + }else{ + DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); + } DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); } } + +static int clean_dll_bindings(CODEC* codec) +{ + if(codec->m_hdll) + { + FreeLibrary(codec->m_hdll); + codec->m_hdll = NULL; + codec->xvid_global_func = NULL; + codec->xvid_encore_func = NULL; + codec->xvid_decore_func = NULL; + codec->xvid_plugin_single_func = NULL; + codec->xvid_plugin_2pass1_func = NULL; + codec->xvid_plugin_2pass2_func = NULL; + codec->xvid_plugin_lumimasking_func = NULL; + codec->xvid_plugin_psnr_func = NULL; + } + return 0; +}