[SDL] displaying decoded video frame on sdl surface
Ryan C. Gordon
icculus at icculus.org
Mon Feb 19 12:36:03 PST 2007
> //display this buffer on the sdl window
> screen->pixels = pFrame->data[0];//pointing to video frame data.
> //display it on the screen
> SDL_UpdateRect(screen,0,0,0,0);
You absolutely can't change the ->pixels field! You have to memcpy()
into it in the right format, taking into account the ->pitch, and ->w
and ->h.
The ->pixels field is a buffer allocated by SDL_SetVideoMode().
> /* Attempt to set a 640x480 video mode */
> screen = SDL_SetVideoMode(640,480,16,SDL_FULLSCREEN);
> [...]
> // Convert the image from its native format to RGB
> img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24,
> (AVPicture*)pFrame, pCodecCtx->pix_fmt,
> pCodecCtx->width,
> pCodecCtx->height);
Also, you created a 16-bit surface and then want to feed it 24-bit data.
--ryan.
More information about the SDL
mailing list