ref: 3627875986f321266a84fae04ecd3b648c9ad6e1
parent: 567302eb9ae735353da4edca8bd4a75a287640f4
parent: c5390521ecdc60d17049c24d765f5e446988d4a5
author: Ethan Hugg <[email protected]>
date: Mon Mar 10 05:45:51 EDT 2014
Merge pull request #456 from mstorsjo/use-common-threadlib Make the processing lib use mutexes from WelsThreadLib from the common library
--- a/codec/common/WelsThreadLib.cpp
+++ b/codec/common/WelsThreadLib.cpp
@@ -63,13 +63,14 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef MT_ENABLED
#ifdef _WIN32
-void WelsSleep (uint32_t dwMilliseconds) {
- Sleep (dwMilliseconds);
-}
+#ifdef WINAPI_FAMILY
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
+#endif
+#endif
WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
InitializeCriticalSection (mutex);
@@ -95,6 +96,35 @@
return WELS_THREAD_ERROR_OK;
}
+#else /* _WIN32 */
+
+WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
+ return pthread_mutex_init (mutex, NULL);
+}
+
+WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
+ return pthread_mutex_lock (mutex);
+}
+
+WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
+ return pthread_mutex_unlock (mutex);
+}
+
+WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
+ return pthread_mutex_destroy (mutex);
+}
+
+#endif /* !_WIN32 */
+
+
+#ifdef MT_ENABLED
+
+#ifdef _WIN32
+
+void WelsSleep (uint32_t dwMilliseconds) {
+ Sleep (dwMilliseconds);
+}
+
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* event, const char* event_name) {
WELS_EVENT h = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -209,22 +239,6 @@
WELS_THREAD_HANDLE WelsThreadSelf() {
return pthread_self();
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
- return pthread_mutex_init (mutex, NULL);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
- return pthread_mutex_lock (mutex);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
- return pthread_mutex_unlock (mutex);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
- return pthread_mutex_destroy (mutex);
}
// unnamed semaphores aren't supported on OS X
--- a/codec/processing/build/iOS/processing.xcodeproj/project.pbxproj
+++ b/codec/processing/build/iOS/processing.xcodeproj/project.pbxproj
@@ -21,7 +21,6 @@
4CE4478B18BC62960017DF25 /* AdaptiveQuantization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4475D18BC62960017DF25 /* AdaptiveQuantization.cpp */; };
4CE4478F18BC62960017DF25 /* BackgroundDetection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4476418BC62960017DF25 /* BackgroundDetection.cpp */; };
4CE4479018BC62960017DF25 /* memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4476718BC62960017DF25 /* memory.cpp */; };
- 4CE4479118BC62960017DF25 /* thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4476A18BC62960017DF25 /* thread.cpp */; };
4CE4479218BC62960017DF25 /* WelsFrameWork.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4476E18BC62960017DF25 /* WelsFrameWork.cpp */; };
4CE4479318BC62960017DF25 /* WelsFrameWorkEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4477018BC62960017DF25 /* WelsFrameWorkEx.cpp */; };
4CE4479418BC62960017DF25 /* ComplexityAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4477418BC62960017DF25 /* ComplexityAnalysis.cpp */; };
@@ -80,8 +79,6 @@
4CE4476718BC62960017DF25 /* memory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memory.cpp; sourceTree = "<group>"; };
4CE4476818BC62960017DF25 /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
4CE4476918BC62960017DF25 /* resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resource.h; sourceTree = "<group>"; };
- 4CE4476A18BC62960017DF25 /* thread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = thread.cpp; sourceTree = "<group>"; };
- 4CE4476B18BC62960017DF25 /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = thread.h; sourceTree = "<group>"; };
4CE4476C18BC62960017DF25 /* typedef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = typedef.h; sourceTree = "<group>"; };
4CE4476D18BC62960017DF25 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; };
4CE4476E18BC62960017DF25 /* WelsFrameWork.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WelsFrameWork.cpp; sourceTree = "<group>"; };
@@ -240,8 +237,6 @@
4CE4476718BC62960017DF25 /* memory.cpp */,
4CE4476818BC62960017DF25 /* memory.h */,
4CE4476918BC62960017DF25 /* resource.h */,
- 4CE4476A18BC62960017DF25 /* thread.cpp */,
- 4CE4476B18BC62960017DF25 /* thread.h */,
4CE4476C18BC62960017DF25 /* typedef.h */,
4CE4476D18BC62960017DF25 /* util.h */,
4CE4476E18BC62960017DF25 /* WelsFrameWork.cpp */,
@@ -409,7 +404,6 @@
4CE4479C18BC62960017DF25 /* SceneChangeDetectionCommon.cpp in Sources */,
4CE4479418BC62960017DF25 /* ComplexityAnalysis.cpp in Sources */,
4CE4479E18BC62960017DF25 /* vaacalculation.cpp in Sources */,
- 4CE4479118BC62960017DF25 /* thread.cpp in Sources */,
4C34067A18C5A4AD00DFA14A /* pixel_sad_neon.S in Sources */,
4CE4478F18BC62960017DF25 /* BackgroundDetection.cpp in Sources */,
4CE4479618BC62960017DF25 /* denoise_filter.cpp in Sources */,
--- a/codec/processing/build/win32/WelsVP_2008.vcproj
+++ b/codec/processing/build/win32/WelsVP_2008.vcproj
@@ -388,7 +388,7 @@
>
</File>
<File
- RelativePath="..\..\src\common\thread.cpp"
+ RelativePath="..\..\..\common\WelsThreadLib.cpp"
>
</File>
<File
@@ -454,7 +454,7 @@
>
</File>
<File
- RelativePath="..\..\src\common\thread.h"
+ RelativePath="..\..\..\common\WelsThreadLib.h"
>
</File>
<File
--- a/codec/processing/src/common/WelsFrameWork.h
+++ b/codec/processing/src/common/WelsFrameWork.h
@@ -44,7 +44,7 @@
#include "IWelsVP.h"
#include "util.h"
-#include "thread.h"
+#include "WelsThreadLib.h"
WELSVP_NAMESPACE_BEGIN
--- a/codec/processing/src/common/thread.cpp
+++ /dev/null
@@ -1,99 +1,0 @@
-/*!
- * \copy
- * Copyright (c) 2009-2013, Cisco Systems
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * \file thread.cpp
- *
- * \brief Interfaces introduced in thread programming
- *
- * \date 11/17/2009 Created
- *
- *************************************************************************************
- */
-
-#include "thread.h"
-
-WELSVP_NAMESPACE_BEGIN
-
-#if defined(_WIN32)
-
-#ifdef WINAPI_FAMILY
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
-#endif
-#endif
-
-WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
- InitializeCriticalSection (mutex);
-
- return WELS_THREAD_ERROR_OK;
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
- EnterCriticalSection (mutex);
-
- return WELS_THREAD_ERROR_OK;
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
- LeaveCriticalSection (mutex);
-
- return WELS_THREAD_ERROR_OK;
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
- DeleteCriticalSection (mutex);
-
- return WELS_THREAD_ERROR_OK;
-}
-
-#elif defined(__GNUC__)
-
-WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
- return pthread_mutex_init (mutex, NULL);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
- return pthread_mutex_lock (mutex);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
- return pthread_mutex_unlock (mutex);
-}
-
-WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
- return pthread_mutex_destroy (mutex);
-}
-
-#endif
-
-WELSVP_NAMESPACE_END
-
-
-
--- a/codec/processing/src/common/thread.h
+++ /dev/null
@@ -1,89 +1,0 @@
-/*!
- * \copy
- * Copyright (c) 2009-2013, Cisco Systems
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * \file thread.h
- *
- * \brief Interfaces introduced in thread programming
- *
- * \date 11/17/2009 Created
- *
- *************************************************************************************
- */
-
-#ifndef WELSVP_THREAD_H
-#define WELSVP_THREAD_H
-
-#include "typedef.h"
-
-#if defined(_WIN32)
-
-#include <windows.h>
-
-#elif defined(__GNUC__)
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <errno.h>
-
-#endif//WIN32
-
-WELSVP_NAMESPACE_BEGIN
-
-#if defined(_WIN32)
-
-typedef HANDLE WELS_THREAD_HANDLE;
-typedef CRITICAL_SECTION WELS_MUTEX;
-
-#elif defined(__GNUC__)
-
-typedef pthread_t WELS_THREAD_HANDLE;
-typedef pthread_mutex_t WELS_MUTEX;
-
-#endif
-
-typedef int32_t WELS_THREAD_ERROR_CODE;
-
-#define WELS_THREAD_ERROR_OK 0
-#define WELS_THREAD_ERROR_GENERAL ((unsigned long)(-1))
-#define WELS_THREAD_ERROR_WAIT_OBJECT_0 0
-#define WELS_THREAD_ERROR_WAIT_TIMEOUT ((unsigned long)0x00000102L)
-#define WELS_THREAD_ERROR_WAIT_FAILED WELS_THREAD_ERROR_GENERAL
-
-WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex);
-WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex);
-WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
-WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
-
-WELSVP_NAMESPACE_END
-
-#endif
--- a/codec/processing/targets.mk
+++ b/codec/processing/targets.mk
@@ -3,7 +3,6 @@
$(PROCESSING_SRCDIR)/src/adaptivequantization/AdaptiveQuantization.cpp\
$(PROCESSING_SRCDIR)/src/backgrounddetection/BackgroundDetection.cpp\
$(PROCESSING_SRCDIR)/src/common/memory.cpp\
- $(PROCESSING_SRCDIR)/src/common/thread.cpp\
$(PROCESSING_SRCDIR)/src/common/WelsFrameWork.cpp\
$(PROCESSING_SRCDIR)/src/common/WelsFrameWorkEx.cpp\
$(PROCESSING_SRCDIR)/src/complexityanalysis/ComplexityAnalysis.cpp\