[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 | * |
---|
| 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 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" |
---|
| 47 | |
---|
| 48 | #include "TDecGop.h" |
---|
| 49 | #include "TDecEntropy.h" |
---|
| 50 | #include "TDecSbac.h" |
---|
| 51 | #include "TDecCAVLC.h" |
---|
| 52 | #include "SEIread.h" |
---|
| 53 | |
---|
| 54 | struct InputNALUnit; |
---|
| 55 | |
---|
| 56 | //! \ingroup TLibDecoder |
---|
| 57 | //! \{ |
---|
| 58 | |
---|
| 59 | // ==================================================================================================================== |
---|
| 60 | // Class definition |
---|
| 61 | // ==================================================================================================================== |
---|
| 62 | |
---|
| 63 | /// decoder class |
---|
| 64 | class TDecTop |
---|
| 65 | { |
---|
| 66 | private: |
---|
| 67 | Int m_iMaxRefPicNum; |
---|
| 68 | |
---|
[442] | 69 | NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture |
---|
[313] | 70 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
| 71 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
| 72 | |
---|
| 73 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
| 74 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
| 75 | TComSlice* m_apcSlicePilot; |
---|
[442] | 76 | |
---|
[313] | 77 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices |
---|
| 78 | |
---|
| 79 | // functional classes |
---|
| 80 | TComPrediction m_cPrediction; |
---|
| 81 | TComTrQuant m_cTrQuant; |
---|
| 82 | TDecGop m_cGopDecoder; |
---|
| 83 | TDecSlice m_cSliceDecoder; |
---|
| 84 | TDecCu m_cCuDecoder; |
---|
| 85 | TDecEntropy m_cEntropyDecoder; |
---|
| 86 | TDecCavlc m_cCavlcDecoder; |
---|
| 87 | TDecSbac m_cSbacDecoder; |
---|
| 88 | TDecBinCABAC m_cBinCABAC; |
---|
| 89 | SEIReader m_seiReader; |
---|
| 90 | TComLoopFilter m_cLoopFilter; |
---|
| 91 | TComSampleAdaptiveOffset m_cSAO; |
---|
| 92 | |
---|
| 93 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
| 94 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 95 | TComPic* m_pcPic; |
---|
| 96 | UInt m_uiSliceIdx; |
---|
| 97 | #if !SVC_EXTENSION |
---|
| 98 | Int m_prevPOC; |
---|
| 99 | #endif |
---|
| 100 | Bool m_bFirstSliceInPicture; |
---|
| 101 | #if !SVC_EXTENSION |
---|
| 102 | Bool m_bFirstSliceInSequence; |
---|
| 103 | #endif |
---|
[442] | 104 | Bool m_prevSliceSkipped; |
---|
| 105 | Int m_skippedPOC; |
---|
[313] | 106 | |
---|
| 107 | #if SVC_EXTENSION |
---|
| 108 | static UInt m_prevPOC; // POC of the previous slice |
---|
| 109 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
| 110 | static Bool m_bFirstSliceInSequence; |
---|
| 111 | UInt m_layerId; |
---|
| 112 | UInt m_numLayer; |
---|
| 113 | TDecTop** m_ppcTDecTop; |
---|
| 114 | #if AVC_BASE |
---|
| 115 | fstream* m_pBLReconFile; |
---|
| 116 | Int m_iBLSourceWidth; |
---|
[442] | 117 | Int m_iBLSourceHeight; |
---|
[313] | 118 | #endif |
---|
| 119 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
| 120 | Int m_numDirectRefLayers; |
---|
| 121 | Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 122 | Int m_numSamplePredRefLayers; |
---|
| 123 | Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 124 | Int m_numMotionPredRefLayers; |
---|
| 125 | Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 126 | Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 127 | Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 128 | #endif |
---|
[442] | 129 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
[313] | 130 | #endif |
---|
[521] | 131 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 132 | CommonDecoderParams* m_commonDecoderParams; |
---|
| 133 | #endif |
---|
[313] | 134 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
| 135 | fstream* m_pBLSyntaxFile; |
---|
| 136 | #endif |
---|
| 137 | |
---|
[531] | 138 | #if NO_CLRAS_OUTPUT_FLAG |
---|
| 139 | Bool m_noClrasOutputFlag; |
---|
| 140 | Bool m_layerInitializedFlag; |
---|
| 141 | Bool m_firstPicInLayerDecodedFlag; |
---|
| 142 | Bool m_noOutputOfPriorPicsFlags; |
---|
| 143 | |
---|
| 144 | Bool m_bRefreshPending; |
---|
| 145 | #endif |
---|
| 146 | |
---|
[313] | 147 | public: |
---|
| 148 | TDecTop(); |
---|
| 149 | virtual ~TDecTop(); |
---|
| 150 | |
---|
| 151 | Void create (); |
---|
| 152 | Void destroy (); |
---|
| 153 | |
---|
| 154 | void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
| 155 | |
---|
| 156 | Void init(); |
---|
| 157 | #if SVC_EXTENSION |
---|
| 158 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 159 | #else |
---|
| 160 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 161 | #endif |
---|
| 162 | |
---|
| 163 | Void deletePicBuffer(); |
---|
| 164 | |
---|
| 165 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
| 166 | #if SVC_EXTENSION |
---|
[442] | 167 | #if EARLY_REF_PIC_MARKING |
---|
| 168 | Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); |
---|
| 169 | #endif |
---|
[313] | 170 | UInt getLayerId () { return m_layerId; } |
---|
| 171 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
| 172 | UInt getNumLayer () { return m_numLayer; } |
---|
| 173 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
| 174 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
| 175 | Void setLayerDec(TDecTop **p) { m_ppcTDecTop = p; } |
---|
| 176 | TDecTop* getLayerDec(UInt layer) { return m_ppcTDecTop[layer]; } |
---|
| 177 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 178 | TDecTop* getRefLayerDec(UInt refLayerIdc); |
---|
| 179 | #if M0457_PREDICTION_INDICATIONS |
---|
| 180 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
| 181 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
| 182 | |
---|
| 183 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
| 184 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
| 185 | |
---|
| 186 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
| 187 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
| 188 | |
---|
| 189 | Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } |
---|
| 190 | Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } |
---|
| 191 | |
---|
| 192 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
| 193 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
| 194 | |
---|
| 195 | Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } |
---|
| 196 | Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } |
---|
| 197 | |
---|
| 198 | Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } |
---|
| 199 | Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } |
---|
| 200 | |
---|
| 201 | Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } |
---|
| 202 | Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } |
---|
| 203 | |
---|
| 204 | TDecTop* getSamplePredRefLayerDec ( UInt layerId ); |
---|
| 205 | TDecTop* getMotionPredRefLayerDec ( UInt layerId ); |
---|
| 206 | |
---|
| 207 | Void setRefLayerParams( TComVPS* vps ); |
---|
| 208 | #endif |
---|
| 209 | #endif |
---|
| 210 | #if AVC_BASE |
---|
| 211 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
| 212 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
| 213 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
| 214 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
| 215 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
| 216 | #endif |
---|
[442] | 217 | #if REPN_FORMAT_IN_VPS |
---|
| 218 | Void xInitILRP(TComSlice *slice); |
---|
| 219 | #else |
---|
| 220 | Void xInitILRP(TComSPS *pcSPS); |
---|
[313] | 221 | #endif |
---|
[442] | 222 | #endif |
---|
[313] | 223 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
| 224 | Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; } |
---|
| 225 | fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } |
---|
| 226 | #endif |
---|
| 227 | |
---|
| 228 | protected: |
---|
| 229 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
| 230 | Void xCreateLostPicture (Int iLostPOC); |
---|
| 231 | |
---|
| 232 | Void xActivateParameterSets(); |
---|
| 233 | #if SVC_EXTENSION |
---|
[442] | 234 | #if POC_RESET_FLAG |
---|
| 235 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
| 236 | #else |
---|
[313] | 237 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
[442] | 238 | #endif |
---|
[313] | 239 | #else |
---|
| 240 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
| 241 | #endif |
---|
| 242 | Void xDecodeVPS(); |
---|
| 243 | Void xDecodeSPS(); |
---|
| 244 | Void xDecodePPS(); |
---|
| 245 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
[345] | 246 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 247 | TComPic* getMotionPredIlp(TComSlice* pcSlice); |
---|
| 248 | #endif |
---|
[531] | 249 | |
---|
| 250 | #if NO_CLRAS_OUTPUT_FLAG |
---|
| 251 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
| 252 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
| 253 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
| 254 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
| 255 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
| 256 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
| 257 | Int getNoOutputOfPriorPicsFlags() { return m_noOutputOfPriorPicsFlags;} |
---|
| 258 | Void setNoOutputOfPriorPicsFlags(Bool x) { m_noOutputOfPriorPicsFlags = x; } |
---|
| 259 | #endif |
---|
[521] | 260 | public: |
---|
| 261 | #if OUTPUT_LAYER_SET_INDEX |
---|
| 262 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
| 263 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
| 264 | Void checkValueOfOutputLayerSetIdx(TComVPS *vps); |
---|
| 265 | #endif |
---|
[528] | 266 | #if SCALINGLIST_INFERRING |
---|
| 267 | ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } |
---|
| 268 | #endif |
---|
[313] | 269 | };// END CLASS DEFINITION TDecTop |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | //! \} |
---|
| 273 | |
---|
| 274 | #endif // __TDECTOP__ |
---|
| 275 | |
---|