HEVC Test Model (HM)  HM-16.3
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-2015, 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
85 
86  // Access channel
91 
94 
95  // SBAC RD
99 
100 public:
102  Void init ( TEncTop* pcEncTop );
103 
105  Void create ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat );
106 
108  Void destroy ();
109 
111  Void compressCtu ( TComDataCU* pCtu );
112 
114  Void encodeCtu ( TComDataCU* pCtu );
115 
116  Int updateCtuDataISlice ( TComDataCU* pCtu, Int width, Int height );
117 
118 protected:
119  Void finishCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
120 #if AMP_ENC_SPEEDUP
121  Void xCompressCU ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug), PartSize eParentPartSize = NUMBER_OF_PART_SIZES );
122 #else
123  Void xCompressCU ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth );
124 #endif
125  Void xEncodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
126 
127  Int xComputeQP ( TComDataCU* pcCU, UInt uiDepth );
128  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));
129 
130  Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode );
131 
132 #if AMP_MRG
133  Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG = false );
134 #else
135  Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize );
136 #endif
137 
138  Void xCheckRDCostIntra ( TComDataCU *&rpcBestCU,
139  TComDataCU *&rpcTempCU,
140  Double &cost,
141  PartSize ePartSize
143  );
144 
145  Void xCheckDQP ( TComDataCU* pcCU );
146 
147  Void xCheckIntraPCM ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU );
148  Void xCopyAMVPInfo ( AMVPInfo* pSrc, AMVPInfo* pDst );
149  Void xCopyYuv2Pic (TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY );
150  Void xCopyYuv2Tmp ( UInt uhPartUnitIdx, UInt uiDepth );
151 
152  Bool getdQPFlag () { return m_bEncodeDQP; }
153  Void setdQPFlag ( Bool b ) { m_bEncodeDQP = b; }
154 
156  Void setCodeChromaQpAdjFlag( Bool b ) { m_CodeChromaQpAdjFlag = b; }
157 
158 #if ADAPTIVE_QP_SELECTION
159  // Adaptive reconstruction level (ARL) statistics collection functions
161  Int xTuCollectARLStats(TCoeff* rpcCoeff, TCoeff* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples );
162 #endif
163 
164 #if AMP_ENC_SPEEDUP
165 #if AMP_MRG
166  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver);
167 #else
168  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver);
169 #endif
170 #endif
171 
172  Void xFillPCMBuffer ( TComDataCU* pCU, TComYuv* pOrgYuv );
173 };
174 
176 
177 #endif // __TENCMB__
Void xCopyYuv2Pic(TComPic *rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU *pcCU, UInt uiLPelX, UInt uiTPelY)
Definition: TEncCu.cpp:1503
entropy encoder class (header)
Void xCheckIntraPCM(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU)
Definition: TEncCu.cpp:1386
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:274
TComRdCost * m_pcRdCost
Definition: TEncCu.h:90
Void xFillPCMBuffer(TComDataCU *pCU, TComYuv *pOrgYuv)
Definition: TEncCu.cpp:1527
CU data structure class.
Definition: TComDataCU.h:64
Void encodeCtu(TComDataCU *pCtu)
CTU encoding function.
Definition: TEncCu.cpp:252
Int updateCtuDataISlice(TComDataCU *pCtu, Int width, Int height)
Definition: TEncCu.cpp:1128
prediction class (header)
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Bool m_CodeChromaQpAdjFlag
Definition: TEncCu.h:83
Defines constants, macros and tool parameters.
void Void
Definition: TypeDef.h:285
Void destroy()
destroy internal buffers
Definition: TEncCu.cpp:112
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:1495
Void xCheckBestMode(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt uiDepth)
Definition: TEncCu.cpp:1432
TComTrQuant * m_pcTrQuant
Definition: TEncCu.h:89
Void xCtuCollectARLStats(TComDataCU *pCtu)
Collect ARL statistics from one CTU.
Definition: TEncCu.cpp:1585
Void xCheckDQP(TComDataCU *pcCU)
Definition: TEncCu.cpp:1472
Int xTuCollectARLStats(TCoeff *rpcCoeff, TCoeff *rpcArlCoeff, Int NumCoeffInCU, Double *cSum, UInt *numSamples)
Definition: TEncCu.cpp:1559
CAVLC encoder class.
Definition: TEncCavlc.h:61
TComYuv ** m_ppcRecoYuvTemp
Temporary Reconstruction Yuv for each depth.
Definition: TEncCu.h:78
unsigned int UInt
Definition: TypeDef.h:297
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:97
Bool getCodeChromaQpAdjFlag()
Definition: TEncCu.h:155
TComYuv ** m_ppcPredYuvTemp
Temporary Prediction Yuv for each depth.
Definition: TEncCu.h:76
Int m_ChromaQpAdjIdc
Definition: TEncCu.h:84
Void xEncodeCU(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncCu.cpp:933
PartSize
supported partition shape
Definition: TypeDef.h:393
slice encoder class
Definition: TEncSlice.h:61
Bool getdQPFlag()
Definition: TEncCu.h:152
TEncRateCtrl * m_pcRateCtrl
Definition: TEncCu.h:98
general YUV buffer class
Definition: TComYuv.h:54
bool Bool
Definition: TypeDef.h:286
Void setCodeChromaQpAdjFlag(Bool b)
Definition: TEncCu.h:156
TComYuv ** m_ppcOrigYuv
Original Yuv for each depth.
Definition: TEncCu.h:79
TEncBinCABAC * m_pcBinCABAC
Definition: TEncCu.h:93
TEncSbac *** m_pppcRDSbacCoder
Definition: TEncCu.h:96
RD cost computation class.
Definition: TComRdCost.h:104
parameters for AMVP
entropy encoder class
Definition: TEncEntropy.h:121
Int TCoeff
transform coefficient
Definition: TypeDef.h:693
Void compressCtu(TComDataCU *pCtu)
CTU analysis function.
Definition: TEncCu.cpp:228
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:352
Void init(TEncTop *pcEncTop)
copy parameters from encoder class
Definition: TEncCu.cpp:205
unsigned char UChar
Definition: TypeDef.h:293
UChar m_uhTotalDepth
Definition: TEncCu.h:71
encoder search class (header)
#define DEBUG_STRING_PASS_INTO(name)
Definition: TypeDef.h:69
Bool m_bEncodeDQP
Definition: TEncCu.h:82
Void xCompressCU(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt uiDepth, PartSize eParentPartSize=NUMBER_OF_PART_SIZES)
Definition: TEncCu.cpp:349
TEncEntropy * m_pcEntropyCoder
Definition: TEncCu.h:92
Void xCheckRDCostMerge2Nx2N(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, Bool *earlyDetectionSkipMode)
Definition: TEncCu.cpp:1154
#define DEBUG_STRING_FN_DECLARE(name)
Definition: TypeDef.h:71
transform and quantization class
Definition: TComTrQuant.h:98
TEncCfg * m_pcEncCfg
Definition: TEncCu.h:87
Void xCopyYuv2Tmp(UInt uhPartUnitIdx, UInt uiDepth)
Definition: TEncCu.cpp:1516
Void xCheckRDCostInter(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, PartSize ePartSize, Bool bUseMRG=false)
Definition: TEncCu.cpp:1279
TComYuv ** m_ppcResiYuvTemp
Temporary Residual Yuv for each depth.
Definition: TEncCu.h:77
Void finishCU(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncCu.cpp:878
int Int
Definition: TypeDef.h:296
encoder class
Definition: TEncTop.h:68
Void xCheckRDCostIntra(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, Double &cost, PartSize ePartSize)
Definition: TEncCu.cpp:1318
Rate control manager class.
transform and quantization class (header)
CU encoder class.
Definition: TEncCu.h:65
encoder configuration class
Definition: TEncCfg.h:99
SBAC encoder class.
Definition: TEncSbac.h:66
double Double
Definition: TypeDef.h:298
CU data structure (header)
Class for counting bits (header)
Void setdQPFlag(Bool b)
Definition: TEncCu.h:153
Void create(UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat)
create internal buffers
Definition: TEncCu.cpp:62
TEncSearch * m_pcPredSearch
Definition: TEncCu.h:88
Int xComputeQP(TComDataCU *pcCU, UInt uiDepth)
Definition: TEncCu.cpp:902
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