summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vd_odivx.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-06-06 19:57:37 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-06-06 19:57:37 +0000
commit1864646717e2ca3a15ef08b7950a4cc37681fbba (patch)
tree4cc0f79e75e040ba87ded341c662741d5ea3945f /libmpcodecs/vd_odivx.c
parentf68ae8a4e9b4ccc756fb3eb82a1745b505cdd047 (diff)
downloadmpv-1864646717e2ca3a15ef08b7950a4cc37681fbba.tar.bz2
mpv-1864646717e2ca3a15ef08b7950a4cc37681fbba.tar.xz
I've found some time to implement the encoding support for the new
DivX API. Now it's possible to play and encode movies with the latest DivX release. One thing that doesn't work is the new Video Buffer Verifier (VBV) multipass encoding. The encoder segfaults. Maybe it just isn't supported with the standard profile of the released binary encoder. Andreas Hess <jaska@gmx.net> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10253 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/vd_odivx.c')
-rw-r--r--libmpcodecs/vd_odivx.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/libmpcodecs/vd_odivx.c b/libmpcodecs/vd_odivx.c
index b9700a476d..986814939a 100644
--- a/libmpcodecs/vd_odivx.c
+++ b/libmpcodecs/vd_odivx.c
@@ -53,6 +53,14 @@ LIBVD_EXTERN(odivx)
#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,33 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){
switch(cmd){
case VDCTRL_QUERY_MAX_PP_LEVEL:
#ifdef NEW_DECORE
- 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 +130,45 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){
// 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, NULL);
+ decore(dec_handle, DEC_OPT_SETOUT, pbi, NULL);
+
+ 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 +211,7 @@ static int init(sh_video_t *sh){
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 +220,12 @@ static int init(sh_video_t *sh){
// 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 +235,12 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
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
@@ -180,6 +249,10 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
dec_frame.render_flag = (flags&3)?0:1;
#ifdef NEW_DECORE
+#if DECORE_VERSION >= 20021112
+ dec_frame.stride=sh->disp_w;
+ 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 +260,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
#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;