Mercurial > mplayer.hg
changeset 6701:522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
in xvid it can be used along with divx4.
author | albeu |
---|---|
date | Wed, 10 Jul 2002 20:56:57 +0000 |
parents | 3b1be2b0fa55 |
children | df3bf0f971d1 |
files | Makefile codec-cfg.c codec-cfg.h configure etc/codecs.conf libmpcodecs/Makefile libmpcodecs/vd.c libmpcodecs/vd_divx4.c libmpcodecs/vd_odivx.c libmpcodecs/vd_xvid.c |
diffstat | 10 files changed, 260 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Wed Jul 10 13:58:54 2002 +0000 +++ b/Makefile Wed Jul 10 20:56:57 2002 +0000 @@ -50,7 +50,7 @@ AO_LIBS = -Llibao2 -lao2 A_LIBS = $(ALSA_LIB) $(ARTS_LIB) $(NAS_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(SGIAUDIO_LIB) -CODEC_LIBS = -Llibmpcodecs -lmpcodecs -Lmp3lib -lMP3 -Lliba52 -la52 -Llibmpeg2 -lmpeg2 $(AV_LIB) $(FAME_LIB) +CODEC_LIBS = -Llibmpcodecs -lmpcodecs -Lmp3lib -lMP3 -Lliba52 -la52 -Llibmpeg2 -lmpeg2 $(AV_LIB) $(FAME_LIB) $(XVID_LIB) COMMON_LIBS = $(CODEC_LIBS) -Llibmpdemux -lmpdemux $(NEW_INPUT_LIB) $(LIB_LOADER) $(A_LIBS) $(CSS_LIB) $(ARCH_LIB) -Lpostproc -lpostproc $(DECORE_LIB) -Llinux -losdep $(TERMCAP_LIB) $(STREAMING_LIB) $(Z_LIB) $(GTK_LIBS) $(PNG_LIB) $(JPEG_LIB) $(GIF_LIB) $(CDPARANOIA_LIB) -lm ifeq ($(VIDIX),yes) MISC_LIBS += -Llibdha -ldha -Lvidix -lvidix
--- a/codec-cfg.c Wed Jul 10 13:58:54 2002 +0000 +++ b/codec-cfg.c Wed Jul 10 20:56:57 2002 +0000 @@ -263,6 +263,7 @@ "mpegpes", "realvid", "svq1", + "xvid", NULL }; char **drv=audioflag?audiodrv:videodrv;
--- a/codec-cfg.h Wed Jul 10 13:58:54 2002 +0000 +++ b/codec-cfg.h Wed Jul 10 20:56:57 2002 +0000 @@ -76,6 +76,7 @@ #define VFM_MPEGPES 25 #define VFM_REAL 26 #define VFM_SVQ1 27 +#define VFM_XVID 28 #ifndef GUID_TYPE #define GUID_TYPE
--- a/configure Wed Jul 10 13:58:54 2002 +0000 +++ b/configure Wed Jul 10 20:56:57 2002 +0000 @@ -3547,37 +3547,67 @@ echores "$_zr" fi - -echocheck "XviD/DivX4linux/DivX5linux/OpenDivX decore" +echocheck "XviD" +cat > $TMPC << EOF +#include <xvid.h> +int main(void) { xvid_init(0, 0, 0, 0); return 0; } +EOF +if test "$_xvid" != no && cc_check -lm "$_xvidcore" ; then + _xvid=yes + _ld_xvid="$_xvidcore" + _def_xvid='#define HAVE_XVID 1' + _codecmodules="xvid $_codecmodules" +elif test "$_xvid" != no && cc_check -lm -lxvidcore ; then + _xvid=yes + _ld_xvid='-lxvidcore' + _def_xvid='#define HAVE_XVID 1' + _codecmodules="xvid $_codecmodules" +else + _xvid=no + _ld_xvid='' + _def_xvid='#undef HAVE_XVID' + _nocodecmodules="xvid $_nocodecmodules" +fi +echores "$_xvid" + +_xvidcompat=no +_def_divx4_h='#undef HAVE_DIVX4_H' +if test "$_xvid" = yes ; then + echocheck "DivX4 compatibility in XviD" + cat > $TMPC << EOF +#include <divx4.h> +int main(void) { (void) decore(0, 0, 0, 0); return 0; } +EOF + if cc_check -lm "$_ld_xvid" ; then + _xvidcompat='yes (using divx4.h)' + _def_divx4_h='#define HAVE_DIVX4_H 1' + else + cat > $TMPC << EOF +#include <decore.h> +int main(void) { (void) decore(0, 0, 0, 0); return 0; } +EOF + cc_check -lm "$_ld_xvid" && _xvidcompat='yes (using decore.h)' + fi + echores "$_xvidcompat" +fi + +if test "$_xvidcompat" != no ; then + _divx4linux=no + _opendivx=no + _ld_decore='' + _def_decore='#define NEW_DECORE 1' + _def_divx='#define USE_DIVX 1' + _def_divx5='#undef DECORE_DIVX5' + _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS' + _nocodecmodules="opendivx divx5linux divx4linux $_nocodecmodules" +else +echocheck "DivX4linux/DivX5linux/OpenDivX decore" # DivX5: DEC_OPT_MEMORY_REQS - DivX4: DEC_OPT_FRAME_311 cat > $TMPC << EOF #include <decore.h> int main(void) { (void) decore(0, 0, 0, 0); return DEC_OPT_FRAME_311; } EOF -if test "$_xvidcore" && cc_check -lm "$_xvidcore" ; then - _xvid=yes - _divx4linux=no - _opendivx=no - _ld_decore="$_xvidcore" - _def_decore='#define NEW_DECORE 1' - _def_divx='#define USE_DIVX' - _def_divx5='#undef DECORE_DIVX5' - _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS' - _codecmodules="xvid $_codecmodules" - echores "XviD (with $_xvidcore)" -elif test "$_xvid" != no && cc_check -lm -lxvidcore ; then - _xvid=yes - _divx4linux=no - _opendivx=no - _ld_decore='-lxvidcore' - _def_decore='#define NEW_DECORE 1' - _def_divx='#define USE_DIVX' - _def_divx5='#undef DECORE_DIVX5' - _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS' - _codecmodules="xvid $_codecmodules" - echores "XviD (with libxvidcore.so)" -elif test "$_divx4linux" != no && cc_check -lm -ldivxdecore -lm ; then - _xvid=no +if test "$_divx4linux" != no && cc_check -lm -ldivxdecore -lm ; then _divx4linux=yes _opendivx=no _ld_decore='-ldivxdecore' @@ -3586,7 +3616,6 @@ _def_divx5='#undef DECORE_DIVX5' _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS' _codecmodules="divx4linux $_codecmodules" - _nocodecmodules="xvid $_nocodecmodules" echores "DivX4linux (with libdivxdecore.so)" elif test "$_divx4linux" != no ; then # DivX5 check @@ -3597,7 +3626,6 @@ int main(void) { (void) decore(0, 0, 0, 0); return DEC_OPT_MEMORY_REQS; } EOF if cc_check -lm -ldivxdecore -lm ; then - _xvid=no _divx4linux=yes _opendivx=no # _ld_decore='-ldivxdecore opendivx/postprocess.o' @@ -3611,7 +3639,6 @@ _nocodecmodules="divx4linux $_nocodecmodules" echores "DivX5linux (with libdivxdecore.so)" elif test "$_opendivx" != no ; then - _xvid=no _divx4linux=no _opendivx=yes _ld_decore='-Lopendivx -ldecore' @@ -3623,7 +3650,6 @@ _nocodecmodules="divx5linux $_nocodecmodules" echores "OpenDivX" else - _xvid=no _divx4linux=no _opendivx=no _ld_decore='' @@ -3635,7 +3661,7 @@ echores "no" fi # DivX5 check fi - +fi # XviD divx4 compatiblity check # mencoder requires (optional) those libs: libmp3lame and divx4linux encore if test "$_mencoder" != no ; then @@ -4110,6 +4136,7 @@ ARCH_LIB = $_ld_arch $_ld_iconv DIVX4LINUX = $_divx4linux XVID = $_xvid +XVID_LIB = $_ld_xvid DECORE_LIB = $_ld_decore MENCODER = $_mencoder ENCORE_LIB = $_ld_encore $_ld_mp3lame $_ld_libdv @@ -4203,6 +4230,12 @@ /* Define if you are using DivX5Linux Decore library */ $_def_divx5 +/* Define if you are using XviD library */ +$_def_xvid + +/* Define if you have divx4.h in place of decore.h */ +$_def_divx4_h + /* Define to include support for libdv-0.9.5 */ $_def_libdv
--- a/etc/codecs.conf Wed Jul 10 13:58:54 2002 +0000 +++ b/etc/codecs.conf Wed Jul 10 20:56:57 2002 +0000 @@ -268,6 +268,20 @@ dll mpeg4 ;opendivx out YV12,I420,IYUV +videocodec xvid + info "Xvid (MPEG-4)" + status working + fourcc DIVX,divx + fourcc xvid,XVID,XviD + format 0x4 + driver xvid + out YV12 + out I420 + out YUY2 + out UYVY + out YVYU + out BGR32,BGR24,BGR16,BGR15 + ; divx4 does direct render, and is native on linux videocodec odivx
--- a/libmpcodecs/Makefile Wed Jul 10 13:58:54 2002 +0000 +++ b/libmpcodecs/Makefile Wed Jul 10 20:56:57 2002 +0000 @@ -5,7 +5,7 @@ LIBNAME2 = libmpencoders.a AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dk4adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c ad_faad.c ad_vorbis.c ad_libmad.c ad_real.c -VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_real.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c vd_svq1.c +VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_real.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c vd_svq1.c vd_xvid.c VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/cyuv.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c
--- a/libmpcodecs/vd.c Wed Jul 10 13:58:54 2002 +0000 +++ b/libmpcodecs/vd.c Wed Jul 10 20:56:57 2002 +0000 @@ -52,6 +52,7 @@ extern vd_functions_t mpcodecs_vd_mpegpes; extern vd_functions_t mpcodecs_vd_real; extern vd_functions_t mpcodecs_vd_svq1; +extern vd_functions_t mpcodecs_vd_xvid; vd_functions_t* mpcodecs_vd_drivers[] = { &mpcodecs_vd_null, @@ -101,6 +102,9 @@ &mpcodecs_vd_real, #endif &mpcodecs_vd_svq1, +#ifdef HAVE_XVID + &mpcodecs_vd_xvid, +#endif NULL };
--- a/libmpcodecs/vd_divx4.c Wed Jul 10 13:58:54 2002 +0000 +++ b/libmpcodecs/vd_divx4.c Wed Jul 10 20:56:57 2002 +0000 @@ -27,7 +27,11 @@ LIBVD_EXTERN(divx4) +#ifdef HAVE_DIVX4_H +#include <divx4.h> +#else #include <decore.h> +#endif // to set/get/query special features/parameters static int control(sh_video_t *sh,int cmd,void* arg,...){
--- a/libmpcodecs/vd_odivx.c Wed Jul 10 13:58:54 2002 +0000 +++ b/libmpcodecs/vd_odivx.c Wed Jul 10 20:56:57 2002 +0000 @@ -36,6 +36,8 @@ #ifndef NEW_DECORE #include "opendivx/decore.h" #include "postproc/postprocess.h" +#elif HAVE_DIVX4_H +#include <divx4.h> #else #include <decore.h> #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmpcodecs/vd_xvid.c Wed Jul 10 20:56:57 2002 +0000 @@ -0,0 +1,168 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "config.h" +#include "mp_msg.h" + +#ifdef HAVE_XVID + +#include "vd_internal.h" + +#include <divx4.h> +#include <xvid.h> + + +static vd_info_t info = +{ + "xvid decoder", + "xvid", + VFM_XVID, + "Albeu", + "Albeu", + "" +}; + +LIBVD_EXTERN(xvid) + +typedef struct { + int cs; + void* hdl; + mp_image_t* mpi; +} priv_t; + +// to set/get/query special features/parameters +static int control(sh_video_t *sh,int cmd,void* arg,...){ + return CONTROL_UNKNOWN; +} + +// init driver +static int init(sh_video_t *sh){ + XVID_INIT_PARAM ini; + XVID_DEC_PARAM dec_p; + priv_t* p; + int cs; + + memset(&ini,0,sizeof(XVID_INIT_PARAM)); + memset(&dec_p,0,sizeof(XVID_DEC_PARAM)); + + if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12)) + return 0; + + switch(sh->codec->outfmt[sh->outfmtidx]){ + case IMGFMT_YV12: + cs= XVID_CSP_USER; + break; + case IMGFMT_YUY2: + cs=XVID_CSP_YUY2; + break; + case IMGFMT_UYVY: + cs=XVID_CSP_UYVY; + break; + case IMGFMT_I420: + cs=XVID_CSP_I420; + break; + case IMGFMT_BGR15: + cs=XVID_CSP_RGB555; + break; + case IMGFMT_BGR16: + cs=XVID_CSP_RGB565; + break; + case IMGFMT_BGR24: + cs=XVID_CSP_RGB24; + break; + case IMGFMT_BGR32: + cs=XVID_CSP_RGB32; + break; + case IMGFMT_YVYU: + cs=XVID_CSP_YVYU; + break; + default: + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]); + return 0; + } + + if(xvid_init(NULL, 0, &ini, NULL)) + return 0; + + if(ini.api_version != API_VERSION) { + if(ini.api_version < API_VERSION) { + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Too old version of xivd (min. %d)\n",API_VERSION); + return 0; + } + mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Bad xvid version %d was compiled with %d\n", + ini.api_version,API_VERSION); + } + + dec_p.width = sh->disp_w; + dec_p.height = sh->disp_h; + + if(xvid_decore(NULL, XVID_DEC_CREATE, &dec_p, NULL)) { + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"xvid init failed\n"); + return 0; + } + + p = (priv_t*)malloc(sizeof(priv_t)); + p->cs = cs; + p->hdl = dec_p.handle; + sh->context = p; + + return 1; +} + +// uninit driver +static void uninit(sh_video_t *sh){ + priv_t* p = sh->context; + if(!p) + return; + xvid_decore(p->hdl,XVID_DEC_DESTROY, NULL, NULL); + free(p); +} + +// decode a frame +static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ + XVID_DEC_FRAME dec; + DEC_PICTURE d4_pic; + priv_t* p = sh->context; + + mp_image_t* mpi = mpcodecs_get_image(sh, p->cs == XVID_CSP_USER ? + MP_IMGTYPE_EXPORT : MP_IMGTYPE_TEMP, + MP_IMGFLAG_ACCEPT_STRIDE, + sh->disp_w,sh->disp_h); + + if(!data || !mpi || len <= 0) + return NULL; + + memset(&dec,0,sizeof(XVID_DEC_FRAME)); + + dec.bitstream = data; + dec.length = len; + switch(p->cs) { + case XVID_CSP_USER: + dec.image = &d4_pic; + break; + default: + dec.image = mpi->planes[0]; + if(IMGFMT_IS_BGR(mpi->imgfmt) || IMGFMT_IS_RGB(mpi->imgfmt)) + dec.stride = mpi->width; + else + dec.stride = mpi->stride[0]; + } + dec.colorspace = p->cs; + + if(xvid_decore(p->hdl,XVID_DEC_DECODE,&dec,NULL)) { + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"decoding error\n"); + return NULL; + } + + if(p->cs == XVID_CSP_USER) { + mpi->planes[0] = d4_pic.y; + mpi->planes[1] = d4_pic.u; + mpi->planes[2] = d4_pic.v; + mpi->stride[0] = d4_pic.stride_y; + mpi->stride[1] = mpi->stride[2] = d4_pic.stride_uv; + } + + return mpi; +} + +#endif