Realtime video?

Hello

I have an application that needs to draw a full videoframe (maximum 720x576)
very fast. I currently use gdk_draw_rgb_image to draw each frame in a window
but its too slow. Would it be faster to use SDL to draw it? Maximum time to
draw the image on screen is ~35 ms (less on smaller images) but the call to
the drawing function must return within 2 ms. And the actual drawing cannot
use any (or very little) cpu time. Is this possible with SDL? If so, how?
The image is a plain RGB24 (can be RGB32 if required) image that i have a
plain pointer to. The times i specified is in reference to a standard
pentium2 (400 MHz) running linux.

One more thing. Sam, I know its only been a week but any progress on yuv
support?

Thanks in advance
Mattias Blomqvist

I have an application that needs to draw a full videoframe (maximum 720x576)
very fast. I currently use gdk_draw_rgb_image to draw each frame in a window
but its too slow. Would it be faster to use SDL to draw it? Maximum time to
draw the image on screen is ~35 ms (less on smaller images) but the call to
the drawing function must return within 2 ms. And the actual drawing cannot
use any (or very little) cpu time. Is this possible with SDL?

I believe this is possible with SDL.
Try creating an RGB32 video mode and drawing directly to the video memory and
then calling SDL_Flip() at the end of the frame. There is a hack to squeeze
even more speed out of SDL in this situation if it is still too slow. Contact
me privately if you need to talk about it.

One more thing. Sam, I know its only been a week but any progress on yuv
support?

Yes, I received YUV conversion code from somebody, and I’m waiting for
a G400 to test the XvImage code in XFree86 4.0 I’m guessing I’ll have
an initial implementation in several weeks.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Yes, I received YUV conversion code from somebody, and I’m waiting
for
a G400 to test the XvImage code in XFree86 4.0 I’m guessing I’ll
have
an initial implementation in several weeks.

I know. That was from me :wink: Same person different email-address…

Mattias

I believe this is possible with SDL.
Try creating an RGB32 video mode and drawing directly to the
video memory and
then calling SDL_Flip() at the end of the frame. There is a
hack to squeeze
even more speed out of SDL in this situation if it is still
too slow. Contact
me privately if you need to talk about it.

Sounds good. Only question is. How do I do it?
Code below does open a window and draw something. But it looks like it is
the top line repeated over and over again. frame is a pointer to a RGB24
image. What have i missed?

Thanks in advance
Mattias Blomqvist

if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
exit(1);
}
screen = SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE|SDL_FULLSCREEN);
if ( screen == NULL ) {
exit(1);
}
done = 0;

while (!done && (dv_one_frame(frame, 0) != 0)) {
  screen2 = SDL_CreateRGBSurfaceFrom(frame, FRAME_WIDTH, FRAME_HEIGHT,

24, 0, 0xff0000, 0xff00, 0xff,0);
dstrect.x = (screen->w-screen2->w)/2;
dstrect.y = (screen->h-screen2->h)/2;
dstrect.w = screen2->w;
dstrect.h = screen2->h;
if ( SDL_BlitSurface(screen2, NULL, screen, &dstrect) < 0 ) {
SDL_FreeSurface(screen2);
exit(1);
}
SDL_UpdateRects(screen, 1, &dstrect);
while ( SDL_PollEvent(&event) ) {
switch (event.type) {
case SDL_KEYDOWN:
if ( event.key.keysym.sym == SDLK_ESCAPE ) {
done = 1;
}
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
}
SDL_Quit();