SDL or mga X server bug?

On XFree86 4.0.1, SDL-1.1.3, Matrox G400,
the following SDL program will draw single white pixel
on black background if SDL_VIDEO_YUV_HWACCEL=0.
But the pixel becomes gray if I set SDL_VIDEO_YUV_HWACCEL=1.

Is this a problem of SDL or X server?
(the problem doesn’t happen on Xv-extension-patched ATI rage128 X server)

Thanks for any idea.

#include <SDL/SDL.h>
#define WIDTH 256
#define HEIGHT 256
int main()
{
SDL_Surface *surface;
SDL_Overlay *overlay;
SDL_Rect dstrect;
SDL_Event event;

SDL_Init(SDL_INIT_VIDEO);
surface = SDL_SetVideoMode(WIDTH , HEIGHT, 0, SDL_SWSURFACE);
overlay = SDL_CreateYUVOverlay(WIDTH, HEIGHT, SDL_YV12_OVERLAY, surface);
dstrect.x = 0;
dstrect.y = 0;
dstrect.w = WIDTH;
dstrect.h = HEIGHT;
atexit(SDL_Quit);

while(1)
{
    if(SDL_PollEvent(&event) && event.type == SDL_QUIT)
        exit(0);

    SDL_LockYUVOverlay(overlay);
    memset(overlay->pixels,0,WIDTH*HEIGHT);
    memset(overlay->pixels+WIDTH*HEIGHT,128,WIDTH*HEIGHT/2);
    ((char *)(overlay->pixels))[100*WIDTH+100] = 255;
    SDL_UnlockYUVOverlay(overlay);
    SDL_DisplayYUVOverlay(overlay, &dstrect);
}

return 0;

}

On XFree86 4.0.1, SDL-1.1.3, Matrox G400,
the following SDL program will draw single white pixel
on black background if SDL_VIDEO_YUV_HWACCEL=0.
But the pixel becomes gray if I set SDL_VIDEO_YUV_HWACCEL=1.

What’s the correct output? Does video play correctly with plaympeg?

Is this a problem of SDL or X server?
(the problem doesn’t happen on Xv-extension-patched ATI rage128 X server)

I’m guessing it’s a bug in the G400 server, but I don’t know the
correct translation from luminance = 255, Cr = 128, Cb = 128 to RGB.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

In article you wrote:
:> On XFree86 4.0.1, SDL-1.1.3, Matrox G400,
:> the following SDL program will draw single white pixel
:> on black background if SDL_VIDEO_YUV_HWACCEL=0.
:> But the pixel becomes gray if I set SDL_VIDEO_YUV_HWACCEL=1.

: What’s the correct output? Does video play correctly with plaympeg?

The correct output is single white pixel.
plaympeg works fine, it is not easy to spot the bug.
(It seems horizontally adjacent Y components are mixed)

:> Is this a problem of SDL or X server?
:> (the problem doesn’t happen on Xv-extension-patched ATI rage128 X server)

: I’m guessing it’s a bug in the G400 server, but I don’t know the
: correct translation from luminance = 255, Cr = 128, Cb = 128 to RGB.

I tried G200 and it has the same problem. I will ask the author of
the driver. Thanks.