1 | |
---|
2 | |
---|
3 | /** \file TEncEntropy.h |
---|
4 | \brief entropy encoder class (header) |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __TENCENTROPY__ |
---|
8 | #define __TENCENTROPY__ |
---|
9 | |
---|
10 | #include "../TLibCommon/TComSlice.h" |
---|
11 | #include "../TLibCommon/TComDataCU.h" |
---|
12 | #include "../TLibCommon/TComBitStream.h" |
---|
13 | #include "../TLibCommon/ContextModel.h" |
---|
14 | #include "../TLibCommon/TComPic.h" |
---|
15 | #include "../TLibCommon/TComTrQuant.h" |
---|
16 | class TEncSbac; |
---|
17 | class TEncCavlc; |
---|
18 | class SEI; |
---|
19 | |
---|
20 | // ==================================================================================================================== |
---|
21 | // Class definition |
---|
22 | // ==================================================================================================================== |
---|
23 | |
---|
24 | /// entropy encoder pure class |
---|
25 | class TEncEntropyIf |
---|
26 | { |
---|
27 | public: |
---|
28 | virtual Bool getAlfCtrl() = 0; |
---|
29 | virtual UInt getMaxAlfCtrlDepth() = 0; |
---|
30 | virtual Void setAlfCtrl(Bool bAlfCtrl) = 0; |
---|
31 | virtual Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) = 0; |
---|
32 | |
---|
33 | virtual Void resetEntropy () = 0; |
---|
34 | virtual Void setBitstream ( TComBitIf* p ) = 0; |
---|
35 | virtual Void setSlice ( TComSlice* p ) = 0; |
---|
36 | virtual Void resetBits () = 0; |
---|
37 | virtual Void resetCoeffCost () = 0; |
---|
38 | virtual UInt getNumberOfWrittenBits() = 0; |
---|
39 | virtual UInt getCoeffCost () = 0; |
---|
40 | |
---|
41 | virtual Void codeNALUnitHeader ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ) = 0; |
---|
42 | |
---|
43 | virtual Void codeSPS ( TComSPS* pcSPS ) = 0; |
---|
44 | virtual Void codePPS ( TComPPS* pcPPS ) = 0; |
---|
45 | virtual void codeSEI(const SEI&) = 0; |
---|
46 | virtual Void codeSliceHeader ( TComSlice* pcSlice ) = 0; |
---|
47 | virtual Void codeTerminatingBit ( UInt uilsLast ) = 0; |
---|
48 | virtual Void codeSliceFinish () = 0; |
---|
49 | |
---|
50 | virtual Void codeAlfCtrlDepth() = 0; |
---|
51 | virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
52 | |
---|
53 | virtual Void codeViewIdx( Int iViewIdx ) = 0; |
---|
54 | |
---|
55 | public: |
---|
56 | virtual Void codeAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
57 | |
---|
58 | virtual Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
59 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
60 | virtual Void codeMvInheritanceFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
61 | #endif |
---|
62 | virtual Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
63 | virtual Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
64 | virtual Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
65 | virtual Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
66 | |
---|
67 | virtual Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
68 | virtual Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
69 | |
---|
70 | virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0; |
---|
71 | virtual Void codeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0; |
---|
72 | virtual Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
73 | virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
74 | |
---|
75 | virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
76 | virtual Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
77 | virtual Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
78 | virtual Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
79 | virtual Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
80 | virtual Void codeCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0; |
---|
81 | virtual Void codeBlockCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiQPartNum, Bool bRD = false) = 0; |
---|
82 | #if CAVLC_RQT_CBP |
---|
83 | virtual Void codeCbfTrdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
84 | virtual UInt xGetFlagPattern ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
85 | #endif |
---|
86 | virtual Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType, Bool bRD = false ) = 0; |
---|
87 | |
---|
88 | virtual Void codeAlfFlag ( UInt uiCode ) = 0; |
---|
89 | virtual Void codeAlfUvlc ( UInt uiCode ) = 0; |
---|
90 | virtual Void codeAlfSvlc ( Int iCode ) = 0; |
---|
91 | #if TSB_ALF_HEADER |
---|
92 | virtual Void codeAlfFlagNum ( UInt uiCode, UInt minValue ) = 0; |
---|
93 | virtual Void codeAlfCtrlFlag ( UInt uiSymbol ) = 0; |
---|
94 | #endif |
---|
95 | #if MTK_SAO |
---|
96 | virtual Void codeAoFlag ( UInt uiCode ) = 0; |
---|
97 | virtual Void codeAoUvlc ( UInt uiCode ) = 0; |
---|
98 | virtual Void codeAoSvlc ( Int iCode ) = 0; |
---|
99 | #endif |
---|
100 | virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType) = 0; |
---|
101 | |
---|
102 | virtual ~TEncEntropyIf() {} |
---|
103 | }; |
---|
104 | |
---|
105 | /// entropy encoder class |
---|
106 | class TEncEntropy |
---|
107 | { |
---|
108 | public: |
---|
109 | Void setEntropyCoder ( TEncEntropyIf* e, TComSlice* pcSlice ); |
---|
110 | Void setBitstream ( TComBitIf* p ) { m_pcEntropyCoderIf->setBitstream(p); } |
---|
111 | Void resetBits () { m_pcEntropyCoderIf->resetBits(); } |
---|
112 | Void resetCoeffCost () { m_pcEntropyCoderIf->resetCoeffCost(); } |
---|
113 | UInt getNumberOfWrittenBits () { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); } |
---|
114 | UInt getCoeffCost () { return m_pcEntropyCoderIf->getCoeffCost(); } |
---|
115 | Void resetEntropy () { m_pcEntropyCoderIf->resetEntropy(); } |
---|
116 | |
---|
117 | Void encodeSliceHeader ( TComSlice* pcSlice ); |
---|
118 | Void encodeTerminatingBit ( UInt uiIsLast ); |
---|
119 | Void encodeSliceFinish (); |
---|
120 | |
---|
121 | Void encodeAlfParam(ALFParam* pAlfParam); |
---|
122 | Void encodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false ); |
---|
123 | |
---|
124 | Void encodeViewIdx(Int iViewIdx ); |
---|
125 | |
---|
126 | TEncEntropyIf* m_pcEntropyCoderIf; |
---|
127 | |
---|
128 | public: |
---|
129 | // SPS |
---|
130 | Void encodeSPS ( TComSPS* pcSPS ); |
---|
131 | Void encodePPS ( TComPPS* pcPPS ); |
---|
132 | void encodeSEI(const SEI&); |
---|
133 | Bool getAlfCtrl() {return m_pcEntropyCoderIf->getAlfCtrl();} |
---|
134 | UInt getMaxAlfCtrlDepth() {return m_pcEntropyCoderIf->getMaxAlfCtrlDepth();} |
---|
135 | Void setAlfCtrl(Bool bAlfCtrl) {m_pcEntropyCoderIf->setAlfCtrl(bAlfCtrl);} |
---|
136 | Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) {m_pcEntropyCoderIf->setMaxAlfCtrlDepth(uiMaxAlfCtrlDepth);} |
---|
137 | |
---|
138 | Void encodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
139 | Void encodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
140 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
141 | Void encodeMvInheritanceFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
142 | #endif |
---|
143 | Void encodePUWise ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
144 | Void encodeInterDirPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx ); |
---|
145 | Void encodeRefFrmIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
146 | Void encodeMvdPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
147 | Void encodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
148 | Void encodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx ); |
---|
149 | #if HHI_MRG_SKIP |
---|
150 | Void encodeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false ); |
---|
151 | #else |
---|
152 | Void encodeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx ); |
---|
153 | #endif |
---|
154 | Void encodeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false ); |
---|
155 | Void encodeAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
156 | #if TSB_ALF_HEADER |
---|
157 | Void encodeAlfCtrlParam ( ALFParam *pAlfParam ); |
---|
158 | #endif |
---|
159 | Void encodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
160 | Void encodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
161 | |
---|
162 | Void encodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
163 | Void encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
164 | |
---|
165 | Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
166 | Void encodeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
167 | Void encodeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false ); |
---|
168 | Void encodeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false ); |
---|
169 | |
---|
170 | Void encodeTransformIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
171 | Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ); |
---|
172 | Void encodeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ); |
---|
173 | Void encodeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
174 | Void encodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
175 | |
---|
176 | private: |
---|
177 | Void xEncodeTransformSubdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ); |
---|
178 | Void xEncodeCoeff ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType, Bool bRD = false ); |
---|
179 | public: |
---|
180 | Void encodeCoeff ( TComDataCU* pcCU , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight ); |
---|
181 | Void encodeCoeff ( TComDataCU* pcCU, TCoeff* pCoeff , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiMaxTrMode, UInt uiTrMode, TextType eType, Bool bRD = false ); |
---|
182 | |
---|
183 | Void encodeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType, Bool bRD = false ); |
---|
184 | |
---|
185 | Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiWidth, TextType eTType); |
---|
186 | |
---|
187 | // ALF-related |
---|
188 | Void codeAuxCountBit(ALFParam* pAlfParam, Int64* ruiRate); |
---|
189 | Void codeFiltCountBit(ALFParam* pAlfParam, Int64* ruiRate); |
---|
190 | Void codeAux (ALFParam* pAlfParam); |
---|
191 | Void codeFilt (ALFParam* pAlfParam); |
---|
192 | Int codeFilterCoeff(ALFParam* ALFp); |
---|
193 | Int writeFilterCodingParams(int minKStart, int maxScanVal, int kMinTab[]); |
---|
194 | Int writeFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[], |
---|
195 | int **FilterCoeff, int kMinTab[]); |
---|
196 | Int golombEncode(int coeff, int k); |
---|
197 | Int lengthGolomb(int coeffVal, int k); |
---|
198 | #if MTK_SAO |
---|
199 | Void encodeQAOOnePart(SAOParam* pQaoParam, Int part_idx); |
---|
200 | Void encodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int part_idx); |
---|
201 | Void encodeSaoParam(SAOParam* pQaoParam) ; |
---|
202 | #endif |
---|
203 | |
---|
204 | };// END CLASS DEFINITION TEncEntropy |
---|
205 | |
---|
206 | |
---|
207 | #endif // __TENCENTROPY__ |
---|
208 | |
---|