[Ffmpeg-devel] Memory leek when converting images

paolo mosna paolo.mosna
Fri Feb 9 08:08:44 CET 2007


Hi all,

I have a problem when converting an image from YCrCb to RGB using following
implementation:

-------------------------------------------------------------------------------------------

  AVFrame * pFrameRGB = avcodec_alloc_frame();
  if(pFrameRGB==NULL){
    throw Exception("Unable to allocate frame!");
  }

  // Determine required buffer size and allocate buffer
  int numBytes=avpicture_get_size(PIX_FMT_RGB24, _width, _height);
  uint8_t *buffer=new uint8_t[numBytes];

  // Assign appropriate parts of buffer to image planes in pFrameRGB
  avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24, _width,
_height);

  img_convert((AVPicture *)pFrameRGB, format, (AVPicture*)_pFrame, _pixFmt,
_width, _height);

  MFX_IFrame *result = new MFX_MPEGFrame(pFrameRGB, _width, _height,
format);

  if(buffer != NULL)
      delete [] buffer;

-------------------------------------------------------------------------------------------

The last two instructions:

  if(buffer != NULL)
      delete [] buffer;

are used to release the created buffer.

Here there are two situations:

(1) Buffer is NOT release:
If I do not release the buffer the system works correctly, but using unix
top
command I noticed that the process memory is continuously increasing
till blocking the system...

(2) Buffer is released
If I release the buffer the system doesn't work with all the videos, but
when it works, process memory usage (monitored with top command)
does NOT increase, without overloading system

In the other part of the system all the data are correctly released
using av_free().

Does anyone have any clues about this behavior?
where is method avpicture_fill() declared? I would check-out method
implementation.

Thanks.


-- 
Ing. Paolo Mosna
Senior Software Analyst

Phone: +39 329 7776617
Skype: paolo.mosna
Email: paolo.mosna at tiscali.it
Address:
  Strada Granda 41,
  Torbole sul Garda,
  TRENTO (ITALY)




More information about the ffmpeg-devel mailing list