[Mplayer-cvslog] CVS: main/libmpcodecs vd_xvid.c,NONE,1.1 Makefile,1.48,1.49 vd.c,1.42,1.43 vd_divx4.c,1.8,1.9 vd_odivx.c,1.9,1.10

Alban Bedel CVS albeu at mplayerhq.hu
Wed Jul 10 22:57:00 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv25137/libmpcodecs

Modified Files:
	Makefile vd.c vd_divx4.c vd_odivx.c 
Added Files:
	vd_xvid.c 
Log Message:
Support for Xvid using their new api. If divx4 compatiblity is disabeled
in xvid it can be used along with divx4.


--- NEW FILE ---
#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

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- Makefile	22 Jun 2002 23:09:40 -0000	1.48
+++ Makefile	10 Jul 2002 20:56:57 -0000	1.49
@@ -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

Index: vd.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- vd.c	22 Jun 2002 23:09:40 -0000	1.42
+++ vd.c	10 Jul 2002 20:56:57 -0000	1.43
@@ -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
 };
 

Index: vd_divx4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_divx4.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vd_divx4.c	21 Mar 2002 18:59:07 -0000	1.8
+++ vd_divx4.c	10 Jul 2002 20:56:57 -0000	1.9
@@ -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,...){

Index: vd_odivx.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_odivx.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- vd_odivx.c	21 Mar 2002 18:59:07 -0000	1.9
+++ vd_odivx.c	10 Jul 2002 20:56:57 -0000	1.10
@@ -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




More information about the MPlayer-cvslog mailing list