Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

branches\avi_play: removed memory leak

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.