[SDL] Blitting SDL_Surface to SDL_Overlay...

Sheshadri Mantha sheshadri.mantha at schange.com
Fri Jan 23 12:38:06 PST 2009


hi;
i've got a video player that renders yuv using SDL_Overlay.  my video is 
typically PAL so 720x576.  the video images are rendered using 
SDL_DisplayYUVOverlay, where the rectangle is derived from aspect ratio 
that is in the incoming video stream (lets say its 4:3).  Then the 
resulting rect used in SDL_DisplayYUVOverlay turns out to be {0, 18, 
720, 540}.  This is fine...  BTW: the code is modeled after FFmpeg's 
sample ffplay.c.

problem arises with graphics that i wish to display on top of the 
video...  such graphic is collected in an SDL_Surface.  Typically these 
graphics are in the {0, 0, 720, 576} "coordinate space".

currently i have a homegrown fn which blits the graphic SDL_Surface, YUV 
video image.

PROBLEM is that since the rect for SDL_DisplayYUVOverlay is that which 
is result of video aspect ratio, portions of the graphic don't get shown.

Calling SDL_DisplayYUVOverlay 2x causes terrible flicker (as can be deduced)
Doing an UpdateRect of the SDL_Surface shows nothing ('cause i imagine 
that the subsequent DisplayYUVOverlay scrubs the graphics)

I've also tried converting the video image to RGB, blitting graphic and 
video RGB... its ok but in full screen the update is terrible (extremely 
slow!)

Questions:
- Any idea how i can effectively blit a SDL_Surface onto an SDL_Overlay 
so that the video appears with proper aspect ratio and graphic appears 
in its rectangle ?
- how can i *hack* (even platform dependent method/access to SDL_Overlay 
private data) to effectively get a SDL_Surface to SDL_Surface blit ?  i 
tried this by adding a SDL_GetDisplayYUV_SW - my env only loads the sw 
overlays - to return the SDL_Surface in overlay's private data, and then 
do a blit but this crashes - Yes i realize i ought not to be accessing 
these structures - but i've gotta but this release out and need a quick 
fix. or a fix.
- why isn't there a "take this graphic and lay it on top of the YUV 
image in the overlay" method ? Or is there?

Any help quick/otherwise is **GREATLY** appreciated.  Till now my 
customers (internal though they are) are very, very disappointed in this...

Kindest regards,
S-




More information about the SDL mailing list