1 /*! 2 * \copy 3 * Copyright (c) 2010-2013, Cisco Systems 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * 32 * \file mt_defs.h 33 * 34 * \brief Main macros for multiple threading implementation 35 * 36 * \date 2/26/2010 Created 37 * 38 ************************************************************************************* 39 */ 40 #if !defined(MULTIPLE_THREADING_DEFINES_H__) 41 #define MULTIPLE_THREADING_DEFINES_H__ 42 43 #include "typedefs.h" 44 #include "codec_app_def.h" 45 #include "wels_const.h" 46 #include "WelsThreadLib.h" 47 #include "slice.h" 48 49 using namespace WelsEnc; 50 /* 51 * MT_DEBUG: output trace MT related into log file 52 */ 53 //#define MT_DEBUG 54 //#define ENABLE_TRACE_MT 55 56 #define THRESHOLD_RMSE_CORE8 0.0320f // v1.1: 0.0320f; v1.0: 0.02f 57 #define THRESHOLD_RMSE_CORE4 0.0215f // v1.1: 0.0215f; v1.0: 0.03f 58 #define THRESHOLD_RMSE_CORE2 0.0200f // v1.1: 0.0200f; v1.0: 0.04f 59 60 typedef struct TagSliceThreadPrivateData { 61 void* pWelsPEncCtx; 62 SFrameBSInfo* pFrameBsInfo; 63 int32_t iSliceIndex; // slice index, zero based 64 int32_t iThreadIndex; // thread index, zero based 65 66 } SSliceThreadPrivateData; 67 68 typedef struct TagSliceThreading { 69 SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx] 70 char eventNamespace[100]; 71 WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx] 72 WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx] 73 WELS_EVENT pSliceCodedMasterEvent; // events for signalling that some event in pSliceCodedEvent has been signalled 74 WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx] 75 WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices 76 WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list 77 78 WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT 79 80 #ifdef MT_DEBUG 81 FILE* pFSliceDiff; // file handle for debug 82 #endif//MT_DEBUG 83 84 uint8_t* pThreadBsBuffer[MAX_THREADS_NUM]; //actual memory for slice buffer 85 bool bThreadBsBufferUsage[MAX_THREADS_NUM]; 86 WELS_MUTEX mutexThreadBsBufferUsage; 87 WELS_MUTEX mutexEvent; 88 WELS_MUTEX mutexThreadSlcBuffReallocate; 89 } SSliceThreading; 90 91 #endif//MULTIPLE_THREADING_DEFINES_H__ 92