2013-12-09 13:51:09 +01:00
|
|
|
/*!
|
|
|
|
* \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 {
|
2013-12-12 23:21:12 +01:00
|
|
|
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
|
2013-12-09 13:51:09 +01:00
|
|
|
} SSliceThreadPrivateData;
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
typedef struct TagSliceThreading {
|
|
|
|
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
|
2014-03-02 22:23:56 +01:00
|
|
|
char eventNamespace[100];
|
2014-03-03 21:23:34 +01:00
|
|
|
WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
|
|
|
|
WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
|
|
|
|
WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
|
|
|
|
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
|
2014-03-02 21:22:23 +01:00
|
|
|
#ifdef _WIN32
|
2014-03-03 21:23:34 +01:00
|
|
|
WELS_EVENT pFinSliceCodingEvent[MAX_THREADS_NUM]; // notify slice coding thread is done
|
|
|
|
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
|
2013-12-09 13:51:09 +01:00
|
|
|
#else
|
|
|
|
|
2014-03-03 21:23:34 +01:00
|
|
|
WELS_THREAD_HANDLE pUpdateMbListThrdHandles[MAX_THREADS_NUM]; // thread handles for update mb list thread, [iThreadIdx]
|
2013-12-15 08:18:19 +01:00
|
|
|
#endif//_WIN32
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
|
|
|
|
float* pSliceComplexRatio[MAX_DEPENDENCY_LAYER];
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
#ifdef MT_DEBUG
|
2013-12-12 23:21:12 +01:00
|
|
|
FILE* pFSliceDiff; // file handle for debug
|
2013-12-09 13:51:09 +01:00
|
|
|
#endif//MT_DEBUG
|
|
|
|
|
|
|
|
} SSliceThreading;
|
|
|
|
|
|
|
|
#endif//MULTIPLE_THREADING_DEFINES_H__
|