diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/fifo.c | 47 | ||||
-rw-r--r-- | libhb/work.c | 4 |
2 files changed, 27 insertions, 24 deletions
diff --git a/libhb/fifo.c b/libhb/fifo.c index a36bb7774..4f844795c 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -93,39 +93,42 @@ hb_buffer_t * hb_buffer_init( int size ) int b_alloc; int resize = 0; - /* - * The buffer pools are allocated in increasing size - */ - for( i = 0; i < buffers.entries; i++ ) + if( size > 0 ) { - if( buffers.pool[i]->buffer_size >= size ) + /* + * The buffer pools are allocated in increasing size + */ + for( i = 0; i < buffers.entries; i++ ) { - /* - * This pool is big enough, but are there any buffers in it? - */ - if( hb_fifo_size( buffers.pool[i] ) ) + if( buffers.pool[i]->buffer_size >= size ) { /* - * We've found a matching buffer pool, with buffers. - */ - buffer_pool = buffers.pool[i]; - resize = buffers.pool[i]->buffer_size; - } else { - /* - * Buffer pool is empty, + * This pool is big enough, but are there any buffers in it? */ - if( resize ) { + if( hb_fifo_size( buffers.pool[i] ) ) + { /* - * This is the second time through, so break out of here to avoid - * using too large a buffer for a small job. + * We've found a matching buffer pool, with buffers. */ - break; + buffer_pool = buffers.pool[i]; + resize = buffers.pool[i]->buffer_size; + } else { + /* + * Buffer pool is empty, + */ + if( resize ) { + /* + * This is the second time through, so break + * out of here to avoid using too large a + * buffer for a small job. + */ + break; + } + resize = buffers.pool[i]->buffer_size; } - resize = buffers.pool[i]->buffer_size; } } } - /* * Don't reuse the 0 size buffers, not much gain. */ diff --git a/libhb/work.c b/libhb/work.c index 326da8e61..8bf8a4eac 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -576,8 +576,6 @@ static void do_job( hb_job_t * job, int cpu_count ) hb_fifo_close( &job->fifo_render ); hb_fifo_close( &job->fifo_mpeg4 ); - hb_buffer_pool_free(); - for (i=0; i < hb_list_count(title->list_subtitle); i++) { subtitle = hb_list_item( title->list_subtitle, i); if( subtitle ) @@ -689,6 +687,8 @@ static void do_job( hb_job_t * job, int cpu_count ) } } + hb_buffer_pool_free(); + hb_title_close( &job->title ); free( job ); } |