[313] | 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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 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 | |
---|
| 34 | /** \file TEncEntropy.h |
---|
| 35 | \brief entropy encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TENCENTROPY__ |
---|
| 39 | #define __TENCENTROPY__ |
---|
| 40 | |
---|
| 41 | #include "TLibCommon/TComSlice.h" |
---|
| 42 | #include "TLibCommon/TComDataCU.h" |
---|
| 43 | #include "TLibCommon/TComBitStream.h" |
---|
| 44 | #include "TLibCommon/ContextModel.h" |
---|
| 45 | #include "TLibCommon/TComPic.h" |
---|
| 46 | #include "TLibCommon/TComTrQuant.h" |
---|
| 47 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
[1029] | 48 | #include "TLibCommon/TComChromaFormat.h" |
---|
[313] | 49 | |
---|
| 50 | class TEncSbac; |
---|
| 51 | class TEncCavlc; |
---|
| 52 | class SEI; |
---|
[1212] | 53 | #if CGS_3D_ASYMLUT |
---|
[713] | 54 | class TEnc3DAsymLUT; |
---|
| 55 | #endif |
---|
[313] | 56 | |
---|
| 57 | // ==================================================================================================================== |
---|
| 58 | // Class definition |
---|
| 59 | // ==================================================================================================================== |
---|
| 60 | |
---|
| 61 | /// entropy encoder pure class |
---|
| 62 | class TEncEntropyIf |
---|
| 63 | { |
---|
| 64 | public: |
---|
[1291] | 65 | virtual Void resetEntropy (const TComSlice *pSlice) = 0; |
---|
| 66 | virtual SliceType determineCabacInitIdx (const TComSlice *pSlice) = 0; |
---|
[313] | 67 | virtual Void setBitstream ( TComBitIf* p ) = 0; |
---|
| 68 | virtual Void resetBits () = 0; |
---|
| 69 | virtual UInt getNumberOfWrittenBits() = 0; |
---|
| 70 | |
---|
[1235] | 71 | virtual Void codeVPS ( const TComVPS* pcVPS ) = 0; |
---|
| 72 | virtual Void codeSPS ( const TComSPS* pcSPS ) = 0; |
---|
[1212] | 73 | #if CGS_3D_ASYMLUT |
---|
[1235] | 74 | virtual Void codePPS ( const TComPPS* pcPPS, TEnc3DAsymLUT * pc3DAsymLUT ) = 0; |
---|
| 75 | #else |
---|
| 76 | virtual Void codePPS ( const TComPPS* pcPPS ) = 0; |
---|
[713] | 77 | #endif |
---|
[313] | 78 | virtual Void codeSliceHeader ( TComSlice* pcSlice ) = 0; |
---|
| 79 | |
---|
| 80 | virtual Void codeTilesWPPEntryPoint ( TComSlice* pSlice ) = 0; |
---|
| 81 | virtual Void codeTerminatingBit ( UInt uilsLast ) = 0; |
---|
| 82 | virtual Void codeSliceFinish () = 0; |
---|
[1235] | 83 | virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
[1029] | 84 | |
---|
[313] | 85 | public: |
---|
| 86 | virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 87 | virtual Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 88 | virtual Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 89 | virtual Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 90 | virtual Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[345] | 91 | |
---|
[313] | 92 | virtual Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 93 | virtual Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
[1029] | 94 | |
---|
[313] | 95 | virtual Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 96 | |
---|
| 97 | virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0; |
---|
[1029] | 98 | virtual Void codeQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) = 0; |
---|
[313] | 99 | virtual Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
[1029] | 100 | virtual Void codeQtCbfZero ( TComTU &rTu, const ChannelType chType ) = 0; |
---|
[1307] | 101 | virtual Void codeQtRootCbfZero ( ) = 0; |
---|
[313] | 102 | virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiplePU ) = 0; |
---|
[1029] | 103 | |
---|
[313] | 104 | virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 105 | virtual Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 106 | virtual Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
| 107 | virtual Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0; |
---|
[1029] | 108 | |
---|
| 109 | virtual Void codeCrossComponentPrediction( TComTU &rTu, ComponentID compID ) = 0; |
---|
| 110 | |
---|
[313] | 111 | virtual Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
[1029] | 112 | virtual Void codeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; |
---|
| 113 | virtual Void codeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ) = 0; |
---|
| 114 | virtual Void codeTransformSkipFlags ( TComTU &rTu, ComponentID component ) = 0; |
---|
[1287] | 115 | virtual Void codeSAOBlkParam (SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false) =0; |
---|
[1029] | 116 | virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0; |
---|
[313] | 117 | |
---|
[1029] | 118 | virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0; |
---|
| 119 | |
---|
[313] | 120 | virtual ~TEncEntropyIf() {} |
---|
[1287] | 121 | |
---|
| 122 | #if SVC_EXTENSION |
---|
| 123 | virtual Void codeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow ) = 0; |
---|
| 124 | #endif |
---|
[313] | 125 | }; |
---|
| 126 | |
---|
| 127 | /// entropy encoder class |
---|
| 128 | class TEncEntropy |
---|
| 129 | { |
---|
| 130 | public: |
---|
[1291] | 131 | Void setEntropyCoder ( TEncEntropyIf* e ); |
---|
[313] | 132 | Void setBitstream ( TComBitIf* p ) { m_pcEntropyCoderIf->setBitstream(p); } |
---|
| 133 | Void resetBits () { m_pcEntropyCoderIf->resetBits(); } |
---|
| 134 | UInt getNumberOfWrittenBits () { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); } |
---|
[1291] | 135 | Void resetEntropy (const TComSlice *pSlice) { m_pcEntropyCoderIf->resetEntropy(pSlice); } |
---|
| 136 | SliceType determineCabacInitIdx (const TComSlice *pSlice) { return m_pcEntropyCoderIf->determineCabacInitIdx(pSlice); } |
---|
[1029] | 137 | |
---|
[313] | 138 | Void encodeSliceHeader ( TComSlice* pcSlice ); |
---|
| 139 | Void encodeTilesWPPEntryPoint( TComSlice* pSlice ); |
---|
| 140 | Void encodeTerminatingBit ( UInt uiIsLast ); |
---|
| 141 | Void encodeSliceFinish (); |
---|
| 142 | TEncEntropyIf* m_pcEntropyCoderIf; |
---|
[1029] | 143 | |
---|
[313] | 144 | public: |
---|
[1235] | 145 | Void encodeVPS ( const TComVPS* pcVPS); |
---|
[313] | 146 | // SPS |
---|
[1235] | 147 | Void encodeSPS ( const TComSPS* pcSPS ); |
---|
[1212] | 148 | #if CGS_3D_ASYMLUT |
---|
[1235] | 149 | Void encodePPS ( const TComPPS* pcPPS, TEnc3DAsymLUT * pc3DAsymLUT ); |
---|
| 150 | #else |
---|
| 151 | Void encodePPS ( const TComPPS* pcPPS ); |
---|
[713] | 152 | #endif |
---|
[313] | 153 | Void encodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
| 154 | Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
| 155 | Void encodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
[1029] | 156 | Void encodePUWise ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[313] | 157 | Void encodeInterDirPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx ); |
---|
| 158 | Void encodeRefFrmIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
| 159 | Void encodeMvdPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
| 160 | Void encodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
| 161 | Void encodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 162 | Void encodeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
| 163 | Void encodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
| 164 | Void encodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); |
---|
| 165 | Void encodeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
[1029] | 166 | Void encodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[313] | 167 | Void encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU = false ); |
---|
[1029] | 168 | |
---|
| 169 | Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 170 | |
---|
[313] | 171 | Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ); |
---|
[1029] | 172 | Void encodeQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ); |
---|
| 173 | |
---|
| 174 | Void encodeQtCbfZero ( TComTU &rTu, const ChannelType chType ); |
---|
[1307] | 175 | Void encodeQtRootCbfZero ( ); |
---|
[313] | 176 | Void encodeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 177 | Void encodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
[1029] | 178 | Void encodeChromaQpAdjustment ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); |
---|
[313] | 179 | |
---|
[1029] | 180 | Void encodeCrossComponentPrediction( TComTU &rTu, ComponentID compID ); |
---|
| 181 | |
---|
[313] | 182 | private: |
---|
[1029] | 183 | Void xEncodeTransform ( Bool& bCodeDQP, Bool& codeChromaQpAdj, TComTU &rTu ); |
---|
| 184 | |
---|
[313] | 185 | public: |
---|
[1029] | 186 | Void encodeCoeff ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& codeChromaQpAdj ); |
---|
| 187 | |
---|
| 188 | Void encodeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ); |
---|
| 189 | |
---|
| 190 | Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType ); |
---|
[1287] | 191 | |
---|
| 192 | Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, bitDepths, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);} |
---|
| 193 | |
---|
| 194 | static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); |
---|
| 195 | |
---|
[644] | 196 | #if SVC_EXTENSION |
---|
[1207] | 197 | Void encodeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow ); |
---|
[644] | 198 | #endif |
---|
[313] | 199 | };// END CLASS DEFINITION TEncEntropy |
---|
| 200 | |
---|
| 201 | //! \} |
---|
| 202 | |
---|
| 203 | #endif // __TENCENTROPY__ |
---|
| 204 | |
---|