Changeset 6149 in orxonox.OLD for branches/avi_play/src/lib/graphics
- Timestamp:
- Dec 17, 2005, 4:32:29 PM (19 years ago)
- Location:
- branches/avi_play/src/lib/graphics/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r6127 r6149 52 52 MediaContainer::~MediaContainer() 53 53 { 54 54 55 // Free the RGB image 55 56 delete [] buffer; … … 72 73 } 73 74 74 GLuintMediaContainer::getNextFrame()75 SDL_Surface * MediaContainer::getNextFrame() 75 76 { 76 77 /* get next frame */ … … 91 92 PRINTF(1)("frame_number: %i\n", codec_context->frame_number); 92 93 93 // Convert the image from its native format to RGB 94 // Conversion from YUV to RGB 95 // Most codecs return images in YUV 420 format 96 // (one luminance and two chrominance channels, with the chrominance 97 // channels samples at half the spatial resolution of the luminance channel) 94 98 img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt, 95 99 codec_context->width, codec_context->height); … … 101 105 data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)]; 102 106 for(int i = 0; i < codec_context->height; i++) 103 memcpy(&data[i*codec_context->width*3], 104 picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 105 106 107 glGenTextures(1, &texture); 107 memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 108 109 Uint32 rmask, gmask, bmask, amask; 110 111 /* SDL interprets each pixel as a 32-bit number, so our masks must depend 112 on the endianness (byte order) of the machine */ 113 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 114 rmask = 0xff000000; 115 gmask = 0x00ff0000; 116 bmask = 0x0000ff00; 117 amask = 0x000000ff; 118 #else 119 rmask = 0x000000ff; 120 gmask = 0x0000ff00; 121 bmask = 0x00ff0000; 122 amask = 0xff000000; 123 #endif 124 surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height, 125 32, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0); 126 127 return surface; 128 /*glGenTextures(1, &texture); 108 129 glBindTexture(GL_TEXTURE_2D, texture); 109 130 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); … … 113 134 //{ 114 135 // build the texture 115 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);136 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, picture->data); 116 137 //} 117 138 // if its not the first use glTexSubImage2D <-- faster then creating always a new texture … … 120 141 121 142 122 glBindTexture(GL_TEXTURE_2D, 0); 143 glBindTexture(GL_TEXTURE_2D, 0);*/ 123 144 ////////////////////////////////////////////// 124 145 ///////////////////////////////////////////// … … 127 148 //this->saveCurrentFrame(); 128 149 129 return texture;150 //return texture; 130 151 } 131 152 } … … 285 306 PRINTF(1)("========================\n"); 286 307 } 287 288 289 //pts = av_q2d(is->video_st->time_base)*pkt->dts;290 //pkt = packet291 //avstrream = viedo_st292 //pts = double -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6127 r6149 21 21 #include "base_object.h" 22 22 23 #include <SDL.h> 24 23 25 /* using namespace std is default, this needs to be here */ 24 26 using namespace std; … … 31 33 double fps; 32 34 GLuint texture; 35 SDL_Surface *surface; 33 36 uint8_t* data; 34 37 … … 51 54 52 55 GLuint getFrame(int frame_number); 53 GLuintgetNextFrame();56 SDL_Surface * getNextFrame(); 54 57 void loadMedia(const char* filename); 55 58 -
branches/avi_play/src/lib/graphics/importer/texture_sequence.cc
r6112 r6149 149 149 } 150 150 this->setAlpha(hasAlpha); 151 152 //PRINTF(1)("added frame"); 153 151 154 return true; 152 155 }
Note: See TracChangeset
for help on using the changeset viewer.