[MPlayer-dev-eng] [PATCH] DivX6 support
Dominik 'Rathann' Mierzejewski
dominik at rangers.eu.org
Mon Jun 19 05:47:19 CEST 2006
Here's a preliminary but already working interface to DivX6 .so decoder
based on vd_divx4.c.
The decoder binary and headers can be downloaded from
http://download.divx.com/labs/divx611-20060201-gcc4.0.1.tar.gz
TODO:
- implement control()
- fix YV12 csp
Feedback welcome.
Regards,
R.
--
MPlayer developer and RPMs maintainer: http://rpm.greysector.net/mplayer/
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
-------------- next part --------------
--- mplayer/libmpcodecs/vd.c.divx6 2006-06-19 05:38:00.000000000 +0200
+++ mplayer/libmpcodecs/vd.c 2006-06-19 05:39:03.000000000 +0200
@@ -36,6 +36,7 @@
extern vd_functions_t mpcodecs_vd_vfwex;
extern vd_functions_t mpcodecs_vd_odivx;
extern vd_functions_t mpcodecs_vd_divx4;
+extern vd_functions_t mpcodecs_vd_divx6;
extern vd_functions_t mpcodecs_vd_raw;
extern vd_functions_t mpcodecs_vd_hmblck;
extern vd_functions_t mpcodecs_vd_xanim;
@@ -75,6 +76,9 @@
&mpcodecs_vd_divx4,
#endif
#endif
+#ifdef HAVE_DIVX6
+ &mpcodecs_vd_divx6,
+#endif
&mpcodecs_vd_lzo,
&mpcodecs_vd_raw,
&mpcodecs_vd_hmblck,
--- /dev/null 2006-06-15 22:17:56.455481500 +0200
+++ mplayer/libmpcodecs/vd_divx6.c 2006-06-19 05:39:03.000000000 +0200
@@ -0,0 +1,178 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+#ifdef HAVE_DIVX6
+
+#include "vd_internal.h"
+
+static vd_info_t info = {
+ "DivX 6 lib",
+ "divx6",
+ "Dominik Mierzejewski, based on code by A'rpi",
+ "http://www.divx.com",
+ "native binary codec"
+};
+
+LIBVD_EXTERN(divx6)
+
+#include <decoder/LibQDec.h>
+
+static void* pHandle = NULL;
+static LibQDecoreFunction* pDecore;
+
+// to set/get/query special features/parameters
+static int control(sh_video_t *sh,int cmd,void* arg,...){
+#if 0
+ switch(cmd){
+ case VDCTRL_QUERY_MAX_PP_LEVEL:
+ return 6; // divx4linux >= 5.0.5 -> 0..60
+ case VDCTRL_SET_PP_LEVEL: {
+ int quality=*((int*)arg);
+ int32_t iInstruction, iPostproc;
+ if(quality<0 || quality>6) quality=6;
+ iInstruction = DEC_ADJ_POSTPROCESSING | DEC_ADJ_SET;
+ iPostproc = quality*10;
+ decore(dec_handle, DEC_OPT_ADJUST, &iInstruction, &iPostproc);
+ return CONTROL_OK;
+ }
+ case VDCTRL_SET_EQUALIZER: {
+ va_list ap;
+ int value;
+ int option;
+ va_start(ap, arg);
+ value=va_arg(ap, int);
+ va_end(ap);
+
+ if(!strcasecmp(arg,"Brightness"))
+ option=DEC_ADJ_BRIGHTNESS | DEC_ADJ_SET;
+ else if(!strcasecmp(arg, "Contrast"))
+ option=DEC_ADJ_CONTRAST | DEC_ADJ_SET;
+ else if(!strcasecmp(arg,"Saturation"))
+ option=DEC_ADJ_SATURATION | DEC_ADJ_SET;
+ else return CONTROL_FALSE;
+
+ value = (value * 128) / 100;
+ decore(dec_handle, DEC_OPT_ADJUST, &option, &value);
+ return CONTROL_OK;
+ }
+ }
+#endif
+ return CONTROL_UNKNOWN;
+}
+
+// init driver
+static int init(sh_video_t *sh){
+ DecInit decInit;
+ int iOperation;
+ int err;
+
+ if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;
+
+ memset(&decInit, 0, sizeof(DecInit));
+
+ switch(sh->format) {
+ case mmioFOURCC('d','i','v','3'):
+ case mmioFOURCC('d','i','v','4'):
+ case mmioFOURCC('d','i','v','5'):
+ case mmioFOURCC('d','i','v','x'):
+ case mmioFOURCC('D','I','V','X'):
+ case mmioFOURCC('d','x','5','0'):
+ case mmioFOURCC('D','X','5','0'):
+ decInit.formatIn.fourCC=sh->format;
+ break;
+ case mmioFOURCC('D','I','V','3'):
+ case mmioFOURCC('D','I','V','4'):
+ case mmioFOURCC('D','I','V','5'):
+ decInit.formatIn.fourCC=FourCC_lowerCase(sh->format);
+ break;
+ default:
+ decInit.formatIn.fourCC=mmioFOURCC('D','X','5','0');
+ }
+
+ pDecore=getDecore(decInit.formatIn.fourCC);
+ if(!pDecore){
+ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"getDecore() failed for FourCC: 0x%X\n",decInit.formatIn.fourCC);
+ return 0;
+ }
+
+ decInit.formatIn.width=sh->bih->biWidth;
+ decInit.formatIn.height=sh->bih->biHeight;
+ decInit.formatIn.framePeriodIsConstant = 1;
+
+ mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Trying out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]);
+ switch(sh->codec->outfmt[sh->outfmtidx]){
+ case IMGFMT_YV12: {
+ decInit.formatOut.fourCC=mmioFOURCC('Y','V','1','2');
+ break;
+ }
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ {
+ decInit.formatOut.fourCC=mmioFOURCC('I','Y','U','V');
+ break;
+ }
+ default:
+ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]);
+ return 0;
+ }
+ mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Selected out_fmt: 0x%X\n",decInit.formatOut.fourCC);
+
+ decInit.formatOut.width = sh->disp_w;
+ decInit.formatOut.height = sh->disp_h;
+ decInit.formatOut.framePeriodIsConstant = 1;
+
+ if(pDecore(NULL, DEC_OPT_INIT, (void*) &pHandle, &decInit)!=DEC_OK){
+ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"DivX6 video codec init FAILED!\n");
+ return 0;
+ }
+ assert(pHandle != 0);
+
+ iOperation = DEC_PAR_POSTPROCESSING;
+ if((err=pDecore(pHandle, DEC_OPT_SET, &iOperation, &divx_quality))!=DEC_OK){
+ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"WARN: DivX6 video codec pp level setting failed: %d\n",err);
+ }
+
+ mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX6 video codec init OK!\n");
+
+ return 1;
+}
+
+// uninit driver
+static void uninit(sh_video_t *sh){
+ int rv = pDecore(pHandle, DEC_OPT_RELEASE, 0, 0);
+ assert(rv == DEC_OK);
+}
+
+//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
+
+// decode a frame
+static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
+ mp_image_t* mpi;
+ DecFrame decFrame;
+
+ if(len<=0) return NULL; // skipped frame
+
+ decFrame.bitstream.iLength = len;
+ decFrame.bitstream.pBuff = data;
+ decFrame.shallowDecode = (flags&VDFLAGS_DROPFRAME)?1:0;
+
+ mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH,
+ sh->disp_w, sh->disp_h);
+ if(!mpi) return NULL;
+
+ decFrame.pBmp = mpi->planes[0];
+ decFrame.bmpStride = mpi->width; // FIXME ignored by decoder
+
+ int rv = pDecore(pHandle,DEC_OPT_FRAME,&decFrame,0);
+ assert(rv == DEC_OK);
+ // if (!decFrame.frameWasDecoded) return NULL; // FIXME do we need this?
+
+ return mpi;
+}
+#endif
--- mplayer/libmpcodecs/Makefile.divx6 2006-06-19 05:38:00.000000000 +0200
+++ mplayer/libmpcodecs/Makefile 2006-06-19 05:39:03.000000000 +0200
@@ -58,6 +58,7 @@
vd_sgi.c \
VIDEO_SRCS_OPT=vd_divx4.c \
+ vd_divx6.c \
vd_dmo.c \
vd_dshow.c \
vd_libdv.c \
@@ -275,6 +276,7 @@
$(LIBAV_INC) \
$(EXTRA_INC) \
$(X264_INC) \
+ $(DIVX6_INC) \
$(XVID_INC) \
-D_GNU_SOURCE \
--- mplayer/etc/codecs.conf.divx6 2006-06-19 05:38:00.000000000 +0200
+++ mplayer/etc/codecs.conf 2006-06-19 05:39:03.000000000 +0200
@@ -651,6 +651,26 @@
out UYVY
out BGR32,BGR24,BGR16,BGR15
+videocodec divx6
+ info "DivX6"
+ comment "with postprocessing"
+ status working
+ fourcc mp4v
+ fourcc DIVX,divx
+ fourcc DIV1,div1 divx
+; fourcc MP4S,mp4s ; ISO MPEG-4 Video V1
+ fourcc MP43,mp43,DIV3,div3,DIV4,div4 DIV3 ; for DivX4Linux only!
+ fourcc div5,DIV5
+ fourcc AP41 DIV3 ; AngelPotion stuff
+ fourcc xvid,XVID,XviD
+ fourcc DX50,BLZ0 DX50
+ format 0x4
+ driver divx6
+ dll libdivx
+; out YV12
+ out I420
+ out IYUV
+
; is divx4vfw stable enough, working everywhere and faster than divxds?
videocodec divx4vfw
--- mplayer/configure.divx6 2006-06-19 05:38:16.000000000 +0200
+++ mplayer/configure 2006-06-19 05:39:36.000000000 +0200
@@ -262,6 +262,7 @@
--disable-xvid disable XviD codec [autodetect]
--disable-x264 disable H.264 encoder [autodetect]
--disable-divx4linux disable DivX4linux/Divx5linux codec [autodetect]
+ --disable-divx6 disable DivX 6.x codec [autodetect]
--enable-opendivx enable _old_ OpenDivx codec [disable]
--disable-libavutil disable libavutil [autodetect]
--disable-libavcodec disable libavcodec [autodetect]
@@ -412,6 +413,8 @@
--with-xvidincdir=DIR XviD header in DIR (*)
--with-x264libdir=DIR libx264 in DIR
--with-x264incdir=DIR x264 header in DIR
+ --with-divx6libdir=DIR libdivx (DivX6) in DIR (*)
+ --with-divx6incdir=DIR DivX6 header in DIR (*)
--with-libdtslibdir=DIR libdts library in DIR (*)
--with-libdtsincdir=DIR libdts header in DIR (*)
--with-livelibdir=DIR LIVE555 Streaming Media libraries in DIR
@@ -1651,6 +1654,7 @@
_x264=auto
_divx4linux=auto
_opendivx=no
+_divx6=auto
_lirc=auto
_lircc=auto
_gui=no
@@ -1897,6 +1901,8 @@
--disable-divx4linux) _divx4linux=no ;;
--enable-opendivx) _opendivx=yes ;;
--disable-opendivx) _opendivx=no ;;
+ --enable-divx6) _divx6=yes ;;
+ --disable-divx6) _divx6=no ;;
--enable-libavutil) _libavutil=yes ;;
--disable-libavutil) _libavutil=no ;;
--enable-libavutil_so) _libavutil_so=yes ;;
@@ -2122,6 +2128,12 @@
--with-x264incdir=*)
_inc_x264=-I`echo $ac_option | cut -d '=' -f 2 |sed 's,:, -I,g'`
;;
+ --with-divx6libdir=*)
+ _ld_divx6=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
+ ;;
+ --with-divx6incdir=*)
+ _inc_divx6=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
+ ;;
--with-sdl-config=*)
_sdlconfig=`echo $ac_option | cut -d '=' -f 2`
;;
@@ -6569,6 +6581,33 @@
fi
echores "$_x264"
+echocheck "DivX 6.x decore"
+# DivX6
+cat > $TMPC << EOF
+#include <decoder/LibQDec.h>
+int main(void) {
+ LibQDecoreFunction* pDecore=getDecore(FourCC_create("DX50"));
+ return pDecore(0, DEC_OPT_INIT, 0, 0);
+}
+EOF
+_ld_divx6="$_ld_divx6 -ldivx"
+for _inc_divx6 in "$_inc_divx6" \
+ "-I/usr/local/include/divx" \
+ "-I/usr/include/divx"; do
+ cc_check $_inc_divx6 $_ld_divx6 && _divx6=yes && break
+done
+if test "$_divx6" = yes ; then
+ _divx6=yes
+ _def_divx6='#define HAVE_DIVX6 1'
+ _codecmodules="divx6 $_codecmodules"
+else
+ _divx6=no
+ _ld_divx6=''
+ _def_divx6='#undef HAVE_DIVX6'
+ _nocodecmodules="divx6 $_nocodecmodules"
+fi
+echores "$_divx6"
+
echocheck "DivX4linux/DivX5linux/OpenDivX decore"
# DivX5: DEC_OPT_MEMORY_REQS - DivX4: DEC_OPT_FRAME_311
cat > $TMPC << EOF
@@ -7526,6 +7565,8 @@
X264 = $_x264
X264_INC = $_inc_x264
X264_LIB = $_ld_x264
+DIVX6_INC = $_inc_divx6
+DIVX6_LIB = $_ld_divx6
CONFIG_DTS = $_libdts
DTS_INC = $_inc_libdts
DTS_LIB = $_ld_libdts
@@ -7704,6 +7745,9 @@
/* Define if you are using DivX5Linux Decore library */
$_def_divx5
+/* Define if you are using DivX6 Codec library */
+$_def_divx6
+
/* Define if you are using XviD library */
$_def_xvid3
$_def_xvid4
--- mplayer/Makefile.divx6 2006-06-19 05:38:00.000000000 +0200
+++ mplayer/Makefile 2006-06-19 05:39:03.000000000 +0200
@@ -95,6 +95,7 @@
$(FAAD_LIB) \
$(LIBLZO_LIB) \
$(DECORE_LIB) \
+ $(DIVX6_LIB) \
$(XVID_LIB) \
$(DTS_LIB) \
$(PNG_LIB) \
More information about the MPlayer-dev-eng
mailing list