[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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, 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 TDecTop.h |
---|
| 35 | \brief decoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TDECTOP__ |
---|
| 39 | #define __TDECTOP__ |
---|
| 40 | |
---|
| 41 | #include "TLibCommon/CommonDef.h" |
---|
| 42 | #include "TLibCommon/TComList.h" |
---|
| 43 | #include "TLibCommon/TComPicYuv.h" |
---|
| 44 | #include "TLibCommon/TComPic.h" |
---|
| 45 | #include "TLibCommon/TComTrQuant.h" |
---|
| 46 | #include "TLibCommon/SEI.h" |
---|
[713] | 47 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 48 | #include "TLibCommon/TCom3DAsymLUT.h" |
---|
| 49 | #endif |
---|
[313] | 50 | |
---|
| 51 | #include "TDecGop.h" |
---|
| 52 | #include "TDecEntropy.h" |
---|
| 53 | #include "TDecSbac.h" |
---|
| 54 | #include "TDecCAVLC.h" |
---|
| 55 | #include "SEIread.h" |
---|
| 56 | |
---|
| 57 | struct InputNALUnit; |
---|
| 58 | |
---|
| 59 | //! \ingroup TLibDecoder |
---|
| 60 | //! \{ |
---|
| 61 | |
---|
| 62 | // ==================================================================================================================== |
---|
| 63 | // Class definition |
---|
| 64 | // ==================================================================================================================== |
---|
| 65 | |
---|
| 66 | /// decoder class |
---|
| 67 | class TDecTop |
---|
| 68 | { |
---|
| 69 | private: |
---|
| 70 | Int m_iMaxRefPicNum; |
---|
| 71 | |
---|
[442] | 72 | NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture |
---|
[313] | 73 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
| 74 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
| 75 | |
---|
| 76 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
| 77 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
| 78 | TComSlice* m_apcSlicePilot; |
---|
[442] | 79 | |
---|
[313] | 80 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices |
---|
| 81 | |
---|
| 82 | // functional classes |
---|
| 83 | TComPrediction m_cPrediction; |
---|
[713] | 84 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 85 | TCom3DAsymLUT m_c3DAsymLUTPPS; |
---|
| 86 | TComPicYuv* m_pColorMappedPic; |
---|
| 87 | #endif |
---|
[313] | 88 | TComTrQuant m_cTrQuant; |
---|
| 89 | TDecGop m_cGopDecoder; |
---|
| 90 | TDecSlice m_cSliceDecoder; |
---|
| 91 | TDecCu m_cCuDecoder; |
---|
| 92 | TDecEntropy m_cEntropyDecoder; |
---|
| 93 | TDecCavlc m_cCavlcDecoder; |
---|
| 94 | TDecSbac m_cSbacDecoder; |
---|
| 95 | TDecBinCABAC m_cBinCABAC; |
---|
| 96 | SEIReader m_seiReader; |
---|
| 97 | TComLoopFilter m_cLoopFilter; |
---|
| 98 | TComSampleAdaptiveOffset m_cSAO; |
---|
| 99 | |
---|
| 100 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
| 101 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 102 | TComPic* m_pcPic; |
---|
| 103 | UInt m_uiSliceIdx; |
---|
| 104 | #if !SVC_EXTENSION |
---|
| 105 | Int m_prevPOC; |
---|
| 106 | #endif |
---|
| 107 | Bool m_bFirstSliceInPicture; |
---|
| 108 | #if !SVC_EXTENSION |
---|
| 109 | Bool m_bFirstSliceInSequence; |
---|
| 110 | #endif |
---|
[442] | 111 | Bool m_prevSliceSkipped; |
---|
| 112 | Int m_skippedPOC; |
---|
[713] | 113 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 114 | Bool m_bFirstSliceInBitstream; |
---|
| 115 | Int m_lastPOCNoOutputPriorPics; |
---|
| 116 | Bool m_isNoOutputPriorPics; |
---|
| 117 | Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic |
---|
| 118 | #endif |
---|
[815] | 119 | #if Q0177_EOS_CHECKS |
---|
| 120 | Bool m_isLastNALWasEos; |
---|
| 121 | #endif |
---|
[313] | 122 | #if SVC_EXTENSION |
---|
| 123 | static UInt m_prevPOC; // POC of the previous slice |
---|
| 124 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
| 125 | static Bool m_bFirstSliceInSequence; |
---|
| 126 | UInt m_layerId; |
---|
| 127 | UInt m_numLayer; |
---|
| 128 | TDecTop** m_ppcTDecTop; |
---|
[906] | 129 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
| 130 | Bool m_pocResettingFlag; |
---|
| 131 | Bool m_pocDecrementedInDPBFlag; |
---|
| 132 | #endif |
---|
[313] | 133 | #if AVC_BASE |
---|
| 134 | fstream* m_pBLReconFile; |
---|
[713] | 135 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 136 | Int m_iBLSourceWidth; |
---|
[713] | 137 | Int m_iBLSourceHeight; |
---|
[313] | 138 | #endif |
---|
[713] | 139 | #endif |
---|
[588] | 140 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[313] | 141 | Int m_numDirectRefLayers; |
---|
| 142 | Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 143 | Int m_numSamplePredRefLayers; |
---|
| 144 | Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 145 | Int m_numMotionPredRefLayers; |
---|
| 146 | Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 147 | Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 148 | Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 149 | #endif |
---|
[442] | 150 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
[313] | 151 | #endif |
---|
[540] | 152 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 153 | CommonDecoderParams* m_commonDecoderParams; |
---|
| 154 | #endif |
---|
[713] | 155 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[540] | 156 | Bool m_noClrasOutputFlag; |
---|
| 157 | Bool m_layerInitializedFlag; |
---|
| 158 | Bool m_firstPicInLayerDecodedFlag; |
---|
| 159 | #endif |
---|
[815] | 160 | #if POC_RESET_IDC_DECODER |
---|
| 161 | Int m_parseIdc; |
---|
| 162 | Int m_lastPocPeriodId; |
---|
| 163 | Int m_prevPicOrderCnt; |
---|
| 164 | #endif |
---|
[588] | 165 | #if RESOLUTION_BASED_DPB |
---|
[713] | 166 | Int m_subDpbIdx; // Index to the sub-DPB that the layer belongs to. |
---|
| 167 | // When new VPS is activated, this should be re-initialized to -1 |
---|
[588] | 168 | #endif |
---|
[313] | 169 | public: |
---|
[906] | 170 | #if POC_RESET_RESTRICTIONS |
---|
| 171 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
| 172 | static Int m_pocResetIdcOrCurrAu; |
---|
| 173 | static Bool m_baseLayerIdrFlag; |
---|
| 174 | static Bool m_baseLayerPicPresentFlag; |
---|
| 175 | static Bool m_baseLayerIrapFlag; |
---|
| 176 | static Bool m_nonBaseIdrPresentFlag; |
---|
| 177 | static Int m_nonBaseIdrType; |
---|
| 178 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
| 179 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
[713] | 180 | #endif |
---|
[906] | 181 | #if POC_RESET_VALUE_RESTRICTION |
---|
| 182 | static Int m_crossLayerPocResetPeriodId; |
---|
| 183 | static Int m_crossLayerPocResetIdc; |
---|
| 184 | #endif |
---|
[713] | 185 | |
---|
[313] | 186 | TDecTop(); |
---|
| 187 | virtual ~TDecTop(); |
---|
| 188 | |
---|
| 189 | Void create (); |
---|
| 190 | Void destroy (); |
---|
| 191 | |
---|
| 192 | void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
[906] | 193 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
| 194 | void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } |
---|
| 195 | #endif |
---|
[313] | 196 | |
---|
| 197 | Void init(); |
---|
| 198 | #if SVC_EXTENSION |
---|
| 199 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 200 | #else |
---|
| 201 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 202 | #endif |
---|
| 203 | |
---|
| 204 | Void deletePicBuffer(); |
---|
| 205 | |
---|
[713] | 206 | |
---|
| 207 | TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); } |
---|
| 208 | |
---|
| 209 | |
---|
[313] | 210 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
[713] | 211 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 212 | Void checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic); |
---|
| 213 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
| 214 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
| 215 | #endif |
---|
| 216 | |
---|
[313] | 217 | #if SVC_EXTENSION |
---|
[442] | 218 | #if EARLY_REF_PIC_MARKING |
---|
| 219 | Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); |
---|
| 220 | #endif |
---|
[815] | 221 | #if POC_RESET_IDC_DECODER |
---|
| 222 | Int getParseIdc() { return m_parseIdc;} |
---|
| 223 | Void setParseIdc(Int x) { m_parseIdc = x;} |
---|
| 224 | Void markAllPicsAsNoCurrAu(); |
---|
| 225 | |
---|
| 226 | Int getLastPocPeriodId() { return m_lastPocPeriodId; } |
---|
| 227 | Void setLastPocPeriodId(Int x) { m_lastPocPeriodId = x; } |
---|
| 228 | |
---|
| 229 | Int getPrevPicOrderCnt() { return m_prevPicOrderCnt; } |
---|
| 230 | Void setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; } |
---|
| 231 | #endif |
---|
[313] | 232 | UInt getLayerId () { return m_layerId; } |
---|
| 233 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
| 234 | UInt getNumLayer () { return m_numLayer; } |
---|
| 235 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
| 236 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
| 237 | Void setLayerDec(TDecTop **p) { m_ppcTDecTop = p; } |
---|
| 238 | TDecTop* getLayerDec(UInt layer) { return m_ppcTDecTop[layer]; } |
---|
| 239 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 240 | TDecTop* getRefLayerDec(UInt refLayerIdc); |
---|
| 241 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
| 242 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
| 243 | |
---|
| 244 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
| 245 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
| 246 | |
---|
| 247 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
| 248 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
| 249 | |
---|
| 250 | Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } |
---|
| 251 | Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } |
---|
| 252 | |
---|
| 253 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
| 254 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
| 255 | |
---|
| 256 | Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } |
---|
| 257 | Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } |
---|
| 258 | |
---|
| 259 | Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } |
---|
| 260 | Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } |
---|
| 261 | |
---|
| 262 | Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } |
---|
| 263 | Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } |
---|
| 264 | |
---|
| 265 | TDecTop* getSamplePredRefLayerDec ( UInt layerId ); |
---|
| 266 | TDecTop* getMotionPredRefLayerDec ( UInt layerId ); |
---|
| 267 | |
---|
| 268 | Void setRefLayerParams( TComVPS* vps ); |
---|
| 269 | #endif |
---|
| 270 | #if AVC_BASE |
---|
| 271 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
| 272 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
[713] | 273 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 274 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
| 275 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
| 276 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
| 277 | #endif |
---|
[713] | 278 | #endif |
---|
[442] | 279 | #if REPN_FORMAT_IN_VPS |
---|
| 280 | Void xInitILRP(TComSlice *slice); |
---|
| 281 | #else |
---|
| 282 | Void xInitILRP(TComSPS *pcSPS); |
---|
[313] | 283 | #endif |
---|
[595] | 284 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 285 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
| 286 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
| 287 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
[442] | 288 | #endif |
---|
[595] | 289 | #if SCALINGLIST_INFERRING |
---|
| 290 | ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } |
---|
| 291 | #endif |
---|
| 292 | #if RESOLUTION_BASED_DPB |
---|
| 293 | Void setSubDpbIdx(Int idx) { m_subDpbIdx = idx; } |
---|
| 294 | Int getSubDpbIdx() { return m_subDpbIdx; } |
---|
| 295 | Void assignSubDpbs(TComVPS *vps); |
---|
| 296 | #endif |
---|
| 297 | #endif //SVC_EXTENSION |
---|
[906] | 298 | |
---|
[313] | 299 | protected: |
---|
| 300 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
| 301 | Void xCreateLostPicture (Int iLostPOC); |
---|
| 302 | |
---|
| 303 | Void xActivateParameterSets(); |
---|
| 304 | #if SVC_EXTENSION |
---|
[442] | 305 | #if POC_RESET_FLAG |
---|
| 306 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 307 | #else |
---|
[313] | 308 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
[442] | 309 | #endif |
---|
[313] | 310 | #else |
---|
| 311 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
| 312 | #endif |
---|
| 313 | Void xDecodeVPS(); |
---|
| 314 | Void xDecodeSPS(); |
---|
[713] | 315 | Void xDecodePPS( |
---|
| 316 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 317 | TCom3DAsymLUT * pc3DAsymLUT |
---|
| 318 | #endif |
---|
| 319 | ); |
---|
[313] | 320 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
| 321 | |
---|
[540] | 322 | #if NO_CLRAS_OUTPUT_FLAG |
---|
| 323 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
| 324 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
| 325 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
| 326 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
| 327 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
| 328 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
| 329 | #endif |
---|
[713] | 330 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 331 | Void initAsymLut(TComSlice *pcSlice); |
---|
[644] | 332 | #endif |
---|
[906] | 333 | #if POC_RESET_RESTRICTIONS |
---|
| 334 | Void resetPocRestrictionCheckParameters(); |
---|
| 335 | #endif |
---|
[313] | 336 | };// END CLASS DEFINITION TDecTop |
---|
| 337 | |
---|
| 338 | |
---|
[906] | 339 | |
---|
[313] | 340 | //! \} |
---|
| 341 | |
---|
| 342 | #endif // __TDECTOP__ |
---|
| 343 | |
---|