diff options
author | eddyg <[email protected]> | 2008-08-29 00:16:22 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2008-08-29 00:16:22 +0000 |
commit | 06413f74f4cce1662ed00b9d4a20285f7eeed914 (patch) | |
tree | 517416a0c8907913078a8a0a0cb7d1be2f6d211f /libhb | |
parent | e746a5c30f6532923f5008effd29b52903833a2b (diff) |
Change buffer reuse policy to MRU to hopefully improve cache and VM performance.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1659 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/fifo.c | 39 | ||||
-rw-r--r-- | libhb/internal.h | 1 |
2 files changed, 39 insertions, 1 deletions
diff --git a/libhb/fifo.c b/libhb/fifo.c index 1bf2a9de6..ea2a29287 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -190,7 +190,7 @@ void hb_buffer_close( hb_buffer_t ** _b ) if( buffer_pool && b->data && !hb_fifo_is_full( buffer_pool ) ) { - hb_fifo_push( buffer_pool, b ); + hb_fifo_push_head( buffer_pool, b ); return; } /* either the pool is full or this size doesn't use a pool - free the buf */ @@ -334,6 +334,43 @@ void hb_fifo_push( hb_fifo_t * f, hb_buffer_t * b ) hb_unlock( f->lock ); } +void hb_fifo_push_head( hb_fifo_t * f, hb_buffer_t * b ) +{ + hb_buffer_t * tmp; + uint32_t size = 0; + + if( !b ) + { + return; + } + + hb_lock( f->lock ); + + /* + * If there are a chain of buffers prepend the lot + */ + tmp = b; + while( tmp->next ) + { + tmp = tmp->next; + size += 1; + } + + if( f->size > 0 ) + { + tmp->next = f->first; + } + else + { + f->last = tmp; + } + + f->first = b; + f->size += ( size + 1 ); + + hb_unlock( f->lock ); +} + void hb_fifo_close( hb_fifo_t ** _f ) { hb_fifo_t * f = *_f; diff --git a/libhb/internal.h b/libhb/internal.h index 36dca0d80..5f04e3852 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -85,6 +85,7 @@ hb_buffer_t * hb_fifo_get( hb_fifo_t * ); hb_buffer_t * hb_fifo_see( hb_fifo_t * ); hb_buffer_t * hb_fifo_see2( hb_fifo_t * ); void hb_fifo_push( hb_fifo_t *, hb_buffer_t * ); +void hb_fifo_push_head( hb_fifo_t *, hb_buffer_t * ); void hb_fifo_close( hb_fifo_t ** ); /*********************************************************************** |