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

hdavid at ee.ethz.ch hdavid
Fri Dec 16 14:12:03 CET 2005


hey
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:

...
...
...
// Convert the image from its native format to RGB
img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,   
codec_context->pix_fmt,codec_context->width, codec_context->height);

picture = (AVPicture*)RGB_frame;

data = 0;
data =  new 
uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
for(int i = 0; i < codec_context->height; i++)
  memcpy(&data[i*codec_context->width*3],picture->data[0]+i *    
picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);


glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

// build the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, 
codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

glBindTexture(GL_TEXTURE_2D, 0);

return texture;

...
...

is there an easy way to do this?

greetz





More information about the ffmpeg-devel mailing list