summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c21
-rw-r--r--libhb/deca52.c3
-rw-r--r--libhb/encavcodec.c4
-rw-r--r--libhb/encfaac.c2
-rw-r--r--libhb/encx264.c15
-rw-r--r--libhb/hb.c2
-rw-r--r--libhb/reader.c2
-rw-r--r--libhb/render.c5
-rw-r--r--libhb/scan.c5
-rw-r--r--libhb/sync.c3
-rw-r--r--libhb/work.c5
11 files changed, 59 insertions, 8 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 1d66e0bcf..560a839e6 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -515,11 +515,30 @@ hb_title_t * hb_title_init( char * dvd, int index )
void hb_title_close( hb_title_t ** _t )
{
hb_title_t * t = *_t;
+ hb_audio_t * audio;
+ hb_chapter_t * chapter;
+ hb_subtitle_t * subtitle;
+ while( ( audio = hb_list_item( t->list_audio, 0 ) ) )
+ {
+ hb_list_rem( t->list_audio, audio );
+ free( audio );
+ }
hb_list_close( &t->list_audio );
+
+ while( ( chapter = hb_list_item( t->list_chapter, 0 ) ) )
+ {
+ hb_list_rem( t->list_chapter, chapter );
+ free( chapter );
+ }
hb_list_close( &t->list_chapter );
+
+ while( ( subtitle = hb_list_item( t->list_subtitle, 0 ) ) )
+ {
+ hb_list_rem( t->list_subtitle, subtitle );
+ free( subtitle );
+ }
hb_list_close( &t->list_subtitle );
- free( t->job );
free( t );
*_t = NULL;
diff --git a/libhb/deca52.c b/libhb/deca52.c
index a5f312335..0664584c9 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -105,6 +105,9 @@ void deca52Close( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
a52_free( pv->state );
+ hb_list_empty( &pv->list );
+ free( pv );
+ w->private_data = NULL;
}
/***********************************************************************
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index c71c8384e..721644fbe 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -151,12 +151,16 @@ void encavcodecClose( hb_work_object_t * w )
if( pv->context )
{
hb_log( "encavcodec: closing libavcodec" );
+ avcodec_flush_buffers( pv->context );
avcodec_close( pv->context );
+ free( pv->context );
}
if( pv->file )
{
fclose( pv->file );
}
+ free( pv );
+ w->private_data = NULL;
}
/***********************************************************************
diff --git a/libhb/encfaac.c b/libhb/encfaac.c
index 5eee39508..7ed9853d7 100644
--- a/libhb/encfaac.c
+++ b/libhb/encfaac.c
@@ -122,6 +122,8 @@ void encfaacClose( hb_work_object_t * w )
faacEncClose( pv->faac );
free( pv->buf );
hb_list_empty( &pv->list );
+ free( pv );
+ w->private_data = NULL;
}
/***********************************************************************
diff --git a/libhb/encx264.c b/libhb/encx264.c
index 747bae9f2..b48bfdafb 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -28,7 +28,6 @@ struct hb_work_private_s
hb_job_t * job;
x264_t * x264;
x264_picture_t pic_in;
- x264_picture_t pic_out;
char filename[1024];
};
@@ -215,7 +214,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
void encx264Close( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
+ x264_picture_clean( &pv->pic_in );
x264_encoder_close( pv->x264 );
+ free( pv );
+ w->private_data = NULL;
/* TODO */
}
@@ -226,6 +228,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_work_private_t * pv = w->private_data;
hb_job_t * job = pv->job;
hb_buffer_t * in = *buf_in, * buf;
+ x264_picture_t pic_out;
int i_nal;
x264_nal_t * nal;
int i;
@@ -253,7 +256,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
pv->pic_in.i_pts = in->start;
x264_encoder_encode( pv->x264, &nal, &i_nal,
- &pv->pic_in, &pv->pic_out );
+ &pv->pic_in, &pic_out );
/* Should be way too large */
buf = hb_buffer_init( 3 * job->width * job->height / 2 );
@@ -300,12 +303,12 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
/* For IDR (key frames), buf->key = 1,
and the same for regular I-frames. */
- if( (pv->pic_out.i_type == X264_TYPE_IDR) || (pv->pic_out.i_type == X264_TYPE_I) )
+ if( (pic_out.i_type == X264_TYPE_IDR) || (pic_out.i_type == X264_TYPE_I) )
{
buf->key = 1;
}
/* For B-frames, buf->key = 2 */
- else if( (pv->pic_out.i_type == X264_TYPE_B) )
+ else if( (pic_out.i_type == X264_TYPE_B) )
{
buf->key = 2;
}
@@ -313,7 +316,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
However, it doesn't seem to ever be used...
They just show up as buf->key == 2 like
regular b-frames. */
- else if( (pv->pic_out.i_type == X264_TYPE_BREF) )
+ else if( (pic_out.i_type == X264_TYPE_BREF) )
{
buf->key = 3;
}
@@ -326,7 +329,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
/* Store the output presentation time stamp
from x264 for use by muxmp4 in off-setting
b-frames with the CTTS atom. */
- buf->encodedPTS = pv->pic_out.i_pts;
+ buf->encodedPTS = pic_out.i_pts;
buf->size += size;
}
diff --git a/libhb/hb.c b/libhb/hb.c
index c1748e8b5..d1eac132f 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -556,6 +556,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
/* Copy the job */
job_copy = calloc( sizeof( hb_job_t ), 1 );
memcpy( job_copy, job, sizeof( hb_job_t ) );
+ title_copy->job = job_copy;
job_copy->title = title_copy;
job_copy->file = strdup( job->file );
job_copy->h = h;
@@ -680,6 +681,7 @@ void hb_close( hb_handle_t ** _h )
while( ( title = hb_list_item( h->list_title, 0 ) ) )
{
hb_list_rem( h->list_title, title );
+ free( title->job );
hb_title_close( &title );
}
hb_list_close( &h->list_title );
diff --git a/libhb/reader.c b/libhb/reader.c
index 47ec9d546..35939f96b 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -115,6 +115,8 @@ static void ReaderFunc( void * _r )
hb_buffer_close( &r->ps );
hb_dvd_stop( r->dvd );
hb_dvd_close( &r->dvd );
+ free( r );
+ _r = NULL;
hb_log( "reader: done" );
}
diff --git a/libhb/render.c b/libhb/render.c
index cf6d7b31c..170047093 100644
--- a/libhb/render.c
+++ b/libhb/render.c
@@ -151,6 +151,11 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
void renderClose( hb_work_object_t * w )
{
+ hb_work_private_t * pv = w->private_data;
+
+ img_resample_close( pv->context );
+ free( pv );
+ w->private_data = NULL;
}
int renderInit( hb_work_object_t * w, hb_job_t * job )
diff --git a/libhb/scan.c b/libhb/scan.c
index 5d817c737..e969a4380 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -114,7 +114,7 @@ static void ScanFunc( void * _data )
hb_log( "scan: title %d is duplicate with title %d",
title->index, title_tmp->index );
hb_list_rem( data->list_title, title );
- free( title );
+ free( title ); /* This _will_ leak! */
continue;
}
@@ -225,6 +225,9 @@ static void ScanFunc( void * _data )
{
hb_dvd_close( &data->dvd );
}
+ free( data->path );
+ free( data );
+ _data = NULL;
}
/***********************************************************************
diff --git a/libhb/sync.c b/libhb/sync.c
index 22266ec63..b8f49fd01 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -135,6 +135,9 @@ void syncClose( hb_work_object_t * w )
src_delete( pv->sync_audio[i].state );
}
}
+
+ free( pv );
+ w->private_data = NULL;
}
/***********************************************************************
diff --git a/libhb/work.c b/libhb/work.c
index 97c332bec..3c1ceadd5 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -369,6 +369,8 @@ static void do_job( hb_job_t * job, int cpu_count )
w = NULL;
}
}
+
+ hb_list_close( &job->list_work );
/* Stop read & write threads */
hb_thread_close( &job->reader );
@@ -393,6 +395,9 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_fifo_close( &audio->fifo_sync );
hb_fifo_close( &audio->fifo_out );
}
+
+ hb_title_close( &job->title );
+ free( job );
}
/**