[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 | * |
---|
[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; |
---|
[1029] | 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 |
---|
[1029] | 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 |
---|
[1029] | 117 | #if O0043_BEST_EFFORT_DECODING |
---|
| 118 | UInt m_forceDecodeBitDepth; |
---|
[713] | 119 | #endif |
---|
[1029] | 120 | std::ostream *m_pDecodedSEIOutputStream; |
---|
| 121 | |
---|
| 122 | #if SVC_EXTENSION |
---|
[815] | 123 | #if Q0177_EOS_CHECKS |
---|
| 124 | Bool m_isLastNALWasEos; |
---|
| 125 | #endif |
---|
[978] | 126 | Bool m_lastPicHasEos; |
---|
[313] | 127 | static UInt m_prevPOC; // POC of the previous slice |
---|
| 128 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
| 129 | static Bool m_bFirstSliceInSequence; |
---|
| 130 | UInt m_layerId; |
---|
| 131 | UInt m_numLayer; |
---|
| 132 | TDecTop** m_ppcTDecTop; |
---|
[1005] | 133 | UInt m_smallestLayerId; |
---|
[903] | 134 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
| 135 | Bool m_pocResettingFlag; |
---|
| 136 | Bool m_pocDecrementedInDPBFlag; |
---|
| 137 | #endif |
---|
[313] | 138 | #if AVC_BASE |
---|
| 139 | fstream* m_pBLReconFile; |
---|
[713] | 140 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 141 | Int m_iBLSourceWidth; |
---|
[713] | 142 | Int m_iBLSourceHeight; |
---|
[313] | 143 | #endif |
---|
[713] | 144 | #endif |
---|
[1148] | 145 | |
---|
[313] | 146 | Int m_numDirectRefLayers; |
---|
[1047] | 147 | Int m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1]; |
---|
[313] | 148 | Int m_numSamplePredRefLayers; |
---|
| 149 | Int m_numMotionPredRefLayers; |
---|
[1148] | 150 | |
---|
[442] | 151 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
[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 |
---|
[924] | 165 | #if CONFORMANCE_BITSTREAM_MODE |
---|
| 166 | Bool m_confModeFlag; |
---|
| 167 | std::vector<TComPic> m_confListPic; // Dynamic buffer for storing pictures for conformance purposes |
---|
| 168 | #endif |
---|
[953] | 169 | Bool m_isOutputLayerFlag; |
---|
[1111] | 170 | #endif //SVC_EXTENSION |
---|
| 171 | |
---|
[313] | 172 | public: |
---|
[1111] | 173 | #if SVC_EXTENSION |
---|
[851] | 174 | #if POC_RESET_RESTRICTIONS |
---|
| 175 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
| 176 | static Int m_pocResetIdcOrCurrAu; |
---|
| 177 | static Bool m_baseLayerIdrFlag; |
---|
| 178 | static Bool m_baseLayerPicPresentFlag; |
---|
| 179 | static Bool m_baseLayerIrapFlag; |
---|
| 180 | static Bool m_nonBaseIdrPresentFlag; |
---|
| 181 | static Int m_nonBaseIdrType; |
---|
| 182 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
| 183 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
| 184 | #endif |
---|
[854] | 185 | #if POC_RESET_VALUE_RESTRICTION |
---|
| 186 | static Int m_crossLayerPocResetPeriodId; |
---|
| 187 | static Int m_crossLayerPocResetIdc; |
---|
| 188 | #endif |
---|
[1111] | 189 | #endif //SVC_EXTENSION |
---|
[851] | 190 | |
---|
[313] | 191 | TDecTop(); |
---|
| 192 | virtual ~TDecTop(); |
---|
[1029] | 193 | |
---|
[313] | 194 | Void create (); |
---|
| 195 | Void destroy (); |
---|
| 196 | |
---|
[1029] | 197 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
[313] | 198 | |
---|
| 199 | Void init(); |
---|
| 200 | #if SVC_EXTENSION |
---|
| 201 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 202 | #else |
---|
| 203 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 204 | #endif |
---|
| 205 | |
---|
| 206 | Void deletePicBuffer(); |
---|
| 207 | |
---|
[713] | 208 | |
---|
| 209 | TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); } |
---|
| 210 | |
---|
| 211 | |
---|
[1029] | 212 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
| 213 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
| 214 | |
---|
| 215 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
[713] | 216 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
[1029] | 217 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
| 218 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
| 219 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
| 220 | #if O0043_BEST_EFFORT_DECODING |
---|
| 221 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
[713] | 222 | #endif |
---|
[1029] | 223 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
[713] | 224 | |
---|
[313] | 225 | #if SVC_EXTENSION |
---|
[815] | 226 | #if POC_RESET_IDC_DECODER |
---|
[1043] | 227 | Int getParseIdc () { return m_parseIdc; } |
---|
| 228 | Void setParseIdc (Int x) { m_parseIdc = x; } |
---|
[1049] | 229 | Void markAllPicsAsNoCurrAu (TComVPS *vps); |
---|
[815] | 230 | |
---|
[1043] | 231 | Int getLastPocPeriodId () { return m_lastPocPeriodId; } |
---|
| 232 | Void setLastPocPeriodId (Int x) { m_lastPocPeriodId = x; } |
---|
[815] | 233 | |
---|
[1043] | 234 | Int getPrevPicOrderCnt () { return m_prevPicOrderCnt; } |
---|
| 235 | Void setPrevPicOrderCnt (Int const x) { m_prevPicOrderCnt = x; } |
---|
[815] | 236 | #endif |
---|
[1043] | 237 | UInt getLayerId () { return m_layerId; } |
---|
| 238 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
| 239 | UInt getNumLayer () { return m_numLayer; } |
---|
| 240 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
| 241 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 242 | Void setLayerDec (TDecTop **p) { m_ppcTDecTop = p; } |
---|
[1049] | 243 | TDecTop* getLayerDec (UInt layerId) { return m_ppcTDecTop[layerId]; } |
---|
[1005] | 244 | Void xDeriveSmallestLayerId(TComVPS* vps); |
---|
[1148] | 245 | |
---|
[1043] | 246 | TDecTop* getRefLayerDec (UInt refLayerIdx); |
---|
[313] | 247 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
| 248 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
| 249 | |
---|
| 250 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
| 251 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
| 252 | |
---|
| 253 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
| 254 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
| 255 | |
---|
| 256 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
| 257 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
| 258 | |
---|
| 259 | Void setRefLayerParams( TComVPS* vps ); |
---|
[1148] | 260 | |
---|
[313] | 261 | #if AVC_BASE |
---|
| 262 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
| 263 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
[713] | 264 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 265 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
| 266 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
| 267 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
| 268 | #endif |
---|
[713] | 269 | #endif |
---|
[442] | 270 | #if REPN_FORMAT_IN_VPS |
---|
| 271 | Void xInitILRP(TComSlice *slice); |
---|
| 272 | #else |
---|
| 273 | Void xInitILRP(TComSPS *pcSPS); |
---|
[313] | 274 | #endif |
---|
[595] | 275 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 276 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
| 277 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
| 278 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
[442] | 279 | #endif |
---|
[595] | 280 | #if SCALINGLIST_INFERRING |
---|
| 281 | ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } |
---|
| 282 | #endif |
---|
[924] | 283 | #if CONFORMANCE_BITSTREAM_MODE |
---|
| 284 | std::vector<TComPic>* getConfListPic() {return &m_confListPic; } |
---|
[1029] | 285 | Bool const getConfModeFlag() { return m_confModeFlag; } |
---|
| 286 | Void setConfModeFlag(Bool x) { m_confModeFlag = x; } |
---|
[924] | 287 | #endif |
---|
[595] | 288 | #endif //SVC_EXTENSION |
---|
[820] | 289 | |
---|
[313] | 290 | protected: |
---|
| 291 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
| 292 | Void xCreateLostPicture (Int iLostPOC); |
---|
| 293 | |
---|
| 294 | Void xActivateParameterSets(); |
---|
| 295 | #if SVC_EXTENSION |
---|
| 296 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
[1073] | 297 | Void xSetSpatialEnhLayerFlag(TComSlice* slice, TComPic* pic); |
---|
[313] | 298 | #else |
---|
| 299 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
| 300 | #endif |
---|
| 301 | Void xDecodeVPS(); |
---|
| 302 | Void xDecodeSPS(); |
---|
[713] | 303 | #if Q0048_CGS_3D_ASYMLUT |
---|
[1145] | 304 | Void xDecodePPS( TCom3DAsymLUT * pc3DAsymLUT ); |
---|
| 305 | #else |
---|
| 306 | Void xDecodePPS(); |
---|
[713] | 307 | #endif |
---|
[313] | 308 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
| 309 | |
---|
[1131] | 310 | #if SVC_EXTENSION |
---|
[540] | 311 | #if NO_CLRAS_OUTPUT_FLAG |
---|
| 312 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
| 313 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
| 314 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
| 315 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
| 316 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
| 317 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
| 318 | #endif |
---|
[713] | 319 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 320 | Void initAsymLut(TComSlice *pcSlice); |
---|
[644] | 321 | #endif |
---|
[851] | 322 | #if POC_RESET_RESTRICTIONS |
---|
| 323 | Void resetPocRestrictionCheckParameters(); |
---|
| 324 | #endif |
---|
[978] | 325 | Void xCheckLayerReset(); |
---|
| 326 | Void xSetNoRaslOutputFlag(); |
---|
| 327 | Void xSetLayerInitializedFlag(); |
---|
| 328 | #endif |
---|
[313] | 329 | };// END CLASS DEFINITION TDecTop |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | //! \} |
---|
| 333 | |
---|
| 334 | #endif // __TDECTOP__ |
---|
| 335 | |
---|