[MPlayer-dev-eng] [PATCH] update to new DivX4Linux 5.0.5 API
Andreas Hess
jaska at gmx.net
Sat May 24 10:22:49 CEST 2003
Hi!
DivX4Linux version 5.0.5 is available, but the API has changed. Attached
is a patch, that enables decoding support for this new version. If no one
else has a look at the encoder I will update it in the next few days.
Two questions:
1) DivX 5.0.5 has 'warmth' as a new postprocessing parameter, shall I add
support for it?
2) In vd_divx4 and vd_odivx the max postprocessing level was 9 resulting
in a range of 0..90, but IMHO the correct range should be 0..100. Is it
ok that I've changed it to 10?
Andreas
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.714
diff -u -r1.714 configure
--- configure 23 May 2003 12:37:31 -0000 1.714
+++ configure 24 May 2003 08:10:59 -0000
@@ -4594,7 +4594,7 @@
# ld: Warning: type of symbol `dering' changed from 1 to 2 in opendivx/postprocess.o
cat > $TMPC << EOF
#include <decore.h>
-int main(void) { (void) decore(0, 0, 0, 0); return DEC_OPT_MEMORY_REQS; }
+int main(void) { (void) decore(0, 0, 0, 0); return DEC_OPT_INIT; }
EOF
if test "$_divx4linux" != no && cc_check -lm -ldivxdecore -lm ; then
_opendivx=no
Index: libmpcodecs/vd_divx4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_divx4.c,v
retrieving revision 1.14
diff -u -r1.14 vd_divx4.c
--- libmpcodecs/vd_divx4.c 6 Feb 2003 20:24:14 -0000 1.14
+++ libmpcodecs/vd_divx4.c 24 May 2003 08:11:10 -0000
@@ -42,22 +42,42 @@
#define USE_DIVX_BUILTIN_PP
+#ifndef DECORE_VERSION
+#define DECORE_VERSION 0
+#endif
+
+#if DECORE_VERSION >= 20021112
+static void* dec_handle = NULL;
+#endif
+
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
switch(cmd){
#ifdef USE_DIVX_BUILTIN_PP
case VDCTRL_QUERY_MAX_PP_LEVEL:
- return 9; // for divx4linux
+// return 9; // for divx4linux
+#if DECORE_VERSION >= 20021112
+ return 6; // divx4linux >= 5.0.5 -> 0..60
+#else
+ return 10; // divx4linux < 5.0.5 -> 0..100
+#endif
case VDCTRL_SET_PP_LEVEL: {
+ int quality=*((int*)arg);
+#if DECORE_VERSION >= 20021112
+ 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);
+#else
DEC_SET dec_set;
- int quality=*((int*)arg);
- if(quality<0 || quality>9) quality=9;
+ if(quality<0 || quality>10) quality=10;
dec_set.postproc_level=quality*10;
decore(0x123,DEC_OPT_SETPP,&dec_set,NULL);
+#endif
return CONTROL_OK;
}
#endif
-#ifdef DECORE_VERSION
#if DECORE_VERSION >= 20011010
case VDCTRL_SET_EQUALIZER: {
va_list ap;
@@ -67,17 +87,35 @@
value=va_arg(ap, int);
va_end(ap);
- if(!strcasecmp(arg,"Brightness")) option=DEC_GAMMA_BRIGHTNESS;
- else if(!strcasecmp(arg, "Contrast")) option=DEC_GAMMA_CONTRAST;
- else if(!strcasecmp(arg,"Saturation")) option=DEC_GAMMA_SATURATION;
+ if(!strcasecmp(arg,"Brightness"))
+#if DECORE_VERSION >= 20021112
+ option=DEC_ADJ_BRIGHTNESS | DEC_ADJ_SET;
+#else
+ option=DEC_GAMMA_BRIGHTNESS;
+#endif
+ else if(!strcasecmp(arg, "Contrast"))
+#if DECORE_VERSION >= 20021112
+ option=DEC_ADJ_CONTRAST | DEC_ADJ_SET;
+#else
+ option=DEC_GAMMA_CONTRAST;
+#endif
+ else if(!strcasecmp(arg,"Saturation"))
+#if DECORE_VERSION >= 20021112
+ option=DEC_ADJ_SATURATION | DEC_ADJ_SET;
+#else
+ option=DEC_GAMMA_SATURATION;
+#endif
else return CONTROL_FALSE;
value = (value * 128) / 100;
+#if DECORE_VERSION >= 20021112
+ decore(dec_handle, DEC_OPT_ADJUST, &option, &value);
+#else
decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value);
+#endif
return CONTROL_OK;
}
#endif
-#endif
}
@@ -86,6 +124,89 @@
// init driver
static int init(sh_video_t *sh){
+#if DECORE_VERSION >= 20021112
+ DEC_INIT dec_init;
+ int iSize=sizeof(DivXBitmapInfoHeader);
+ DivXBitmapInfoHeader* pbi=malloc(iSize);
+ int32_t iInstruction;
+
+ if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
+
+ memset(&dec_init, 0, sizeof(dec_init));
+ memset(pbi, 0, iSize);
+
+ switch(sh->format) {
+ case mmioFOURCC('D','I','V','3'):
+ dec_init.codec_version = 311;
+ break;
+ case mmioFOURCC('D','I','V','X'):
+ dec_init.codec_version = 412;
+ break;
+ case mmioFOURCC('D','X','5','0'):
+ default: // Fallback to DivX 5 behaviour
+ dec_init.codec_version = 500;
+ }
+
+ // no smoothing of the CPU load
+ dec_init.smooth_playback = 0;
+
+ pbi->biSize=iSize;
+
+ switch(sh->codec->outfmt[sh->outfmtidx]){
+ case IMGFMT_YV12: {
+ pbi->biCompression=mmioFOURCC('Y','V','1','2');
+ break;
+ }
+ case IMGFMT_YUY2: {
+ pbi->biCompression=mmioFOURCC('Y','U','Y','2');
+ break;
+ }
+ case IMGFMT_UYVY: {
+ pbi->biCompression=mmioFOURCC('U','Y','V','Y');
+ break;
+ }
+ case IMGFMT_I420: {
+ pbi->biCompression=mmioFOURCC('I','4','2','0');
+ break;
+ }
+ case IMGFMT_BGR15: {
+ pbi->biCompression=0;
+ pbi->biBitCount=16;
+ break;
+ }
+ case IMGFMT_BGR16: {
+ pbi->biCompression=3;
+ pbi->biBitCount=16;
+ break;
+ }
+ case IMGFMT_BGR24: {
+ pbi->biCompression=0;
+ pbi->biBitCount=24;
+ break;
+ }
+ case IMGFMT_BGR32: {
+ pbi->biCompression=0;
+ pbi->biBitCount=32;
+ break;
+ }
+ default:
+ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]);
+ return 0;
+ }
+
+ pbi->biWidth = sh->disp_w;
+ pbi->biHeight = sh->disp_h;
+
+ decore(&dec_handle, DEC_OPT_INIT, &dec_init, NULL);
+ decore(dec_handle, DEC_OPT_SETOUT, pbi, NULL);
+
+#ifdef USE_DIVX_BUILTIN_PP
+ iInstruction = DEC_ADJ_POSTPROCESSING | DEC_ADJ_SET;
+ decore(dec_handle, DEC_OPT_ADJUST, &iInstruction, &divx_quality);
+#endif
+
+ free(pbi);
+#else // DECORE_VERSION < 20021112
DEC_PARAM dec_param;
DEC_SET dec_set;
int bits=16;
@@ -142,7 +263,8 @@
dec_set.postproc_level = divx_quality;
decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
#endif
-
+#endif // DECORE_VERSION
+
mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX4Linux video codec init OK!\n");
return 1;
@@ -150,7 +272,12 @@
// uninit driver
static void uninit(sh_video_t *sh){
+#if DECORE_VERSION >= 20021112
+ decore(dec_handle, DEC_OPT_RELEASE, NULL, NULL);
+ dec_handle = NULL;
+#else
decore(0x123,DEC_OPT_RELEASE,NULL,NULL);
+#endif
}
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
@@ -176,7 +303,12 @@
dec_frame.bmp=mpi->planes[0];
dec_frame.stride=mpi->width;
- decore(0x123,
+ decore(
+#if DECORE_VERSION >= 20021112
+ dec_handle,
+#else
+ 0x123,
+#endif
#ifndef DEC_OPT_FRAME_311
DEC_OPT_FRAME,
#else
Index: libmpcodecs/vd_odivx.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_odivx.c,v
retrieving revision 1.14
diff -u -r1.14 vd_odivx.c
--- libmpcodecs/vd_odivx.c 6 Feb 2003 20:24:14 -0000 1.14
+++ libmpcodecs/vd_odivx.c 24 May 2003 08:11:11 -0000
@@ -53,6 +53,14 @@
#include <decore.h>
#endif
+#ifndef DECORE_VERSION
+#define DECORE_VERSION 0
+#endif
+
+#if DECORE_VERSION >= 20021112
+static void* dec_handle = NULL;
+#endif
+
//**************************************************************************//
// The OpenDivX stuff:
//**************************************************************************//
@@ -85,21 +93,34 @@
switch(cmd){
case VDCTRL_QUERY_MAX_PP_LEVEL:
#ifdef NEW_DECORE
- return 9; // for divx4linux
+// return 9; // for divx4linux
+#if DECORE_VERSION >= 20021112
+ return 6; // divx4linux >= 5.0.5 -> 0..60
+#else
+ return 10; // divx4linux < 5.0.5 -> 0..100
+#endif
#else
return PP_QUALITY_MAX; // for opendivx
#endif
case VDCTRL_SET_PP_LEVEL: {
- DEC_SET dec_set;
int quality=*((int*)arg);
+#if DECORE_VERSION >= 20021112
+ 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);
+#else
+ DEC_SET dec_set;
#ifdef NEW_DECORE
- if(quality<0 || quality>9) quality=9;
+ if(quality<0 || quality>10) quality=10;
dec_set.postproc_level=quality*10;
#else
if(quality<0 || quality>PP_QUALITY_MAX) quality=PP_QUALITY_MAX;
dec_set.postproc_level=getPpModeForQuality(quality);
#endif
decore(0x123,DEC_OPT_SETPP,&dec_set,NULL);
+#endif
return CONTROL_OK;
}
@@ -110,6 +131,45 @@
// init driver
static int init(sh_video_t *sh){
+#if DECORE_VERSION >= 20021112
+ DEC_INIT dec_init;
+ int iSize=sizeof(DivXBitmapInfoHeader);
+ DivXBitmapInfoHeader* pbi=malloc(iSize);
+ int32_t iInstruction;
+
+ memset(&dec_init, 0, sizeof(dec_init));
+ memset(pbi, 0, iSize);
+
+ switch(sh->format) {
+ case mmioFOURCC('D','I','V','3'):
+ dec_init.codec_version = 311;
+ break;
+ case mmioFOURCC('D','I','V','X'):
+ dec_init.codec_version = 412;
+ break;
+ case mmioFOURCC('D','X','5','0'):
+ default: // Fallback to DivX 5 behaviour
+ dec_init.codec_version = 500;
+ }
+
+ // no smoothing of the CPU load
+ dec_init.smooth_playback = 0;
+
+ pbi->biSize=iSize;
+
+ pbi->biCompression=mmioFOURCC('U','S','E','R');
+
+ pbi->biWidth = sh->disp_w;
+ pbi->biHeight = sh->disp_h;
+
+ decore(&dec_handle, DEC_OPT_INIT, &dec_init, 0);
+ decore(dec_handle, DEC_OPT_SETOUT, pbi, 0);
+
+ iInstruction = DEC_ADJ_POSTPROCESSING | DEC_ADJ_SET;
+ decore(dec_handle, DEC_OPT_ADJUST, &iInstruction, &divx_quality);
+
+ free(pbi);
+#else // DECORE_VERSION < 20021112
DEC_PARAM dec_param;
DEC_SET dec_set;
@@ -152,6 +212,7 @@
dec_set.postproc_level = divx_quality;
decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
+#endif // DECORE_VERSION
mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n");
@@ -160,7 +221,12 @@
// uninit driver
static void uninit(sh_video_t *sh){
+#if DECORE_VERSION >= 20021112
+ decore(dec_handle, DEC_OPT_RELEASE, NULL, NULL);
+ dec_handle = NULL;
+#else
decore(0x123,DEC_OPT_RELEASE,NULL,NULL);
+#endif
}
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
@@ -170,8 +236,12 @@
mp_image_t* mpi;
DEC_FRAME dec_frame;
#ifdef NEW_DECORE
+#if DECORE_VERSION >= 20021112
+ DEC_FRAME_INFO dec_pic;
+#else
DEC_PICTURE dec_pic;
#endif
+#endif
if(len<=0) return NULL; // skipped frame
@@ -179,7 +249,15 @@
dec_frame.bitstream = data;
dec_frame.render_flag = (flags&3)?0:1;
+ mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
+ sh->disp_w, sh->disp_h);
+ if(!mpi) return NULL;
+
#ifdef NEW_DECORE
+#if DECORE_VERSION >= 20021112
+ dec_frame.stride=mpi->width;
+ decore(dec_handle, DEC_OPT_FRAME, &dec_frame, &dec_pic);
+#else
dec_frame.bmp=&dec_pic;
dec_pic.y=dec_pic.u=dec_pic.v=NULL;
#ifndef DEC_OPT_FRAME_311
@@ -187,6 +265,7 @@
#else
decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
#endif
+#endif
#else
// opendivx:
opendivx_src[0]=NULL;
@@ -200,10 +279,6 @@
#else
if(!opendivx_src[0]) return NULL; // bad frame
#endif
-
- mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
- sh->disp_w, sh->disp_h);
- if(!mpi) return NULL;
#ifdef NEW_DECORE
mpi->planes[0]=dec_pic.y;
More information about the MPlayer-dev-eng
mailing list