[324] | 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-2013, ITU/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 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 TDecSbac.h |
---|
| 35 | \brief SBAC decoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TDECSBAC__ |
---|
| 39 | #define __TDECSBAC__ |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | #if _MSC_VER > 1000 |
---|
| 43 | #pragma once |
---|
| 44 | #endif // _MSC_VER > 1000 |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | #include "TDecEntropy.h" |
---|
| 48 | #include "TDecBinCoder.h" |
---|
| 49 | #include "TLibCommon/ContextTables.h" |
---|
| 50 | #include "TLibCommon/ContextModel.h" |
---|
| 51 | #include "TLibCommon/ContextModel3DBuffer.h" |
---|
| 52 | |
---|
| 53 | //! \ingroup TLibDecoder |
---|
| 54 | //! \{ |
---|
| 55 | |
---|
| 56 | // ==================================================================================================================== |
---|
| 57 | // Class definition |
---|
| 58 | // ==================================================================================================================== |
---|
| 59 | |
---|
| 60 | /// SBAC decoder class |
---|
| 61 | class TDecSbac : public TDecEntropyIf |
---|
| 62 | { |
---|
| 63 | public: |
---|
| 64 | TDecSbac(); |
---|
| 65 | virtual ~TDecSbac(); |
---|
| 66 | |
---|
| 67 | Void init ( TDecBinIf* p ) { m_pcTDecBinIf = p; } |
---|
| 68 | Void uninit ( ) { m_pcTDecBinIf = 0; } |
---|
| 69 | |
---|
| 70 | Void load ( TDecSbac* pScr ); |
---|
| 71 | Void loadContexts ( TDecSbac* pScr ); |
---|
| 72 | Void xCopyFrom ( TDecSbac* pSrc ); |
---|
| 73 | Void xCopyContextsFrom ( TDecSbac* pSrc ); |
---|
| 74 | |
---|
| 75 | Void resetEntropy (TComSlice* pSlice ); |
---|
| 76 | Void setBitstream ( TComInputBitstream* p ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); } |
---|
| 77 | Void parseVPS ( TComVPS* /*pcVPS*/ ) {} |
---|
[446] | 78 | #if H_3D |
---|
| 79 | Void parseSPS ( TComSPS* /*pcSPS*/ , Int /*viewIndex*/, Bool /*depthFlag*/ ) {} |
---|
| 80 | #else |
---|
[324] | 81 | Void parseSPS ( TComSPS* /*pcSPS*/ ) {} |
---|
[446] | 82 | #endif |
---|
[324] | 83 | Void parsePPS ( TComPPS* /*pcPPS*/ ) {} |
---|
| 84 | |
---|
| 85 | Void parseSliceHeader ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {} |
---|
| 86 | Void parseTerminatingBit ( UInt& ruiBit ); |
---|
| 87 | Void parseMVPIdx ( Int& riMVPIdx ); |
---|
| 88 | Void parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ); |
---|
| 89 | Void parseSaoMerge ( UInt& ruiVal ); |
---|
| 90 | Void parseSaoTypeIdx ( UInt& ruiVal ); |
---|
| 91 | Void parseSaoUflc ( UInt uiLength, UInt& ruiVal ); |
---|
| 92 | Void parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp); |
---|
| 93 | Void parseSaoOffset (SaoLcuParam* psSaoLcuParam, UInt compIdx); |
---|
| 94 | private: |
---|
| 95 | Void xReadUnarySymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ); |
---|
| 96 | Void xReadUnaryMaxSymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ); |
---|
| 97 | Void xReadEpExGolomb ( UInt& ruiSymbol, UInt uiCount ); |
---|
| 98 | Void xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ); |
---|
[531] | 99 | #if H_3D_DIM |
---|
| 100 | Void xReadExGolombLevel ( UInt& ruiSymbol, ContextModel& rcSCModel ); |
---|
| 101 | Void xParseDimDeltaDC ( Pel& rValDeltaDC, UInt dimType ); |
---|
| 102 | #if H_3D_DIM_DMM |
---|
| 103 | Void xParseDmm1WedgeIdx ( UInt& ruiTabIdx, Int iNumBit ); |
---|
[554] | 104 | #if !SEC_DMM2_E0146 |
---|
[531] | 105 | Void xParseDmm2Offset ( Int& riOffset ); |
---|
[554] | 106 | #endif |
---|
[531] | 107 | Void xParseDmm3WedgeIdx ( UInt& ruiIntraIdx, Int iNumBit ); |
---|
| 108 | #endif |
---|
| 109 | #if H_3D_DIM_RBC |
---|
| 110 | Void xParseRbcEdge ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 111 | #endif |
---|
| 112 | #if H_3D_DIM_SDC |
---|
| 113 | Void xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ); |
---|
| 114 | #endif |
---|
| 115 | #endif |
---|
[324] | 116 | private: |
---|
| 117 | TComInputBitstream* m_pcBitstream; |
---|
| 118 | TDecBinIf* m_pcTDecBinIf; |
---|
| 119 | |
---|
| 120 | public: |
---|
| 121 | |
---|
| 122 | Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 123 | Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 124 | Void parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 125 | Void parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ); |
---|
| 126 | Void parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ); |
---|
[504] | 127 | #if H_3D_ARP |
---|
| 128 | Void parseARPW ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 129 | #endif |
---|
| 130 | #if H_3D_IC |
---|
| 131 | Void parseICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 132 | #endif |
---|
[324] | 133 | Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 134 | Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 135 | |
---|
| 136 | Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 137 | |
---|
| 138 | Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 139 | |
---|
[531] | 140 | #if H_3D_DIM |
---|
| 141 | Void parseIntraDepth ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ); |
---|
| 142 | Void parseIntraDepthMode ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ); |
---|
| 143 | #endif |
---|
| 144 | |
---|
[324] | 145 | Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ); |
---|
| 146 | Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ); |
---|
| 147 | Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ); |
---|
| 148 | |
---|
| 149 | Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ); |
---|
| 150 | Void parseQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ); |
---|
| 151 | Void parseQtRootCbf ( UInt uiAbsPartIdx, UInt& uiQtRootCbf ); |
---|
| 152 | |
---|
| 153 | Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 154 | |
---|
| 155 | Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth); |
---|
| 156 | |
---|
| 157 | Void parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ); |
---|
| 158 | Void parseCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ); |
---|
| 159 | Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType); |
---|
| 160 | |
---|
| 161 | Void updateContextTables( SliceType eSliceType, Int iQp ); |
---|
| 162 | |
---|
| 163 | Void parseScalingList ( TComScalingList* /*scalingList*/ ) {} |
---|
| 164 | |
---|
| 165 | private: |
---|
| 166 | UInt m_uiLastDQpNonZero; |
---|
| 167 | UInt m_uiLastQp; |
---|
| 168 | |
---|
| 169 | ContextModel m_contextModels[MAX_NUM_CTX_MOD]; |
---|
| 170 | Int m_numContextModels; |
---|
| 171 | ContextModel3DBuffer m_cCUSplitFlagSCModel; |
---|
| 172 | ContextModel3DBuffer m_cCUSkipFlagSCModel; |
---|
| 173 | ContextModel3DBuffer m_cCUMergeFlagExtSCModel; |
---|
| 174 | ContextModel3DBuffer m_cCUMergeIdxExtSCModel; |
---|
[504] | 175 | #if H_3D_ARP |
---|
| 176 | ContextModel3DBuffer m_cCUPUARPWSCModel; |
---|
| 177 | #endif |
---|
| 178 | #if H_3D_IC |
---|
| 179 | ContextModel3DBuffer m_cCUICFlagSCModel; |
---|
| 180 | #endif |
---|
[324] | 181 | ContextModel3DBuffer m_cCUPartSizeSCModel; |
---|
| 182 | ContextModel3DBuffer m_cCUPredModeSCModel; |
---|
| 183 | ContextModel3DBuffer m_cCUIntraPredSCModel; |
---|
| 184 | ContextModel3DBuffer m_cCUChromaPredSCModel; |
---|
| 185 | ContextModel3DBuffer m_cCUDeltaQpSCModel; |
---|
| 186 | ContextModel3DBuffer m_cCUInterDirSCModel; |
---|
| 187 | ContextModel3DBuffer m_cCURefPicSCModel; |
---|
| 188 | ContextModel3DBuffer m_cCUMvdSCModel; |
---|
| 189 | ContextModel3DBuffer m_cCUQtCbfSCModel; |
---|
| 190 | ContextModel3DBuffer m_cCUTransSubdivFlagSCModel; |
---|
| 191 | ContextModel3DBuffer m_cCUQtRootCbfSCModel; |
---|
| 192 | |
---|
| 193 | ContextModel3DBuffer m_cCUSigCoeffGroupSCModel; |
---|
| 194 | ContextModel3DBuffer m_cCUSigSCModel; |
---|
| 195 | ContextModel3DBuffer m_cCuCtxLastX; |
---|
| 196 | ContextModel3DBuffer m_cCuCtxLastY; |
---|
| 197 | ContextModel3DBuffer m_cCUOneSCModel; |
---|
| 198 | ContextModel3DBuffer m_cCUAbsSCModel; |
---|
| 199 | |
---|
| 200 | ContextModel3DBuffer m_cMVPIdxSCModel; |
---|
| 201 | |
---|
| 202 | ContextModel3DBuffer m_cCUAMPSCModel; |
---|
| 203 | ContextModel3DBuffer m_cSaoMergeSCModel; |
---|
| 204 | ContextModel3DBuffer m_cSaoTypeIdxSCModel; |
---|
| 205 | ContextModel3DBuffer m_cTransformSkipSCModel; |
---|
| 206 | ContextModel3DBuffer m_CUTransquantBypassFlagSCModel; |
---|
[531] | 207 | |
---|
| 208 | #if H_3D_DIM |
---|
| 209 | ContextModel3DBuffer m_cDepthIntraModeSCModel; |
---|
| 210 | ContextModel3DBuffer m_cDdcFlagSCModel; |
---|
| 211 | ContextModel3DBuffer m_cDdcDataSCModel; |
---|
| 212 | #if H_3D_DIM_DMM |
---|
| 213 | ContextModel3DBuffer m_cDmm1DataSCModel; |
---|
[554] | 214 | #if !SEC_DMM2_E0146 |
---|
[531] | 215 | ContextModel3DBuffer m_cDmm2DataSCModel; |
---|
[554] | 216 | #endif |
---|
[531] | 217 | ContextModel3DBuffer m_cDmm3DataSCModel; |
---|
| 218 | #endif |
---|
| 219 | #if H_3D_DIM_RBC |
---|
| 220 | ContextModel3DBuffer m_cRbcDataSCModel; |
---|
| 221 | #endif |
---|
| 222 | #if H_3D_DIM_SDC |
---|
| 223 | ContextModel3DBuffer m_cSDCResidualFlagSCModel; |
---|
| 224 | ContextModel3DBuffer m_cSDCResidualSCModel; |
---|
| 225 | #endif |
---|
| 226 | #endif |
---|
[324] | 227 | }; |
---|
| 228 | |
---|
| 229 | //! \} |
---|
| 230 | |
---|
| 231 | #endif // !defined(AFX_TDECSBAC_H__CFCAAA19_8110_47F4_9A16_810C4B5499D5__INCLUDED_) |
---|