summaryrefslogtreecommitdiffstats
path: root/libhb/ports.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/ports.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/ports.c')
-rw-r--r--libhb/ports.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libhb/ports.c b/libhb/ports.c
index 120038618..10b598c37 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -604,6 +604,35 @@ void hb_cond_wait( hb_cond_t * c, hb_lock_t * lock )
#endif
}
+void hb_clock_gettime( struct timespec *tp )
+{
+ struct timeval tv;
+ time_t sec;
+
+ sec = time( NULL );
+ gettimeofday( &tv, NULL );
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = tv.tv_usec * 1000;
+}
+
+void hb_cond_timedwait( hb_cond_t * c, hb_lock_t * lock, int msec )
+{
+#if defined( SYS_BEOS )
+ c->thread = find_thread( NULL );
+ release_sem( lock->sem );
+ suspend_thread( c->thread );
+ acquire_sem( lock->sem );
+ c->thread = -1;
+#elif USE_PTHREAD
+ struct timespec ts;
+ hb_clock_gettime(&ts);
+ ts.tv_nsec += (msec % 1000) * 1000000;
+ ts.tv_sec += msec / 1000 + (ts.tv_nsec / 1000000000);
+ ts.tv_nsec %= 1000000000;
+ pthread_cond_timedwait( &c->cond, &lock->mutex, &ts );
+#endif
+}
+
void hb_cond_signal( hb_cond_t * c )
{
#if defined( SYS_BEOS )