• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    slice_multi_threading.c
33  *
34  * \brief   slice based multiple threading
35  *
36  * \date    04/16/2010 Created
37  *
38  *************************************************************************************
39  */
40 #ifndef SVC_SLICE_MULTIPLE_THREADING_H__
41 #define SVC_SLICE_MULTIPLE_THREADING_H__
42 
43 
44 #include "typedefs.h"
45 #include "codec_app_def.h"
46 #include "param_svc.h"
47 #include "encoder_context.h"
48 #include "svc_enc_frame.h"
49 #include "svc_enc_macroblock.h"
50 #include "svc_enc_slice_segment.h"
51 #include "WelsThreadLib.h"
52 
53 namespace WelsEnc {
54 void UpdateMbListNeighborParallel (SDqLayer* pCurDq,
55                                    SMB* pMbList,
56                                    const int32_t kiSliceIdc);
57 
58 void CalcSliceComplexRatio (SDqLayer* pCurDq);
59 
60 int32_t NeedDynamicAdjust (SSlice** ppSliceInLayer, const int32_t iSliceNum);
61 
62 void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
63                            SDqLayer* pCurDqLayer,
64                            int32_t iCurDid);
65 
66 int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pParam, const int32_t kiCountBsLen,
67                            const int32_t kiTargetSpatialBsSize, bool bDynamicSlice);
68 
69 void ReleaseMtResource (sWelsEncCtx** ppCtx);
70 
71 int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t kiSliceCount);
72 
73 #if !defined(_WIN32)
74 WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg);
75 #endif//!_WIN32
76 
77 int32_t DynamicDetectCpuCores();
78 
79 
80 int32_t AdjustBaseLayer (sWelsEncCtx* pCtx);
81 int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid);
82 
83 
84 
85 #if defined(MT_DEBUG)
86 void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t kiCurDid);
87 #endif
88 #if defined(MT_DEBUG)
89 void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t kiSpatialNum);
90 #endif//defined(MT_DEBUG)
91 
92 void SetOneSliceBsBufferUnderMultithread(sWelsEncCtx* pCtx, const int32_t kiThreadIdx, SSlice* pSlice);
93 int32_t WriteSliceBs (sWelsEncCtx* pCtx,SWelsSliceBs* pSliceBs,const int32_t iSliceIdx,int32_t& iSliceSize);
94 }
95 
96 #endif//SVC_SLICE_MULTIPLE_THREADING_H__
97 
98