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