diff options
-rw-r--r-- | libhb/common.c | 20 | ||||
-rw-r--r-- | libhb/hb.c | 16 | ||||
-rw-r--r-- | libhb/internal.h | 2 | ||||
-rw-r--r-- | libhb/render.c | 19 | ||||
-rw-r--r-- | libhb/work.c | 24 |
5 files changed, 60 insertions, 21 deletions
diff --git a/libhb/common.c b/libhb/common.c index 39e6140ec..b23f42d4b 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -613,3 +613,23 @@ void hb_title_close( hb_title_t ** _t ) *_t = NULL; } +/********************************************************************** + * hb_filter_close + ********************************************************************** + * + *********************************************************************/ +void hb_filter_close( hb_filter_object_t ** _f ) +{ + hb_filter_object_t * f = *_f; + + f->close( f->private_data ); + + if( f->name ) + free( f->name ); + if( f->settings ) + free( f->settings ); + + free( f ); + *_f = NULL; +} + diff --git a/libhb/hb.c b/libhb/hb.c index 6c2e5034f..9f1b6bec9 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -935,8 +935,22 @@ void hb_add( hb_handle_t * h, hb_job_t * job ) job_copy->filters = hb_list_init(); for( i = 0; i < filter_count; i++ ) { + /* + * Copy the filters, since the MacGui reuses the global filter objects + * meaning that queued up jobs overwrite the previous filter settings. + * In reality, settings is probably the only field that needs duplicating + * since it's the only value that is ever changed. But name is duplicated + * as well for completeness. Not copying private_data since it gets + * created for each job in renderInit. + */ hb_filter_object_t * filter = hb_list_item( job->filters, i ); - hb_list_add( job_copy->filters, filter ); + hb_filter_object_t * filter_copy = malloc( sizeof( hb_filter_object_t ) ); + memcpy( filter_copy, filter, sizeof( hb_filter_object_t ) ); + if( filter->name ) + filter_copy->name = strdup( filter->name ); + if( filter->settings ) + filter_copy->settings = strdup( filter->settings ); + hb_list_add( job_copy->filters, filter_copy ); } } diff --git a/libhb/internal.h b/libhb/internal.h index e4d5bee49..3a4e86a95 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -19,6 +19,8 @@ void hb_list_empty( hb_list_t ** ); hb_title_t * hb_title_init( char * dvd, int index ); void hb_title_close( hb_title_t ** ); +void hb_filter_close( hb_filter_object_t ** ); + /*********************************************************************** * hb.c **********************************************************************/ diff --git a/libhb/render.c b/libhb/render.c index 4253a9237..3a0a02572 100644 --- a/libhb/render.c +++ b/libhb/render.c @@ -447,25 +447,6 @@ void renderClose( hb_work_object_t * w ) hb_fifo_close( &pv->delay_queue ); } - /* Cleanup filters */ - /* TODO: Move to work.c? */ - if( pv->job->filters ) - { - int filter_count = hb_list_count( pv->job->filters ); - int i; - - for( i = 0; i < filter_count; i++ ) - { - hb_filter_object_t * filter = hb_list_item( pv->job->filters, i ); - - if( !filter ) continue; - - filter->close( filter->private_data ); - } - - hb_list_close( &pv->job->filters ); - } - /* Cleanup render work structure */ free( pv ); w->private_data = NULL; diff --git a/libhb/work.c b/libhb/work.c index e1d342f59..2f7bed926 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -178,7 +178,19 @@ static void do_job( hb_job_t * job, int cpu_count ) } if (!detelecine_present) - hb_list_add( job->filters, &hb_filter_detelecine ); + { + /* Allocate the filter. */ + hb_filter_object_t * filter = malloc( sizeof( hb_filter_object_t ) ); + + /* Copy in the contents of the detelecine struct. */ + memcpy( filter, &hb_filter_detelecine, sizeof( hb_filter_object_t ) ); + + /* Set the name to a copy of the template name so render.c has something to free. */ + filter->name = strdup(hb_filter_detelecine.name); + + /* Add it to the list. */ + hb_list_add( job->filters, filter ); + } hb_log("work: VFR mode -- Switching FPS to 29.97 and detelecining."); } @@ -728,6 +740,16 @@ static void do_job( hb_job_t * job, int cpu_count ) } } + if( job->filters ) + { + for( i = 0; i < hb_list_count( job->filters ); i++ ) + { + hb_filter_object_t * filter = hb_list_item( job->filters, i ); + hb_filter_close( &filter ); + } + hb_list_close( &job->filters ); + } + hb_buffer_pool_free(); hb_title_close( &job->title ); |