[FFmpeg-devel] dear friends,help me with memory leak.
44072429
44072429
Tue Jan 4 07:03:22 CET 2011
dear friends.
i search about one week on google.
and no result.some one met memory leak,because they didn't free resources.
and different to me.
i tested on windows xp sp3 and windows 7.
IDE,Visual studio 6.0,Visual studio 2005
the source was ffmpeg 0.6.not the lastest.because the lastest can't compile with mingw32.
there is 3 test streams.h264 mpeg4 mjpeg,all of them memory leak after i called avcodec_decode_video2
and ffmpeg.exe works currectly.
the following code is my decode wrapper.
service_error_t FFMpegVideoDecoder::Decode(const char* input,const int input_len,int* use_len,video_frame_t* video_frame)
{
service_error_t service_error;
if(!codec_context)
{
service_error.init(service_error_type_failed,"codec_context wasn't inited");
return service_error;
}
AVPacket* pkt = (AVPacket*)av_malloc(sizeof(AVPacket));
av_init_packet(pkt);
AVFrame * picture = avcodec_alloc_frame();
av_new_packet(pkt,input_len);
pkt->flags = AV_PKT_FLAG_KEY;
memcpy(pkt->data,input,input_len);
int len = avcodec_decode_video2(
codec_context,
picture,
&got_picture_ptr,
pkt);
if (len < 0)
{
service_error.init(service_error_type_failed,"Error while decoding");
return service_error;
}
if(got_picture_ptr == 0)
{
service_error.init(service_error_type_failed,"input buffer is less to form a frame");
return service_error;
}
else
{
for(int i = 0; i < 4; i++)
{
video_frame->data[i] = (char*)picture->data[i];
video_frame->linesize[i] = picture->linesize[i];
}
video_frame->index = picture->coded_picture_number;
video_frame->video_frame_colorspace = yk_colorspace(codec_context->pix_fmt);
m_param.width = codec_context->width;
m_param.height = codec_context->height;
video_frame->width = Width();
video_frame->height = Height();
}
*use_len = input_len;
av_free_packet(pkt);
av_free(pkt);
av_free(picture);
return service_error;
}
this made me crasy......help.....
Regards.
More information about the ffmpeg-devel
mailing list