YUV Overlay vs. XV_AUTOPAINT_COLORKEY

Hi,

I have a problem with SDL’s YUV Overlay support using X11 Xv. Some people
reported that they get nothing but a black screen. I’ve compared the
output of xvattr they’ve sent me with the values I get here. It turned
out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature
everything works fine.
Anyway, why doesn’t SDL enable this itself? Is there a way to enable it
manually in SDL? Or do I have to use Xv directly to change this
attribute? I already have the necessary code, so it’s not a big deal
to workaround this problem for me. Though, I cannot really believe
that this is necessary. Am I missing something?–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040824/b8ab7c95/attachment.pgp

Hi,

I have a problem with SDL’s YUV Overlay support using X11 Xv. Some people
reported that they get nothing but a black screen. I’ve compared the
output of xvattr they’ve sent me with the values I get here. It turned
out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature
everything works fine.
Anyway, why doesn’t SDL enable this itself? Is there a way to enable it
manually in SDL? Or do I have to use Xv directly to change this
attribute? I already have the necessary code, so it’s not a big deal
to workaround this problem for me. Though, I cannot really believe
that this is necessary. Am I missing something?

It’s never been needed before. What version of X11 are you using and
what video card do you have? Can you submit a patch?

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

I have a problem with SDL’s YUV Overlay support using X11 Xv. Some people
reported that they get nothing but a black screen. I’ve compared the
output of xvattr they’ve sent me with the values I get here. It turned
out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature
everything works fine.

It’s never been needed before. What version of X11 are you using and
what video card do you have?

I have a simple NVidia GeForce 440 MX using a stock XFree86 4.3.0
installation. I myself had no such problem, also I can forcefully reproduce
it by turning XV_AUTOPAINT_COLORKEY off. People reporting used XFree86
with ATI or NVidia cards - I assume binary drivers. I have no clue why
this feature is disabled in some people’s setups. Technically, you can
manually paint the colorkey into the window. However, this leaves you
with the problem to discover the colorkey used by the overlay.
SDL_SetColorKey() turned out to be a red herring in this case.

Can you submit a patch?

I’ve had a quick glance at mplayer and it seems to enable this feature
using the X11/Xv interface when compiled for X11 no matter whether you
use -vo sdl or -vo xv. Just look for the attribute in libvo/vo_xv.c,
it’s just a couple of lines. Well, if you don’t want to add this yourself,
I can send you a patch within the next 2 days.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040824/f736d6a5/attachment.pgp

Christian Biere wrote:

Sam Lantinga wrote:

I have a problem with SDL’s YUV Overlay support using X11 Xv. Some people
reported that they get nothing but a black screen. I’ve compared the
output of xvattr they’ve sent me with the values I get here. It turned
out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature
everything works fine.

Can you submit a patch?

Attached is the patch which should fix the problem. At least, it works
for me.–
Christian
-------------- next part --------------
Index: SDL_x11yuv.c

RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/x11/SDL_x11yuv.c,v
retrieving revision 1.15
diff -u -r1.15 SDL_x11yuv.c
— SDL_x11yuv.c 12 Feb 2004 16:05:30 -0000 1.15
+++ SDL_x11yuv.c 25 Aug 2004 04:15:42 -0000
@@ -73,10 +73,11 @@
};

+static int (*X_handler)(Display *, XErrorEvent ) = NULL;
+
#ifndef NO_SHARED_MEMORY
/
Shared memory error handler routine */
static int shm_error;
-static int (*X_handler)(Display *, XErrorEvent *) = NULL;
static int shm_errhandler(Display *d, XErrorEvent e)
{
if ( e->error_code == BadAccess ) {
@@ -87,6 +88,15 @@
}
#endif /
!NO_SHARED_MEMORY */

+static int xv_error;
+static int xv_errhandler(Display *d, XErrorEvent *e)
+{

  •    if ( e->error_code == BadMatch ) {
    
  •    	xv_error = True;
    
  •    	return(0);
    
  •    } else
    
  •   return(X_handler(d,e));
    

+}

SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
{
@@ -192,6 +202,30 @@
return(NULL);
}

  • /* Enable auto-painting of the overlay colorkey */
  • {
  •   static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" };
    
  •   unsigned int i;
    
  •   SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True);
    
  •   X_handler = XSetErrorHandler(xv_errhandler);
    
  •   for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) {
    
  •   	Atom a;
    
  •   	xv_error = False;
    
  •   	a = XInternAtom(GFX_Display, attr[i], True);
    
  •   	if ( a != None ) {
    
  • 				SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
    
  •   		XSync(GFX_Display, True);
    
  •   		if ( ! xv_error ) {
    
  •   			break;
    
  •   		}
    
  •   	}
    
  •   }
    
  •   XSetErrorHandler(X_handler);
    
  •   SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
    
  • }
  • /* Create the overlay structure */
    overlay = (SDL_Overlay *)malloc(sizeof *overlay);
    if ( overlay == NULL ) {
    -------------- next part --------------
    A non-text attachment was scrubbed…
    Name: not available
    Type: application/pgp-signature
    Size: 186 bytes
    Desc: not available
    URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040825/6ecf0e15/attachment.pgp

Attached is the patch which should fix the problem. At least, it works
for me.

Thanks! Your patch was very helpful, and succinct.

Is there any server which uses XV_AUTOPAINT_COLOURKEY and not XV_AUTOPAINT_COLORKEY?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

Is there any server which uses XV_AUTOPAINT_COLOURKEY and not
XV_AUTOPAINT_COLORKEY?

No idea. Some ATI drivers have both. It looks like one is just an alias
for the other but I thought it would be better to use both. Just in case
there’s really a driver which supports the british version only. Though,
I surely wouldn’t mind if you scrapped that part.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040825/92abd93d/attachment.pgp