Changeset 6324 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer
- Timestamp:
- Dec 27, 2005, 10:25:48 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
r6323 r6324 87 87 } 88 88 89 GLuint MediaContainer::getFrame(int frame_number)89 void MediaContainer::gotoFrame(int frame_number) 90 90 { 91 91 // seek doesnt work for the first two frames … … 96 96 av_seek_frame(format_context, video_stream, 0, AVSEEK_FLAG_BACKWARD); 97 97 frame_num = 0; 98 return this->getNextFrame();99 98 } 100 99 else … … 117 116 118 117 frame_num = frame_number; 119 120 return this->getNextFrame();121 118 } 122 119 } … … 215 212 } 216 213 217 void MediaContainer::skipFrame(int num_frames) 218 { 219 214 GLuint MediaContainer::skipFrame(int num_frames) 215 { 216 frame_num += num_frames; 217 218 while(num_frames != 0) 219 { 220 if(av_read_frame(format_context, &packet) < 0) 221 break; 222 if(packet.stream_index == video_stream) 223 { 224 int frame_finished; 225 // We have to decode the frame to not get ugly fragments 226 avcodec_decode_video(codec_context, frame, &frame_finished, 227 packet.data, packet.size); 228 229 // Did we get a video frame? 230 if(frame_finished) 231 num_frames--; 232 } 233 av_free_packet(&packet); 234 } 235 236 return this->getNextFrame(); 220 237 } 221 238 -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6320 r6324 58 58 59 59 void init(); 60 GLuint getFrame(int frame_number);60 void gotoFrame(int frame_number); 61 61 GLuint getNextFrame(); 62 voidskipFrame(int num_frames);62 GLuint skipFrame(int num_frames); 63 63 vector<GLuint> getFrameList(); 64 64 void loadMedia(const char* filename); -
branches/avi_play/src/lib/graphics/importer/movie_player.cc
r6323 r6324 57 57 { 58 58 status = STOP; 59 timer = 0; 59 60 60 61 material = new Material; … … 82 83 void MoviePlayer::start(unsigned int start_frame) 83 84 { 84 texture = media_container->getFrame(start_frame); 85 status = PLAY; 86 timer = 0; 87 fps = media_container->getFPS(); 85 88 86 status = PLAY; 89 media_container->gotoFrame(start_frame); 90 91 PRINTF(0)("start\n"); 87 92 } 88 93 … … 90 95 { 91 96 if(status == STOP) 92 texture = media_container->getFrame(0); 93 status = PLAY; 97 this->start(0); 98 else 99 status = PLAY; 100 101 PRINTF(0)("resume\n"); 94 102 } 95 103 … … 98 106 if(status != STOP) 99 107 status = PAUSE; 108 109 PRINTF(0)("pause\n"); 100 110 } 101 111 … … 104 114 status = STOP; 105 115 texture = NULL; 116 117 PRINTF(0)("stop\n"); 106 118 } 107 119 108 void MoviePlayer::tick(float time)120 void MoviePlayer::tick(float dt) 109 121 { 110 122 if(status == PLAY) 111 123 { 112 texture = media_container->getNextFrame(); 124 current_frame = media_container->getFrameNumber(); 125 timer += dt; 126 actuel_frame = timer * fps; 127 128 if(actuel_frame != current_frame) 129 { 130 if(actuel_frame - current_frame == 1) 131 texture = media_container->getNextFrame(); 132 else 133 texture = media_container->skipFrame(actuel_frame - current_frame - 1); 134 } 113 135 //PRINTF(0)("frame_number: %i\n", media_container->getFrameNumber()); 114 if(texture == NULL) 115 status = STOP; 136 137 if(texture == NULL && current_frame != 0) 138 this->stop(); 116 139 } 117 140 } -
branches/avi_play/src/lib/graphics/importer/movie_player.h
r6317 r6324 39 39 40 40 MP_STATUS status; 41 float speed; 41 float speed; 42 float timer; 43 int actuel_frame; 44 int current_frame; 45 float fps; 42 46 43 47 public: … … 55 59 void stop(); 56 60 57 void tick(float time);61 void tick(float dt); 58 62 const void draw(); 59 63
Note: See TracChangeset
for help on using the changeset viewer.