YUV hardware overlay Display problems / Not all Frames displayed!

Hi all,

I’de be very glad if someone could help me with this…
I’ve been searching the
Net extensively tonight and not yet found a definitive answer to my question…

I’m developing a video displayer for YUV data.
I use the packed format
(SDL_YUY2_OVERLAY), because I have 4:2:2 data (Y1 U1 Y2 V1).

toreturn.surface = SDL_SetVideoMode(newwidth, newheight, 32,
SDL_HWSURFACE|SDL_DOUBLEBUF); //was 24

toreturn.overlay = SDL_CreateYUVOverlay(newwidth, newheight,
SDL_YUY2_OVERLAY,
toreturn.surface);

Now, first I have been using 24 bitdepth mode for my overlay,
and I got neither
the overlay nor the surface to be hardware - accelerated.
When I switch to 32 bitdepth mode, ONLY the overlay is hardware accelerated!

  • That means, the pointer I get back (overlay->pixels[0],
    as in packed mode we
    have only one plane) for a hardware accelerated overlay
    (overlay->hw_overlay ==
  1. is a pointer to the video memory?
  • Does it make any difference which YUV mode I use in accelerated mode?

My problem is, that the frames don’t display, instead there’s a black screen.
BUT, there are occasional flicks of correct frames.
I use the following code to
update the display EACH time my main loop is passed:

  SDL_LockSurface(info.surface);
  SDL_LockYUVOverlay(info.overlay);   
  /*COPY NEW DATA TO THE OVERLAY*/
  memcpy(info.overlay->pixels[0],info.memposition,

info.rect.h * info.rect.w * 2);
SDL_UnlockYUVOverlay(info.overlay);
SDL_DisplayYUVOverlay(info.overlay, &info.rect);
SDL_UnlockSurface(info.surface);
SDL_Flip(info.surface);

With a very big sequence it plays slower, and displays
around 20 % (the upper
part) correctly.

The same behaviour occurs in Fullscreen mode (then, the
surface is also a
hardware surface).

Can someone help me with this, please?
I’ll be very, very grateful :slight_smile:

  • Max

Max wrote:

Allocate the surface with:

SDL_SetVideoMode(info.rect.w, info.rect.h, 0, 0)

SDL_LockYUVOverlay(info.overlay);   
/*COPY NEW DATA TO THE OVERLAY*/
memcpy(info.overlay->pixels[0],info.memposition,

info.rect.h * info.rect.w * 2);
SDL_UnlockYUVOverlay(info.overlay);
SDL_DisplayYUVOverlay(info.overlay, &info.rect);

… and do the main loop this way.

You don’t need to flip the screen surface, otherwise you’ll flip away
also the overlay.

You don’t have to lock the screen surface, otherwise the YUV blit may
fail (if in software mode), since it does the lock by itself.

Bye,
Gabry