[5] | 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-2011, 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 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 | */ |
---|
[2] | 33 | |
---|
| 34 | |
---|
[5] | 35 | |
---|
[2] | 36 | /** \file TDecEntropy.h |
---|
| 37 | \brief entropy decoder class (header) |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #ifndef __TDECENTROPY__ |
---|
| 41 | #define __TDECENTROPY__ |
---|
| 42 | |
---|
| 43 | #include "../TLibCommon/CommonDef.h" |
---|
| 44 | #include "../TLibCommon/TComBitStream.h" |
---|
| 45 | #include "../TLibCommon/TComSlice.h" |
---|
| 46 | #include "../TLibCommon/TComPic.h" |
---|
| 47 | #include "../TLibCommon/TComPrediction.h" |
---|
| 48 | #include "../TLibCommon/TComAdaptiveLoopFilter.h" |
---|
| 49 | |
---|
| 50 | class TDecSbac; |
---|
| 51 | class TDecCavlc; |
---|
| 52 | class SEImessages; |
---|
| 53 | |
---|
| 54 | // ==================================================================================================================== |
---|
| 55 | // Class definition |
---|
| 56 | // ==================================================================================================================== |
---|
| 57 | |
---|
| 58 | /// entropy decoder pure class |
---|
| 59 | class TDecEntropyIf |
---|
| 60 | { |
---|
| 61 | public: |
---|
| 62 | // Virtual list for SBAC/CAVLC |
---|
| 63 | virtual Void setAlfCtrl(Bool bAlfCtrl) = 0; |
---|
| 64 | virtual Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) = 0; |
---|
[5] | 65 | |
---|
[2] | 66 | virtual Void resetEntropy (TComSlice* pcSlice) = 0; |
---|
| 67 | virtual Void setBitstream ( TComBitstream* p ) = 0; |
---|
| 68 | |
---|
[50] | 69 | #if BITSTREAM_EXTRACTION |
---|
| 70 | virtual Void parseNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId ) = 0; |
---|
| 71 | #else |
---|
[5] | 72 | virtual Void parseNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag ) = 0; |
---|
[50] | 73 | #endif |
---|
[5] | 74 | |
---|
[2] | 75 | virtual Void parseSPS ( TComSPS* pcSPS ) = 0; |
---|
| 76 | virtual Void parsePPS ( TComPPS* pcPPS ) = 0; |
---|
| 77 | virtual void parseSEI(SEImessages&) = 0; |
---|
| 78 | virtual Void parseSliceHeader ( TComSlice*& rpcSlice ) = 0; |
---|
| 79 | virtual Void parseTerminatingBit ( UInt& ruilsLast ) = 0; |
---|
[5] | 80 | |
---|
[2] | 81 | virtual Void parseMVPIdx ( TComDataCU* pcCU, Int& riMVPIdx, Int iMVPNum, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; |
---|
[5] | 82 | |
---|
[2] | 83 | public: |
---|
| 84 | virtual Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 85 | virtual Void parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 86 | virtual Void parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0; |
---|
| 87 | virtual Void parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 88 | virtual Void parseResPredFlag ( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 89 | virtual Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 90 | virtual Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[5] | 91 | |
---|
[2] | 92 | virtual Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[5] | 93 | |
---|
[2] | 94 | virtual Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[5] | 95 | |
---|
[2] | 96 | virtual Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 97 | virtual Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; |
---|
| 98 | virtual Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartAddr, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; |
---|
[5] | 99 | |
---|
[2] | 100 | virtual Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) = 0; |
---|
| 101 | virtual Void parseQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) = 0; |
---|
| 102 | virtual Void parseQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) = 0; |
---|
[5] | 103 | |
---|
[2] | 104 | virtual Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[5] | 105 | |
---|
[2] | 106 | virtual Void parseCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) = 0; |
---|
| 107 | virtual Void parseBlockCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth, UInt uiQPartNum ) = 0; |
---|
| 108 | #if CAVLC_RQT_CBP |
---|
| 109 | virtual Void parseCbfTrdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiTrDepth, UInt uiDepth, UInt& uiSubdiv ) = 0; |
---|
| 110 | #endif |
---|
[5] | 111 | |
---|
[2] | 112 | virtual Void parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; |
---|
[5] | 113 | |
---|
[2] | 114 | virtual Void parseAlfFlag ( UInt& ruiVal ) = 0; |
---|
| 115 | virtual Void parseAlfUvlc ( UInt& ruiVal ) = 0; |
---|
| 116 | virtual Void parseAlfSvlc ( Int& riVal ) = 0; |
---|
| 117 | virtual Void parseAlfCtrlDepth ( UInt& ruiAlfCtrlDepth ) = 0; |
---|
| 118 | virtual Void parseAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 119 | #if TSB_ALF_HEADER |
---|
| 120 | virtual Void parseAlfFlagNum ( UInt& ruiVal, UInt minValue, UInt depth ) = 0; |
---|
| 121 | virtual Void parseAlfCtrlFlag ( UInt &ruiAlfCtrlFlag ) = 0; |
---|
| 122 | #endif |
---|
| 123 | |
---|
| 124 | #if MTK_SAO |
---|
| 125 | virtual Void parseAoFlag ( UInt& ruiVal ) = 0; |
---|
| 126 | virtual Void parseAoUvlc ( UInt& ruiVal ) = 0; |
---|
| 127 | virtual Void parseAoSvlc ( Int& riVal ) = 0; |
---|
| 128 | #endif |
---|
| 129 | virtual Void parseViewIdx ( Int& riViewIdx ) = 0; |
---|
| 130 | virtual ~TDecEntropyIf() {} |
---|
| 131 | }; |
---|
| 132 | |
---|
| 133 | /// entropy decoder class |
---|
| 134 | class TDecEntropy |
---|
| 135 | { |
---|
| 136 | private: |
---|
| 137 | TDecEntropyIf* m_pcEntropyDecoderIf; |
---|
| 138 | TComPrediction* m_pcPrediction; |
---|
[5] | 139 | |
---|
[2] | 140 | public: |
---|
| 141 | Void init (TComPrediction* p) {m_pcPrediction = p;} |
---|
| 142 | Void decodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList, TComDataCU* pcSubCU ); |
---|
| 143 | Void decodePUWise ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ); |
---|
| 144 | Void decodeInterDirPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ); |
---|
| 145 | Void decodeRefFrmIdxPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
| 146 | Void decodeMvdPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
| 147 | Void decodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
[5] | 148 | |
---|
[2] | 149 | Void setEntropyDecoder ( TDecEntropyIf* p ); |
---|
| 150 | Void setBitstream ( TComBitstream* p ) { m_pcEntropyDecoderIf->setBitstream(p); } |
---|
| 151 | Void resetEntropy ( TComSlice* p) { m_pcEntropyDecoderIf->resetEntropy(p); } |
---|
| 152 | |
---|
[50] | 153 | #if BITSTREAM_EXTRACTION |
---|
| 154 | Void decodeNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId ) |
---|
| 155 | { m_pcEntropyDecoderIf->parseNalUnitHeader( eNalUnitType, TemporalId, uiLayerId ); } |
---|
| 156 | #else |
---|
[5] | 157 | Void decodeNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag ) |
---|
[2] | 158 | { m_pcEntropyDecoderIf->parseNalUnitHeader(eNalUnitType, TemporalId, bOutputFlag ); } |
---|
[50] | 159 | #endif |
---|
[2] | 160 | |
---|
| 161 | Void decodeSPS ( TComSPS* pcSPS ) { m_pcEntropyDecoderIf->parseSPS(pcSPS); } |
---|
| 162 | Void decodePPS ( TComPPS* pcPPS ) { m_pcEntropyDecoderIf->parsePPS(pcPPS); } |
---|
| 163 | void decodeSEI(SEImessages& seis) { m_pcEntropyDecoderIf->parseSEI(seis); } |
---|
| 164 | Void decodeSliceHeader ( TComSlice*& rpcSlice ) { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice); } |
---|
| 165 | Void decodeTerminatingBit ( UInt& ruiIsLast ) { m_pcEntropyDecoderIf->parseTerminatingBit(ruiIsLast); } |
---|
[5] | 166 | |
---|
[2] | 167 | // Adaptive Loop filter |
---|
| 168 | Void decodeAlfParam(ALFParam* pAlfParam); |
---|
| 169 | //--Adaptive Loop filter |
---|
[5] | 170 | |
---|
[2] | 171 | TDecEntropyIf* getEntropyDecoder() { return m_pcEntropyDecoderIf; } |
---|
[5] | 172 | |
---|
[2] | 173 | public: |
---|
| 174 | Void decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 175 | Void decodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 176 | Void decodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ); |
---|
| 177 | Void decodeMergeIndex ( TComDataCU* pcSubCU, UInt uiPartIdx, UInt uiPartAddr, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ); |
---|
[5] | 178 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 179 | Void decodeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ); |
---|
[5] | 180 | #endif |
---|
[2] | 181 | Void decodeAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 182 | #if TSB_ALF_HEADER |
---|
| 183 | Void decodeAlfCtrlParam ( ALFParam *pAlfParam ); |
---|
| 184 | #endif |
---|
[5] | 185 | |
---|
[2] | 186 | Void decodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 187 | Void decodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[5] | 188 | |
---|
[2] | 189 | Void decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ); |
---|
[5] | 190 | |
---|
[2] | 191 | Void decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 192 | Void decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 193 | Void decodeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 194 | Void decodeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ); |
---|
| 195 | Void decodeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ); |
---|
| 196 | Void decodeRefViewIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ); |
---|
| 197 | // |
---|
| 198 | Void decodeTransformIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 199 | Void decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[5] | 200 | |
---|
[2] | 201 | Void decodeViewidx ( Int& riViewIdx ); |
---|
[5] | 202 | |
---|
| 203 | |
---|
[2] | 204 | private: |
---|
| 205 | Void xDecodeTransformSubdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ); |
---|
[5] | 206 | |
---|
[2] | 207 | Void xDecodeCoeff ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType ); |
---|
| 208 | public: |
---|
| 209 | Void decodeCoeff ( TComDataCU* pcCU , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight ); |
---|
[5] | 210 | |
---|
[2] | 211 | // ALF-related |
---|
| 212 | Void decodeAux(ALFParam* pAlfParam); |
---|
| 213 | Void decodeFilt(ALFParam* pAlfParam); |
---|
| 214 | Void readFilterCodingParams(ALFParam* pAlfParam); |
---|
| 215 | Void readFilterCoeffs(ALFParam* pAlfParam); |
---|
| 216 | Void decodeFilterCoeff (ALFParam* pAlfParam); |
---|
| 217 | Int golombDecode(Int k); |
---|
| 218 | |
---|
| 219 | #if MTK_SAO |
---|
| 220 | Void decodeQAOOnePart(SAOParam* pQaoParam, Int part_idx); |
---|
| 221 | Void decodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int part_idx); |
---|
| 222 | Void decodeSaoParam(SAOParam* pQaoParam) ; |
---|
| 223 | #endif |
---|
| 224 | |
---|
| 225 | };// END CLASS DEFINITION TDecEntropy |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | #endif // __TDECENTROPY__ |
---|
| 229 | |
---|