[Ffmpeg-devel] get from an AVPicture/AVFrame a SDL_Survace or OpenGL texture

Mat heavensdoor78
Mon Dec 19 10:41:20 CET 2005

hdavid at ee.ethz.ch wrote:

> how can i get from the data of an AVPicture or Avframe a SDL_Survace 
> or a OpenGL texture. i looked to the ffplay.c file but i cant figure 
> out how he fills in the SDL_Survace.  I tried it this way but it 
> doesnt work:
> ...
> is there an easy way to do this?

I don't know with OpenGL, but with SDL ( with SDL_Overlay ) is easy.
After I decoded a frame I use this function:

void YUVImage_Put( SDL_Overlay *yuvOverlay, SDL_Rect *rect, char *frame )
    SDL_LockYUVOverlay( yuvOverlay );
    yuvOverlay->pixels[0] = frame;
    yuvOverlay->pixels[2] = yuvOverlay->pixels[0] + IMG_AREA;
    yuvOverlay->pixels[1] = yuvOverlay->pixels[2] + IMG_AREA_QUATER;
    SDL_UnlockYUVOverlay( yuvOverlay );
    SDL_DisplayYUVOverlay( yuvOverlay, rect );

( in frame buffer of the function you need to copy the data from the 
AVFrame, ex. YYYY...U...V... ( from pFrame->data[0], pFrame->data[1] and 
pFrame->data[2] ) for YUV420P )

More information about the ffmpeg-devel mailing list