1 | |
---|
2 | |
---|
3 | /** \file TEncSbac.h |
---|
4 | \brief Context-adaptive entropy encoder class (header) |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __TENCSBAC__ |
---|
8 | #define __TENCSBAC__ |
---|
9 | |
---|
10 | #if _MSC_VER > 1000 |
---|
11 | #pragma once |
---|
12 | #endif // _MSC_VER > 1000 |
---|
13 | |
---|
14 | #include "../TLibCommon/TComBitStream.h" |
---|
15 | #include "../TLibCommon/ContextTables.h" |
---|
16 | #include "../TLibCommon/ContextModel.h" |
---|
17 | #include "../TLibCommon/ContextModel3DBuffer.h" |
---|
18 | #include "TEncEntropy.h" |
---|
19 | #include "TEncBinCoder.h" |
---|
20 | #include "TEncBinCoderCABAC.h" |
---|
21 | |
---|
22 | class TEncTop; |
---|
23 | |
---|
24 | // ==================================================================================================================== |
---|
25 | // Class definition |
---|
26 | // ==================================================================================================================== |
---|
27 | |
---|
28 | /// SBAC encoder class |
---|
29 | class TEncSbac : public TEncEntropyIf |
---|
30 | { |
---|
31 | public: |
---|
32 | TEncSbac(); |
---|
33 | virtual ~TEncSbac(); |
---|
34 | |
---|
35 | Void init ( TEncBinIf* p ) { m_pcBinIf = p; } |
---|
36 | Void uninit () { m_pcBinIf = 0; } |
---|
37 | |
---|
38 | // Virtual list |
---|
39 | Void resetEntropy (); |
---|
40 | Void setBitstream ( TComBitIf* p ) { m_pcBitIf = p; m_pcBinIf->init( p ); } |
---|
41 | Void setSlice ( TComSlice* p ) { m_pcSlice = p; } |
---|
42 | |
---|
43 | Bool getAlfCtrl () { return m_bAlfCtrl; } |
---|
44 | UInt getMaxAlfCtrlDepth () { return m_uiMaxAlfCtrlDepth; } |
---|
45 | Void setAlfCtrl ( Bool bAlfCtrl ) { m_bAlfCtrl = bAlfCtrl; } |
---|
46 | Void setMaxAlfCtrlDepth ( UInt uiMaxAlfCtrlDepth ) { m_uiMaxAlfCtrlDepth = uiMaxAlfCtrlDepth; } |
---|
47 | |
---|
48 | // SBAC RD |
---|
49 | Void resetCoeffCost () { m_uiCoeffCost = 0; } |
---|
50 | UInt getCoeffCost () { return m_uiCoeffCost; } |
---|
51 | |
---|
52 | Void load ( TEncSbac* pScr ); |
---|
53 | Void store ( TEncSbac* pDest ); |
---|
54 | Void resetBits () { m_pcBinIf->resetBits(); m_pcBitIf->resetBits(); } |
---|
55 | UInt getNumberOfWrittenBits () { return m_pcBinIf->getNumWrittenBits(); } |
---|
56 | //--SBAC RD |
---|
57 | |
---|
58 | Void codeNALUnitHeader ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ); |
---|
59 | |
---|
60 | Void codeSPS ( TComSPS* pcSPS ); |
---|
61 | Void codePPS ( TComPPS* pcPPS ); |
---|
62 | void codeSEI(const SEI&); |
---|
63 | Void codeSliceHeader ( TComSlice* pcSlice ); |
---|
64 | Void codeTerminatingBit ( UInt uilsLast ); |
---|
65 | Void codeSliceFinish (); |
---|
66 | |
---|
67 | Void codeAlfFlag ( UInt uiCode ); |
---|
68 | Void codeAlfUvlc ( UInt uiCode ); |
---|
69 | Void codeAlfSvlc ( Int uiCode ); |
---|
70 | Void codeAlfCtrlDepth (); |
---|
71 | #if TSB_ALF_HEADER |
---|
72 | Void codeAlfFlagNum ( UInt uiCode, UInt minValue ); |
---|
73 | Void codeAlfCtrlFlag ( UInt uiSymbol ); |
---|
74 | #endif |
---|
75 | #if MTK_SAO |
---|
76 | Void codeAoFlag ( UInt uiCode ); |
---|
77 | Void codeAoUvlc ( UInt uiCode ); |
---|
78 | Void codeAoSvlc ( Int uiCode ); |
---|
79 | #endif |
---|
80 | |
---|
81 | private: |
---|
82 | Void xWriteUnarySymbol ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset ); |
---|
83 | Void xWriteUnaryMaxSymbol ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ); |
---|
84 | Void xWriteEpExGolomb ( UInt uiSymbol, UInt uiCount ); |
---|
85 | #if E253 |
---|
86 | Void xWriteGoRiceExGolomb ( UInt uiSymbol, UInt &ruiGoRiceParam ); |
---|
87 | #if HHI_DMM_INTRA |
---|
88 | Void xWriteExGolombLevel ( UInt uiSymbol, ContextModel& rcSCModel ); |
---|
89 | #endif |
---|
90 | #else |
---|
91 | Void xWriteExGolombLevel ( UInt uiSymbol, ContextModel& rcSCModel ); |
---|
92 | #endif |
---|
93 | Void xWriteTerminatingBit ( UInt uiBit ); |
---|
94 | |
---|
95 | Void xCheckCoeff( TCoeff* pcCoef, UInt uiSize, UInt uiDepth, UInt& uiNumofCoeff, UInt& uiPart ); |
---|
96 | |
---|
97 | #if MVD_CTX |
---|
98 | Void xWriteMvd ( Int iMvd, UInt uiAbsSumL, UInt uiAbsSumA, UInt uiCtx ); |
---|
99 | #else |
---|
100 | Void xWriteMvd ( Int iMvd, UInt uiAbsSum, UInt uiCtx ); |
---|
101 | #endif |
---|
102 | Void xWriteExGolombMvd ( UInt uiSymbol, ContextModel* pcSCModel, UInt uiMaxBin ); |
---|
103 | Void xCopyFrom ( TEncSbac* pSrc ); |
---|
104 | |
---|
105 | #if HHI_DMM_INTRA |
---|
106 | Void xCodeWedgeFullInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
107 | Void xCodeWedgeFullDeltaInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
108 | Void xCodeWedgePredDirInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
109 | Void xCodeWedgePredDirDeltaInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
110 | Void xCodeWedgePredTexDeltaInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
111 | Void xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
112 | #endif |
---|
113 | |
---|
114 | protected: |
---|
115 | TComBitIf* m_pcBitIf; |
---|
116 | TComSlice* m_pcSlice; |
---|
117 | TEncBinIf* m_pcBinIf; |
---|
118 | Bool m_bAlfCtrl; |
---|
119 | |
---|
120 | //SBAC RD |
---|
121 | UInt m_uiCoeffCost; |
---|
122 | |
---|
123 | // Adaptive loop filter |
---|
124 | UInt m_uiMaxAlfCtrlDepth; |
---|
125 | //--Adaptive loop filter |
---|
126 | |
---|
127 | public: |
---|
128 | Void codeAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
129 | Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
130 | Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
131 | Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
132 | Void codeMergeIndexMV ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
133 | Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
134 | Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
135 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
136 | Void codeMvInheritanceFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
137 | #endif |
---|
138 | Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
139 | |
---|
140 | Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
141 | Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
142 | |
---|
143 | Void codeTransformSubdivFlag ( UInt uiSymbol, UInt uiCtx ); |
---|
144 | Void codeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ); |
---|
145 | Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
146 | |
---|
147 | Void codeIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
148 | |
---|
149 | Void codeIntraDirChroma ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
150 | Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
151 | Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
152 | Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
153 | |
---|
154 | Void codeViewIdx (Int iViewIdx); |
---|
155 | |
---|
156 | Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
157 | Void codeCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) {} |
---|
158 | Void codeBlockCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiQPartNum, Bool bRD = false ) {} |
---|
159 | |
---|
160 | #if CAVLC_RQT_CBP |
---|
161 | Void codeCbfTrdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) {} |
---|
162 | UInt xGetFlagPattern ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) { return 0; } |
---|
163 | #endif |
---|
164 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
165 | __inline Void codeLastSignificantXY ( UInt uiPosX, UInt uiPosY, const UInt uiWidth, const TextType eTType, const UInt uiCTXIdx, const UInt uiScanIdx ); |
---|
166 | #endif |
---|
167 | Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType, Bool bRD = false ); |
---|
168 | |
---|
169 | // ------------------------------------------------------------------------------------------------------------------- |
---|
170 | // for RD-optimizatioon |
---|
171 | // ------------------------------------------------------------------------------------------------------------------- |
---|
172 | |
---|
173 | Void estBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType ); |
---|
174 | Void estCBFBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType ); |
---|
175 | Void estSignificantMapBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType ); |
---|
176 | Void estSignificantCoefficientsBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType ); |
---|
177 | |
---|
178 | __inline Int biari_no_bits ( Short symbol, ContextModel& rcSCModel ); |
---|
179 | |
---|
180 | TEncBinIf* getEncBinIf() { return m_pcBinIf; } |
---|
181 | private: |
---|
182 | UInt m_uiLastQp; |
---|
183 | ContextModel3DBuffer m_cCUSplitFlagSCModel; |
---|
184 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
185 | ContextModel3DBuffer m_cCUMvInheritanceFlagSCModel; |
---|
186 | #endif |
---|
187 | ContextModel3DBuffer m_cCUSkipFlagSCModel; |
---|
188 | ContextModel3DBuffer m_cCUMergeFlagExtSCModel; |
---|
189 | ContextModel3DBuffer m_cCUMergeIdxExtSCModel; |
---|
190 | ContextModel3DBuffer m_cCUMVMergeIdxExtSCModel; |
---|
191 | ContextModel3DBuffer m_cResPredFlagSCModel; |
---|
192 | ContextModel3DBuffer m_cCUPartSizeSCModel; |
---|
193 | ContextModel3DBuffer m_cCUPredModeSCModel; |
---|
194 | ContextModel3DBuffer m_cCUAlfCtrlFlagSCModel; |
---|
195 | ContextModel3DBuffer m_cCUIntraPredSCModel; |
---|
196 | #if ADD_PLANAR_MODE |
---|
197 | ContextModel3DBuffer m_cPlanarFlagSCModel; |
---|
198 | #endif |
---|
199 | ContextModel3DBuffer m_cCUChromaPredSCModel; |
---|
200 | ContextModel3DBuffer m_cCUDeltaQpSCModel; |
---|
201 | ContextModel3DBuffer m_cCUInterDirSCModel; |
---|
202 | ContextModel3DBuffer m_cCURefPicSCModel; |
---|
203 | ContextModel3DBuffer m_cCUMvdSCModel; |
---|
204 | ContextModel3DBuffer m_cCUQtCbfSCModel; |
---|
205 | ContextModel3DBuffer m_cCUTransSubdivFlagSCModel; |
---|
206 | ContextModel3DBuffer m_cCUQtRootCbfSCModel; |
---|
207 | |
---|
208 | ContextModel3DBuffer m_cCUSigSCModel; |
---|
209 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
210 | ContextModel3DBuffer m_cCuCtxLastX; |
---|
211 | ContextModel3DBuffer m_cCuCtxLastY; |
---|
212 | #else |
---|
213 | ContextModel3DBuffer m_cCULastSCModel; |
---|
214 | #endif |
---|
215 | ContextModel3DBuffer m_cCUOneSCModel; |
---|
216 | ContextModel3DBuffer m_cCUAbsSCModel; |
---|
217 | |
---|
218 | ContextModel3DBuffer m_cMVPIdxSCModel; |
---|
219 | |
---|
220 | ContextModel3DBuffer m_cALFFlagSCModel; |
---|
221 | ContextModel3DBuffer m_cALFUvlcSCModel; |
---|
222 | ContextModel3DBuffer m_cALFSvlcSCModel; |
---|
223 | #if MTK_SAO |
---|
224 | ContextModel3DBuffer m_cAOFlagSCModel; |
---|
225 | ContextModel3DBuffer m_cAOUvlcSCModel; |
---|
226 | ContextModel3DBuffer m_cAOSvlcSCModel; |
---|
227 | #endif |
---|
228 | ContextModel3DBuffer m_cViewIdxSCModel; |
---|
229 | #if HHI_DMM_INTRA |
---|
230 | ContextModel3DBuffer m_cIntraDMMSCModel; |
---|
231 | ContextModel3DBuffer m_cIntraWedgeSCModel; |
---|
232 | #endif |
---|
233 | }; |
---|
234 | |
---|
235 | #endif // !defined(AFX_TENCSBAC_H__DDA7CDC4_EDE3_4015_9D32_2156249C82AA__INCLUDED_) |
---|