Make the processing lib use mutexes from WelsThreadLib from the common library
This requires always building the WelsMutex* functions, even if MT_ENABLED isn't set.
This commit is contained in:
@@ -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 @@ WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
|
||||
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
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {
|
||||
|
||||
@@ -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 */,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#include "IWelsVP.h"
|
||||
#include "util.h"
|
||||
#include "thread.h"
|
||||
#include "WelsThreadLib.h"
|
||||
|
||||
WELSVP_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
@@ -1,99 +0,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
|
||||
|
||||
|
||||
|
||||
@@ -1,89 +0,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
|
||||
@@ -3,7 +3,6 @@ PROCESSING_CPP_SRCS=\
|
||||
$(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\
|
||||
|
||||
Reference in New Issue
Block a user