HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TEncSbac.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-2017, 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 __TENCSBAC__
39 #define __TENCSBAC__
40 
41 #if _MSC_VER > 1000
42 #pragma once
43 #endif // _MSC_VER > 1000
44 
49 #include "TEncEntropy.h"
50 #include "TEncBinCoder.h"
51 #include "TEncBinCoderCABAC.h"
52 #if FAST_BIT_EST
54 #endif
55 
56 class TEncTop;
57 
60 
61 // ====================================================================================================================
62 // Class definition
63 // ====================================================================================================================
64 
66 class TEncSbac : public TEncEntropyIf
67 {
68 public:
69  TEncSbac();
70  virtual ~TEncSbac();
71 
72  Void init ( TEncBinIf* p ) { m_pcBinIf = p; }
73  Void uninit () { m_pcBinIf = 0; }
74 
75  // Virtual list
76  Void resetEntropy (const TComSlice *pSlice);
79 
80  Void load ( const TEncSbac* pSrc );
81  Void loadIntraDirMode ( const TEncSbac* pScr, const ChannelType chType );
82  Void store ( TEncSbac* pDest ) const;
83  Void loadContexts ( const TEncSbac* pSrc );
86  //--SBAC RD
87 
88  Void codeVPS ( const TComVPS* pcVPS );
89  Void codeSPS ( const TComSPS* pcSPS );
90  Void codePPS ( const TComPPS* pcPPS );
91  Void codeSliceHeader ( TComSlice* pcSlice );
93  Void codeTerminatingBit ( UInt uilsLast );
95  Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol );
96  Void codeSaoMerge ( UInt uiCode );
97  Void codeSaoTypeIdx ( UInt uiCode);
98  Void codeSaoUflc ( UInt uiLength, UInt uiCode );
99  Void codeSAOSign ( UInt uiCode); //<! code SAO offset sign
100 
101  Void codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled, const Int channelBitDepth);
102  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths
103  , Bool* sliceEnabled
104  , Bool leftMergeAvail
105  , Bool aboveMergeAvail
106  , Bool onlyEstMergeInfo = false
107  );
108 
109 private:
110  Void xWriteUnarySymbol ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset );
111  Void xWriteUnaryMaxSymbol ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol );
112  Void xWriteEpExGolomb ( UInt uiSymbol, UInt uiCount );
113  Void xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange );
114 
115  Void xCopyFrom ( const TEncSbac* pSrc );
116  Void xCopyContextsFrom ( const TEncSbac* pSrc );
117 
118 protected:
121 
122  //--Adaptive loop filter
123 
124 public:
125  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
126  Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx );
127  Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx );
128  Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx );
129  Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
130  Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
131 
132  Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
133  Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx );
134  Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx );
135  Void codeTransformSubdivFlag ( UInt uiSymbol, UInt uiCtx );
136  Void codeQtCbf ( TComTU & rTu, const ComponentID compID, const Bool lowestLevel );
137  Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx );
138  Void codeQtCbfZero ( TComTU &rTu, const ChannelType chType );
140  Void codeIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiple);
141 
142  Void codeIntraDirChroma ( TComDataCU* pcCU, UInt uiAbsPartIdx );
143  Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx );
144  Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
145  Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
146 
148 
149  Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx );
150  Void codeChromaQpAdjustment ( TComDataCU* cu, UInt absPartIdx );
151 
152  Void codeLastSignificantXY ( UInt uiPosX, UInt uiPosY, Int width, Int height, ComponentID component, UInt uiScanIdx );
153  Void codeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID );
154  Void codeTransformSkipFlags ( TComTU &rTu, ComponentID component );
155 
156  // -------------------------------------------------------------------------------------------------------------------
157  // for RD-optimizatioon
158  // -------------------------------------------------------------------------------------------------------------------
159 
160  Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType);
161  Void estCBFBit ( estBitsSbacStruct* pcEstBitsSbac );
163  Void estSignificantMapBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
164  Void estLastSignificantPositionBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType );
166 
167  Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID );
168 
169 
171 private:
189 
196 
198 
206 
209 
211 };
212 
214 
215 #endif // !defined(AFX_TENCSBAC_H__DDA7CDC4_EDE3_4015_9D32_2156249C82AA__INCLUDED_)
ContextModel3DBuffer m_cSaoTypeIdxSCModel
Definition: TEncSbac.h:200
Void codeQtCbfZero(TComTU &rTu, const ChannelType chType)
Definition: TEncSbac.cpp:1087
entropy encoder class (header)
Void init(TEncBinIf *p)
Definition: TEncSbac.h:72
ContextModel3DBuffer m_explicitRdpcmFlagSCModel
Definition: TEncSbac.h:203
Void estSignificantMapBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType)
estimate SAMBAC bit cost for significant coefficient map
Definition: TEncSbac.cpp:1796
Void codeSplitFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncSbac.cpp:613
Void codeSPS(const TComSPS *pcSPS)
Definition: TEncSbac.cpp:229
SliceType
supported slice type
Definition: TypeDef.h:283
ContextModel3DBuffer m_cCUMergeFlagExtSCModel
Definition: TEncSbac.h:176
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:301
Void codeCoeffNxN(TComTU &rTu, TCoeff *pcCoef, const ComponentID compID)
Definition: TEncSbac.cpp:1181
virtual Void resetBits()=0
Void estSignificantCoefficientsBit(estBitsSbacStruct *pcEstBitsSbac, ChannelType chType)
estimate bit cost of significant coefficient
Definition: TEncSbac.cpp:1944
ContextModel3DBuffer m_cCUPredModeSCModel
Definition: TEncSbac.h:179
ContextModel3DBuffer m_cCURefPicSCModel
Definition: TEncSbac.h:184
Void estCBFBit(estBitsSbacStruct *pcEstBitsSbac)
estimate bit cost for each CBP bit
Definition: TEncSbac.cpp:1750
void Void
Definition: TypeDef.h:203
Void codeSliceHeader(TComSlice *pcSlice)
Definition: TEncSbac.cpp:241
pure virtual class for basic bit handling
Definition: TComBitStream.h:58
Void estSignificantCoeffGroupMapBit(estBitsSbacStruct *pcEstBitsSbac, ChannelType chType)
estimate SAMBAC bit cost for significant coefficient group map
Definition: TEncSbac.cpp:1776
Void codeSaoTypeIdx(UInt uiCode)
Definition: TEncSbac.cpp:1592
unsigned int UInt
Definition: TypeDef.h:212
TEncBinIf * m_pcBinIf
Definition: TEncSbac.h:120
ContextModel3DBuffer m_cCUInterDirSCModel
Definition: TEncSbac.h:183
Void codeSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:543
Void codeSAOSign(UInt uiCode)
Definition: TEncSbac.cpp:1543
UInt m_golombRiceAdaptationStatistics[RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS]
Definition: TEncSbac.h:210
ContextModel3DBuffer m_cCUChromaPredSCModel
Definition: TEncSbac.h:181
Void codeSaoMaxUvlc(UInt code, UInt maxSymbol)
Definition: TEncSbac.cpp:1548
ContextModel3DBuffer m_cCuCtxLastX
Definition: TEncSbac.h:192
Void codeLastSignificantXY(UInt uiPosX, UInt uiPosY, Int width, Int height, ComponentID component, UInt uiScanIdx)
Definition: TEncSbac.cpp:1115
Void codeVPS(const TComVPS *pcVPS)
Definition: TEncSbac.cpp:223
ContextModel3DBuffer m_cCUDeltaQpSCModel
Definition: TEncSbac.h:182
Void codePPS(const TComPPS *pcPPS)
Definition: TEncSbac.cpp:235
Void codeCrossComponentPrediction(TComTU &rTu, ComponentID compID)
Definition: TEncSbac.cpp:833
virtual ~TEncSbac()
Definition: TEncSbac.cpp:97
ContextModel3DBuffer m_cCUAbsSCModel
Definition: TEncSbac.h:195
ContextModel3DBuffer m_cCUOneSCModel
Definition: TEncSbac.h:194
Void loadContexts(const TEncSbac *pSrc)
Definition: TEncSbac.cpp:1978
Void estLastSignificantPositionBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType)
estimate bit cost of significant coefficient
Definition: TEncSbac.cpp:1870
Void codeIntraDirChroma(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:698
ContextModel3DBuffer m_cCUQtCbfSCModel
Definition: TEncSbac.h:186
context model class
Definition: ContextModel.h:57
ContextModel3DBuffer m_cCUSigSCModel
Definition: TEncSbac.h:191
Void xWriteCoefRemainExGolomb(UInt symbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange)
Definition: TEncSbac.cpp:337
Void codeSAOBlkParam(SAOBlkParam &saoBlkParam, const BitDepths &bitDepths, Bool *sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo=false)
Definition: TEncSbac.cpp:1683
ContextModel3DBuffer m_cCUSkipFlagSCModel
Definition: TEncSbac.h:175
ContextModel3DBuffer m_cCUTransSubdivFlagSCModel
Definition: TEncSbac.h:187
TComBitIf * m_pcBitIf
Definition: TEncSbac.h:119
Void codeIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:1034
Void codeMergeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:563
bool Bool
Definition: TypeDef.h:204
ContextModel3DBuffer m_cCUPartSizeSCModel
Definition: TEncSbac.h:178
Void setBitstream(TComBitIf *p)
Definition: TEncSbac.h:78
Void xCopyContextsFrom(const TEncSbac *pSrc)
Definition: TEncSbac.cpp:1972
Void xCopyFrom(const TEncSbac *pSrc)
Definition: TEncSbac.cpp:421
Void xWriteUnarySymbol(UInt uiSymbol, ContextModel *pcSCModel, Int iOffset)
Definition: TEncSbac.cpp:263
ContextModel3DBuffer m_cCUQtRootCbfSCModel
Definition: TEncSbac.h:188
Int m_numContextModels
Definition: TEncSbac.h:173
Void codeSAOOffsetParam(ComponentID compIdx, SAOOffset &ctbParam, Bool sliceEnabled, const Int channelBitDepth)
Definition: TEncSbac.cpp:1605
virtual Void init(TComBitIf *pcTComBitIf)=0
PPS class.
Definition: TComSlice.h:1034
Void codeQtCbf(TComTU &rTu, const ComponentID compID, const Bool lowestLevel)
Definition: TEncSbac.cpp:920
Void codeExplicitRdpcmMode(TComTU &rTu, const ComponentID compID)
Definition: TEncSbac.cpp:1987
Void load(const TEncSbac *pSrc)
Definition: TEncSbac.cpp:396
binary entropy encoder of CABAC
Void loadIntraDirMode(const TEncSbac *pScr, const ChannelType chType)
Definition: TEncSbac.cpp:401
Defines constants and tables for SBAC.
Void codeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)
Definition: TEncSbac.cpp:630
Void estBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType)
estimate bit cost for CBP, significant map and significant coefficients
Definition: TEncSbac.cpp:1726
ContextModel3DBuffer m_ChromaQpAdjFlagSCModel
Definition: TEncSbac.h:207
Int TCoeff
transform coefficient
Definition: TypeDef.h:250
RefPicList
reference list index
Definition: TypeDef.h:370
Void xWriteEpExGolomb(UInt uiSymbol, UInt uiCount)
Definition: TEncSbac.cpp:308
Void codeTransformSkipFlags(TComTU &rTu, ComponentID component)
Definition: TEncSbac.cpp:997
ContextModel3DBuffer m_cMVPIdxSCModel
Definition: TEncSbac.h:197
Void codeSaoMerge(UInt uiCode)
Definition: TEncSbac.cpp:1585
COEFF_SCAN_TYPE
coefficient scanning type used in ACS
Definition: TypeDef.h:473
class for handling bitstream (header)
Void codeMvd(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncSbac.cpp:779
Void codeTilesWPPEntryPoint(TComSlice *pSlice)
Definition: TEncSbac.cpp:247
UInt getNumberOfWrittenBits()
Definition: TEncSbac.h:85
Void codeDeltaQP(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:879
entropy encoder pure class
Definition: TEncEntropy.h:59
ContextModel3DBuffer m_cCrossComponentPredictionSCModel
Definition: TEncSbac.h:205
Void codePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncSbac.cpp:435
ContextModel3DBuffer m_cCUIntraPredSCModel
Definition: TEncSbac.h:180
Void codeCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:532
ContextModel3DBuffer m_cTransformSkipSCModel
Definition: TEncSbac.h:201
Void codePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:526
context model 3D buffer class
ContextModel m_contextModels[512]
Definition: TEncSbac.h:172
context model class (header)
binary entropy encoder interface
ContextModel3DBuffer m_cCUSplitFlagSCModel
Definition: TEncSbac.h:174
ContextModel3DBuffer m_ChromaQpAdjIdcSCModel
Definition: TEncSbac.h:208
ContextModel3DBuffer m_cCUSigCoeffGroupSCModel
Definition: TEncSbac.h:190
TEncBinIf * getEncBinIf()
Definition: TEncSbac.h:170
Definition: TComTU.h:48
Void codeTerminatingBit(UInt uilsLast)
Definition: TEncSbac.cpp:253
Void codeMergeIndex(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:583
Void resetEntropy(const TComSlice *pSlice)
Definition: TEncSbac.cpp:105
Void resetBits()
Definition: TEncSbac.h:84
Void store(TEncSbac *pDest) const
Definition: TEncSbac.cpp:415
Void codeSliceFinish()
Definition: TEncSbac.cpp:258
Void codeMVPIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncSbac.cpp:427
ContextModel3DBuffer m_cSaoMergeSCModel
Definition: TEncSbac.h:199
ContextModel3DBuffer m_explicitRdpcmDirSCModel
Definition: TEncSbac.h:204
#define MAX_NUM_CTX_MOD
maximum number of supported contexts
Definition: ContextTables.h:49
int Int
Definition: TypeDef.h:211
context model 3D buffer class (header)
static const Int RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS
Definition: CommonDef.h:213
ContextModel3DBuffer m_cCUMvdSCModel
Definition: TEncSbac.h:185
encoder class
Definition: TEncTop.h:68
Void codeChromaQpAdjustment(TComDataCU *cu, UInt absPartIdx)
Definition: TEncSbac.cpp:906
ComponentID
Definition: TypeDef.h:308
TEncSbac()
Definition: TEncSbac.cpp:57
Void codeSaoUflc(UInt uiLength, UInt uiCode)
Definition: TEncSbac.cpp:1578
Void codeRefFrmIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncSbac.cpp:748
SBAC encoder class.
Definition: TEncSbac.h:66
Void codeInterDir(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:729
slice header class
Definition: TComSlice.h:1225
Void codeIntraDirLumaAng(TComDataCU *pcCU, UInt absPartIdx, Bool isMultiple)
Definition: TEncSbac.cpp:643
ContextModel3DBuffer m_cCuCtxLastY
Definition: TEncSbac.h:193
Void codeQtRootCbfZero()
Definition: TEncSbac.cpp:1097
Void xWriteUnaryMaxSymbol(UInt uiSymbol, ContextModel *pcSCModel, Int iOffset, UInt uiMaxSymbol)
Definition: TEncSbac.cpp:280
ContextModel3DBuffer m_cCUMergeIdxExtSCModel
Definition: TEncSbac.h:177
Void uninit()
Definition: TEncSbac.h:73
ContextModel3DBuffer m_CUTransquantBypassFlagSCModel
Definition: TEncSbac.h:202
SliceType determineCabacInitIdx(const TComSlice *pSlice)
Definition: TEncSbac.cpp:162
virtual UInt getNumWrittenBits()=0
SPS class.
Definition: TComSlice.h:740
virtual Void resetBits()=0
Void codeQtRootCbf(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncSbac.cpp:1071