diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-06-06 19:57:37 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-06-06 19:57:37 +0000 |
commit | 1864646717e2ca3a15ef08b7950a4cc37681fbba (patch) | |
tree | 4cc0f79e75e040ba87ded341c662741d5ea3945f /libmpcodecs/vd_divx4.c | |
parent | f68ae8a4e9b4ccc756fb3eb82a1745b505cdd047 (diff) | |
download | mpv-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_divx4.c')
-rw-r--r-- | libmpcodecs/vd_divx4.c | 151 |
1 files changed, 141 insertions, 10 deletions
diff --git a/libmpcodecs/vd_divx4.c b/libmpcodecs/vd_divx4.c index 0d9735a92f..fc348e20cd 100644 --- a/libmpcodecs/vd_divx4.c +++ b/libmpcodecs/vd_divx4.c @@ -42,22 +42,41 @@ LIBVD_EXTERN(divx4) #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 +#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 +86,35 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){ 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 +123,89 @@ 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; + + 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 +262,8 @@ static int init(sh_video_t *sh){ 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 +271,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); @@ -176,7 +302,12 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ 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 |