diff options
author | John Koleszar <jkoleszar@google.com> | 2012-06-15 15:40:13 -0700 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2012-06-15 16:26:39 -0700 |
commit | 8df79e9d427fe2e334f110a8abfe3e43449d87c4 (patch) | |
tree | c8283f130d56f73be77e1aeb36d9f3e530c29a2d /vp8/common/generic/systemdependent.c | |
parent | 0164a1cc5b13909407587109effabea92e487986 (diff) | |
download | libvpx-8df79e9d427fe2e334f110a8abfe3e43449d87c4.tar libvpx-8df79e9d427fe2e334f110a8abfe3e43449d87c4.tar.gz libvpx-8df79e9d427fe2e334f110a8abfe3e43449d87c4.tar.bz2 libvpx-8df79e9d427fe2e334f110a8abfe3e43449d87c4.zip |
Remove threading dependencies with --disable-multithread
Avoid a pthreads dependency via pthread_once() when compiled with
--disable-multithread.
In addition, this synchronization is disabled for Win32 as well, even
though we can be sure that the required primatives exist, so that the
requirements on the application when built with --disable-multithread
are consistent across platforms.
Users using libvpx built with --disable-multithread in a multithreaded
context should provide their own synchronization. Updated the
documentation to vpx_codec_enc_init_ver() and vpx_codec_dec_init_ver()
to note this requirement. Moved the RTCD initialization call to match
this description, as previously it didn't happen until the first
frame.
Change-Id: Id576f6bce2758362188278d3085051c218a56d4a
Diffstat (limited to 'vp8/common/generic/systemdependent.c')
-rw-r--r-- | vp8/common/generic/systemdependent.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/vp8/common/generic/systemdependent.c b/vp8/common/generic/systemdependent.c index 2a3016618..5a6ac7b0e 100644 --- a/vp8/common/generic/systemdependent.c +++ b/vp8/common/generic/systemdependent.c @@ -83,57 +83,6 @@ static int get_cpu_count() #endif -#if HAVE_PTHREAD_H -#include <pthread.h> -static void once(void (*func)(void)) -{ - static pthread_once_t lock = PTHREAD_ONCE_INIT; - pthread_once(&lock, func); -} - - -#elif defined(_WIN32) -static void once(void (*func)(void)) -{ - /* Using a static initializer here rather than InitializeCriticalSection() - * since there's no race-free context in which to execute it. Protecting - * it with an atomic op like InterlockedCompareExchangePointer introduces - * an x86 dependency, and InitOnceExecuteOnce requires Vista. - */ - static CRITICAL_SECTION lock = {(void *)-1, -1, 0, 0, 0, 0}; - static int done; - - EnterCriticalSection(&lock); - - if (!done) - { - func(); - done = 1; - } - - LeaveCriticalSection(&lock); -} - - -#else -/* No-op version that performs no synchronization. vpx_rtcd() is idempotent, - * so as long as your platform provides atomic loads/stores of pointers - * no synchronization is strictly necessary. - */ - -static void once(void (*func)(void)) -{ - static int done; - - if(!done) - { - func(); - done = 1; - } -} -#endif - - void vp8_machine_specific_config(VP8_COMMON *ctx) { #if CONFIG_MULTITHREAD @@ -145,6 +94,4 @@ void vp8_machine_specific_config(VP8_COMMON *ctx) #elif ARCH_X86 || ARCH_X86_64 ctx->cpu_caps = x86_simd_caps(); #endif - - once(vpx_rtcd); } |