Web lists-archives.com

Re: [MPlayer-dev-eng] how to add lookup / add functions in loader/win32.c ?




On Sat, 16 May 2015 18:27:16 -0400
compn <tempn@xxxxxxxxx> wrote:

> trying to get G729DecoderDmo.dll to work in linux.
> http://samples.ffmpeg.org/drivers32/new/G729DecoderDMO.dll
> https://trac.ffmpeg.org/attachment/ticket/4553/g729stereo.wav
> (use ffmpeg -i g729stereo.wav -acodec copy out.wav to get proper wav header)
> 
> a@lappy:~/Desktop/trunk$ ./mplayer out.wav -v -v -v
> MPlayer SVN-r37401-4.7 (C) 2000-2015 MPlayer Team
> 
> ...
> 
> Opening audio decoder: [dmo] Win32/DMO decoders
> Called unk__initterm_e
> Called unk__initterm
> Called unk_memset
> DisableThreadLibraryCalls(0x60e50000) => 0
> Called unk_ATL90.DLL:15
> 
> 
> MPlayer interrupted by signal 11 in module: init_audio_codec
> 
[...]
> 
> any loader devs still around want to clean up and finish this? :)
> 
> maybe write a howto add codecs this time! :P
> 
> not terribly important, just bored. 
> hey i was able to copy paste my way around the loader, yay.
> 
> patch to make it work on linux with latest SVN mplayer attached.
> 

Hi compn,
 the attached patch is an attempt (unsuccessful) to make it work by
 using the external atl90.dll and emulated msvcr90.dll.

The codec runs with no error, but the output does not sound good
(you can hear the voices but there are some cracks and noises).

I'm running this in a vm, since my main system is 64bit, but it should
not make a difference.

The md5 of my atl90.dll is 47857df83c1bd9755afd1c7f0ae65465, I
downloaded it somewhere.

The input file is preprocessed by ffmpeg (git from yesterday) as you
wrote (else the codec fails with an invalid input error).


Some comments on the patch:
 - ignore everyting related to atl90 emulation, it's a failed 
experiment but I was too lazy to remove it
 - the ATL90.DLL is loaded from codec directory, and must be 
all uppercase
 - in msvcr90 I emulated only the function that were called during my
   tests (unk_*)

The last change in my patch should be the only one required to load
the external atl90.dll.


Can you test it and confirm if you get the same output as your
previous attempts?


Ciao,
 Roberto
Index: win32.c
===================================================================
--- win32.c	(revisione 37401)
+++ win32.c	(copia locale)
@@ -5113,6 +5113,26 @@
     return 0;
 }
 
+// Fake implementation of _encode_pointer from msvcr90.dll, needed by G729DecoderDMO.dll
+// NOTE: undocumented function, probably the declaration is not right
+static void* exp_encode_pointer(void *ptr)
+{
+    dbgprintf("_encode_pointer (0x%08x)\n", ptr);
+    return ptr;
+}
+
+// Fake implementation of _lock from msvcr90.dll, needed by G729DecoderDMO.dll
+static void exp_lock(int locknum)
+{
+    dbgprintf("_lock (%d)\n", locknum);
+}
+
+// Fake implementation of _unlock from msvcr90.dll, needed by G729DecoderDMO.dll
+static void exp_unlock(int locknum)
+{
+    dbgprintf("_unlock (%d)\n", locknum);
+}
+
 /* Fake implementation of sdt::_Lockit::_Lockit(void) from msvcp60.dll
    Needed by SCLS.DLL */
 static int exp_0Lockit_dummy(void)
@@ -5158,6 +5178,39 @@
     return 0;
 }
 
+static HRESULT WINAPI expAtlComModuleGetClassObject(void* pm, char* rclsid, char* riid, void* ptr4)
+{
+    dbgprintf("AltComModuleGetClassObject (15) %s %s\n",rclsid,riid);
+    return 1;
+}
+
+static HRESULT expAtlUpdateRegistryFromResourceD(long l1, long l2, void* p3, void* p4)
+{
+    dbgprintf("AltUpdateRegistryFromResourceD (23)\n");
+    return 1; // Success
+}
+
+static HRESULT expAtlInternalQueryInterface(void* p1, void *p2, void* p3, void* p4)
+{
+    dbgprintf("AltInternalQueryInterface (32)\n");
+}
+
+static HRESULT expAtlRegisterClassCategoriesHelper(void* p1, void *p2, long l3)
+{
+    dbgprintf("AltRegisterClassCategoriesHelper (49)\n");
+}
+
+static HRESULT WINAPI expAtlCreateRegistrar(void* p1)
+{
+    dbgprintf("AltCreateRegistrar (61)\n");
+    return 1; // S_OK
+}
+
+static HRESULT WINAPI expAtlCallTermFunc(void* p1)
+{
+    dbgprintf("AtlCallTermFunc (64)\n");
+}
+
 struct exports
 {
     char name[64];
@@ -5649,6 +5702,31 @@
     {"??3@YAXPAX@Z", -1, expdelete}
 };
 
+static const struct exports exp_msvcr90[]={
+    FF(memset, -1)
+    FF(_initterm_e, -1)
+    FF(_initterm, -1)
+    {"??2@YAPAXI@Z", -1, expnew},
+    {"??3@YAXPAX@Z", -1, expdelete},
+    FF(_decode_pointer, -1)
+    FF(_encode_pointer, -1)
+    FF(__dllonexit, -1)
+    FF(_lock, -1)
+    FF(_unlock, -1)
+    FF(malloc, -1)
+    FF(memcpy, -1)
+    {"??_U@YAPAXI@Z", -1, expnew},
+};
+
+static const struct exports exp_atl90[]={
+    FF(AtlComModuleGetClassObject, 15)
+    FF(AtlUpdateRegistryFromResourceD, 23)
+    FF(AtlInternalQueryInterface, 32)
+    FF(AtlRegisterClassCategoriesHelper, 49)
+    FF(AtlCreateRegistrar, 61)
+    FF(AtlCallTermFunc, 64)
+};
+
 #define LL(X) \
     {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
 
@@ -5678,6 +5756,8 @@
     LL(msvcr80)
     LL(msvcp60)
     LL(msvcr100)
+    LL(msvcr90)
+//    LL(atl90)
 };
 
 static WIN_BOOL WINAPI ext_stubs(void)
@@ -5757,7 +5837,7 @@
 
 #ifndef LOADLIB_TRY_NATIVE
   /* hack for truespeech and vssh264*/
-  if (!strcmp(library, "tsd32.dll") || !strcmp(library,"vssh264dec.dll") || !strcmp(library,"LCMW2.dll") || !strcmp(library,"VDODEC32.dll"))
+  if (!strcmp(library, "tsd32.dll") || !strcmp(library,"vssh264dec.dll") || !strcmp(library,"LCMW2.dll") || !strcmp(library,"VDODEC32.dll") || !strcmp(library,"ATL90.DLL"))
 #endif
     /* ok, this is a hack, and a big memory leak. should be fixed. - alex */
     {
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng