diff options
author | eddyg <[email protected]> | 2007-10-04 00:44:41 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-10-04 00:44:41 +0000 |
commit | e20b60acb5d0fd0eec5c28b631c0f61286ee5961 (patch) | |
tree | 7f0b73eff548d70ffea091cef4bca90e3030346d | |
parent | 7b750d30e23312c7c9924be13b81c0b8c9296c99 (diff) |
Two changes, one ensure zero size buffers are zero size, second change the buffer cleanup to be later.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@999 b64f7644-9d1e-0410-96f1-a4d463321fa5
-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 ); } |