[vlc-devel] non-win32 dmo encoding

Alex Antropoff alant at transtelecom.md
Thu Sep 20 00:23:21 CEST 2007


Hello, after fixing wma1/wma2 encoding with ffmpeg i found, what resulting mms stream correctly played with WMP,
but it doesn't work with Media Player Mobile, so i decide to check dmo encoding under linux(i'm using fc6)

Call to SetOutputType in EncoderSetAudioType always failed with DMO_E_TYPE_NOT_ACCEPTED.
After reading some docs I found, what MoInitMediaType must just 
allocate memory for pbFormat and set pbUnknown to NULL, 
but current implementation zeroes all MediaType structure. 
WMA encoding dmo set some params before calling MoInitMediaType,
so under linux we have them zeroed befor SetOutputType.
First patch fixes it.

DMO initialization work with fixed MoInitMediaType, but I got second trouble - extra data for decoder was not getting by muxers,
because EncOpen called later. 
In comments I see 'We can't open it now, because of ldt_keeper or something Open/Encode/Close has to be done in the same thread'

I removed ifdefs and got working wma2 encoding to files/streaming.
Later I tried to make wmv3 encoding and found what wmvdmoe.dll doesn't handle wma3 codec, 
so I added new guid and change dll name to wmvdmoe2.dll.

Attached 2 diffs to loader/win32.c and modules/codec/dmo/dmo.c

-- 
Regards, 
Alex Antropoff
-------------- next part --------------
--- vlc-0.8.6c.orig/loader/win32.c	2007-06-16 17:25:19.000000000 +0300
+++ vlc-0.8.6c/loader/win32.c	2007-09-20 00:49:41.141453672 +0300
@@ -3936,7 +3936,8 @@
  */
 typedef struct __attribute__((__packed__))
 {
-    char hay[0x40];
+    char hay[0x3C];
+    void*	pbUnknown;		//0x3C
     unsigned long cbFormat;		//0x40
     char*	pbFormat;		//0x44
 } MY_MEDIA_TYPE;
@@ -3958,13 +3959,19 @@
 {
     if (!dest)
         return E_POINTER;
-    memset(dest, 0, sizeof(MY_MEDIA_TYPE));
+
+    dest->pbUnknown = NULL;
+    dest->cbFormat = cbFormat;
     if (cbFormat)
     {
 	dest->pbFormat = (char*) my_mreq(cbFormat, 0);
 	if (!dest->pbFormat)
             return E_OUTOFMEMORY;
     }
+    else 
+    {
+    dest->pbFormat=NULL;
+    }
     return S_OK;
 }
 static HRESULT WINAPI expMoCreateMediaType(MY_MEDIA_TYPE** dest, DWORD cbFormat)
-------------- next part --------------
diff -ru --exclude Makefile vlc-0.8.6c.orig/modules/codec/dmo/dmo.c vlc-0.8.6c/modules/codec/dmo/dmo.c
--- vlc-0.8.6c.orig/modules/codec/dmo/dmo.c	2007-06-16 17:25:12.000000000 +0300
+++ vlc-0.8.6c/modules/codec/dmo/dmo.c	2007-09-20 00:42:55.870644108 +0300
@@ -142,6 +142,7 @@
 static const GUID guid_wma = { 0x874131cb, 0x4ecc, 0x443b, { 0x89, 0x48, 0x74, 0x6b, 0x89, 0x59, 0x5d, 0x20 } };
 
 static const GUID guid_wmv_enc = { 0x3181343b, 0x94a2, 0x4feb, { 0xad, 0xef, 0x30, 0xa1, 0xdd, 0xe6, 0x17, 0xb4 } };
+static const GUID guid_wmv_enc2 = { 0x96b57cdd, 0x8966, 0x410c,{ 0xbb, 0x1f, 0xc9, 0x7e, 0xea, 0x76, 0x5c, 0x04 } };
 static const GUID guid_wma_enc = { 0x70f598e9, 0xf4ab, 0x495a, { 0x99, 0xe2, 0xa7, 0xc4, 0xd3, 0xd8, 0x9a, 0xbf } };
 
 typedef struct
@@ -184,12 +185,15 @@
 
 static const codec_dll encoders_table[] =
 {
+    /* WMV3 */
+    { VLC_FOURCC('W','M','V','3'), "wmvdmoe2.dll", &guid_wmv_enc2 },
+    { VLC_FOURCC('w','m','v','3'), "wmvdmoe2.dll", &guid_wmv_enc2 },
     /* WMV2 */
-    { VLC_FOURCC('W','M','V','2'), "wmvdmoe.dll", &guid_wmv_enc },
-    { VLC_FOURCC('w','m','v','2'), "wmvdmoe.dll", &guid_wmv_enc },
+    { VLC_FOURCC('W','M','V','2'), "wmvdmoe2.dll", &guid_wmv_enc2 },
+    { VLC_FOURCC('w','m','v','2'), "wmvdmoe2.dll", &guid_wmv_enc2 },
     /* WMV1 */
-    { VLC_FOURCC('W','M','V','1'), "wmvdmoe.dll", &guid_wmv_enc },
-    { VLC_FOURCC('w','m','v','1'), "wmvdmoe.dll", &guid_wmv_enc },
+    { VLC_FOURCC('W','M','V','1'), "wmvdmoe2.dll", &guid_wmv_enc2 },
+    { VLC_FOURCC('w','m','v','1'), "wmvdmoe2.dll", &guid_wmv_enc2 },
 
     /* WMA 3 */
     { VLC_FOURCC('W','M','A','3'), "wmadmoe.dll", &guid_wma_enc },
@@ -960,31 +965,9 @@
 {
     encoder_t *p_enc = (encoder_t*)p_this;
 
-#ifndef LOADER
     int i_ret = EncOpen( p_this );
     if( i_ret != VLC_SUCCESS ) return i_ret;
 
-#else
-    /* We can't open it now, because of ldt_keeper or something
-     * Open/Encode/Close has to be done in the same thread */
-    int i;
-
-    /* Probe if we support it */
-    for( i = 0; encoders_table[i].i_fourcc != 0; i++ )
-    {
-        if( encoders_table[i].i_fourcc == p_enc->fmt_out.i_codec )
-        {
-            msg_Dbg( p_enc, "DMO codec for %4.4s may work with dll=%s",
-                     (char*)&p_enc->fmt_out.i_codec,
-                     encoders_table[i].psz_dll );
-            break;
-        }
-    }
-
-    p_enc->p_sys = NULL;
-    if( !encoders_table[i].i_fourcc ) return VLC_EGENERIC;
-#endif /* LOADER */
-
     /* Set callbacks */
     p_enc->pf_encode_video = (block_t *(*)(encoder_t *, picture_t *))
         EncodeBlock;
@@ -1026,7 +1009,6 @@
 
     /* Setup input format */
     memset( &dmo_type, 0, sizeof(dmo_type) );
-    dmo_type.pUnk = 0;
     memset( &vih, 0, sizeof(VIDEOINFOHEADER) );
 
     p_bih = &vih.bmiHeader;
@@ -1404,16 +1403,6 @@
     int i_result;
     mtime_t i_pts;
 
-    if( p_sys == NULL )
-    {
-        if( EncOpen( VLC_OBJECT(p_enc) ) )
-        {
-            msg_Err( p_enc, "EncOpen failed" );
-            return NULL;
-        }
-        p_sys = p_enc->p_sys;
-    }
-
     if( !p_data ) return NULL;
 
     if( p_enc->fmt_out.i_cat == VIDEO_ES )


More information about the vlc-devel mailing list