summaryrefslogtreecommitdiff
path: root/vp8/common/rtcd.c
diff options
context:
space:
mode:
authorChristian Duvivier <cduvivier@google.com>2012-08-08 15:47:36 -0700
committerChristian Duvivier <cduvivier@google.com>2012-08-08 16:43:48 -0700
commit707b65bd160766f22d82c2c9b3dfc74955c3e2df (patch)
tree553e5d7e8e3dd7eba09f9ab6936d637461fae9e6 /vp8/common/rtcd.c
parent2056f7e0d8d3fc4fd05e53d199dc15b8779bcb64 (diff)
downloadlibvpx-707b65bd160766f22d82c2c9b3dfc74955c3e2df.tar
libvpx-707b65bd160766f22d82c2c9b3dfc74955c3e2df.tar.gz
libvpx-707b65bd160766f22d82c2c9b3dfc74955c3e2df.tar.bz2
libvpx-707b65bd160766f22d82c2c9b3dfc74955c3e2df.zip
Partial import of "New RTCD implementation" from master branch.
Latest version of all scripts/makefile but rtcd_defs.sh is empty, all existing functions are still selected using the old/current way. Change-Id: Ib92946a48a31d6c8d1d7359eca524bc1d3e66174
Diffstat (limited to 'vp8/common/rtcd.c')
-rw-r--r--vp8/common/rtcd.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/vp8/common/rtcd.c b/vp8/common/rtcd.c
new file mode 100644
index 000000000..4980f48ad
--- /dev/null
+++ b/vp8/common/rtcd.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+#include "vpx_config.h"
+#define RTCD_C
+#include "vpx_rtcd.h"
+
+#if CONFIG_MULTITHREAD && 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 CONFIG_MULTITHREAD && defined(_WIN32)
+#include <windows.h>
+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 vpx_rtcd()
+{
+ once(setup_rtcd_internal);
+}