[MPlayer-cygwin] Using CoreAVC DShow H.264 filter with mplayer

Alan Nisota alannisota at gmail.com
Fri Mar 31 23:00:50 CEST 2006


There was a discussion in January about using coreavc in mplayer, but
no one had much success.  I thought I'd respond that I have spent a
couple of days working on it, and have gotten it to work with some
very crude hacks.  Specifically, I had to hard-code the resolution in
a couple of places, as well as some other nasty things.  Also, it
currently works on one stream which is h.264 in an MPEG2 container,
but doesn't work in some HD streams I got from apple.com.

This is also, likely, bad timing as a new (probably commercial)
version of coreavc is due out today.

But whatever, it is a starting point, and it is much faster than ffmpeg:

for a 54 second 1280x720 video on a P4 2.8GHz (on linux)

using ffmpeg:
mplayer -vo null -nosound -benchmark h264.mpg
BENCHMARKs: VC:  47.711s VO:   0.038s A:   0.000s Sys:   0.732s =   48.481s
BENCHMARK%: VC: 98.4132% VO:  0.0779% A:  0.0000% Sys:  1.5089% = 100.0000%

using coreAVC:
mplayer -vo null -nosound -benchmark -vc coreavc h264.mpg
BENCHMARKs: VC:  35.498s VO:   0.040s A:   0.000s Sys:   0.750s =   36.288s
BENCHMARK%: VC: 97.8222% VO:  0.1109% A:  0.0000% Sys:  2.0669% = 100.0000%


Here is what I did:
in libmpcodecs/vd.c:
hardcode width and height (this should obviously be fixed):
     /* XXX: HACK, if sh->disp_* aren't set,
      * but we have w and h, set them :: atmos */
+    w = 1280;
+    h = 720;

in loader/dshow/DS_Filter.c:
hardcode part of CSID (this also is a hack and needs to be debugged and fixed):
        This->m_pOurType = in_fmt;
        This->m_pDestType = out_fmt;
+        This->m_pOurType->subtype.f1 = 0x31435641;

in loader/dshow/DS_VideoDecoder.c:
force BITMAPINFOHEADER definition (more hacks):
     //memset(&m_obh, 0, sizeof(m_obh));
     //m_obh.biSize = sizeof(m_obh);
     /*try*/
+    BITMAPINFOHEADER tmpbmi;
+    format = &tmpbmi;
+    format->biSize = sizeof(BITMAPINFOHEADER);
+    format->biWidth = 1280;
+    format->biHeight = 720;
+    format->biPlanes = 1;
+    format->biBitCount = 16;
+    format->biCompression = 0;
+    format->biSizeImage = 0;
+    format->biXPelsPerMeter=10000;
+    format->biYPelsPerMeter=10000;
+    format->biClrUsed=0;
+    format->biClrImportant=0;
+
     {
         unsigned int bihs;

and change subtype to YV12 (ths could be easily fixed by changing the
ReceiveConnection call for the outpu-pin in DS_Filter.c)
        this->m_sDestType.majortype = MEDIATYPE_Video;
-       this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
+//     this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
+       this->m_sDestType.subtype = MEDIASUBTYPE_YV12;
        this->m_sDestType.formattype = FORMAT_VideoInfo;

in loader/dshow/allocator.c:
Emulate call to QueryInterface (should probably just implement it
instead).  I'm not sure this is needed, as it may have been a fallback
when the initial MemAllocation wasn't working (fixed by specifying a
valid BITMAPINFOHEADER above)
     p = (IMemAllocator*) MemAllocatorCreate();
-    result = p->vt->QueryInterface((IUnknown*)p, iid, ppv);
-    p->vt->Release((IUnknown*)p);
+    *ppv = p;
+    //result = p->vt->QueryInterface((IUnknown*)p, iid, ppv);
+    //p->vt->Release((IUnknown*)p);

-    return result;
+    //return result;
+    return 0;
Additionally, don't unregister the comclass (again this may not be
required anymore, not sure)
 #ifdef WIN32_LOADER
-    if (--AllocatorKeeper == 0)
-       UnregisterComClass(&CLSID_MemoryAllocator,
MemAllocator_CreateAllocator);
+//    if (--AllocatorKeeper == 0)
+//     UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator)
                                                                      
         in loader/win32.c:
Return NULL instead of a stub for unimplemented funtions.  coreAVC
tries to use several Net/Vista calls, which are unnecessary and
unimplemented:
 no_dll_byname:
     if(pos>150)return 0;// to many symbols
     strcpy(export_names[pos], name);
-    return add_stub();
+    return NULL;
+//    return add_stub();
 }

here is the codecs.conf section I was using:
; NEW SG
videocodec coreavc
  info "CoreAVC DShow H264 decoder for x86 - http://corecodec.org/"
  status untested
  format 0x10000005
;  format 0x31637661 ; avc1
  fourcc H264,h264
  fourcc X264,x264
  fourcc avc1
  fourcc davc,DAVC
  driver dshow
  dll "CoreAVCDecoder.ax"
  guid 0x09571a4b, 0xf1fe, 0x4c60, 0x97, 0x60, 0xde, 0x6d, 0x31, 0x0c,
0x7c, 0x31
  out YV12,IYUV,I420,YUY2

note the 'format' definition.  I just set it to whatever mplayer
reported for ffmpeg's h264 value.

That's 'all' there was to it.  I'll work on getting the .mov to work,
and try to fix the hardcoding of the resolution, but I though some one
might be interested in the progress.




More information about the MPlayer-cygwin mailing list