[gst-devel] patch: correct handling of XVideo COLORKEY attributes

Christian Fredrik Kalager Schaller Uraeus at linuxrising.org
Thu Nov 14 22:49:09 CET 2002


Ok, patch reviewed and commited. Thanks a lot Ben :)

Christian

On Sun, 2002-11-03 at 07:10, Ben Liblit wrote:
> My video card (a GeForce 3) offers several settable XVideo attributes, 
> such as brightness, contrast, etc.  Two of those attributes are 
> XV_COLORKEY and XV_AUTOPAINT_COLORKEY.  I don't *completely* understand 
> these, but the impression that I get is that XV_COLORKEY is a pixel 
> which will be used as a video output mask: video is only painted over 
> those parts of the window which are colored using the XV_COLORKEY pixel.
> 
> In the common case where you don't want any masking at all, you can fill 
> the entire window using XV_COLORKEY.  A simpler approach, though, is to 
> set the boolean XV_AUTOPAINT_COLORKEY attribute to "true".  This 
> apparently causes the driver to do the XV_COLORKEY window filling 
> automatically.
> 
> Curiously, the Xine movie player turns XV_AUTOPAINT_COLORKEY off, and 
> leaves it off even after it is done.  So any subsequent video player 
> that comes along will not get any video in its video window unless it 
> either turns XV_AUTOPAINT_COLORKEY back on or else does some painting of 
> its own using the XV_COLORKEY pixel.  GStreamer suffers from exactly 
> this bug.  If Xine has *ever* been run on a display, then GStreamer's 
> xvideosink plugin will not yield any output.  :-(
> 
> Attached below please find a small patch to fix this problem by turning 
> XV_AUTOPAINT_COLORKEY back on.  I've tested it on my system and it works 
> like a charm.  It should harmlessly do nothing on video cards that don't 
> have this attribute at all.  The patch fixes both videosink and 
> xvideosink.  I fixed the former before learning that it has been 
> deprecated by the later.  Feel free to ignore the videosink change if 
> that code is truly dead.
> 
> MPlayer had this same bug until very recently; I discovered the problem 
> and submitted essentially the same fix, which was incorporated into the 
> recent mplayer 0.90-pre9 release.  If you're interested, see 
> <http://mplayerhq.hu/pipermail/mplayer-users/2002-October/022024.html> 
> and 
> <http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-October/012071.html> 
> for archives of the discussions which led to my current understanding of 
> the issue.
> 
> Thank you!
> 
> ______________________________________________________________________
> 
> Index: sys/videosink/gstxvimage.c
> ===================================================================
> RCS file: /cvsroot/gstreamer/gst-plugins/sys/videosink/gstxvimage.c,v
> retrieving revision 1.5
> diff -u -u -r1.5 gstxvimage.c
> --- sys/videosink/gstxvimage.c	14 Sep 2002 13:25:43 -0000	1.5
> +++ sys/videosink/gstxvimage.c	3 Nov 2002 05:30:34 -0000
> @@ -26,6 +26,7 @@
>  
>  #include <X11/extensions/Xv.h>
>  #include <X11/extensions/Xvlib.h>
> +#include <string.h>
>  
>  #include "gstvideosink.h"
>  
> @@ -375,6 +376,21 @@
>  static void
>  gst_xvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
>  {
> +  const GstXvConnection * const xvconn = gst_xv_connection (conn);
> +  Display * const display = xvconn->display;
> +  const XvPortID port = xvconn->port;
> +  
> +  int i, count;
> +  const XvAttribute * const attr = XvQueryPortAttributes(display, port, &count);
> +  static const char autopaint[] = "XV_AUTOPAINT_COLORKEY";
> +
> +  for (i = 0; i < count; ++i)
> +    if (!strcmp(attr[i].name, autopaint))
> +      {
> +	const Atom atom = XInternAtom(display, autopaint, False);
> +	XvSetPortAttribute(display, port, atom, 1);
> +	break;
> +      }
>  }
>  static void
>  gst_xvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
> Index: sys/xvideo/gstxvimage.c
> ===================================================================
> RCS file: /cvsroot/gstreamer/gst-plugins/sys/xvideo/gstxvimage.c,v
> retrieving revision 1.13
> diff -u -u -r1.13 gstxvimage.c
> --- sys/xvideo/gstxvimage.c	22 Sep 2002 00:44:21 -0000	1.13
> +++ sys/xvideo/gstxvimage.c	3 Nov 2002 05:30:35 -0000
> @@ -170,6 +170,20 @@
>          im_port = ai[i].base_id;
>          im_adaptor = i;
>  
> +	{
> +	  int count;
> +	  const XvAttribute * const attr = XvQueryPortAttributes(display, im_port, &count);
> +	  static const char autopaint[] = "XV_AUTOPAINT_COLORKEY";
> +
> +	  for (j = 0; j < count; ++j)
> +	    if (!strcmp(attr[j].name, autopaint))
> +	      {
> +		const Atom atom = XInternAtom(display, autopaint, False);
> +		XvSetPortAttribute(display, im_port, atom, 1);
> +		break;
> +	      }
> +	}
> +
>          /* *** image scaler port *** */
>          fo = XvListImageFormats(display, im_port, &formats);
>  
-- 
Christian Fredrik Kalager Schaller <Uraeus at linuxrising.org>





More information about the gstreamer-devel mailing list