changeset 28696:fdc03572004c

Change code to actually work when NUM_OUTPUT_SURFACES is changed.
author reimar
date Wed, 25 Feb 2009 12:01:00 +0000
parents 127a1f702873
children 5b749a93fc89
files libvo/vo_vdpau.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vdpau.c	Wed Feb 25 09:32:32 2009 +0000
+++ b/libvo/vo_vdpau.c	Wed Feb 25 12:01:00 2009 +0000
@@ -75,7 +75,7 @@
                message, vdp_get_error_string(vdp_st));
 
 /* number of video and output surfaces */
-#define NUM_OUTPUT_SURFACES                3
+#define NUM_OUTPUT_SURFACES                2
 #define MAX_VIDEO_SURFACES                 50
 
 /* number of palette entries */
@@ -128,7 +128,6 @@
 static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle;
 static VdpPresentationQueueTargetCreateX11       *vdp_presentation_queue_target_create_x11;
 
-/* output_surfaces[2] is used in composite-picture. */
 static VdpOutputSurfaceRenderOutputSurface       *vdp_output_surface_render_output_surface;
 static VdpOutputSurfacePutBitsIndexed            *vdp_output_surface_put_bits_indexed;
 static VdpOutputSurfaceRenderBitmapSurface       *vdp_output_surface_render_bitmap_surface;
@@ -142,7 +141,9 @@
 static VdpDecoderRender                          *vdp_decoder_render;
 
 static void                              *vdpau_lib_handle;
-static VdpOutputSurface                   output_surfaces[NUM_OUTPUT_SURFACES];
+/* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */
+#define osd_surface output_surfaces[NUM_OUTPUT_SURFACES]
+static VdpOutputSurface                   output_surfaces[NUM_OUTPUT_SURFACES + 1];
 static int                                output_surface_width, output_surface_height;
 
 static VdpVideoMixer                      video_mixer;
@@ -266,7 +267,7 @@
             output_surface_height = FFMAX(output_surface_height, vo_dheight);
         }
         // Creation of output_surfaces
-        for (i = 0; i < NUM_OUTPUT_SURFACES; i++) {
+        for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) {
             if (output_surfaces[i] != VDP_INVALID_HANDLE)
                 vdp_output_surface_destroy(output_surfaces[i]);
             vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8,
@@ -585,8 +586,8 @@
 
     pitch = w*2;
 
-    // write source_data to output_surfaces[2].
-    vdp_st = vdp_output_surface_put_bits_indexed(output_surfaces[2],
+    // write source_data to osd_surface.
+    vdp_st = vdp_output_surface_put_bits_indexed(osd_surface,
                                                  VDP_INDEXED_FORMAT_I8A8,
                                                  (const void *const*)&index_data,
                                                  &pitch,
@@ -605,7 +606,7 @@
 
     vdp_st = vdp_output_surface_render_output_surface(output_surface,
                                                       &output_indexed_rect_vid,
-                                                      output_surfaces[2],
+                                                      osd_surface,
                                                       &output_indexed_rect_vid,
                                                       NULL,
                                                       &blend_state,
@@ -747,7 +748,7 @@
                                             0);
     CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display")
 
-    surface_num = !surface_num;
+    surface_num = (surface_num + 1) % NUM_OUTPUT_SURFACES;
     visible_buf = 1;
 }
 
@@ -888,7 +889,7 @@
     vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target);
     CHECK_ST_WARNING("Error when calling vdp_presentation_queue_target_destroy")
 
-    for (i = 0; i < NUM_OUTPUT_SURFACES; i++) {
+    for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) {
         vdp_st = vdp_output_surface_destroy(output_surfaces[i]);
         output_surfaces[i] = VDP_INVALID_HANDLE;
         CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy")