- Timestamp:
- Dec 14, 2005, 4:23:11 PM (19 years ago)
- Location:
- branches/avi_play/src
- Files:
-
- 5 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 } -
branches/avi_play/src/lib/sound/sound_engine.cc
r6013 r6112 292 292 ALubyte deviceName[] = 293 293 #else 294 AL CchardeviceName[] =294 ALubyte deviceName[] = 295 295 #endif 296 296 -
branches/avi_play/src/subprojects/importer/multitex.cc
r6094 r6112 37 37 MediaContainer* movie; 38 38 39 float counter = 0;39 int counter = 0; 40 40 41 41 42 42 void Framework::moduleInit(int argc, char** argv) 43 43 { 44 movie = new MediaContainer("/home/ david/Desktop/Face2.avi");44 movie = new MediaContainer("/home/lieni/Desktop/Face2.avi"); 45 45 46 46 // print information about the media file … … 52 52 53 53 seq = new TextureSequence(); 54 for (int i = 1; i < argc; i++)55 {56 seq->addFrame(argv[i]);57 printf("%s\n", argv[i]);58 }54 //for (int i = 1; i < argc; i++) 55 //{ 56 // seq->addFrame(argv[i]); 57 // printf("%s\n", argv[i]); 58 //} 59 59 60 // add one frame from the movie 61 seq->addFrame(movie->getNextFrame()); 60 // add one frame from the movie 61 //seq->addFrame(movie->getNextFrame()); 62 GLuint tex; 63 while((tex = movie->getNextFrame()) != NULL) 64 seq->addFrame(tex); 62 65 63 66 test = new Texture(argv[1]); … … 99 102 void Framework::moduleTick(float dt) 100 103 { 101 counter+ =dt;104 counter++; 102 105 103 seq->gotoFrame((unsigned int)counter); 104 if ((unsigned int)counter > seq->getFrameCount()) 106 seq->gotoFrame(counter); 107 108 if (counter > seq->getFrameCount()) 105 109 counter = 0; 110 106 111 } 107 112
Note: See TracChangeset
for help on using the changeset viewer.