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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TEncCU.h |
---|
37 | \brief CU encoder class (header) |
---|
38 | */ |
---|
39 | |
---|
40 | #ifndef __TENCCU__ |
---|
41 | #define __TENCCU__ |
---|
42 | |
---|
43 | // Include files |
---|
44 | #include "../TLibCommon/CommonDef.h" |
---|
45 | #include "../TLibCommon/TComYuv.h" |
---|
46 | #include "../TLibCommon/TComPrediction.h" |
---|
47 | #include "../TLibCommon/TComTrQuant.h" |
---|
48 | #include "../TLibCommon/TComBitCounter.h" |
---|
49 | #include "../TLibCommon/TComDataCU.h" |
---|
50 | |
---|
51 | #include "TEncEntropy.h" |
---|
52 | #include "TEncSearch.h" |
---|
53 | |
---|
54 | class TEncTop; |
---|
55 | class TEncSbac; |
---|
56 | class TEncCavlc; |
---|
57 | class TEncSlice; |
---|
58 | |
---|
59 | // ==================================================================================================================== |
---|
60 | // Class definition |
---|
61 | // ==================================================================================================================== |
---|
62 | |
---|
63 | /// CU encoder class |
---|
64 | class TEncCu |
---|
65 | { |
---|
66 | private: |
---|
67 | |
---|
68 | TComDataCU** m_ppcBestCU; ///< Best CUs in each depth |
---|
69 | TComDataCU** m_ppcTempCU; ///< Temporary CUs in each depth |
---|
70 | UChar m_uhTotalDepth; |
---|
71 | |
---|
72 | TComYuv** m_ppcPredYuvBest; ///< Best Prediction Yuv for each depth |
---|
73 | TComYuv** m_ppcResiYuvBest; ///< Best Residual Yuv for each depth |
---|
74 | TComYuv** m_ppcRecoYuvBest; ///< Best Reconstruction Yuv for each depth |
---|
75 | TComYuv** m_ppcPredYuvTemp; ///< Temporary Prediction Yuv for each depth |
---|
76 | TComYuv** m_ppcResiYuvTemp; ///< Temporary Residual Yuv for each depth |
---|
77 | TComYuv** m_ppcRecoYuvTemp; ///< Temporary Reconstruction Yuv for each depth |
---|
78 | TComYuv** m_ppcOrigYuv; ///< Original Yuv for each depth |
---|
79 | TComYuv** m_ppcResPredTmp; ///< Temporary residual prediction for each depth |
---|
80 | #if POZNAN_CU_SKIP |
---|
81 | TComYuv** m_ppcAvailYuv; ///< Avaiability map for each depth |
---|
82 | #endif |
---|
83 | #if POZNAN_CU_SYNTH |
---|
84 | TComYuv** m_ppcSynthYuv; ///< Synthetized Yuv for each depth |
---|
85 | #endif |
---|
86 | |
---|
87 | // Data : encoder control |
---|
88 | Int m_iQp; ///< Last QP |
---|
89 | |
---|
90 | // Access channel |
---|
91 | TEncCfg* m_pcEncCfg; |
---|
92 | TEncTop* m_pcEncTop; |
---|
93 | TComPrediction* m_pcPrediction; |
---|
94 | TEncSearch* m_pcPredSearch; |
---|
95 | TComTrQuant* m_pcTrQuant; |
---|
96 | TComBitCounter* m_pcBitCounter; |
---|
97 | TComRdCost* m_pcRdCost; |
---|
98 | |
---|
99 | TEncEntropy* m_pcEntropyCoder; |
---|
100 | TEncCavlc* m_pcCavlcCoder; |
---|
101 | TEncSbac* m_pcSbacCoder; |
---|
102 | TEncBinCABAC* m_pcBinCABAC; |
---|
103 | |
---|
104 | // SBAC RD |
---|
105 | TEncSbac*** m_pppcRDSbacCoder; |
---|
106 | TEncSbac* m_pcRDGoOnSbacCoder; |
---|
107 | Bool m_bUseSBACRD; |
---|
108 | |
---|
109 | #if HHI_MPI |
---|
110 | UChar *m_puhDepthSaved; |
---|
111 | UChar *m_puhWidthSaved; |
---|
112 | UChar *m_puhHeightSaved; |
---|
113 | #endif |
---|
114 | |
---|
115 | #if POZNAN_STAT_JK |
---|
116 | Bool m_bStatFileEnabled; |
---|
117 | #endif |
---|
118 | |
---|
119 | public: |
---|
120 | /// copy parameters from encoder class |
---|
121 | Void init ( TEncTop* pcEncTop ); |
---|
122 | |
---|
123 | /// create internal buffers |
---|
124 | Void create ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight ); |
---|
125 | |
---|
126 | /// destroy internal buffers |
---|
127 | Void destroy (); |
---|
128 | |
---|
129 | /// CU analysis function |
---|
130 | Void compressCU ( TComDataCU*& rpcCU ); |
---|
131 | |
---|
132 | /// CU encoding function |
---|
133 | Void encodeCU ( TComDataCU* pcCU, Bool bForceTerminate = false ); |
---|
134 | |
---|
135 | /// set QP value |
---|
136 | Void setQpLast ( Int iQp ) { m_iQp = iQp; } |
---|
137 | |
---|
138 | #if POZNAN_STAT_JK |
---|
139 | Void setStatFileEnabled(Bool bStatFileEnabled){m_bStatFileEnabled = bStatFileEnabled;} |
---|
140 | #endif |
---|
141 | |
---|
142 | protected: |
---|
143 | Void xCompressCU ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ); |
---|
144 | Void xEncodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
145 | |
---|
146 | Void xCheckRDCostAMVPSkip( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ); |
---|
147 | |
---|
148 | #if HHI_INTERVIEW_SKIP |
---|
149 | Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bFullyRendered ) ; |
---|
150 | #else |
---|
151 | Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ); |
---|
152 | #endif |
---|
153 | |
---|
154 | Void xCheckRDCostSkip ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bBSkipRes ); |
---|
155 | #if HHI_INTERVIEW_SKIP |
---|
156 | Void xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFullyRendered ) ; |
---|
157 | #else |
---|
158 | Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ); |
---|
159 | #endif |
---|
160 | Void xCheckRDCostIntra ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ); |
---|
161 | Void xCheckBestMode ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UChar uhDepth ); |
---|
162 | |
---|
163 | Void xCopyAMVPInfo ( AMVPInfo* pSrc, AMVPInfo* pDst ); |
---|
164 | Void xCopyYuv2Pic ( TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsZorderIdx, UInt uiDepth ); |
---|
165 | Void xCopyYuv2Tmp ( UInt uhPartUnitIdx, UInt uiDepth ); |
---|
166 | Void xAddMVISignallingBits( TComDataCU* pcCU ); |
---|
167 | #if HHI_MPI |
---|
168 | Void xCheckRDCostMvInheritance( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UChar uhTextureModeDepth, Bool bSkipResidual, Bool bRecursiveCall ); |
---|
169 | Void xSaveDepthWidthHeight( TComDataCU* pcCU ); |
---|
170 | Void xRestoreDepthWidthHeight( TComDataCU* pcCU ); |
---|
171 | #endif |
---|
172 | |
---|
173 | #if POZNAN_EIVD & !POZNAN_EIVD_COMPRESS_ME_DATA |
---|
174 | Void xSaveEIVDData(TComDataCU* pcCU) { pcCU->getSlice()->getMP()->saveEIVDData(pcCU);} |
---|
175 | #endif |
---|
176 | |
---|
177 | #if POZNAN_STAT_JK |
---|
178 | Void xStatFile ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
179 | #endif |
---|
180 | }; |
---|
181 | |
---|
182 | |
---|
183 | #endif // __TENCMB__ |
---|
184 | |
---|