Changeset 6163 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer/media_container.cc
- Timestamp:
- Dec 19, 2005, 6:43:39 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r6160 r6163 42 42 fps = 0; 43 43 44 /* SDL interprets each pixel as a 32-bit number, so our masks must depend45 on the endianness (byte order) of the machine */46 #if SDL_BYTEORDER == SDL_BIG_ENDIAN47 rmask = 0xff000000;48 gmask = 0x00ff0000;49 bmask = 0x0000ff00;50 #else51 rmask = 0x000000ff;52 gmask = 0x0000ff00;53 bmask = 0x00ff0000;54 #endif55 56 44 if (filename != NULL) 57 45 this->loadMedia(filename); … … 64 52 MediaContainer::~MediaContainer() 65 53 { 54 // delete all surfaces in the list 55 while(!this->surface_list.empty()) 56 { 57 SDL_FreeSurface(this->surface_list.back()); 58 this->surface_list.pop_back(); 59 } 60 SDL_FreeSurface(surface); 66 61 67 62 // Free the RGB image … … 97 92 int frame_finished; 98 93 // Decode video frame 99 avcodec_decode_video(codec_context, frame, &frame_finished, packet.data, packet.size); 94 avcodec_decode_video(codec_context, frame, &frame_finished, 95 packet.data, packet.size); 100 96 101 97 // Did we get a video frame? 102 98 if(frame_finished) 103 99 { 104 PRINTF(1)("frame_number: %i\n", codec_context->frame_number);105 106 100 // Conversion from YUV to RGB 107 101 // Most codecs return images in YUV 420 format 108 102 // (one luminance and two chrominance channels, with the chrominance 109 103 // channels samples at half the spatial resolution of the luminance channel) 110 img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,111 104 img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, 105 codec_context->pix_fmt, codec_context->width, codec_context->height); 112 106 113 107 picture = (AVPicture*)RGB_frame; … … 119 113 memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 120 114 121 surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height, 122 24, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0); 115 surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, 116 codec_context->height,24, 117 codec_context->width*sizeof(uint8_t)*3, 118 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 119 0x000000FF, 120 0x0000FF00, 121 0x00FF0000, 122 0 123 #else 124 0xFF000000, 125 0x00FF0000, 126 0x0000FF00, 127 0 128 #endif 129 ); 123 130 124 131 return surface; … … 130 137 else 131 138 return NULL; 139 } 140 141 vector<SDL_Surface*> MediaContainer::getFrameList() 142 { 143 144 while((surface = this->getNextFrame()) != NULL) 145 surface_list.push_back(surface); 146 147 return surface_list; 132 148 } 133 149 … … 200 216 // Allocate video frame 201 217 frame = avcodec_alloc_frame(); 202 218 RGB_frame = avcodec_alloc_frame(); 203 219 204 220 // Determine required buffer size and allocate buffer
Note: See TracChangeset
for help on using the changeset viewer.