On 02/15/2013 02:36 PM, Holger Kaelberer wrote:

On 02/15/2013 02:10 PM, Holger Kaelberer wrote:
Thinking about a good value for this background color, I wonder whether it 
could not be bound to,
i.e. derived from VADisplayAttribBackgroundColor which is already mapped to
VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR in vdpau-driver.

The attached patch implements this approach.

Updated patch attached after testing with mplayer-vaapi: Also check va_display_attrs_mtime to avoid setting background unintentionally to initialization value of va_display_attrs (which would be plain black :-(.

Thanks,
  Holger
>From 29f45cd58777c463403d3ab742975a807f740167 Mon Sep 17 00:00:00 2001
From: Holger Kaelberer <[email protected]>
Date: Tue, 19 Feb 2013 11:12:49 +0100
Subject: [PATCH] Initialize surface background from
 VADisplayAttribBackgroundColor

This initializes the background color of vdpau surfaces from
VADisplayAttribBackgroundColor, if set. The default value is changed
to (almost) black because the default greenish value of libvdpau
(0.462745, 0.725490, 0.003922) leads to ugly green flickering during
initialization and shutdown phase.

Note: Plain black or white should not be set as background, because it
is commonly used and causes video to bleed through into other
windows using this color.
---
 src/vdpau_video_x11.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/vdpau_video_x11.c b/src/vdpau_video_x11.c
index 8171549..595c7be 100644
--- a/src/vdpau_video_x11.c
+++ b/src/vdpau_video_x11.c
@@ -206,6 +206,10 @@ output_surface_create(
 
     if (drawable != None) {
         VdpStatus vdp_status;
+        /* note: choose a rare color close to plain black as default background
+         * 0/0/0 causes the window to bleed through black in other windows.*/
+        VdpColor vdp_bg = {0.003922f, 0.007843f, 0.003922f, 0};
+        unsigned int i;
         vdp_status = vdpau_presentation_queue_target_create_x11(
             driver_data,
             driver_data->vdp_device,
@@ -227,6 +231,23 @@ output_surface_create(
             output_surface_destroy(driver_data, obj_output);
             return NULL;
         }
+
+        for (i = 0; i < driver_data->va_display_attrs_count; i++) {
+            VADisplayAttribute * const attr = &driver_data->va_display_attrs[i];
+            if (attr->type != VADisplayAttribBackgroundColor ||
+                driver_data->va_display_attrs_mtime[i] < 1)
+                continue;
+            vdp_bg.red   = ((attr->value >> 16) & 0xff) / 255.0f;
+            vdp_bg.green = ((attr->value >> 8) & 0xff) / 255.0f;
+            vdp_bg.blue  = (attr->value & 0xff)/ 255.0f;
+            vdp_bg.alpha = 0.0f;
+        }
+
+        vdp_status = vdpau_presentation_queue_set_background_color(
+            driver_data,
+            obj_output->vdp_flip_queue,
+            &vdp_bg
+        );
     }
     return obj_output;
 }
-- 
1.7.9.5

_______________________________________________
Libva mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to