summaryrefslogtreecommitdiffstats
path: root/libhb/reader.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-12-05 17:15:57 +0000
committerjstebbins <[email protected]>2009-12-05 17:15:57 +0000
commitc6caa91a4ff436198e22d518d6b5e6882921576b (patch)
tree8831fdf29ffffe86c30fc008e20d848254a37046 /libhb/reader.c
parent8209d6c285d54482da16aa5eb7b5dfe96c2b3264 (diff)
Reduce the amount of buffering used and eliminate hb_snooze in the encoding pipeline
For HD sources on an 8 core system with hyperthreading, we were using 1.5GB of ram. Add to that the 600MB x264 uses for rc-lookahead, pushes it north of 2GB. To reduce our memory usage, the fifo depths have been reduced are are no longer a multiple of cpu count. Use of hb_snooze has been eliminated in the encoding pipeline so that performance doesn't fall as a result of the reduced fifo depths. In sync, each audio and video were given separate threads so that each can wait on it's respective input fifo without blocking the others. In muxcommon, each stream being muxed was given a separate thread so that each can wait on it's respective fifo. This allows the removal of hb_snooze in the sync and muxer work loops. In both sync and muxer, there is common data that is shared by all threads, so special init routines allocate this shared data and initialize the threads. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3007 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/reader.c')
-rw-r--r--libhb/reader.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/libhb/reader.c b/libhb/reader.c
index 94ee77efb..346cafd5a 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -69,15 +69,7 @@ hb_thread_t * hb_reader_init( hb_job_t * job )
static void push_buf( const hb_reader_t *r, hb_fifo_t *fifo, hb_buffer_t *buf )
{
- while( !*r->die && !r->job->done && hb_fifo_is_full( fifo ) )
- {
- /*
- * Loop until the incoming fifo is ready to receive
- * this buffer.
- */
- hb_snooze( 50 );
- }
- hb_fifo_push( fifo, buf );
+ hb_fifo_push_wait( fifo, buf );
}
static int is_audio( hb_reader_t *r, int id )
@@ -466,20 +458,23 @@ static void ReaderFunc( void * _r )
done:
// send empty buffers downstream to video & audio decoders to signal we're done.
- push_buf( r, r->job->fifo_mpeg2, hb_buffer_init(0) );
-
- hb_audio_t *audio;
- for( n = 0; ( audio = hb_list_item( r->job->title->list_audio, n ) ); ++n )
+ if( !*r->die && !r->job->done )
{
- if ( audio->priv.fifo_in )
- push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
- }
+ push_buf( r, r->job->fifo_mpeg2, hb_buffer_init(0) );
- hb_subtitle_t *subtitle;
- for( n = 0; ( subtitle = hb_list_item( r->job->title->list_subtitle, n ) ); ++n )
- {
- if ( subtitle->fifo_in && subtitle->source == VOBSUB)
- push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
+ hb_audio_t *audio;
+ for( n = 0; (audio = hb_list_item( r->job->title->list_audio, n)); ++n )
+ {
+ if ( audio->priv.fifo_in )
+ push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
+ }
+
+ hb_subtitle_t *subtitle;
+ for( n = 0; (subtitle = hb_list_item( r->job->title->list_subtitle, n)); ++n )
+ {
+ if ( subtitle->fifo_in && subtitle->source == VOBSUB)
+ push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
+ }
}
hb_list_empty( &list );