Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6382 in orxonox.OLD for branches/avi_play/src


Ignore:
Timestamp:
Jan 1, 2006, 7:58:56 PM (19 years ago)
Author:
hdavid
Message:

branches\avi_play: removed memory leak

Location:
branches/avi_play/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r6373 r6382  
    8888
    8989  // Find the first video stream and take it
    90   video_stream = -1;
    91   for(int i = 0; i < format_context->nb_streams; i++)
    92   {
    93     // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
    94     // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)
    95     if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
    96     {
    97       video_stream = i;
    98       break;
    99     }
    100   }
    101 
     90  video_stream = av_find_default_stream_index(format_context);
     91 
    10292  if(video_stream == -1)
    10393    PRINTF(1)("Could not find a video stream in %s\n", filename);
     
    124114  num_bytes = avpicture_get_size(PIX_FMT_RGB24, codec_context->width, codec_context->height);
    125115  buffer=new uint8_t[num_bytes];
     116
     117  // data buffer for the texture
     118  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    126119
    127120  // Assign appropriate parts of buffer to image planes in RGB_frame
     
    180173                    codec_context->pix_fmt, codec_context->width, codec_context->height);
    181174
    182         data = 0;
    183         data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    184175        for(int i = 0; i < codec_context->height; i++)
    185176          memcpy(&data[i*codec_context->width*3],
     
    187178                 ((AVPicture*)RGB_frame)->linesize[0],
    188179                  codec_context->width*sizeof(uint8_t)*3);
    189 /*
    190         surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
     180
     181        /*surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
    191182                                           codec_context->height,24,
    192183                                           codec_context->width*sizeof(uint8_t)*3,
     
    226217                        GL_UNSIGNED_BYTE,
    227218                        surface->pixels);
    228         glBindTexture(GL_TEXTURE_2D, 0);  */   
     219        glBindTexture(GL_TEXTURE_2D, 0); */
    229220
    230221        // Create an OpenGL texture
  • branches/avi_play/src/lib/graphics/importer/movie_player.cc

    r6373 r6382  
    102102
    103103  // Find the first video stream and take it
    104   video_stream = -1;
    105   for(int i = 0; i < format_context->nb_streams; i++)
    106   {
    107     // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
    108     // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)
    109     if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
    110     {
    111       video_stream = i;
    112       break;
    113     }
    114   }
     104  video_stream = av_find_default_stream_index(format_context);
    115105
    116106  if(video_stream == -1)
     
    141131  // Assign appropriate parts of buffer to image planes in RGB_frame
    142132  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
     133
     134  // data buffer for the texture
     135  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    143136
    144137  // Calculate fps
     
    192185                    codec_context->pix_fmt, codec_context->width, codec_context->height);
    193186
    194         data = 0;
    195         data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    196187        for(int i = 0; i < codec_context->height; i++)
    197188          memcpy(&data[i*codec_context->width*3], ((AVPicture*)RGB_frame)->data[0]+i *
     
    247238                        data);
    248239        glBindTexture(GL_TEXTURE_2D, 0);
    249 
    250         //avcodec_flush_buffers(codec_context);
    251240
    252241      }
     
    327316}
    328317
    329 void MoviePlayer::start(unsigned int start_time)
     318void MoviePlayer::start(float start_time)
    330319{
    331320  status = PLAY;
     
    339328void MoviePlayer::resume()
    340329{
    341   if(status == STOP)
    342     this->start(0);
    343   else
     330  if(status == PAUSE)
     331  {
    344332    status = PLAY;
    345 
    346    PRINTF(0)("resume\n");
     333    PRINTF(0)("resume\n");
     334  }
    347335}
    348336
    349337void MoviePlayer::pause()
    350338{
    351   if(status != STOP)
     339  if(status == PLAY)
     340  {
    352341    status = PAUSE;
    353 
    354   PRINTF(0)("pause\n");
     342    PRINTF(0)("pause\n");
     343  }
    355344}
    356345
  • branches/avi_play/src/lib/graphics/importer/movie_player.h

    r6373 r6382  
    7171  void loadMovie(const char* filename);
    7272
    73         void start(unsigned int start_time);
     73        void start(float start_time);
    7474        void resume();
    7575        void pause();
  • branches/avi_play/src/subprojects/importer/movie_player_test.cc

    r6353 r6382  
    2222
    2323MoviePlayer* movie_player;
     24float start_time;
    2425
    2526void Framework::moduleInit(int argc, char** argv)
    2627{
     28  if( argc <= 1)
     29  {
     30    printf("Wrong arguments try following notations:\n");
     31    printf("./movie_player_test [media_file]\n");
     32    exit(0);
     33  }
     34
    2735  movie_player = new MoviePlayer(argv[1]);
    28 
    2936  movie_player->printInformation();
     37 
     38  //start_time = atoi(argv[2]);
     39  start_time = 0;
    3040}
    3141
     
    3848      {
    3949        case SDLK_1:
    40           movie_player->start(0);
     50          movie_player->start(start_time);
    4151          break;
    4252        case SDLK_2:
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6353 r6382  
    7474          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
    7575          break;
    76         case SDLK_5:
    77           media_container->loadFrames();
    78           counter = 0;
    79           timer = 0;
    80           SDL_Delay(1000);
    81           break;
    8276        // increase fps
    8377        case SDLK_9:
     
    107101      timer = 0;
    108102      counter = 0;
    109       PRINTF(0)("BEGIN\n");
    110       PRINTF(0)("total_frames: %i\n", media_container->getFrameCount());
    111103    }
    112104  }
Note: See TracChangeset for help on using the changeset viewer.