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