changeset 6756:6af6d7b40638

Add direct rendering method 2
author albeu
date Sat, 20 Jul 2002 13:53:53 +0000
parents a31b9f15cbff
children f72fc85934e5
files cfg-common.h libmpcodecs/vd_xvid.c
diffstat 2 files changed, 44 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Fri Jul 19 20:51:48 2002 +0000
+++ b/cfg-common.h	Sat Jul 20 13:53:53 2002 +0000
@@ -137,6 +137,9 @@
 #ifdef USE_LIBAVCODEC
 	{"lavdopts", lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 #endif
+#ifdef HAVE_XVID
+	{"xvidopts", xvid_dec_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+#endif
 // ------------------------- subtitles options --------------------
 
 #ifdef USE_SUB
@@ -259,4 +262,8 @@
 extern struct config lavc_decode_opts_conf[];
 #endif
 
+#ifdef HAVE_XVID
+extern struct config xvid_dec_opts[];
 #endif
+
+#endif
--- a/libmpcodecs/vd_xvid.c	Fri Jul 19 20:51:48 2002 +0000
+++ b/libmpcodecs/vd_xvid.c	Sat Jul 20 13:53:53 2002 +0000
@@ -7,10 +7,14 @@
 #ifdef HAVE_XVID
 
 #include "vd_internal.h"
+#include "cfgparser.h"
 
 #include <divx4.h>
 #include <xvid.h>
 
+#ifndef XVID_CSP_EXTERN
+#error "You need lastest XviD CVS"
+#endif
 
 static vd_info_t info = 
 {
@@ -26,10 +30,19 @@
 
 typedef struct {
   int cs;
+  unsigned char img_type;
   void* hdl;
   mp_image_t* mpi;
 } priv_t;
 
+static int do_dr2 = 0;
+
+struct config xvid_dec_opts[] = {
+  { "dr2", &do_dr2, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+  { "nodr2", &do_dr2, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+  {NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
 // to set/get/query special features/parameters
 static int control(sh_video_t *sh,int cmd,void* arg,...){
   return CONTROL_UNKNOWN;
@@ -50,7 +63,7 @@
 
   switch(sh->codec->outfmt[sh->outfmtidx]){
   case IMGFMT_YV12:
-    cs= XVID_CSP_USER;
+    cs= do_dr2 ? XVID_CSP_EXTERN : XVID_CSP_USER;
     break;
   case IMGFMT_YUY2:
     cs=XVID_CSP_YUY2;
@@ -106,6 +119,18 @@
   p->hdl = dec_p.handle;
   sh->context = p;
 
+  switch(cs) {
+  case XVID_CSP_EXTERN:
+    p->img_type = MP_IMGTYPE_STATIC;
+    break;
+  case XVID_CSP_USER:
+    p->img_type = MP_IMGTYPE_EXPORT;
+    break;
+  default:
+    p->img_type = MP_IMGTYPE_TEMP;
+    break;
+  }
+
   return 1;
 }
 
@@ -122,10 +147,10 @@
 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
   XVID_DEC_FRAME dec;
   DEC_PICTURE d4_pic;
+  XVID_DEC_PICTURE 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_image_t* mpi = mpcodecs_get_image(sh,  p->img_type,
 				       MP_IMGFLAG_ACCEPT_STRIDE,
 				       sh->disp_w,sh->disp_h);
 
@@ -140,6 +165,15 @@
   case XVID_CSP_USER:
     dec.image = &d4_pic;
     break;
+  case XVID_CSP_EXTERN:
+    pic.y = mpi->planes[0];
+    pic.u = mpi->planes[1];
+    pic.v = mpi->planes[2];
+    pic.stride_y = mpi->stride[0];
+    pic.stride_u = mpi->stride[1];
+    pic.stride_v = mpi->stride[2];
+    dec.image = &pic;
+    break;
   default:
     dec.image = mpi->planes[0];
     if(IMGFMT_IS_BGR(mpi->imgfmt) || IMGFMT_IS_RGB(mpi->imgfmt))