source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncCu.h @ 1405

Last change on this file since 1405 was 1405, checked in by tech, 8 years ago

Merged HTM-16.1-dev@1404.

  • Property svn:eol-style set to native
File size: 8.8 KB
Line 
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-2016, 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     TEncCu.h
35    \brief    Coding Unit (CU) encoder class (header)
36*/
37
38#ifndef __TENCCU__
39#define __TENCCU__
40
41// Include files
42#include "TLibCommon/CommonDef.h"
43#include "TLibCommon/TComYuv.h"
44#include "TLibCommon/TComPrediction.h"
45#include "TLibCommon/TComTrQuant.h"
46#include "TLibCommon/TComBitCounter.h"
47#include "TLibCommon/TComDataCU.h"
48
49#include "TEncEntropy.h"
50#include "TEncSearch.h"
51#include "TEncRateCtrl.h"
52//! \ingroup TLibEncoder
53//! \{
54
55class TEncTop;
56class TEncSbac;
57class TEncCavlc;
58class TEncSlice;
59
60// ====================================================================================================================
61// Class definition
62// ====================================================================================================================
63
64/// CU encoder class
65class TEncCu
66{
67private:
68
69  TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
70  TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
71#if NH_3D_ARP
72  TComDataCU**            m_ppcWeightedTempCU;
73#endif
74  UChar                   m_uhTotalDepth;
75
76  TComYuv**               m_ppcPredYuvBest; ///< Best Prediction Yuv for each depth
77  TComYuv**               m_ppcResiYuvBest; ///< Best Residual Yuv for each depth
78  TComYuv**               m_ppcRecoYuvBest; ///< Best Reconstruction Yuv for each depth
79  TComYuv**               m_ppcPredYuvTemp; ///< Temporary Prediction Yuv for each depth
80  TComYuv**               m_ppcResiYuvTemp; ///< Temporary Residual Yuv for each depth
81  TComYuv**               m_ppcRecoYuvTemp; ///< Temporary Reconstruction Yuv for each depth
82  TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
83
84#if NH_3D_DBBP
85  TComYuv**               m_ppcOrigYuvDBBP;
86#endif
87 
88  //  Data : encoder control
89  Bool                    m_bEncodeDQP;
90  Bool                    m_bFastDeltaQP;
91  Bool                    m_stillToCodeChromaQpOffsetFlag; //indicates whether chroma QP offset flag needs to coded at this particular CU granularity.
92  Int                     m_cuChromaQpOffsetIdxPlus1; // if 0, then cu_chroma_qp_offset_flag will be 0, otherwise cu_chroma_qp_offset_flag will be 1.
93
94  //  Access channel
95  TEncCfg*                m_pcEncCfg;
96  TEncSearch*             m_pcPredSearch;
97  TComTrQuant*            m_pcTrQuant;
98  TComRdCost*             m_pcRdCost;
99
100  TEncEntropy*            m_pcEntropyCoder;
101  TEncBinCABAC*           m_pcBinCABAC;
102
103  // SBAC RD
104  TEncSbac***             m_pppcRDSbacCoder;
105  TEncSbac*               m_pcRDGoOnSbacCoder;
106  TEncRateCtrl*           m_pcRateCtrl;
107
108#if KWU_RC_MADPRED_E0227
109  UInt                    m_LCUPredictionSAD;
110  Int                     m_addSADDepth;
111  Int                     m_temporalSAD;
112  Int                     m_spatialSAD;
113#endif
114public:
115  /// copy parameters from encoder class
116  Void  init                ( TEncTop* pcEncTop );
117
118  /// create internal buffers
119  Void  create              ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat );
120
121  /// destroy internal buffers
122  Void  destroy             ();
123
124  /// CTU analysis function
125  Void  compressCtu         ( TComDataCU*  pCtu );
126
127  /// CTU encoding function
128  Void  encodeCtu           ( TComDataCU*  pCtu );
129
130  Int   updateCtuDataISlice ( TComDataCU* pCtu, Int width, Int height );
131#if KWU_RC_MADPRED_E0227
132  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
133#endif
134
135  Void setFastDeltaQp       ( Bool b)                 { m_bFastDeltaQP = b;         }
136
137protected:
138  Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx );
139#if AMP_ENC_SPEEDUP
140  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug), PartSize eParentPartSize = NUMBER_OF_PART_SIZES );
141#else
142  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth        );
143#endif
144  Void  xEncodeCU           ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
145
146  Int   xComputeQP          ( TComDataCU* pcCU, UInt uiDepth );
147  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));
148
149  Void  xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode );
150
151#if AMP_MRG
152#if  NH_3D_FAST_TEXTURE_ENCODING
153  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug),  Bool bFMD, Bool bUseMRG = false  ) ;
154#else
155  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG = false  );
156#endif
157#else
158  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
159#endif
160#if NH_3D_DBBP
161  Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
162  Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  DEBUG_STRING_FN_DECLARE(sDebug),  Bool bUseMRG = false );
163#endif
164#if NH_3D_DIS
165  Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug) );
166#endif
167  Void  xCheckRDCostIntra   ( TComDataCU *&rpcBestCU,
168                              TComDataCU *&rpcTempCU,
169                              PartSize     ePartSize
170                              DEBUG_STRING_FN_DECLARE(sDebug)
171#if NH_3D_ENC_DEPTH
172                            , Bool bOnlyIVP
173#endif
174                            );
175  Void  xCheckDQP           ( TComDataCU*  pcCU );
176
177  Void  xCheckIntraPCM      ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU                      );
178  Void  xCopyAMVPInfo       ( AMVPInfo* pSrc, AMVPInfo* pDst );
179  Void  xCopyYuv2Pic        (TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth );
180  Void  xCopyYuv2Tmp        ( UInt uhPartUnitIdx, UInt uiDepth );
181
182  Bool getdQPFlag           ()                        { return m_bEncodeDQP;        }
183  Void setdQPFlag           ( Bool b )                { m_bEncodeDQP = b;           }
184
185  Bool getFastDeltaQp       () const                  { return m_bFastDeltaQP;      }
186
187  Bool getCodeChromaQpAdjFlag() { return m_stillToCodeChromaQpOffsetFlag; }
188  Void setCodeChromaQpAdjFlag( Bool b ) { m_stillToCodeChromaQpOffsetFlag = b; }
189
190#if ADAPTIVE_QP_SELECTION
191  // Adaptive reconstruction level (ARL) statistics collection functions
192  Void xCtuCollectARLStats(TComDataCU* pCtu);
193  Int  xTuCollectARLStats(TCoeff* rpcCoeff, TCoeff* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples );
194#endif
195
196#if AMP_ENC_SPEEDUP
197#if AMP_MRG
198  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver);
199#else
200  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver);
201#endif
202#endif
203
204  Void  xFillPCMBuffer     ( TComDataCU* pCU, TComYuv* pOrgYuv );
205};
206
207//! \}
208
209#endif // __TENCMB__
Note: See TracBrowser for help on using the repository browser.