HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TEncCu.h
Go to the documentation of this file.
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-2017, 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 
38 #ifndef __TENCCU__
39 #define __TENCCU__
40 
41 // Include files
42 #include "TLibCommon/CommonDef.h"
43 #include "TLibCommon/TComYuv.h"
45 #include "TLibCommon/TComTrQuant.h"
47 #include "TLibCommon/TComDataCU.h"
48 
49 #include "TEncEntropy.h"
50 #include "TEncSearch.h"
51 #include "TEncRateCtrl.h"
54 
55 class TEncTop;
56 class TEncSbac;
57 class TEncCavlc;
58 class TEncSlice;
59 
60 // ====================================================================================================================
61 // Class definition
62 // ====================================================================================================================
63 
65 class TEncCu
66 {
67 private:
68 
72 
80 
81  // Data : encoder control
84  Bool m_stillToCodeChromaQpOffsetFlag; //indicates whether chroma QP offset flag needs to coded at this particular CU granularity.
85  Int m_cuChromaQpOffsetIdxPlus1; // if 0, then cu_chroma_qp_offset_flag will be 0, otherwise cu_chroma_qp_offset_flag will be 1.
89 
90  // Access channel
95 
98 
99  // SBAC RD
103 
104 public:
106  Void init ( TEncTop* pcEncTop );
107 
108  Void setSliceEncoder( TEncSlice* pSliceEncoder ) { m_pcSliceEncoder = pSliceEncoder; }
111  Int calculateLumaDQP( TComDataCU *pCU, const UInt absPartIdx, const TComYuv * pOrgYuv );
112 
114  Void create ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat );
115 
117  Void destroy ();
118 
120  Void compressCtu ( TComDataCU* pCtu );
121 
123  Void encodeCtu ( TComDataCU* pCtu );
124 
125  Int updateCtuDataISlice ( TComDataCU* pCtu, Int width, Int height );
126 
128 
129 protected:
130  Void finishCU ( TComDataCU* pcCU, UInt uiAbsPartIdx );
131 #if AMP_ENC_SPEEDUP
132  Void xCompressCU ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug), PartSize eParentPartSize = NUMBER_OF_PART_SIZES );
133 #else
134  Void xCompressCU ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth );
135 #endif
136  Void xEncodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
137 
138  Int xComputeQP ( TComDataCU* pcCU, UInt uiDepth );
139  Void xCheckBestMode ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sParent) DEBUG_STRING_FN_DECLARE(sTest) DEBUG_STRING_PASS_INTO(Bool bAddSizeInfo=true));
140 
141  Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode );
142 
143 #if AMP_MRG
144  Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG = false );
145 #else
146  Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize );
147 #endif
148 
149  Void xCheckRDCostIntra ( TComDataCU *&rpcBestCU,
150  TComDataCU *&rpcTempCU,
151  PartSize ePartSize
153  );
154 
155  Void xCheckDQP ( TComDataCU* pcCU );
156 
157  Void xCheckIntraPCM ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU );
158  Void xCopyAMVPInfo ( AMVPInfo* pSrc, AMVPInfo* pDst );
159  Void xCopyYuv2Pic (TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth );
160  Void xCopyYuv2Tmp ( UInt uhPartUnitIdx, UInt uiDepth );
161 
162  Bool getdQPFlag () { return m_bEncodeDQP; }
164 
165  Bool getFastDeltaQp () const { return m_bFastDeltaQP; }
166 
169 
170 #if ADAPTIVE_QP_SELECTION
171  // Adaptive reconstruction level (ARL) statistics collection functions
173  Int xTuCollectARLStats(TCoeff* rpcCoeff, TCoeff* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples );
174 #endif
175 
176 #if AMP_ENC_SPEEDUP
177 #if AMP_MRG
178  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver);
179 #else
180  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver);
181 #endif
182 #endif
183 
184  Void xFillPCMBuffer ( TComDataCU* pCU, TComYuv* pOrgYuv );
185 };
186 
188 
189 #endif // __TENCMB__
entropy encoder class (header)
Void xCheckIntraPCM(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU)
Definition: TEncCu.cpp:1575
Void deriveTestModeAMP(TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver)
Derive small set of test modes for AMP encoder speed-up.
Definition: TEncCu.cpp:360
TComRdCost * m_pcRdCost
Definition: TEncCu.h:94
Void xFillPCMBuffer(TComDataCU *pCU, TComYuv *pOrgYuv)
Definition: TEncCu.cpp:1725
CU data structure class.
Definition: TComDataCU.h:64
Void encodeCtu(TComDataCU *pCtu)
CTU encoding function.
Definition: TEncCu.cpp:255
Int updateCtuDataISlice(TComDataCU *pCtu, Int width, Int height)
Definition: TEncCu.cpp:1267
prediction class (header)
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Defines version information, constants and small in-line functions.
void Void
Definition: TypeDef.h:203
Void destroy()
destroy internal buffers
Definition: TEncCu.cpp:113
TComDataCU ** m_ppcTempCU
Temporary CUs in each depth.
Definition: TEncCu.h:70
general YUV buffer class (header)
Void xCopyAMVPInfo(AMVPInfo *pSrc, AMVPInfo *pDst)
Definition: TEncCu.cpp:1693
Void xCheckBestMode(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt uiDepth)
Definition: TEncCu.cpp:1631
TComTrQuant * m_pcTrQuant
Definition: TEncCu.h:93
Void xCtuCollectARLStats(TComDataCU *pCtu)
Collect ARL statistics from one CTU.
Definition: TEncCu.cpp:1783
Void xCheckDQP(TComDataCU *pcCU)
Definition: TEncCu.cpp:1671
Int xTuCollectARLStats(TCoeff *rpcCoeff, TCoeff *rpcArlCoeff, Int NumCoeffInCU, Double *cSum, UInt *numSamples)
Definition: TEncCu.cpp:1757
CAVLC encoder class.
Definition: TEncCavlc.h:70
TComYuv ** m_ppcRecoYuvTemp
Temporary Reconstruction Yuv for each depth.
Definition: TEncCu.h:78
Int m_lumaLevelToDeltaQPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE]
Definition: TEncCu.h:86
unsigned int UInt
Definition: TypeDef.h:212
TComDataCU ** m_ppcBestCU
Best CUs in each depth.
Definition: TEncCu.h:69
TComYuv ** m_ppcRecoYuvBest
Best Reconstruction Yuv for each depth.
Definition: TEncCu.h:75
encoder search class
Definition: TEncSearch.h:68
TEncSbac * m_pcRDGoOnSbacCoder
Definition: TEncCu.h:101
Bool getCodeChromaQpAdjFlag()
Definition: TEncCu.h:167
TComYuv ** m_ppcPredYuvTemp
Temporary Prediction Yuv for each depth.
Definition: TEncCu.h:76
Void xCheckRDCostIntra(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, PartSize ePartSize)
Definition: TEncCu.cpp:1500
Void xEncodeCU(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncCu.cpp:1067
Int calculateLumaDQP(TComDataCU *pCU, const UInt absPartIdx, const TComYuv *pOrgYuv)
Definition: TEncCu.cpp:299
PartSize
supported partition shape
Definition: TypeDef.h:348
slice encoder class
Definition: TEncSlice.h:61
Bool getdQPFlag()
Definition: TEncCu.h:162
TEncRateCtrl * m_pcRateCtrl
Definition: TEncCu.h:102
general YUV buffer class
Definition: TComYuv.h:54
bool Bool
Definition: TypeDef.h:204
Void xCopyYuv2Pic(TComPic *rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth)
Definition: TEncCu.cpp:1701
Int m_lumaQPOffset
Definition: TEncCu.h:87
Void setCodeChromaQpAdjFlag(Bool b)
Definition: TEncCu.h:168
TComYuv ** m_ppcOrigYuv
Original Yuv for each depth.
Definition: TEncCu.h:79
TEncBinCABAC * m_pcBinCABAC
Definition: TEncCu.h:97
TEncSbac *** m_pppcRDSbacCoder
Definition: TEncCu.h:100
RD cost computation class.
Definition: TComRdCost.h:111
parameters for AMVP
Bool m_stillToCodeChromaQpOffsetFlag
Definition: TEncCu.h:84
Bool getFastDeltaQp() const
Definition: TEncCu.h:165
entropy encoder class
Definition: TEncEntropy.h:116
Int m_cuChromaQpOffsetIdxPlus1
Definition: TEncCu.h:85
Int TCoeff
transform coefficient
Definition: TypeDef.h:250
Void compressCtu(TComDataCU *pCtu)
CTU analysis function.
Definition: TEncCu.cpp:231
Void setFastDeltaQp(Bool b)
Definition: TEncCu.h:127
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
Void init(TEncTop *pcEncTop)
copy parameters from encoder class
Definition: TEncCu.cpp:206
unsigned char UChar
Definition: TypeDef.h:208
Void setSliceEncoder(TEncSlice *pSliceEncoder)
Definition: TEncCu.h:108
Void finishCU(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCu.cpp:1012
UChar m_uhTotalDepth
Definition: TEncCu.h:71
encoder search class (header)
static const UInt LUMA_LEVEL_TO_DQP_LUT_MAXSIZE
max LUT size for QP offset based on luma
Definition: CommonDef.h:246
#define DEBUG_STRING_PASS_INTO(name)
Definition: TypeDef.h:180
TEncSlice * m_pcSliceEncoder
Definition: TEncCu.h:88
Bool m_bEncodeDQP
Definition: TEncCu.h:82
TEncEntropy * m_pcEntropyCoder
Definition: TEncCu.h:96
Void xCheckRDCostMerge2Nx2N(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, Bool *earlyDetectionSkipMode)
Definition: TEncCu.cpp:1293
#define DEBUG_STRING_FN_DECLARE(name)
Definition: TypeDef.h:182
Void xCompressCU(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, const UInt uiDepth, PartSize eParentPartSize=NUMBER_OF_PART_SIZES)
Definition: TEncCu.cpp:435
transform and quantization class
Definition: TComTrQuant.h:98
TEncCfg * m_pcEncCfg
Definition: TEncCu.h:91
TEncSlice * getSliceEncoder()
Definition: TEncCu.h:109
Void xCopyYuv2Tmp(UInt uhPartUnitIdx, UInt uiDepth)
Definition: TEncCu.cpp:1714
Void xCheckRDCostInter(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, PartSize ePartSize, Bool bUseMRG=false)
Definition: TEncCu.cpp:1440
TComYuv ** m_ppcResiYuvTemp
Temporary Residual Yuv for each depth.
Definition: TEncCu.h:77
int Int
Definition: TypeDef.h:211
encoder class
Definition: TEncTop.h:68
Rate control manager class.
transform and quantization class (header)
CU encoder class.
Definition: TEncCu.h:65
encoder configuration class
Definition: TEncCfg.h:111
Bool m_bFastDeltaQP
Definition: TEncCu.h:83
SBAC encoder class.
Definition: TEncSbac.h:66
double Double
Definition: TypeDef.h:213
CU data structure (header)
Void initLumaDeltaQpLUT()
Definition: TEncCu.cpp:275
Class for counting bits (header)
Void setdQPFlag(Bool b)
Definition: TEncCu.h:163
Void create(UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat)
create internal buffers
Definition: TEncCu.cpp:62
TEncSearch * m_pcPredSearch
Definition: TEncCu.h:92
Int xComputeQP(TComDataCU *pcCU, UInt uiDepth)
Definition: TEncCu.cpp:1036
TComYuv ** m_ppcPredYuvBest
Best Prediction Yuv for each depth.
Definition: TEncCu.h:73
TComYuv ** m_ppcResiYuvBest
Best Residual Yuv for each depth.
Definition: TEncCu.h:74