[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 |
---|
[916] | 4 | * granted under this license. |
---|
[313] | 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; |
---|
[916] | 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 |
---|
[916] | 77 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
[313] | 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 | Bool m_bFirstSliceInBitstream; |
---|
| 114 | Int m_lastPOCNoOutputPriorPics; |
---|
| 115 | Bool m_isNoOutputPriorPics; |
---|
| 116 | Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic |
---|
[916] | 117 | #if O0043_BEST_EFFORT_DECODING |
---|
| 118 | UInt m_forceDecodeBitDepth; |
---|
[713] | 119 | #endif |
---|
[916] | 120 | std::ostream *m_pDecodedSEIOutputStream; |
---|
| 121 | |
---|
| 122 | #if SVC_EXTENSION |
---|
[815] | 123 | #if Q0177_EOS_CHECKS |
---|
| 124 | Bool m_isLastNALWasEos; |
---|
| 125 | #endif |
---|
[313] | 126 | static UInt m_prevPOC; // POC of the previous slice |
---|
| 127 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
| 128 | static Bool m_bFirstSliceInSequence; |
---|
| 129 | UInt m_layerId; |
---|
| 130 | UInt m_numLayer; |
---|
| 131 | TDecTop** m_ppcTDecTop; |
---|
[903] | 132 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
| 133 | Bool m_pocResettingFlag; |
---|
| 134 | Bool m_pocDecrementedInDPBFlag; |
---|
| 135 | #endif |
---|
[313] | 136 | #if AVC_BASE |
---|
| 137 | fstream* m_pBLReconFile; |
---|
[713] | 138 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 139 | Int m_iBLSourceWidth; |
---|
[713] | 140 | Int m_iBLSourceHeight; |
---|
[313] | 141 | #endif |
---|
[713] | 142 | #endif |
---|
[588] | 143 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[313] | 144 | Int m_numDirectRefLayers; |
---|
| 145 | Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 146 | Int m_numSamplePredRefLayers; |
---|
| 147 | Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 148 | Int m_numMotionPredRefLayers; |
---|
| 149 | Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 150 | Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 151 | Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 152 | #endif |
---|
[442] | 153 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
[313] | 154 | #endif |
---|
[540] | 155 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 156 | CommonDecoderParams* m_commonDecoderParams; |
---|
| 157 | #endif |
---|
[713] | 158 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[540] | 159 | Bool m_noClrasOutputFlag; |
---|
| 160 | Bool m_layerInitializedFlag; |
---|
| 161 | Bool m_firstPicInLayerDecodedFlag; |
---|
| 162 | #endif |
---|
[815] | 163 | #if POC_RESET_IDC_DECODER |
---|
| 164 | Int m_parseIdc; |
---|
| 165 | Int m_lastPocPeriodId; |
---|
| 166 | Int m_prevPicOrderCnt; |
---|
| 167 | #endif |
---|
[588] | 168 | #if RESOLUTION_BASED_DPB |
---|
[713] | 169 | Int m_subDpbIdx; // Index to the sub-DPB that the layer belongs to. |
---|
| 170 | // When new VPS is activated, this should be re-initialized to -1 |
---|
[588] | 171 | #endif |
---|
[313] | 172 | public: |
---|
[851] | 173 | #if POC_RESET_RESTRICTIONS |
---|
| 174 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
| 175 | static Int m_pocResetIdcOrCurrAu; |
---|
| 176 | static Bool m_baseLayerIdrFlag; |
---|
| 177 | static Bool m_baseLayerPicPresentFlag; |
---|
| 178 | static Bool m_baseLayerIrapFlag; |
---|
| 179 | static Bool m_nonBaseIdrPresentFlag; |
---|
| 180 | static Int m_nonBaseIdrType; |
---|
| 181 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
| 182 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
| 183 | #endif |
---|
[854] | 184 | #if POC_RESET_VALUE_RESTRICTION |
---|
| 185 | static Int m_crossLayerPocResetPeriodId; |
---|
| 186 | static Int m_crossLayerPocResetIdc; |
---|
| 187 | #endif |
---|
[851] | 188 | |
---|
[313] | 189 | TDecTop(); |
---|
| 190 | virtual ~TDecTop(); |
---|
[916] | 191 | |
---|
[313] | 192 | Void create (); |
---|
| 193 | Void destroy (); |
---|
| 194 | |
---|
[916] | 195 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
[856] | 196 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
| 197 | void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } |
---|
| 198 | #endif |
---|
[313] | 199 | |
---|
| 200 | Void init(); |
---|
| 201 | #if SVC_EXTENSION |
---|
| 202 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 203 | #else |
---|
| 204 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 205 | #endif |
---|
| 206 | |
---|
| 207 | Void deletePicBuffer(); |
---|
| 208 | |
---|
[713] | 209 | |
---|
| 210 | TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); } |
---|
| 211 | |
---|
| 212 | |
---|
[916] | 213 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
| 214 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
| 215 | |
---|
| 216 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
[713] | 217 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
[916] | 218 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
| 219 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
| 220 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
| 221 | #if O0043_BEST_EFFORT_DECODING |
---|
| 222 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
[713] | 223 | #endif |
---|
[916] | 224 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
[713] | 225 | |
---|
[313] | 226 | #if SVC_EXTENSION |
---|
[442] | 227 | #if EARLY_REF_PIC_MARKING |
---|
| 228 | Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); |
---|
| 229 | #endif |
---|
[815] | 230 | #if POC_RESET_IDC_DECODER |
---|
| 231 | Int getParseIdc() { return m_parseIdc;} |
---|
| 232 | Void setParseIdc(Int x) { m_parseIdc = x;} |
---|
| 233 | Void markAllPicsAsNoCurrAu(); |
---|
| 234 | |
---|
| 235 | Int getLastPocPeriodId() { return m_lastPocPeriodId; } |
---|
| 236 | Void setLastPocPeriodId(Int x) { m_lastPocPeriodId = x; } |
---|
| 237 | |
---|
| 238 | Int getPrevPicOrderCnt() { return m_prevPicOrderCnt; } |
---|
| 239 | Void setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; } |
---|
| 240 | #endif |
---|
[313] | 241 | UInt getLayerId () { return m_layerId; } |
---|
| 242 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
| 243 | UInt getNumLayer () { return m_numLayer; } |
---|
| 244 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
| 245 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
| 246 | Void setLayerDec(TDecTop **p) { m_ppcTDecTop = p; } |
---|
| 247 | TDecTop* getLayerDec(UInt layer) { return m_ppcTDecTop[layer]; } |
---|
| 248 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 249 | TDecTop* getRefLayerDec(UInt refLayerIdc); |
---|
| 250 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
| 251 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
| 252 | |
---|
| 253 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
| 254 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
| 255 | |
---|
| 256 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
| 257 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
| 258 | |
---|
| 259 | Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } |
---|
| 260 | Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } |
---|
| 261 | |
---|
| 262 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
| 263 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
| 264 | |
---|
| 265 | Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } |
---|
| 266 | Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } |
---|
| 267 | |
---|
| 268 | Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } |
---|
| 269 | Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } |
---|
| 270 | |
---|
| 271 | Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } |
---|
| 272 | Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } |
---|
| 273 | |
---|
| 274 | TDecTop* getSamplePredRefLayerDec ( UInt layerId ); |
---|
| 275 | TDecTop* getMotionPredRefLayerDec ( UInt layerId ); |
---|
| 276 | |
---|
| 277 | Void setRefLayerParams( TComVPS* vps ); |
---|
| 278 | #endif |
---|
| 279 | #if AVC_BASE |
---|
| 280 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
| 281 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
[713] | 282 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 283 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
| 284 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
| 285 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
| 286 | #endif |
---|
[713] | 287 | #endif |
---|
[442] | 288 | #if REPN_FORMAT_IN_VPS |
---|
| 289 | Void xInitILRP(TComSlice *slice); |
---|
| 290 | #else |
---|
| 291 | Void xInitILRP(TComSPS *pcSPS); |
---|
[313] | 292 | #endif |
---|
[595] | 293 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 294 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
| 295 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
| 296 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
[442] | 297 | #endif |
---|
[595] | 298 | #if SCALINGLIST_INFERRING |
---|
| 299 | ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } |
---|
| 300 | #endif |
---|
| 301 | #if RESOLUTION_BASED_DPB |
---|
| 302 | Void setSubDpbIdx(Int idx) { m_subDpbIdx = idx; } |
---|
| 303 | Int getSubDpbIdx() { return m_subDpbIdx; } |
---|
| 304 | Void assignSubDpbs(TComVPS *vps); |
---|
| 305 | #endif |
---|
| 306 | #endif //SVC_EXTENSION |
---|
[820] | 307 | |
---|
[313] | 308 | protected: |
---|
| 309 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
| 310 | Void xCreateLostPicture (Int iLostPOC); |
---|
| 311 | |
---|
| 312 | Void xActivateParameterSets(); |
---|
| 313 | #if SVC_EXTENSION |
---|
[442] | 314 | #if POC_RESET_FLAG |
---|
| 315 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 316 | #else |
---|
[313] | 317 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
[442] | 318 | #endif |
---|
[313] | 319 | #else |
---|
| 320 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
| 321 | #endif |
---|
| 322 | Void xDecodeVPS(); |
---|
| 323 | Void xDecodeSPS(); |
---|
[713] | 324 | Void xDecodePPS( |
---|
| 325 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 326 | TCom3DAsymLUT * pc3DAsymLUT |
---|
| 327 | #endif |
---|
| 328 | ); |
---|
[313] | 329 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
| 330 | |
---|
[540] | 331 | #if NO_CLRAS_OUTPUT_FLAG |
---|
| 332 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
| 333 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
| 334 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
| 335 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
| 336 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
| 337 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
| 338 | #endif |
---|
[713] | 339 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 340 | Void initAsymLut(TComSlice *pcSlice); |
---|
[644] | 341 | #endif |
---|
[851] | 342 | #if POC_RESET_RESTRICTIONS |
---|
| 343 | Void resetPocRestrictionCheckParameters(); |
---|
| 344 | #endif |
---|
[313] | 345 | };// END CLASS DEFINITION TDecTop |
---|
| 346 | |
---|
| 347 | |
---|
| 348 | //! \} |
---|
| 349 | |
---|
| 350 | #endif // __TDECTOP__ |
---|
| 351 | |
---|