[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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, 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" |
---|
[1263] | 46 | #include "TLibCommon/TComPrediction.h" |
---|
[313] | 47 | #include "TLibCommon/SEI.h" |
---|
[1212] | 48 | #if CGS_3D_ASYMLUT |
---|
[713] | 49 | #include "TLibCommon/TCom3DAsymLUT.h" |
---|
| 50 | #endif |
---|
[313] | 51 | |
---|
| 52 | #include "TDecGop.h" |
---|
| 53 | #include "TDecEntropy.h" |
---|
| 54 | #include "TDecSbac.h" |
---|
| 55 | #include "TDecCAVLC.h" |
---|
| 56 | #include "SEIread.h" |
---|
| 57 | |
---|
| 58 | struct InputNALUnit; |
---|
| 59 | |
---|
| 60 | //! \ingroup TLibDecoder |
---|
| 61 | //! \{ |
---|
| 62 | |
---|
| 63 | // ==================================================================================================================== |
---|
| 64 | // Class definition |
---|
| 65 | // ==================================================================================================================== |
---|
| 66 | |
---|
| 67 | /// decoder class |
---|
| 68 | class TDecTop |
---|
| 69 | { |
---|
| 70 | private: |
---|
| 71 | Int m_iMaxRefPicNum; |
---|
[1029] | 72 | |
---|
[442] | 73 | NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture |
---|
[313] | 74 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
| 75 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
| 76 | |
---|
| 77 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
[1235] | 78 | ParameterSetManager m_parameterSetManager; // storage for parameter sets |
---|
[313] | 79 | TComSlice* m_apcSlicePilot; |
---|
[442] | 80 | |
---|
[313] | 81 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices |
---|
| 82 | |
---|
| 83 | // functional classes |
---|
| 84 | TComPrediction m_cPrediction; |
---|
[1212] | 85 | #if CGS_3D_ASYMLUT |
---|
[713] | 86 | TCom3DAsymLUT m_c3DAsymLUTPPS; |
---|
| 87 | TComPicYuv* m_pColorMappedPic; |
---|
| 88 | #endif |
---|
[313] | 89 | TComTrQuant m_cTrQuant; |
---|
| 90 | TDecGop m_cGopDecoder; |
---|
| 91 | TDecSlice m_cSliceDecoder; |
---|
| 92 | TDecCu m_cCuDecoder; |
---|
| 93 | TDecEntropy m_cEntropyDecoder; |
---|
| 94 | TDecCavlc m_cCavlcDecoder; |
---|
| 95 | TDecSbac m_cSbacDecoder; |
---|
| 96 | TDecBinCABAC m_cBinCABAC; |
---|
| 97 | SEIReader m_seiReader; |
---|
| 98 | TComLoopFilter m_cLoopFilter; |
---|
| 99 | TComSampleAdaptiveOffset m_cSAO; |
---|
| 100 | |
---|
| 101 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
| 102 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 103 | TComPic* m_pcPic; |
---|
| 104 | UInt m_uiSliceIdx; |
---|
| 105 | #if !SVC_EXTENSION |
---|
| 106 | Int m_prevPOC; |
---|
| 107 | #endif |
---|
[1295] | 108 | Int m_prevTid0POC; |
---|
[313] | 109 | Bool m_bFirstSliceInPicture; |
---|
| 110 | #if !SVC_EXTENSION |
---|
| 111 | Bool m_bFirstSliceInSequence; |
---|
| 112 | #endif |
---|
[442] | 113 | Bool m_prevSliceSkipped; |
---|
| 114 | Int m_skippedPOC; |
---|
[713] | 115 | Bool m_bFirstSliceInBitstream; |
---|
| 116 | Int m_lastPOCNoOutputPriorPics; |
---|
| 117 | Bool m_isNoOutputPriorPics; |
---|
| 118 | Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic |
---|
[1029] | 119 | #if O0043_BEST_EFFORT_DECODING |
---|
| 120 | UInt m_forceDecodeBitDepth; |
---|
[713] | 121 | #endif |
---|
[1029] | 122 | std::ostream *m_pDecodedSEIOutputStream; |
---|
| 123 | |
---|
[1292] | 124 | Bool m_warningMessageSkipPicture; |
---|
| 125 | |
---|
[1029] | 126 | #if SVC_EXTENSION |
---|
[815] | 127 | Bool m_isLastNALWasEos; |
---|
[978] | 128 | Bool m_lastPicHasEos; |
---|
[313] | 129 | static UInt m_prevPOC; // POC of the previous slice |
---|
| 130 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
| 131 | static Bool m_bFirstSliceInSequence; |
---|
| 132 | UInt m_layerId; |
---|
| 133 | UInt m_numLayer; |
---|
| 134 | TDecTop** m_ppcTDecTop; |
---|
[1005] | 135 | UInt m_smallestLayerId; |
---|
[903] | 136 | Bool m_pocResettingFlag; |
---|
| 137 | Bool m_pocDecrementedInDPBFlag; |
---|
[313] | 138 | #if AVC_BASE |
---|
| 139 | fstream* m_pBLReconFile; |
---|
| 140 | #endif |
---|
[1148] | 141 | |
---|
[313] | 142 | Int m_numDirectRefLayers; |
---|
[1047] | 143 | Int m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1]; |
---|
[313] | 144 | Int m_numSamplePredRefLayers; |
---|
| 145 | Int m_numMotionPredRefLayers; |
---|
[1148] | 146 | |
---|
[442] | 147 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
[540] | 148 | CommonDecoderParams* m_commonDecoderParams; |
---|
[713] | 149 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[540] | 150 | Bool m_noClrasOutputFlag; |
---|
| 151 | Bool m_layerInitializedFlag; |
---|
| 152 | Bool m_firstPicInLayerDecodedFlag; |
---|
| 153 | #endif |
---|
[815] | 154 | Int m_parseIdc; |
---|
| 155 | Int m_lastPocPeriodId; |
---|
| 156 | Int m_prevPicOrderCnt; |
---|
[924] | 157 | #if CONFORMANCE_BITSTREAM_MODE |
---|
[1235] | 158 | Bool m_confModeFlag; |
---|
| 159 | std::vector<TComPic> m_confListPic; // Dynamic buffer for storing pictures for conformance purposes |
---|
[924] | 160 | #endif |
---|
[1235] | 161 | Bool m_isOutputLayerFlag; |
---|
[1111] | 162 | #endif //SVC_EXTENSION |
---|
| 163 | |
---|
[313] | 164 | public: |
---|
[1111] | 165 | #if SVC_EXTENSION |
---|
[1235] | 166 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
| 167 | static Int m_pocResetIdcOrCurrAu; |
---|
| 168 | static Bool m_baseLayerIdrFlag; |
---|
| 169 | static Bool m_baseLayerPicPresentFlag; |
---|
| 170 | static Bool m_baseLayerIrapFlag; |
---|
| 171 | static Bool m_nonBaseIdrPresentFlag; |
---|
| 172 | static Int m_nonBaseIdrType; |
---|
| 173 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
| 174 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
| 175 | static Int m_crossLayerPocResetPeriodId; |
---|
| 176 | static Int m_crossLayerPocResetIdc; |
---|
[1111] | 177 | #endif //SVC_EXTENSION |
---|
[851] | 178 | |
---|
[313] | 179 | TDecTop(); |
---|
| 180 | virtual ~TDecTop(); |
---|
[1029] | 181 | |
---|
[313] | 182 | Void create (); |
---|
| 183 | Void destroy (); |
---|
| 184 | |
---|
[1029] | 185 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
[313] | 186 | |
---|
| 187 | Void init(); |
---|
| 188 | #if SVC_EXTENSION |
---|
| 189 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 190 | #else |
---|
| 191 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 192 | #endif |
---|
| 193 | |
---|
| 194 | Void deletePicBuffer(); |
---|
| 195 | |
---|
[1292] | 196 | |
---|
[1029] | 197 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
| 198 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
| 199 | |
---|
| 200 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
[713] | 201 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
[1029] | 202 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
| 203 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
| 204 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
| 205 | #if O0043_BEST_EFFORT_DECODING |
---|
| 206 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
[713] | 207 | #endif |
---|
[1029] | 208 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
[1292] | 209 | UInt getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); } |
---|
[713] | 210 | |
---|
[313] | 211 | #if SVC_EXTENSION |
---|
[1043] | 212 | Int getParseIdc () { return m_parseIdc; } |
---|
| 213 | Void setParseIdc (Int x) { m_parseIdc = x; } |
---|
[1235] | 214 | Void markAllPicsAsNoCurrAu ( const TComVPS *vps ); |
---|
[815] | 215 | |
---|
[1043] | 216 | Int getLastPocPeriodId () { return m_lastPocPeriodId; } |
---|
| 217 | Void setLastPocPeriodId (Int x) { m_lastPocPeriodId = x; } |
---|
[815] | 218 | |
---|
[1043] | 219 | Int getPrevPicOrderCnt () { return m_prevPicOrderCnt; } |
---|
| 220 | Void setPrevPicOrderCnt (Int const x) { m_prevPicOrderCnt = x; } |
---|
[1210] | 221 | |
---|
[1043] | 222 | UInt getLayerId () { return m_layerId; } |
---|
| 223 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
| 224 | UInt getNumLayer () { return m_numLayer; } |
---|
| 225 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
| 226 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 227 | Void setLayerDec (TDecTop **p) { m_ppcTDecTop = p; } |
---|
[1049] | 228 | TDecTop* getLayerDec (UInt layerId) { return m_ppcTDecTop[layerId]; } |
---|
[1005] | 229 | Void xDeriveSmallestLayerId(TComVPS* vps); |
---|
[1148] | 230 | |
---|
[1043] | 231 | TDecTop* getRefLayerDec (UInt refLayerIdx); |
---|
[313] | 232 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
| 233 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
| 234 | |
---|
| 235 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
| 236 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
| 237 | |
---|
| 238 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
| 239 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
| 240 | |
---|
| 241 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
| 242 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
| 243 | |
---|
[1235] | 244 | Void setRefLayerParams( const TComVPS* vps ); |
---|
[1148] | 245 | |
---|
[313] | 246 | #if AVC_BASE |
---|
[1177] | 247 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
| 248 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
[313] | 249 | #endif |
---|
[442] | 250 | Void xInitILRP(TComSlice *slice); |
---|
[1177] | 251 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
| 252 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
[595] | 253 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
[1223] | 254 | |
---|
[1235] | 255 | ParameterSetManager* getParameterSetManager() { return &m_parameterSetManager; } |
---|
[1223] | 256 | |
---|
[924] | 257 | #if CONFORMANCE_BITSTREAM_MODE |
---|
[1282] | 258 | std::vector<TComPic>* getConfListPic() { return &m_confListPic; } |
---|
| 259 | Bool getConfModeFlag() const { return m_confModeFlag; } |
---|
| 260 | Void setConfModeFlag(Bool x) { m_confModeFlag = x; } |
---|
[924] | 261 | #endif |
---|
[595] | 262 | #endif //SVC_EXTENSION |
---|
[820] | 263 | |
---|
[313] | 264 | protected: |
---|
[1235] | 265 | #if SVC_EXTENSION |
---|
[1292] | 266 | Void xGetNewPicBuffer ( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
[1235] | 267 | #else |
---|
[1292] | 268 | Void xGetNewPicBuffer (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
[1235] | 269 | #endif |
---|
[1292] | 270 | Void xCreateLostPicture (Int iLostPOC); |
---|
[313] | 271 | |
---|
| 272 | Void xActivateParameterSets(); |
---|
| 273 | #if SVC_EXTENSION |
---|
| 274 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
[1235] | 275 | Void xSetSpatialEnhLayerFlag( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic* pic ); |
---|
[313] | 276 | #else |
---|
| 277 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
| 278 | #endif |
---|
[1235] | 279 | Void xDecodeVPS(const std::vector<UChar> *pNaluData); |
---|
| 280 | Void xDecodeSPS(const std::vector<UChar> *pNaluData); |
---|
[1212] | 281 | #if CGS_3D_ASYMLUT |
---|
[1235] | 282 | Void xDecodePPS(const std::vector<UChar> *pNaluData, TCom3DAsymLUT *pc3DAsymLUT); |
---|
[1145] | 283 | #else |
---|
[1235] | 284 | Void xDecodePPS(const std::vector<UChar> *pNaluData); |
---|
[713] | 285 | #endif |
---|
[313] | 286 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
[1295] | 287 | Void xUpdatePreviousTid0POC( TComSlice *pSlice ) { if ((pSlice->getTLayer()==0) && (pSlice->isReferenceNalu() && (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) { m_prevTid0POC=pSlice->getPOC(); } } |
---|
[313] | 288 | |
---|
[1295] | 289 | |
---|
[1131] | 290 | #if SVC_EXTENSION |
---|
[540] | 291 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[1235] | 292 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
| 293 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
| 294 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
| 295 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
| 296 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
| 297 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
[540] | 298 | #endif |
---|
[1212] | 299 | #if CGS_3D_ASYMLUT |
---|
[1235] | 300 | Void initAsymLut(TComSlice *pcSlice); |
---|
[644] | 301 | #endif |
---|
[1235] | 302 | Void resetPocRestrictionCheckParameters(); |
---|
| 303 | Void xCheckLayerReset(); |
---|
| 304 | Void xSetNoRaslOutputFlag(); |
---|
| 305 | Void xSetLayerInitializedFlag(); |
---|
[978] | 306 | #endif |
---|
[313] | 307 | };// END CLASS DEFINITION TDecTop |
---|
| 308 | |
---|
| 309 | |
---|
| 310 | //! \} |
---|
| 311 | |
---|
| 312 | #endif // __TDECTOP__ |
---|
| 313 | |
---|