[MPlayer-dev-eng] [Patch] Direct rendering in vo_sdl

Fredrik Kuivinen freku045 at student.liu.se
Tue Mar 12 23:26:25 CET 2002


Hi

$SUBJ says it all. A quick benchmark gave this:

./mplayer -vo sdl -vm -nosound -benchmark -frames 1000 ~/film/Mem.avi

Without the patch:
AVE BENCHMARKs: VC:   2.257s VO:   5.375s A:   0.000s Sys:   0.360s =    7.991s
AVE BENCHMARK%: VC: 28.2432% VO: 67.2580% A:  0.0000% Sys:  4.4988% = 100.0000%

With dr patch:
AVE BENCHMARKs: VC:   2.239s VO:   3.794s A:   0.000s Sys:   0.432s =    6.464s
AVE BENCHMARK%: VC: 34.6330% VO: 58.6911% A:  0.0000% Sys:  6.6759% = 100.0000%

Quite nice speed increase :)

/ Fredrik Kuivinen

-------------- next part --------------
Index: vo_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_sdl.c,v
retrieving revision 1.71
diff -u -3 -p -b -r1.71 vo_sdl.c
--- vo_sdl.c	3 Mar 2002 13:40:23 -0000	1.71
+++ vo_sdl.c	12 Mar 2002 21:51:14 -0000
@@ -114,6 +114,7 @@
 #include "fastmemcpy.h"
 #include "sub.h"
 #include "aspect.h"
+#include "../mp_image.h"
 
 #ifdef HAVE_X11
 #include <X11/Xlib.h>
@@ -263,7 +264,7 @@ static struct sdl_priv_s {
     int osd_has_changed;
     
 	/* source image format (YUV/RGB/...) */
-        int format;
+    uint32_t format;
 
     /* dirty_off_frame[0] contains a bounding box around the osd contents drawn above the image
        dirty_off_frame[1] is the corresponding thing for OSD contents drawn below the image
@@ -1655,10 +1661,51 @@ static uint32_t preinit(const char *arg)
   return 0;
 }
 
+static uint32_t get_image(mp_image_t *mpi)
+{
+	struct sdl_priv_s *priv = &sdl_priv;
+
+    if(priv->format != mpi->imgfmt) return VO_FALSE;
+    if(mpi->type == MP_IMGTYPE_STATIC || mpi->type == MP_IMGTYPE_TEMP) {
+        if(priv->format == IMGFMT_YV12 || priv->format == SDL_IYUV_OVERLAY) {
+            mpi->planes[0] = priv->overlay->pixels[0] + priv->y*priv->overlay->pitches[0];
+            mpi->planes[1] = priv->overlay->pixels[1] + priv->y*priv->overlay->pitches[1]/2;
+            mpi->planes[2] = priv->overlay->pixels[2] + priv->y*priv->overlay->pitches[2]/2;
+            mpi->stride[0] = priv->overlay->pitches[0];
+            mpi->stride[1] = priv->overlay->pitches[1];
+            mpi->stride[2] = priv->overlay->pitches[2];
+        }
+        else if(IMGFMT_IS_RGB(priv->format) || IMGFMT_IS_BGR(priv->format)) {
+            if(priv->dblit) {
+                if(mpi->type == MP_IMGTYPE_STATIC && (priv->surface->flags & SDL_DOUBLEBUF))
+                    return VO_FALSE;
+                
+                mpi->planes[0] = priv->surface->pixels + priv->y*priv->surface->pitch;
+                mpi->stride[0] = priv->surface->pitch;
+            }
+            else {
+                mpi->planes[0] = priv->rgbsurface->pixels + priv->y*priv->rgbsurface->pitch;
+                mpi->stride[0] = priv->rgbsurface->pitch;
+            }
+        }
+        else {
+            mpi->planes[0] = priv->overlay->pixels[0] + priv->y*priv->overlay->pitches[0];
+            mpi->stride[0] = priv->overlay->pitches[0];
+        }
+
+        mpi->flags|=MP_IMGFLAG_DIRECT;
+        return VO_TRUE;
+    }
+
+    return VO_FALSE;
+}
+
 static uint32_t control(uint32_t request, void *data, ...)
 {
   struct sdl_priv_s *priv = &sdl_priv;
   switch (request) {
+  case VOCTRL_GET_IMAGE:
+      return get_image(data);
   case VOCTRL_QUERY_FORMAT:
     return query_format(*((uint32_t*)data));
   case VOCTRL_FULLSCREEN:


More information about the MPlayer-dev-eng mailing list