changeset 26842:c675462d66d9

Render everything as early as possible, doing as little as possible in flip_page. Can improve A-V sync when playing a video that uses little CPU with GPU filtering that is very slow.
author reimar
date Sun, 25 May 2008 11:26:09 +0000
parents 3822def2c61d
children 7ba8584ff843
files libvo/vo_gl.c
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Sun May 25 11:11:32 2008 +0000
+++ b/libvo/vo_gl.c	Sun May 25 11:26:09 2008 +0000
@@ -117,6 +117,8 @@
 
 static unsigned int slice_height = 1;
 
+static void redraw(void);
+
 static void resize(int x,int y){
   mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
   if (WinID >= 0) {
@@ -154,7 +156,7 @@
   vo_osd_changed(OSDTYPE_OSD);
   }
   glClear(GL_COLOR_BUFFER_BIT);
-  flip_page();
+  redraw();
 }
 
 static void texSize(int w, int h, int *texw, int *texh) {
@@ -505,7 +507,7 @@
 {
     int e=vo_check_events();
     if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
-    if(e&VO_EVENT_EXPOSE && int_pause) flip_page();
+    if(e&VO_EVENT_EXPOSE && int_pause) redraw();
 }
 
 /**
@@ -577,6 +579,8 @@
   osdtexCnt++;
 }
 
+static void do_render_osd(void);
+
 static void draw_osd(void)
 {
   if (!use_osd) return;
@@ -587,6 +591,7 @@
     osd_h = (scaled_osd) ? image_height : vo_dheight;
     vo_draw_text(osd_w, osd_h, create_osd_texture);
   }
+  if (vo_doublebuffering) do_render_osd();
 }
 
 static void do_render(void) {
@@ -603,7 +608,9 @@
             mpi_flipped ^ vo_flipped);
   if (image_format == IMGFMT_YV12)
     glDisableYUVConversion(gl_target, yuvconvtype);
+}
 
+static void do_render_osd(void) {
   if (osdtexCnt > 0 || eosdDispList) {
     // set special rendering parameters
     if (!scaled_osd) {
@@ -636,18 +643,24 @@
 }
 
 static void flip_page(void) {
-  do_render();
   if (vo_doublebuffering) {
     if (use_glFinish) glFinish();
     swapGlBuffers();
     if (vo_fs && use_aspect)
       glClear(GL_COLOR_BUFFER_BIT);
   } else {
+    do_render();
+    do_render_osd();
     if (use_glFinish) glFinish();
     else glFlush();
   }
 }
 
+static void redraw(void) {
+  if (vo_doublebuffering) { do_render(); do_render_osd(); }
+  flip_page();
+}
+
 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
 {
@@ -716,7 +729,7 @@
   unsigned char *planes[3];
   mp_image_t mpi2 = *mpi;
   if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
-    return VO_TRUE;
+    goto skip_upload;
   mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP;
   mpi2.width = mpi2.w; mpi2.height = mpi2.h;
   if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) {
@@ -756,6 +769,8 @@
   }
   if (mpi->flags & MP_IMGFLAG_DIRECT)
     BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+skip_upload:
+  if (vo_doublebuffering) do_render();
   return VO_TRUE;
 }