1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TEncSlice.h |
---|
35 | \brief slice encoder class (header) |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef __TENCSLICE__ |
---|
39 | #define __TENCSLICE__ |
---|
40 | |
---|
41 | // Include files |
---|
42 | #include "TLibCommon/CommonDef.h" |
---|
43 | #include "TLibCommon/TComList.h" |
---|
44 | #include "TLibCommon/TComPic.h" |
---|
45 | #include "TLibCommon/TComPicYuv.h" |
---|
46 | #include "TEncCu.h" |
---|
47 | #include "WeightPredAnalysis.h" |
---|
48 | |
---|
49 | //! \ingroup TLibEncoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | class TEncTop; |
---|
53 | class TEncGOP; |
---|
54 | |
---|
55 | // ==================================================================================================================== |
---|
56 | // Class definition |
---|
57 | // ==================================================================================================================== |
---|
58 | |
---|
59 | /// slice encoder class |
---|
60 | class TEncSlice |
---|
61 | : public WeightPredAnalysis |
---|
62 | { |
---|
63 | private: |
---|
64 | // encoder configuration |
---|
65 | TEncCfg* m_pcCfg; ///< encoder configuration class |
---|
66 | |
---|
67 | // pictures |
---|
68 | TComList<TComPic*>* m_pcListPic; ///< list of pictures |
---|
69 | TComPicYuv* m_apcPicYuvPred; ///< prediction picture buffer |
---|
70 | TComPicYuv* m_apcPicYuvResi; ///< residual picture buffer |
---|
71 | |
---|
72 | // processing units |
---|
73 | TEncGOP* m_pcGOPEncoder; ///< GOP encoder |
---|
74 | TEncCu* m_pcCuEncoder; ///< CU encoder |
---|
75 | |
---|
76 | // encoder search |
---|
77 | TEncSearch* m_pcPredSearch; ///< encoder search class |
---|
78 | |
---|
79 | // coding tools |
---|
80 | TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
81 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
82 | TEncSbac* m_pcSbacCoder; ///< SBAC encoder |
---|
83 | TEncBinCABAC* m_pcBinCABAC; ///< Bin encoder CABAC |
---|
84 | TComTrQuant* m_pcTrQuant; ///< transform & quantization |
---|
85 | |
---|
86 | // RD optimization |
---|
87 | TComBitCounter* m_pcBitCounter; ///< bit counter |
---|
88 | TComRdCost* m_pcRdCost; ///< RD cost computation |
---|
89 | TEncSbac*** m_pppcRDSbacCoder; ///< storage for SBAC-based RD optimization |
---|
90 | TEncSbac* m_pcRDGoOnSbacCoder; ///< go-on SBAC encoder |
---|
91 | UInt64 m_uiPicTotalBits; ///< total bits for the picture |
---|
92 | UInt64 m_uiPicDist; ///< total distortion for the picture |
---|
93 | Double m_dPicRdCost; ///< picture-level RD cost |
---|
94 | Double* m_pdRdPicLambda; ///< array of lambda candidates |
---|
95 | Double* m_pdRdPicQp; ///< array of picture QP candidates (double-type for lambda) |
---|
96 | Int* m_piRdPicQp; ///< array of picture QP candidates (int-type) |
---|
97 | TEncBinCABAC* m_pcBufferBinCoderCABACs; ///< line of bin coder CABAC |
---|
98 | TEncSbac* m_pcBufferSbacCoders; ///< line to store temporary contexts |
---|
99 | TEncBinCABAC* m_pcBufferLowLatBinCoderCABACs; ///< dependent tiles: line of bin coder CABAC |
---|
100 | TEncSbac* m_pcBufferLowLatSbacCoders; ///< dependent tiles: line to store temporary contexts |
---|
101 | |
---|
102 | UInt m_uiSliceIdx; |
---|
103 | |
---|
104 | #if MERL_VSP_C0152 |
---|
105 | // Data temporarily stored, will be sent to TComSlice level where the data will be actually used |
---|
106 | TComPic* m_pPicBaseTxt; |
---|
107 | TComPic* m_pPicBaseDepth; |
---|
108 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
109 | Int* m_aiShiftLUT[2]; ///< For reference views from LIST0 and LIST1 |
---|
110 | #else |
---|
111 | Int* m_aiShiftLUT; |
---|
112 | #endif |
---|
113 | Int m_iShiftPrec; |
---|
114 | #endif |
---|
115 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
116 | TComList<TComPic*>* m_pcListDepthPic[MAX_VIEW_NUM]; ///< For three views in total, indexed as viewId = 0, 1, 2 |
---|
117 | #endif |
---|
118 | public: |
---|
119 | TEncSlice(); |
---|
120 | virtual ~TEncSlice(); |
---|
121 | |
---|
122 | Void create ( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth ); |
---|
123 | Void destroy (); |
---|
124 | Void init ( TEncTop* pcEncTop ); |
---|
125 | |
---|
126 | /// preparation of slice encoding (reference marking, QP and lambda) |
---|
127 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
128 | #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
129 | Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, bool isDepth ); |
---|
130 | #else |
---|
131 | Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS ); |
---|
132 | #endif |
---|
133 | #else |
---|
134 | Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ); |
---|
135 | #endif |
---|
136 | // compress and encode slice |
---|
137 | Void precompressSlice ( TComPic*& rpcPic ); ///< precompress slice for multi-loop opt. |
---|
138 | Void compressSlice ( TComPic*& rpcPic ); ///< analysis stage of slice |
---|
139 | Void encodeSlice ( TComPic*& rpcPic, TComOutputBitstream* rpcBitstream, TComOutputBitstream* pcSubstreams ); |
---|
140 | |
---|
141 | // misc. functions |
---|
142 | Void setSearchRange ( TComSlice* pcSlice ); ///< set ME range adaptively |
---|
143 | UInt64 getTotalBits () { return m_uiPicTotalBits; } |
---|
144 | |
---|
145 | TEncCu* getCUEncoder() { return m_pcCuEncoder; } ///< CU encoder |
---|
146 | Void xDetermineStartAndBoundingCUAddr ( UInt& uiStartCUAddr, UInt& uiBoundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice ); |
---|
147 | UInt getSliceIdx() { return m_uiSliceIdx; } |
---|
148 | Void setSliceIdx(UInt i) { m_uiSliceIdx = i; } |
---|
149 | |
---|
150 | #if MERL_VSP_C0152 |
---|
151 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
152 | Void setBWVSPLUTParam ( Int *pShiftLUT, Int iLoG2LUTPrec, Int iNeighborViewId ) { m_aiShiftLUT[iNeighborViewId] = pShiftLUT; m_iShiftPrec = 2-iLoG2LUTPrec; } |
---|
153 | #else |
---|
154 | Void setBWVSPLUTParam ( Int *pShiftLUT, Int iLoG2LUTPrec ) { m_aiShiftLUT = pShiftLUT; m_iShiftPrec = 2-iLoG2LUTPrec; } |
---|
155 | #endif |
---|
156 | Void setRefPicBaseTxt ( TComPic*pPicTxt ) { m_pPicBaseTxt = pPicTxt; } |
---|
157 | Void setRefPicBaseDepth ( TComPic*pPicDepth ) { m_pPicBaseDepth = pPicDepth;} |
---|
158 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
159 | Void getBWVSPLUTParam ( Int*& pShiftLUT, Int& iShiftPrec, Int iNeighborViewId ) { pShiftLUT = m_aiShiftLUT[iNeighborViewId]; iShiftPrec = m_iShiftPrec; } |
---|
160 | #else |
---|
161 | Void getBWVSPLUTParam ( Int*& pShiftLUT, Int& iShiftPrec ) { pShiftLUT = m_aiShiftLUT; iShiftPrec = m_iShiftPrec; } |
---|
162 | #endif |
---|
163 | TComPic* getRefPicBaseTxt () { return m_pPicBaseTxt; } |
---|
164 | TComPic* getRefPicBaseDepth () { return m_pPicBaseDepth; } |
---|
165 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
166 | Void setListDepthPic ( TComList<TComPic*>* pListDepthPic, Int viewId ) { m_pcListDepthPic[viewId] = pListDepthPic; } |
---|
167 | TComList<TComPic*>* getListDepthPic(Int viewId) { return m_pcListDepthPic[viewId]; } |
---|
168 | #endif |
---|
169 | #endif |
---|
170 | }; |
---|
171 | |
---|
172 | //! \} |
---|
173 | |
---|
174 | #endif // __TENCSLICE__ |
---|