source: SHVCSoftware/branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCu.h @ 577

Last change on this file since 577 was 474, checked in by nokia, 11 years ago

Fix inter-layer constrained tile sets for merge and skip modes

  • Property svn:eol-style set to native
File size: 7.9 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-2013, 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  UChar                   m_uhTotalDepth;
72 
73  TComYuv**               m_ppcPredYuvBest; ///< Best Prediction Yuv for each depth
74  TComYuv**               m_ppcResiYuvBest; ///< Best Residual Yuv for each depth
75  TComYuv**               m_ppcRecoYuvBest; ///< Best Reconstruction Yuv for each depth
76  TComYuv**               m_ppcPredYuvTemp; ///< Temporary Prediction Yuv for each depth
77  TComYuv**               m_ppcResiYuvTemp; ///< Temporary Residual Yuv for each depth
78  TComYuv**               m_ppcRecoYuvTemp; ///< Temporary Reconstruction Yuv for each depth
79  TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
80 
81  //  Data : encoder control
82  Bool                    m_bEncodeDQP;
83 
84  //  Access channel
85  TEncCfg*                m_pcEncCfg;
86  TEncSearch*             m_pcPredSearch;
87  TComTrQuant*            m_pcTrQuant;
88  TComBitCounter*         m_pcBitCounter;
89  TComRdCost*             m_pcRdCost;
90 
91#if SVC_EXTENSION
92  TEncTop**               m_ppcTEncTop;
93#endif
94 
95  TEncEntropy*            m_pcEntropyCoder;
96  TEncCavlc*              m_pcCavlcCoder;
97  TEncSbac*               m_pcSbacCoder;
98  TEncBinCABAC*           m_pcBinCABAC;
99 
100  // SBAC RD
101  TEncSbac***             m_pppcRDSbacCoder;
102  TEncSbac*               m_pcRDGoOnSbacCoder;
103  Bool                    m_bUseSBACRD;
104  TEncRateCtrl*           m_pcRateCtrl;
105#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
106  UInt                    m_LCUPredictionSAD;
107  Int                     m_addSADDepth;
108  Int                     m_temporalSAD;
109#endif
110#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
111  Bool                    m_disableILP;
112#endif
113public:
114  /// copy parameters from encoder class
115  Void  init                ( TEncTop* pcEncTop );
116 
117  /// create internal buffers
118  Void  create              ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight );
119 
120  /// destroy internal buffers
121  Void  destroy             ();
122 
123  /// CU analysis function
124  Void  compressCU          ( TComDataCU*&  rpcCU );
125 
126  /// CU encoding function
127  Void  encodeCU            ( TComDataCU*    pcCU );
128 
129  Void setBitCounter        ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; }
130#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
131  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
132#endif
133#if RATE_CONTROL_INTRA
134  Int   updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height );
135#endif
136
137protected:
138  Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
139#if AMP_ENC_SPEEDUP
140  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, PartSize eParentPartSize = SIZE_NONE );
141#else
142  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, 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        );
148 
149  Void  xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode);
150
151#if AMP_MRG
152  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG = false  );
153#else
154  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
155#endif
156  Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
157#if ENCODER_FAST_MODE
158  Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
159#endif
160  Void  xCheckDQP           ( TComDataCU*  pcCU );
161 
162  Void  xCheckIntraPCM      ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU                      );
163  Void  xCopyAMVPInfo       ( AMVPInfo* pSrc, AMVPInfo* pDst );
164  Void  xCopyYuv2Pic        (TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY );
165  Void  xCopyYuv2Tmp        ( UInt uhPartUnitIdx, UInt uiDepth );
166
167  Bool getdQPFlag           ()                        { return m_bEncodeDQP;        }
168  Void setdQPFlag           ( Bool b )                { m_bEncodeDQP = b;           }
169
170#if ADAPTIVE_QP_SELECTION
171  // Adaptive reconstruction level (ARL) statistics collection functions
172  Void xLcuCollectARLStats(TComDataCU* rpcCU);
173  Int  xTuCollectARLStats(TCoeff* rpcCoeff, Int* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples );
174#endif
175
176#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
177  Bool xCheckTileSetConstraint( TComDataCU*& rpcCU );
178  Void xVerifyTileSetConstraint( TComDataCU*& rpcCU );
179#endif
180
181#if AMP_ENC_SPEEDUP
182#if AMP_MRG
183  Void deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver);
184#else
185  Void deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver);
186#endif
187#endif
188
189#if SVC_EXTENSION
190  TEncTop*   getLayerEnc(UInt LayerId)  {return m_ppcTEncTop[LayerId]; }
191#endif
192
193  Void  xFillPCMBuffer     ( TComDataCU*& pCU, TComYuv* pOrgYuv ); 
194};
195
196//! \}
197
198#endif // __TENCMB__
Note: See TracBrowser for help on using the repository browser.