HEVC Test Model (HM)  HM-16.3
TEncEntropy.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-2015, 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 __TENCENTROPY__
39 #define __TENCENTROPY__
40 
41 #include "TLibCommon/TComSlice.h"
42 #include "TLibCommon/TComDataCU.h"
45 #include "TLibCommon/TComPic.h"
46 #include "TLibCommon/TComTrQuant.h"
49 
50 class TEncSbac;
51 class TEncCavlc;
52 class SEI;
53 
54 // ====================================================================================================================
55 // Class definition
56 // ====================================================================================================================
57 
60 {
61 public:
62  virtual Void resetEntropy () = 0;
63  virtual SliceType determineCabacInitIdx () = 0;
64  virtual Void setBitstream ( TComBitIf* p ) = 0;
65  virtual Void setSlice ( TComSlice* p ) = 0;
66  virtual Void resetBits () = 0;
67  virtual UInt getNumberOfWrittenBits() = 0;
68 
69  virtual Void codeVPS ( const TComVPS* pcVPS ) = 0;
70  virtual Void codeSPS ( const TComSPS* pcSPS ) = 0;
71  virtual Void codePPS ( const TComPPS* pcPPS ) = 0;
72  virtual Void codeSliceHeader ( TComSlice* pcSlice ) = 0;
73 
74  virtual Void codeTilesWPPEntryPoint ( TComSlice* pSlice ) = 0;
75  virtual Void codeTerminatingBit ( UInt uilsLast ) = 0;
76  virtual Void codeSliceFinish () = 0;
77  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
78 
79 public:
80  virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
81  virtual Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
82  virtual Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
83  virtual Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
84  virtual Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
85 
86  virtual Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
87  virtual Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
88 
89  virtual Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
90 
91  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
92  virtual Void codeQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) = 0;
93  virtual Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
94  virtual Void codeQtCbfZero ( TComTU &rTu, const ChannelType chType ) = 0;
95  virtual Void codeQtRootCbfZero ( TComDataCU* pcCU ) = 0;
96  virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiplePU ) = 0;
97 
98  virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
99  virtual Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
100  virtual Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
101  virtual Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
102 
103  virtual Void codeCrossComponentPrediction( TComTU &rTu, ComponentID compID ) = 0;
104 
105  virtual Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
106  virtual Void codeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
107  virtual Void codeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ) = 0;
108  virtual Void codeTransformSkipFlags ( TComTU &rTu, ComponentID component ) = 0;
109  virtual Void codeSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false) =0;
110  virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0;
111 
112  virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
113  virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName) = 0;
114 
115  virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0;
116 
117  virtual ~TEncEntropyIf() {}
118 };
119 
122 {
123 public:
124  Void setEntropyCoder ( TEncEntropyIf* e, TComSlice* pcSlice );
130 
131  Void encodeSliceHeader ( TComSlice* pcSlice );
133  Void encodeTerminatingBit ( UInt uiIsLast );
136 
137 public:
138  Void encodeVPS ( const TComVPS* pcVPS);
139  // SPS
140  Void encodeSPS ( const TComSPS* pcSPS );
141  Void encodePPS ( const TComPPS* pcPPS );
142  Void encodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
143  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
144  Void encodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
145  Void encodePUWise ( TComDataCU* pcCU, UInt uiAbsPartIdx );
146  Void encodeInterDirPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx );
147  Void encodeRefFrmIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
148  Void encodeMvdPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
149  Void encodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
150  Void encodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx );
151  Void encodeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
152  Void encodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
153  Void encodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
154  Void encodeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
155  Void encodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx );
156  Void encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU = false );
157 
158  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx );
159 
160  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
161  Void encodeQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel );
162 
163  Void encodeQtCbfZero ( TComTU &rTu, const ChannelType chType );
165  Void encodeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx );
166  Void encodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
167  Void encodeChromaQpAdjustment ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
168 
170 
171 private:
172  Void xEncodeTransform ( Bool& bCodeDQP, Bool& codeChromaQpAdj, TComTU &rTu );
173 
174 public:
175  Void encodeCoeff ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& codeChromaQpAdj );
176 
177  Void encodeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID );
178 
179  Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
180 
181  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
182 
183  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
184 
185 };// END CLASS DEFINITION TEncEntropy
186 
188 
189 #endif // __TENCENTROPY__
190 
virtual Void codeMVPIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)=0
Void encodeMergeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
encode merge flag
sample adaptive offset class (header)
Void encodeSPS(const TComSPS *pcSPS)
Definition: TEncEntropy.cpp:86
Void estimateBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType)
static Int countNonZeroCoeffs(TCoeff *pcCoef, UInt uiSize)
SliceType
supported slice type
Definition: TypeDef.h:343
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:361
Void encodeMvdPU(TComDataCU *pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList)
encode motion vector difference for a PU block
virtual Void codeDeltaQP(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
void Void
Definition: TypeDef.h:285
virtual Void codeCrossComponentPrediction(TComTU &rTu, ComponentID compID)=0
pure virtual class for basic bit handling
Definition: TComBitStream.h:58
Void encodeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)
Void encodeChromaQpAdjustment(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
encode chroma qp adjustment
Void encodePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
encode prediction mode
virtual Void codeSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
slice header and SPS class (header)
Void encodeSplitFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD=false)
encode split flag
char Char
Definition: TypeDef.h:291
CAVLC encoder class.
Definition: TEncCavlc.h:61
virtual Void codeRefFrmIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)=0
Void encodeSliceHeader(TComSlice *pcSlice)
Definition: TEncEntropy.cpp:57
unsigned int UInt
Definition: TypeDef.h:297
virtual Void codeQtRootCbfZero(TComDataCU *pcCU)=0
virtual Void codeSPS(const TComSPS *pcSPS)=0
virtual Void codeExplicitRdpcmMode(TComTU &rTu, const ComponentID compID)=0
virtual Void codeCoeffNxN(TComTU &rTu, TCoeff *pcCoef, const ComponentID compID)=0
Void setEntropyCoder(TEncEntropyIf *e, TComSlice *pcSlice)
Definition: TEncEntropy.cpp:51
Void encodeQtRootCbfZero(TComDataCU *pcCU)
virtual Void codeCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
virtual Void codeDFSvlc(Int iCode, const Char *pSymbolName)=0
picture class (header)
virtual Void codeVPS(const TComVPS *pcVPS)=0
virtual Void codeIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
virtual Void codePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)=0
Void encodeQP(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Void encodeRefFrmIdxPU(TComDataCU *pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList)
encode reference frame index for a PU block
virtual Void codeTransformSkipFlags(TComTU &rTu, ComponentID component)=0
Void encodeCoeffNxN(TComTU &rTu, TCoeff *pcCoef, const ComponentID compID)
virtual Void setSlice(TComSlice *p)=0
virtual Void codeTilesWPPEntryPoint(TComSlice *pSlice)=0
virtual Void codeQtCbfZero(TComTU &rTu, const ChannelType chType)=0
Void xEncodeTransform(Bool &bCodeDQP, Bool &codeChromaQpAdj, TComTU &rTu)
Void encodePUWise(TComDataCU *pcCU, UInt uiAbsPartIdx)
encode motion information for every PU block
virtual Void codeSliceFinish()=0
Void encodeCoeff(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &bCodeDQP, Bool &codeChromaQpAdj)
encode coefficients
bool Bool
Definition: TypeDef.h:286
virtual Void codeDFFlag(UInt uiCode, const Char *pSymbolName)=0
Void encodeIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Void encodeSliceFinish()
Definition: TEncEntropy.cpp:75
virtual Void codeMvd(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)=0
Void encodeQtCbfZero(TComTU &rTu, const ChannelType chType)
PPS class.
Definition: TComSlice.h:977
virtual UInt getNumberOfWrittenBits()=0
virtual SliceType determineCabacInitIdx()=0
Definition: SEI.h:52
virtual Void codeMergeIndex(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
entropy encoder class
Definition: TEncEntropy.h:121
virtual ~TEncEntropyIf()
Definition: TEncEntropy.h:117
virtual Void codeSliceHeader(TComSlice *pcSlice)=0
Int TCoeff
transform coefficient
Definition: TypeDef.h:693
virtual Void resetBits()=0
RefPicList
reference list index
Definition: TypeDef.h:415
SliceType determineCabacInitIdx()
Definition: TEncEntropy.h:129
Void encodeSAOBlkParam(SAOBlkParam &saoBlkParam, Bool *sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail)
Definition: TEncEntropy.h:181
class for handling bitstream (header)
virtual Void codeChromaQpAdjustment(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
Void resetBits()
Definition: TEncEntropy.h:126
Void encodePPS(const TComPPS *pcPPS)
Definition: TEncEntropy.cpp:80
entropy encoder pure class
Definition: TEncEntropy.h:59
virtual Void codeQtCbf(TComTU &rTu, const ComponentID compID, const Bool lowestLevel)=0
Void encodeQtRootCbf(TComDataCU *pcCU, UInt uiAbsPartIdx)
Void encodeIntraDirModeChroma(TComDataCU *pcCU, UInt uiAbsPartIdx)
encode intra direction for chroma
virtual Void codeQtRootCbf(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
virtual Void codeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)=0
virtual Void codeSplitFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)=0
Void encodeTilesWPPEntryPoint(TComSlice *pSlice)
Definition: TEncEntropy.cpp:63
context model class (header)
Void encodeInterDirPU(TComDataCU *pcSubCU, UInt uiAbsPartIdx)
Definition: TComTU.h:48
virtual Void codeIntraDirChroma(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
Void encodeCrossComponentPrediction(TComTU &rTu, ComponentID compID)
virtual Void codePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
Void resetEntropy()
Definition: TEncEntropy.h:128
Void encodeQtCbf(TComTU &rTu, const ComponentID compID, const Bool lowestLevel)
Void encodeCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Definition: TEncEntropy.cpp:92
Void encodePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD=false)
encode partition size
int Int
Definition: TypeDef.h:296
Void setBitstream(TComBitIf *p)
Definition: TEncEntropy.h:125
virtual Void estBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType)=0
Void encodeIntraDirModeLuma(TComDataCU *pcCU, UInt absPartIdx, Bool isMultiplePU=false)
encode intra direction for luma
ComponentID
Definition: TypeDef.h:368
Void encodeMergeIndex(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
encode merge index
transform and quantization class (header)
Void encodeTerminatingBit(UInt uiIsLast)
Definition: TEncEntropy.cpp:68
virtual Void codeMergeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)=0
virtual Void codeIntraDirLumaAng(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool isMultiplePU)=0
SBAC encoder class.
Definition: TEncSbac.h:66
virtual Void resetEntropy()=0
Void encodePredInfo(TComDataCU *pcCU, UInt uiAbsPartIdx)
CU data structure (header)
Void encodeSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
slice header class
Definition: TComSlice.h:1198
virtual Void codeSAOBlkParam(SAOBlkParam &saoBlkParam, Bool *sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo=false)=0
Void encodeMVPIdxPU(TComDataCU *pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList)
virtual Void setBitstream(TComBitIf *p)=0
virtual Void codeTerminatingBit(UInt uilsLast)=0
virtual Void codePPS(const TComPPS *pcPPS)=0
SPS class.
Definition: TComSlice.h:722
UInt getNumberOfWrittenBits()
Definition: TEncEntropy.h:127
Void encodeVPS(const TComVPS *pcVPS)
TEncEntropyIf * m_pcEntropyCoderIf
Definition: TEncEntropy.h:135
virtual Void codeInterDir(TComDataCU *pcCU, UInt uiAbsPartIdx)=0