Changeset 6163 in orxonox.OLD for branches/avi_play/src/lib/graphics
- Timestamp:
- Dec 19, 2005, 6:43:39 PM (19 years ago)
- Location:
- branches/avi_play/src/lib/graphics/importer
- Files:
-
- 4 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 -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6160 r6163 8 8 #define _MEDIA_CONTAINER 9 9 10 #include <SDL.h> 11 #include <vector> 10 12 11 13 #ifdef HAVE_AVFORMAT_H … … 15 17 #endif 16 18 17 18 #include "glincl.h"19 20 19 /* include base_object.h since all classes are derived from this one */ 21 20 #include "base_object.h" 22 23 #include <SDL.h>24 21 25 22 /* using namespace std is default, this needs to be here */ … … 32 29 33 30 double fps; 34 Uint32 rmask, gmask, bmask; 35 SDL_Surface *surface; 31 SDL_Surface* surface; 36 32 uint8_t* data; 37 33 … … 41 37 AVFrame* frame; 42 38 AVPacket packet; 39 AVFrame* RGB_frame; 43 40 AVPicture* picture; 44 AVFrame* RGB_frame;45 41 46 42 int num_bytes; 47 43 uint8_t *buffer; 48 44 int video_stream; 45 46 vector<SDL_Surface*> surface_list; 49 47 50 48 public: … … 55 53 SDL_Surface* getFrame(int frame_number); 56 54 SDL_Surface* getNextFrame(); 55 vector<SDL_Surface*> getFrameList(); 57 56 void loadMedia(const char* filename); 58 57 … … 62 61 double getFPS(); 63 62 64 /* prints some information about the65 media file for debug reasons */ 63 void saveCurrentFrame(); 64 66 65 void printMediaInformation(); 67 66 void printPacketInformation(); 68 void saveCurrentFrame();69 67 70 68 }; 71 69 72 70 73 74 71 #endif /* _MEDIA_CONTAINER */ -
branches/avi_play/src/lib/graphics/importer/texture_sequence.cc
r6149 r6163 150 150 this->setAlpha(hasAlpha); 151 151 152 //PRINTF(1)("added frame"); 152 return true; 153 } 153 154 154 return true; 155 bool TextureSequence::addFrameList(std::vector<SDL_Surface*> surfaces) 156 { 157 // add the surfaces to the list 158 for(int i = 0; i < surfaces.size(); i++) 159 this->addFrame(surfaces[i]); 155 160 } 156 161 -
branches/avi_play/src/lib/graphics/importer/texture_sequence.h
r6094 r6163 30 30 bool addFrame(SDL_Surface* surface); 31 31 bool addFrame(GLuint texture); 32 bool addFrameList(std::vector<SDL_Surface*> surfaces); 32 33 33 34 virtual bool rebuild();
Note: See TracChangeset
for help on using the changeset viewer.