hi,
attached patch fixes first three leaks in producer_avformat.
unfixed leak i found comes from mlt_cache
==11279== 10,612,830 (880 direct, 10,611,950 indirect) bytes in 10
blocks are definitely lost in loss record 50 of 50
==11279== at 0x4A05BB4: calloc (vg_replace_malloc.c:467)
==11279== by 0x4C34BA7: mlt_frame_init (mlt_frame.c:44)
==11279== by 0x4C35EE9: mlt_frame_clone (mlt_frame.c:994)
==11279== by 0x4C4AFAB: mlt_cache_put_frame (mlt_cache.c:552)
==11279== by 0xC0BC1C5: producer_get_image (producer_avformat.c:1711)
==11279== by 0x4C35099: mlt_frame_get_image (mlt_frame.c:452)
==11279== by 0xB683478: filter_get_image (filter_crop.c:77)
==11279== by 0x4C35099: mlt_frame_get_image (mlt_frame.c:452)
==11279== by 0x101E2AB2: filter_get_image (filter_deinterlace.c:271)
==11279== by 0x4C35099: mlt_frame_get_image (mlt_frame.c:452)
==11279== by 0xB688BFA: filter_get_image (filter_rescale.c:217)
==11279== by 0x4C35099: mlt_frame_get_image (mlt_frame.c:452)
==11279==
that seems happens because of frames caching is hack to origin cache
functionality and mlt_cache_close do not destroy cached frames.
would be a good idea to create a local cache in producer_avformat?
--
________________________________________
Maksym Veremeyenko
>From 0c2c4467e76f66c68534998c16b04a977efa7c7d Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <[email protected]>
Date: Thu, 19 Jul 2012 11:09:35 +0300
Subject: [PATCH 2/4] fix memleak if file fails to open
---
src/modules/avformat/producer_avformat.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index d3f0884..263972b 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -199,6 +199,7 @@ mlt_producer producer_avformat_init( mlt_profile profile, const char *service, c
// Clean up
mlt_producer_close( producer );
producer = NULL;
+ producer_avformat_close( self );
}
else if ( self->seekable )
{
--
1.7.7.6
>From 64147d53a194663b4d51192c9a183bae672dc97b Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <[email protected]>
Date: Thu, 19 Jul 2012 12:39:24 +0300
Subject: [PATCH 3/4] fix leak of dv packets
---
src/modules/avformat/producer_avformat.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index 263972b..8b327c3 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -790,8 +790,11 @@ static int get_basic_info( producer_avformat self, mlt_profile profile, const ch
if ( ret >= 0 && pkt.stream_index == self->video_index && pkt.size > 0 )
{
get_aspect_ratio( properties, format->streams[ self->video_index ], codec_context, &pkt );
+ av_free_packet(&pkt);
break;
}
+ if ( ret >= 0 )
+ av_free_packet(&pkt);
}
}
else
--
1.7.7.6
>From 88214fc02a3a740a7f9ae1a1098b946038fe1075 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <[email protected]>
Date: Thu, 19 Jul 2012 13:23:09 +0300
Subject: [PATCH 4/4] move mutex and deque initialization to producer init
method
---
src/modules/avformat/producer_avformat.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index 8b327c3..d93ed29 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -191,6 +191,16 @@ mlt_producer producer_avformat_init( mlt_profile profile, const char *service, c
// Register our get_frame implementation
producer->get_frame = producer_get_frame;
+ // init mutexes
+ pthread_mutex_init( &self->audio_mutex, NULL );
+ pthread_mutex_init( &self->video_mutex, NULL );
+ pthread_mutex_init( &self->packets_mutex, NULL );
+ pthread_mutex_init( &self->open_mutex, NULL );
+
+ // init queues
+ self->apackets = mlt_deque_init();
+ self->vpackets = mlt_deque_init();
+
if ( strcmp( service, "avformat-novalidate" ) )
{
// Open the file
@@ -828,10 +838,6 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha
// Lock the service
if ( take_lock )
{
- pthread_mutex_init( &self->audio_mutex, NULL );
- pthread_mutex_init( &self->video_mutex, NULL );
- pthread_mutex_init( &self->packets_mutex, NULL );
- pthread_mutex_init( &self->open_mutex, NULL );
pthread_mutex_lock( &self->audio_mutex );
pthread_mutex_lock( &self->video_mutex );
}
@@ -948,11 +954,6 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha
}
if ( filename )
free( filename );
- if ( !error )
- {
- self->apackets = mlt_deque_init();
- self->vpackets = mlt_deque_init();
- }
if ( self->dummy_context )
{
--
1.7.7.6
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel