Changeset 6112 in orxonox.OLD for branches/avi_play/src/lib/graphics
- Timestamp:
- Dec 14, 2005, 4:23:11 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
r6094 r6112 92 92 PRINTF(1)("current_frame: %i\n", current_frame); 93 93 94 94 // Convert the image from its native format to RGB 95 95 img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt, 96 96 codec_context->width, codec_context->height); 97 97 98 98 picture = (AVPicture*)RGB_frame; 99 100 ////////////////////////////////////////////// 101 ////////// FIX THIS ////////////////////////// 99 100 101 data = 0; 102 data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)]; 103 for(int i = 0; i < codec_context->height; i++) 104 memcpy(&data[i*codec_context->width*3], 105 picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 106 107 102 108 glGenTextures(1, &texture); 103 109 glBindTexture(GL_TEXTURE_2D, texture); 110 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 111 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 104 112 // if it is the first frame create texture 105 if(current_frame == 1) 106 { 107 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 108 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 109 // build the texture 110 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, codec_context->width, codec_context->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, picture->data[0]); 111 } 113 //if(current_frame == 1) 114 //{ 115 // build the texture 116 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); 117 //} 112 118 // if its not the first use glTexSubImage2D <-- faster then creating always a new texture 113 else114 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_context->width, codec_context->height, GL_RGBA, GL_UNSIGNED_BYTE, picture->data[0]);119 //else 120 // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_context->width, codec_context->height, GL_RGB, GL_UNSIGNED_BYTE, data); 115 121 116 122 … … 142 148 file = fopen(filename, "wb"); 143 149 if(file == NULL) 144 150 return; 145 151 146 152 // Write header … … 163 169 /* Retrieve stream information */ 164 170 if (av_find_stream_info(format_context) < 0) 165 PRINTF(1)("Could not find stream information in %s\n", filename); 171 PRINTF(1)("Could not find stream information in %s\n", filename); 166 172 167 173 // Dump information about file onto standard error … … 173 179 { 174 180 // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis) 175 // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) 181 // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) 176 182 if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) 177 183 { … … 180 186 } 181 187 } 182 188 183 189 if(video_stream == -1) 184 190 PRINTF(1)("Could not find a video stream in %s\n", filename); … … 200 206 // Allocate video frame 201 207 frame = avcodec_alloc_frame(); 202 208 RGB_frame = avcodec_alloc_frame(); 203 209 204 210 // Determine required buffer size and allocate buffer … … 207 213 208 214 // Assign appropriate parts of buffer to image planes in pFrameRGB 209 avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height); 215 avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height); 210 216 211 217 } -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6094 r6112 32 32 int num_frames; 33 33 GLuint texture; 34 uint8_t* data; 34 35 35 36 AVFormatContext* format_context; … … 40 41 AVPicture* picture; 41 42 AVFrame* RGB_frame; 42 43 43 44 int num_bytes; 44 45 uint8_t *buffer; … … 53 54 GLuint getNextFrame(); 54 55 void loadMedia(const char* filename); 55 56 56 57 int getHeight(); 57 58 int getWidth(); 58 59 int getCurrentFrame(); 59 60 int getFrameRate(); 60 61 void getStream(/* stream */); -
branches/avi_play/src/lib/graphics/importer/texture_sequence.cc
r6094 r6112 158 158 bool TextureSequence::addFrame(GLuint texture) 159 159 { 160 if (texture == NULL)160 if (texture == 0) 161 161 return false; 162 162 this->textures.push_back(texture); 163 163 164 164 return true; 165 165 }
Note: See TracChangeset
for help on using the changeset viewer.