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

Last change on this file was 1413, checked in by tech, 6 years ago

Merged HTM-16.2-dev@1412

  • Property svn:eol-style set to native
File size: 9.2 KB
RevLine 
[5]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
[1313]4 * granted under this license.
[5]5 *
[1413]6 * Copyright (c) 2010-2017, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
[56]34/** \file     TEncCu.h
35    \brief    Coding Unit (CU) encoder class (header)
[2]36*/
37
38#ifndef __TENCCU__
39#define __TENCCU__
40
41// Include files
[56]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"
[2]48
49#include "TEncEntropy.h"
50#include "TEncSearch.h"
[608]51#include "TEncRateCtrl.h"
[56]52//! \ingroup TLibEncoder
53//! \{
54
[2]55class TEncTop;
56class TEncSbac;
57class TEncCavlc;
58class TEncSlice;
59
60// ====================================================================================================================
61// Class definition
62// ====================================================================================================================
63
64/// CU encoder class
65class TEncCu
66{
67private:
[1313]68
[2]69  TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
70  TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
[1413]71#if NH_3D
[608]72  TComDataCU**            m_ppcWeightedTempCU;
[443]73#endif
[2]74  UChar                   m_uhTotalDepth;
[1313]75
[2]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
[1313]83
[1413]84#if NH_3D
[833]85  TComYuv**               m_ppcOrigYuvDBBP;
86#endif
87 
[2]88  //  Data : encoder control
[56]89  Bool                    m_bEncodeDQP;
[1313]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.
[1413]93  Int                     m_lumaLevelToDeltaQPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE];
94  Int                     m_lumaQPOffset;
95  TEncSlice*              m_pcSliceEncoder;
[1313]96
[2]97  //  Access channel
98  TEncCfg*                m_pcEncCfg;
99  TEncSearch*             m_pcPredSearch;
100  TComTrQuant*            m_pcTrQuant;
101  TComRdCost*             m_pcRdCost;
[1313]102
[2]103  TEncEntropy*            m_pcEntropyCoder;
104  TEncBinCABAC*           m_pcBinCABAC;
[1313]105
[2]106  // SBAC RD
107  TEncSbac***             m_pppcRDSbacCoder;
108  TEncSbac*               m_pcRDGoOnSbacCoder;
[608]109  TEncRateCtrl*           m_pcRateCtrl;
[1313]110
[872]111#if KWU_RC_MADPRED_E0227
[608]112  UInt                    m_LCUPredictionSAD;
113  Int                     m_addSADDepth;
114  Int                     m_temporalSAD;
[655]115  Int                     m_spatialSAD;
116#endif
[2]117public:
118  /// copy parameters from encoder class
119  Void  init                ( TEncTop* pcEncTop );
[1313]120
[1413]121  Void       setSliceEncoder( TEncSlice* pSliceEncoder ) { m_pcSliceEncoder = pSliceEncoder; }
122  TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; }
123  Void       initLumaDeltaQpLUT();
124  Int        calculateLumaDQP( TComDataCU *pCU, const UInt absPartIdx, const TComYuv * pOrgYuv );
125
[2]126  /// create internal buffers
[1313]127  Void  create              ( UChar uhTotalDepth, UInt iMaxWidth, UInt iMaxHeight, ChromaFormat chromaFormat );
128
[2]129  /// destroy internal buffers
130  Void  destroy             ();
[1313]131
132  /// CTU analysis function
133  Void  compressCtu         ( TComDataCU*  pCtu );
134
135  /// CTU encoding function
136  Void  encodeCtu           ( TComDataCU*  pCtu );
137
138  Int   updateCtuDataISlice ( TComDataCU* pCtu, Int width, Int height );
[872]139#if KWU_RC_MADPRED_E0227
[608]140  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
141#endif
[1313]142
143  Void setFastDeltaQp       ( Bool b)                 { m_bFastDeltaQP = b;         }
144
[2]145protected:
[1313]146  Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx );
[56]147#if AMP_ENC_SPEEDUP
[1313]148  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug), PartSize eParentPartSize = NUMBER_OF_PART_SIZES );
[56]149#else
[1313]150  Void  xCompressCU         ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth        );
[56]151#endif
[2]152  Void  xEncodeCU           ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
[1313]153
[56]154  Int   xComputeQP          ( TComDataCU* pcCU, UInt uiDepth );
[1313]155  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));
[608]156
[1313]157  Void  xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode );
158
[56]159#if AMP_MRG
[1313]160#if  NH_3D_FAST_TEXTURE_ENCODING
161  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug),  Bool bFMD, Bool bUseMRG = false  ) ;
[56]162#else
[1313]163  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG = false  );
[56]164#endif
165#else
[2]166  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
167#endif
[1413]168#if NH_3D
[833]169  Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
[1313]170  Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  DEBUG_STRING_FN_DECLARE(sDebug),  Bool bUseMRG = false );
[1321]171  Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug) );
[1039]172#endif
[1313]173  Void  xCheckRDCostIntra   ( TComDataCU *&rpcBestCU,
174                              TComDataCU *&rpcTempCU,
175                              PartSize     ePartSize
176                              DEBUG_STRING_FN_DECLARE(sDebug)
[1413]177#if NH_3D
[1313]178                            , Bool bOnlyIVP
[1039]179#endif
[1313]180                            );
[56]181  Void  xCheckDQP           ( TComDataCU*  pcCU );
[1313]182
[56]183  Void  xCheckIntraPCM      ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU                      );
[2]184  Void  xCopyAMVPInfo       ( AMVPInfo* pSrc, AMVPInfo* pDst );
[1313]185  Void  xCopyYuv2Pic        (TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth );
[2]186  Void  xCopyYuv2Tmp        ( UInt uhPartUnitIdx, UInt uiDepth );
[56]187
188  Bool getdQPFlag           ()                        { return m_bEncodeDQP;        }
189  Void setdQPFlag           ( Bool b )                { m_bEncodeDQP = b;           }
190
[1313]191  Bool getFastDeltaQp       () const                  { return m_bFastDeltaQP;      }
192
193  Bool getCodeChromaQpAdjFlag() { return m_stillToCodeChromaQpOffsetFlag; }
194  Void setCodeChromaQpAdjFlag( Bool b ) { m_stillToCodeChromaQpOffsetFlag = b; }
195
[56]196#if ADAPTIVE_QP_SELECTION
197  // Adaptive reconstruction level (ARL) statistics collection functions
[1313]198  Void xCtuCollectARLStats(TComDataCU* pCtu);
199  Int  xTuCollectARLStats(TCoeff* rpcCoeff, TCoeff* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples );
[56]200#endif
201
[1313]202#if AMP_ENC_SPEEDUP
[56]203#if AMP_MRG
[1313]204  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver);
[56]205#else
[1313]206  Void deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver);
[56]207#endif
208#endif
209
[1313]210  Void  xFillPCMBuffer     ( TComDataCU* pCU, TComYuv* pOrgYuv );
[2]211};
212
[56]213//! \}
[2]214
215#endif // __TENCMB__
Note: See TracBrowser for help on using the repository browser.