Changeset 6003 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer
- Timestamp:
- Dec 9, 2005, 6:07:05 PM (19 years ago)
- Location:
- branches/avi_play/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r5975 r6003 40 40 av_register_all(); 41 41 42 current_frame = 0; 43 num_frames = 0; 44 42 45 if (filename != NULL) 43 46 this->loadMedia(filename); … … 50 53 MediaContainer::~MediaContainer() 51 54 { 55 //av_free(pFrameRGB); 56 57 /* Free the frame */ 58 av_free(frame); 59 60 /* Close the codec */ 61 avcodec_close(codec_context); 62 63 /* Close the video file */ 64 av_close_input_file(format_context); 52 65 53 66 } 54 67 55 GLuint MediaContainer::getFrame(int frame_number)68 /*GLuint MediaContainer::getFrame(int frame_number) 56 69 { 57 70 … … 61 74 { 62 75 76 }*/ 77 78 SDL_Surface* MediaContainer::getFrame(int frame_number) 79 { 80 SDL_Surface* frame; 81 82 83 return frame; 84 } 85 86 SDL_Surface* MediaContainer::getNextFrame() 87 { 88 current_frame++; 89 return this->getFrame(current_frame); 63 90 } 64 91 … … 68 95 if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 ) 69 96 PRINTF(1)("Could not open %s\n", filename); 97 98 /* Retrieve stream information */ 99 if (av_find_stream_info(format_context) < 0) 100 PRINTF(1)("Could not find stream information in %s\n", filename); 101 102 // Dump information about file onto standard error 103 //dump_format(pFormatCtx, 0, argv[1], false); 104 105 /* Find the first video stream and take it */ 106 video_stream = -1; 107 for(int i = 0; i < format_context->nb_streams; i++) 108 { 109 // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis) 110 // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) 111 if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) 112 { 113 video_stream = i; 114 break; 115 } 116 } 117 118 if(video_stream == -1) 119 PRINTF(1)("Could not find a video stream in %s\n", filename); 120 121 /* Get a pointer to the codec context for the video stream */ 122 // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis) 123 // codec_context = &format_context->streams[video_stream]->codec; 124 codec_context = format_context->streams[video_stream]->codec; 125 126 /* Find the decoder for the video stream */ 127 codec = avcodec_find_decoder(codec_context->codec_id); 128 if (codec == NULL) 129 PRINTF(1)("Could not find codec\n"); 130 131 /* Open codec */ 132 if (avcodec_open(codec_context, codec) < 0) 133 PRINTF(1)("Could not open codec\n"); 134 135 70 136 71 137 } -
branches/avi_play/src/lib/graphics/importer/media_container.h
r5975 r6003 24 24 using namespace std; 25 25 26 /* Forward Declaration */ 27 struct SDL_Surface; 28 26 29 class MediaContainer : public BaseObject 27 30 { … … 31 34 char* filename; 32 35 int current_frame; 36 int num_frames; 33 37 34 38 AVFormatContext* format_context; … … 46 50 ~MediaContainer(); 47 51 48 GLuint getFrame(int frame_number); 49 GLuint getNextFrame(); 52 //GLuint getFrame(int frame_number); 53 SDL_Surface* getFrame(int frame_number); 54 //GLuint getNextFrame(); 55 SDL_Surface* getNextFrame(); 50 56 void loadMedia(const char* filename); 51 57
Note: See TracChangeset
for help on using the changeset viewer.