[MPlayer-dev-eng] [PATCH]: reduce vsync wait in VDPAU

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Feb 25 14:35:28 CET 2009


On Wed, Feb 25, 2009 at 01:59:22PM +0100, Reimar Döffinger wrote:
> On Wed, Feb 25, 2009 at 01:45:39PM +0100, Dan Oscarsson wrote:
> > On 2009-02-25 at 13:05 +0100 Reimar Döffinger wrote:
> > > According to my information, you are supposed to use the timestamps
> > > feature of the flip queue to solve this issue. I have not yet
> > > investigated that though, so I do not know if it is actually appropriate
> > > for MPlayer.
> > 
> > It can probably be used in the sync-to-vsync handling i mplayer, but
> > will not solve this issue.
> 
> As I understood it, it will automatically drop a frame if there is no
> vsync between the requested display time of that and the next frame, so
> it should solve the issue, but in a way that would allow VDPAU to have
> full control and e.g. use strategies to minimize jitter (which are
> easier to implement at driver level).

Tests reveal that you are right though. What concerns me is that in my
own attempt, vdp_presentation_queue_query_surface_status would not work
at all, surfaces would remain in queued state forever.
Maybe someone else can find out why with attached patch.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/vo_vdpau.c
===================================================================
--- libvo/vo_vdpau.c	(revision 28731)
+++ libvo/vo_vdpau.c	(working copy)
@@ -75,7 +75,7 @@
                message, vdp_get_error_string(vdp_st));
 
 /* number of video and output surfaces */
-#define NUM_OUTPUT_SURFACES                2
+#define NUM_OUTPUT_SURFACES                6
 #define MAX_VIDEO_SURFACES                 50
 
 /* number of palette entries */
@@ -125,6 +125,7 @@
 static VdpPresentationQueueCreate        *vdp_presentation_queue_create;
 static VdpPresentationQueueDestroy       *vdp_presentation_queue_destroy;
 static VdpPresentationQueueDisplay       *vdp_presentation_queue_display;
+static VdpPresentationQueueQuerySurfaceStatus    *vdp_presentation_queue_query_surface_status;
 static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle;
 static VdpPresentationQueueTargetCreateX11       *vdp_presentation_queue_target_create_x11;
 
@@ -319,6 +320,8 @@
                         &vdp_presentation_queue_destroy},
         {VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY,
                         &vdp_presentation_queue_display},
+        {VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS,
+                        &vdp_presentation_queue_query_surface_status},
         {VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE,
                         &vdp_presentation_queue_block_until_surface_idle},
         {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11,
@@ -740,6 +743,13 @@
 static void flip_page(void)
 {
     VdpStatus vdp_st;
+    VdpPresentationQueueStatus next_status = VDP_PRESENTATION_QUEUE_STATUS_IDLE;
+    VdpTime time_dummy;
+    int next_surface = (surface_num + 1) % NUM_OUTPUT_SURFACES;
+    vdp_st = vdp_presentation_queue_query_surface_status(vdp_flip_queue,
+                output_surfaces[next_surface], &next_status, &time_dummy);
+    if (vdp_st == VDP_STATUS_OK && next_status == VDP_PRESENTATION_QUEUE_STATUS_QUEUED)
+        return;
     mp_msg(MSGT_VO, MSGL_DBG2, "\nFLIP_PAGE VID:%u -> OUT:%u\n",
            surface_render[vid_surface_num].surface, output_surfaces[surface_num]);
 
@@ -748,7 +758,7 @@
                                             0);
     CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display")
 
-    surface_num = (surface_num + 1) % NUM_OUTPUT_SURFACES;
+    surface_num = next_surface;
     visible_buf = 1;
 }
 


More information about the MPlayer-dev-eng mailing list