[Libav-user] [libav-user] Memory leak in Mac OS X Lion
Quy Pham Sy
phamsyquybk at gmail.com
Tue Oct 16 10:11:21 CEST 2012
Hi,
I made a simple console test base on Dranger 's tutorial code by
replace deprecated function by the new versions.
here the full source code:
https://github.com/phamquy/FFmpeg-tutorial-samples/blob/master/tutorial01.c
It works fine, but there is a huge memory leak (i use Instrument to
for leak detection).
It seem like the leaks caused by the while loop,
there is no leak after i commented out this part:
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0) {
if(packet.stream_index==videoStreamIdx) {
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
if(frameFinished) {
static struct SwsContext *img_convert_ctx;
int w = pCodecCtx->width;
int h = pCodecCtx->height;
img_convert_ctx = sws_getContext(w, h, pCodecCtx->pix_fmt,
w, h, PIX_FMT_RGB24,
SWS_BICUBIC, NULL, NULL, NULL);
sws_scale(img_convert_ctx, (const uint8_t * const
*)pFrame->data,
pFrame->linesize, 0, pCodecCtx->height,
pFrameRGB->data, pFrameRGB->linesize);
if(++i<=5)
SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,
i);
}
}
av_free_packet(&packet);
}
What is wrong with this code?
Thanks
PhamQuy
More information about the Libav-user
mailing list