e0951599ea
The two different variants of the threadlib basically are win32 and unix - use _WIN32 to check for this consistently, instead of occasionally using __GNUC__ to enable the unix codepath. (__GNUC__ is also defined on mingw, which still is a windows platform and should use the _WIN32 code.)
128 lines
4.5 KiB
C
128 lines
4.5 KiB
C
/*!
|
|
* \copy
|
|
* Copyright (c) 2010-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 mt_defs.h
|
|
*
|
|
* \brief Main macros for multiple threading implementation
|
|
*
|
|
* \date 2/26/2010 Created
|
|
*
|
|
*************************************************************************************
|
|
*/
|
|
#if !defined(MULTIPLE_THREADING_DEFINES_H__)
|
|
#define MULTIPLE_THREADING_DEFINES_H__
|
|
|
|
#include "typedefs.h"
|
|
#include "codec_app_def.h"
|
|
#include "wels_const.h"
|
|
#include "WelsThreadLib.h"
|
|
|
|
/*
|
|
* MT_DEBUG: output trace MT related into log file
|
|
*/
|
|
//#define MT_DEBUG
|
|
//#define ENABLE_TRACE_MT
|
|
|
|
#ifdef MT_ENABLED
|
|
|
|
#define DYNAMIC_DETECT_CPU_CORES
|
|
|
|
//#if defined(WIN32)
|
|
//#define BIND_CPU_CORES_TO_THREADS // if it is not defined here mean cross cpu cores load balance automatically
|
|
//#endif//WIN32
|
|
|
|
#else
|
|
|
|
#endif//MT_ENABLED
|
|
|
|
#if !defined(MT_ENABLED)
|
|
|
|
#if defined(MT_DEBUG)
|
|
#undef MT_DEBUG
|
|
#endif//MT_DEBUG
|
|
#if defined(ENABLE_TRACE_MT)
|
|
#undef ENABLE_TRACE_MT
|
|
#endif//ENABLE_TRACE_MT
|
|
|
|
#endif//!MT_ENABLED
|
|
|
|
#define THRESHOLD_RMSE_CORE8 0.0320f // v1.1: 0.0320f; v1.0: 0.02f
|
|
#define THRESHOLD_RMSE_CORE4 0.0215f // v1.1: 0.0215f; v1.0: 0.03f
|
|
#define THRESHOLD_RMSE_CORE2 0.0200f // v1.1: 0.0200f; v1.0: 0.04f
|
|
|
|
typedef struct TagSliceThreadPrivateData {
|
|
void* pWelsPEncCtx;
|
|
SLayerBSInfo* pLayerBs;
|
|
int32_t iSliceIndex; // slice index, zero based
|
|
int32_t iThreadIndex; // thread index, zero based
|
|
|
|
// for dynamic slicing mode
|
|
int32_t iStartMbIndex; // inclusive
|
|
int32_t iEndMbIndex; // exclusive
|
|
} SSliceThreadPrivateData;
|
|
|
|
typedef struct TagSliceThreading {
|
|
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
|
|
WELS_THREAD_HANDLE* pThreadHandles;// thread handles, [iThreadIdx]
|
|
#ifdef _WIN32
|
|
WELS_EVENT* pSliceCodedEvent;// events for slice coded state, [iThreadIdx]
|
|
WELS_EVENT* pReadySliceCodingEvent; // events for slice coding ready, [iThreadIdx]
|
|
WELS_EVENT* pFinSliceCodingEvent; // notify slice coding thread is done
|
|
WELS_EVENT* pExitEncodeEvent; // event for exit encoding event
|
|
#else
|
|
WELS_EVENT* pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
|
|
WELS_EVENT* pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
|
|
#endif//_WIN32
|
|
|
|
#if !defined(_WIN32)
|
|
WELS_THREAD_HANDLE* pUpdateMbListThrdHandles; // thread handles for update mb list thread, [iThreadIdx]
|
|
#endif//!_WIN32
|
|
#ifdef _WIN32
|
|
WELS_EVENT* pUpdateMbListEvent; // signal to update mb list neighbor for various slices
|
|
WELS_EVENT* pFinUpdateMbListEvent; // signal to indicate finish updating mb list
|
|
#else
|
|
WELS_EVENT* pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices
|
|
WELS_EVENT* pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
|
|
#endif//_WIN32
|
|
|
|
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
|
|
|
|
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
|
|
float* pSliceComplexRatio[MAX_DEPENDENCY_LAYER];
|
|
|
|
#ifdef MT_DEBUG
|
|
FILE* pFSliceDiff; // file handle for debug
|
|
#endif//MT_DEBUG
|
|
|
|
} SSliceThreading;
|
|
|
|
#endif//MULTIPLE_THREADING_DEFINES_H__
|