[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | /** \file TDecEntropy.h |
---|
| 35 | \brief entropy decoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TDECENTROPY__ |
---|
| 39 | #define __TDECENTROPY__ |
---|
| 40 | |
---|
| 41 | #include "../TLibCommon/CommonDef.h" |
---|
| 42 | #include "../TLibCommon/TComBitStream.h" |
---|
| 43 | #include "../TLibCommon/TComSlice.h" |
---|
| 44 | #include "../TLibCommon/TComPic.h" |
---|
| 45 | #include "../TLibCommon/TComPrediction.h" |
---|
| 46 | #include "../TLibCommon/TComAdaptiveLoopFilter.h" |
---|
[56] | 47 | #include "../TLibCommon/TComSampleAdaptiveOffset.h" |
---|
[2] | 48 | |
---|
| 49 | class TDecSbac; |
---|
| 50 | class TDecCavlc; |
---|
| 51 | class SEImessages; |
---|
[56] | 52 | class ParameterSetManagerDecoder; |
---|
[2] | 53 | |
---|
[56] | 54 | //! \ingroup TLibDecoder |
---|
| 55 | //! \{ |
---|
| 56 | |
---|
[2] | 57 | // ==================================================================================================================== |
---|
| 58 | // Class definition |
---|
| 59 | // ==================================================================================================================== |
---|
| 60 | |
---|
| 61 | /// entropy decoder pure class |
---|
| 62 | class TDecEntropyIf |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | // Virtual list for SBAC/CAVLC |
---|
[56] | 66 | virtual Void resetEntropy ( TComSlice* pcSlice ) = 0; |
---|
| 67 | virtual Void setBitstream ( TComInputBitstream* p ) = 0; |
---|
[5] | 68 | |
---|
[56] | 69 | #if OL_FLUSH |
---|
| 70 | virtual Void decodeFlush() = 0; |
---|
| 71 | #endif |
---|
[2] | 72 | |
---|
[77] | 73 | #if VIDYO_VPS_INTEGRATION |
---|
| 74 | virtual Void parseVPS ( TComVPS* pcVPS ) = 0; |
---|
| 75 | #endif |
---|
[56] | 76 | #if HHI_MPI |
---|
| 77 | virtual Void parseSPS ( TComSPS* pcSPS, Bool bIsDepth ) = 0; |
---|
[42] | 78 | #else |
---|
[56] | 79 | virtual Void parseSPS ( TComSPS* pcSPS ) = 0; |
---|
[42] | 80 | #endif |
---|
[56] | 81 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 82 | virtual Void parsePPS ( TComPPS* pcPPS, ParameterSetManagerDecoder *parameterSet ) = 0; |
---|
| 83 | #else |
---|
[2] | 84 | virtual Void parsePPS ( TComPPS* pcPPS ) = 0; |
---|
[56] | 85 | #endif |
---|
| 86 | virtual Void parseAPS ( TComAPS* pAPS ) = 0; |
---|
[2] | 87 | virtual void parseSEI(SEImessages&) = 0; |
---|
[5] | 88 | |
---|
[56] | 89 | #if LCU_SYNTAX_ALF |
---|
| 90 | virtual Void parseSliceHeader ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl, AlfParamSet& alfParamSet) = 0; |
---|
| 91 | #else |
---|
| 92 | virtual Void parseSliceHeader ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl ) = 0; |
---|
| 93 | #endif |
---|
[5] | 94 | |
---|
[56] | 95 | virtual Void parseTerminatingBit ( UInt& ruilsLast ) = 0; |
---|
| 96 | |
---|
| 97 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 98 | virtual Void parseMVPIdx ( Int& riMVPIdx, Int iNumAMVPCands ) = 0; |
---|
| 99 | #else |
---|
| 100 | virtual Void parseMVPIdx ( Int& riMVPIdx ) = 0; |
---|
| 101 | #endif |
---|
| 102 | |
---|
[2] | 103 | public: |
---|
| 104 | virtual Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[152] | 105 | #if LGE_ILLUCOMP_B0045 |
---|
| 106 | virtual Void parseICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 107 | #endif |
---|
[2] | 108 | virtual Void parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 109 | virtual Void parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0; |
---|
| 110 | virtual Void parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 111 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 112 | virtual Void parseResPredFlag ( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 113 | #endif |
---|
[2] | 114 | virtual Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 115 | virtual Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 116 | |
---|
[2] | 117 | virtual Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 118 | |
---|
[2] | 119 | virtual Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 120 | |
---|
[2] | 121 | virtual Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
| 122 | virtual Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; |
---|
| 123 | virtual Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartAddr, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; |
---|
[56] | 124 | |
---|
[2] | 125 | virtual Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) = 0; |
---|
| 126 | virtual Void parseQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) = 0; |
---|
| 127 | virtual Void parseQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) = 0; |
---|
[56] | 128 | |
---|
[2] | 129 | virtual Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; |
---|
[56] | 130 | |
---|
| 131 | virtual Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) = 0; |
---|
[5] | 132 | |
---|
[2] | 133 | virtual Void parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; |
---|
[5] | 134 | |
---|
[56] | 135 | /// set slice granularity |
---|
| 136 | virtual Void setSliceGranularity(Int iSliceGranularity) = 0; |
---|
[2] | 137 | |
---|
[56] | 138 | /// get slice granularity |
---|
| 139 | virtual Int getSliceGranularity() = 0; |
---|
| 140 | |
---|
| 141 | virtual Void readTileMarker ( UInt& uiTileIdx, UInt uiBitsUsed ) = 0; |
---|
| 142 | virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0; |
---|
| 143 | |
---|
[2] | 144 | virtual ~TDecEntropyIf() {} |
---|
| 145 | }; |
---|
| 146 | |
---|
| 147 | /// entropy decoder class |
---|
| 148 | class TDecEntropy |
---|
| 149 | { |
---|
| 150 | private: |
---|
| 151 | TDecEntropyIf* m_pcEntropyDecoderIf; |
---|
| 152 | TComPrediction* m_pcPrediction; |
---|
[56] | 153 | UInt m_uiBakAbsPartIdx; |
---|
| 154 | UInt m_uiBakChromaOffset; |
---|
| 155 | #if UNIFIED_TRANSFORM_TREE |
---|
| 156 | UInt m_bakAbsPartIdxCU; |
---|
| 157 | #endif |
---|
| 158 | |
---|
[2] | 159 | public: |
---|
| 160 | Void init (TComPrediction* p) {m_pcPrediction = p;} |
---|
| 161 | Void decodePUWise ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ); |
---|
| 162 | Void decodeInterDirPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ); |
---|
| 163 | Void decodeRefFrmIdxPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
| 164 | Void decodeMvdPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
| 165 | Void decodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); |
---|
[56] | 166 | |
---|
[2] | 167 | Void setEntropyDecoder ( TDecEntropyIf* p ); |
---|
[56] | 168 | Void setBitstream ( TComInputBitstream* p ) { m_pcEntropyDecoderIf->setBitstream(p); } |
---|
[2] | 169 | Void resetEntropy ( TComSlice* p) { m_pcEntropyDecoderIf->resetEntropy(p); } |
---|
| 170 | |
---|
[77] | 171 | #if VIDYO_VPS_INTEGRATION |
---|
| 172 | Void decodeVPS ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); } |
---|
| 173 | #endif |
---|
| 174 | |
---|
[56] | 175 | #if HHI_MPI |
---|
| 176 | Void decodeSPS ( TComSPS* pcSPS, Bool bIsDepth ) { m_pcEntropyDecoderIf->parseSPS(pcSPS, bIsDepth); } |
---|
[42] | 177 | #else |
---|
[56] | 178 | Void decodeSPS ( TComSPS* pcSPS ) { m_pcEntropyDecoderIf->parseSPS(pcSPS); } |
---|
[42] | 179 | #endif |
---|
[56] | 180 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 181 | Void decodePPS ( TComPPS* pcPPS, ParameterSetManagerDecoder *parameterSet ) { m_pcEntropyDecoderIf->parsePPS(pcPPS, parameterSet); } |
---|
| 182 | #else |
---|
[2] | 183 | Void decodePPS ( TComPPS* pcPPS ) { m_pcEntropyDecoderIf->parsePPS(pcPPS); } |
---|
[56] | 184 | #endif |
---|
| 185 | Void decodeAPS ( TComAPS* pAPS ) { m_pcEntropyDecoderIf->parseAPS(pAPS);} |
---|
[2] | 186 | void decodeSEI(SEImessages& seis) { m_pcEntropyDecoderIf->parseSEI(seis); } |
---|
[5] | 187 | |
---|
[56] | 188 | #if LCU_SYNTAX_ALF |
---|
| 189 | Void decodeSliceHeader ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl, AlfParamSet& alfParamSet) { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager, alfCUCtrl, alfParamSet); } |
---|
| 190 | #else |
---|
| 191 | Void decodeSliceHeader ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl ) { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager, alfCUCtrl); } |
---|
| 192 | #endif |
---|
[5] | 193 | |
---|
[56] | 194 | Void decodeTerminatingBit ( UInt& ruiIsLast ) { m_pcEntropyDecoderIf->parseTerminatingBit(ruiIsLast); } |
---|
| 195 | |
---|
[2] | 196 | TDecEntropyIf* getEntropyDecoder() { return m_pcEntropyDecoderIf; } |
---|
[56] | 197 | |
---|
[2] | 198 | public: |
---|
| 199 | Void decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 200 | Void decodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[152] | 201 | #if LGE_ILLUCOMP_B0045 |
---|
| 202 | Void decodeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 203 | #endif |
---|
[2] | 204 | Void decodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ); |
---|
| 205 | Void decodeMergeIndex ( TComDataCU* pcSubCU, UInt uiPartIdx, UInt uiPartAddr, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ); |
---|
[5] | 206 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 207 | Void decodeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ); |
---|
[5] | 208 | #endif |
---|
[2] | 209 | Void decodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 210 | Void decodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[56] | 211 | |
---|
| 212 | Void decodeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[5] | 213 | |
---|
[2] | 214 | Void decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ); |
---|
[56] | 215 | |
---|
[2] | 216 | Void decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 217 | Void decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[56] | 218 | |
---|
| 219 | #if !UNIFIED_TRANSFORM_TREE |
---|
[2] | 220 | Void decodeTransformIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[56] | 221 | #endif |
---|
| 222 | #if UNIFIED_TRANSFORM_TREE |
---|
| 223 | Void decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 224 | #else |
---|
[2] | 225 | Void decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
[56] | 226 | #endif |
---|
| 227 | |
---|
| 228 | Void readTileMarker ( UInt& uiTileIdx, UInt uiBitsUsed ) { m_pcEntropyDecoderIf->readTileMarker( uiTileIdx, uiBitsUsed ); } |
---|
| 229 | Void updateContextTables ( SliceType eSliceType, Int iQp ) { m_pcEntropyDecoderIf->updateContextTables( eSliceType, iQp ); } |
---|
| 230 | |
---|
| 231 | |
---|
[2] | 232 | private: |
---|
[56] | 233 | #if UNIFIED_TRANSFORM_TREE |
---|
| 234 | Void xDecodeTransform ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP ); |
---|
| 235 | #else |
---|
| 236 | Void xDecodeTransformSubdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ); |
---|
| 237 | |
---|
| 238 | Void xDecodeCoeff ( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP ); |
---|
| 239 | #endif //UNIFIED_TRANSFORM_TREE |
---|
[5] | 240 | |
---|
[2] | 241 | public: |
---|
[56] | 242 | Void decodeCoeff ( TComDataCU* pcCU , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ); |
---|
| 243 | |
---|
[2] | 244 | // ALF-related |
---|
| 245 | |
---|
[56] | 246 | /// set slice granularity |
---|
| 247 | Void setSliceGranularity (Int iSliceGranularity) {m_pcEntropyDecoderIf->setSliceGranularity(iSliceGranularity);} |
---|
| 248 | |
---|
| 249 | #if SAO_UNIT_INTERLEAVING |
---|
| 250 | Void decodeSaoParam (SAOParam* saoParam); |
---|
| 251 | void decodeSaoLcu(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Bool &repeatedRow ); |
---|
| 252 | Void decodeSaoOneLcu(SaoLcuParam* saoLcuParam); |
---|
[2] | 253 | #endif |
---|
| 254 | |
---|
[56] | 255 | #if OL_FLUSH |
---|
| 256 | Void decodeFlush() { m_pcEntropyDecoderIf->decodeFlush(); } |
---|
| 257 | #endif |
---|
| 258 | |
---|
[2] | 259 | };// END CLASS DEFINITION TDecEntropy |
---|
| 260 | |
---|
[56] | 261 | //! \} |
---|
[2] | 262 | |
---|
| 263 | #endif // __TDECENTROPY__ |
---|
| 264 | |
---|