[MPlayer-dev-eng] vo_gl PBO patch ..

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Apr 30 20:29:13 CEST 2008


On Tue, Apr 29, 2008 at 01:44:32PM -0600, Sven Gothel wrote:
> version 4 .. reflecting Reimar's suggestions.

I still have some problems understanding the need for most of those
changes.
While it is really ugly for several reasons and I will have to clean it up
once I have a bit more time, could you please use attached patch and
tell me what it misses in functionality compared to yours?
One "issue" I know is that you may have to use -noslices to make it have
an effect.
Another thing is probably the GL_UNPACK_ROW_LENGTH support you said ATI drivers
are lacking, if this still causes a problems with this patch I'd need a bit
more information on this.
The usage would be something like
mplayer -vo gl:yuv=2:force-pbo -noslices file.avi

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/vo_gl.c
===================================================================
--- libvo/vo_gl.c	(revision 26622)
+++ libvo/vo_gl.c	(working copy)
@@ -16,6 +16,7 @@
 #ifdef HAVE_NEW_GUI
 #include "gui/interface.h"
 #endif
+#include "fastmemcpy.h"
 #include "libass/ass.h"
 #include "libass/ass_mp.h"
 
@@ -81,6 +82,7 @@
 static uint32_t image_format;
 static int many_fmts;
 static int use_glFinish;
+static int force_pbo;
 static int swap_interval;
 static GLenum gl_target;
 static GLint gl_texfmt;
@@ -706,10 +708,23 @@
 
 static uint32_t draw_image(mp_image_t *mpi) {
   int slice = slice_height;
-  int stride[3] = {mpi->stride[0], mpi->stride[1], mpi->stride[2]};
-  unsigned char *planes[3] = {mpi->planes[0], mpi->planes[1], mpi->planes[2]};
+  mp_image_t mpi2 = *mpi;
+  int stride[3];
+  unsigned char *planes[3];
   if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
     return VO_TRUE;
+  mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP;
+  if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) {
+    int bpp = mpi->imgfmt == IMGFMT_YV12 ? 1 : mpi->bpp;
+    memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->width * bpp, mpi->height, mpi2.stride[0], mpi->stride[0]);
+    if (mpi->imgfmt == IMGFMT_YV12) {
+      memcpy_pic(mpi2.planes[1], mpi->planes[1], mpi->width >> 1, mpi->height >> 1, mpi2.stride[1], mpi->stride[1]);
+      memcpy_pic(mpi2.planes[2], mpi->planes[2], mpi->width >> 1, mpi->height >> 1, mpi2.stride[2], mpi->stride[2]);
+    }
+    mpi = &mpi2;
+  }
+  stride[0] = mpi->stride[0]; stride[1] = mpi->stride[1]; stride[2] = mpi->stride[2];
+  planes[0] = mpi->planes[0]; planes[1] = mpi->planes[1]; planes[2] = mpi->planes[2];
   mpi_flipped = (stride[0] < 0);
   if (mpi->flags & MP_IMGFLAG_DIRECT) {
     intptr_t base = (intptr_t)planes[0];
@@ -792,6 +807,7 @@
   {"lscale",       OPT_ARG_INT,  &lscale,       (opt_test_f)int_non_neg},
   {"cscale",       OPT_ARG_INT,  &cscale,       (opt_test_f)int_non_neg},
   {"glfinish",     OPT_ARG_BOOL, &use_glFinish, NULL},
+  {"force-pbo",    OPT_ARG_BOOL, &force_pbo,    NULL},
   {"swapinterval", OPT_ARG_INT,  &swap_interval,NULL},
   {"customprog",   OPT_ARG_MSTRZ,&custom_prog,  NULL},
   {"customtex",    OPT_ARG_MSTRZ,&custom_tex,   NULL},
@@ -813,6 +829,7 @@
     cscale = 0;
     use_rectangle = 0;
     use_glFinish = 0;
+    force_pbo = 0;
     swap_interval = 1;
     slice_height = 0;
     custom_prog = NULL;
@@ -837,6 +854,8 @@
               "    0: use power-of-two textures\n"
               "    1: use texture_rectangle\n"
               "    2: use texture_non_power_of_two\n"
+              "  force-pbo\n"
+              "    Force use of PBO even if this involves an extra memcpy\n"
               "  glfinish\n"
               "    Call glFinish() before swapping buffers\n"
               "  swapinterval=<n>\n"


More information about the MPlayer-dev-eng mailing list