[5] | 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 |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TDecTop.h |
---|
| 35 | \brief decoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TDECTOP__ |
---|
| 39 | #define __TDECTOP__ |
---|
| 40 | |
---|
[56] | 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" |
---|
[1200] | 46 | #include "TLibCommon/TComPrediction.h" |
---|
[56] | 47 | #include "TLibCommon/SEI.h" |
---|
[2] | 48 | |
---|
| 49 | #include "TDecGop.h" |
---|
| 50 | #include "TDecEntropy.h" |
---|
| 51 | #include "TDecSbac.h" |
---|
| 52 | #include "TDecCAVLC.h" |
---|
[608] | 53 | #include "SEIread.h" |
---|
[2] | 54 | |
---|
[1200] | 55 | class InputNALUnit; |
---|
[56] | 56 | |
---|
| 57 | //! \ingroup TLibDecoder |
---|
| 58 | //! \{ |
---|
| 59 | |
---|
[2] | 60 | // ==================================================================================================================== |
---|
| 61 | // Class definition |
---|
| 62 | // ==================================================================================================================== |
---|
| 63 | |
---|
[1200] | 64 | #if NH_MV |
---|
[56] | 65 | class TAppDecTop; |
---|
[608] | 66 | #endif |
---|
[1200] | 67 | #if NH_3D |
---|
[2] | 68 | class CamParsCollector |
---|
| 69 | { |
---|
| 70 | public: |
---|
| 71 | CamParsCollector (); |
---|
| 72 | ~CamParsCollector (); |
---|
| 73 | |
---|
[1200] | 74 | Void init ( const TComVPS* vps ); |
---|
| 75 | Void setCodeScaleOffsetFile( FILE* pCodedScaleOffsetFile ) { m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; }; |
---|
[872] | 76 | |
---|
[2] | 77 | Void uninit (); |
---|
| 78 | Void setSlice ( TComSlice* pcSlice ); |
---|
| 79 | |
---|
[608] | 80 | Bool isInitialized() const { return m_bInitialized; } |
---|
| 81 | Int**** getBaseViewShiftLUTI() { return m_aiBaseViewShiftLUT; } |
---|
[57] | 82 | |
---|
[773] | 83 | #if H_3D_IV_MERGE |
---|
[724] | 84 | Void copyCamParamForSlice( TComSlice* pcSlice ); |
---|
| 85 | #endif |
---|
| 86 | |
---|
[833] | 87 | |
---|
[2] | 88 | private: |
---|
[872] | 89 | Void xResetReceivedIdc( Bool overWriteFlag ); |
---|
[2] | 90 | Void xOutput ( Int iPOC ); |
---|
| 91 | |
---|
| 92 | private: |
---|
| 93 | Bool m_bInitialized; |
---|
| 94 | FILE* m_pCodedScaleOffsetFile; |
---|
| 95 | |
---|
| 96 | Int** m_aaiCodedOffset; |
---|
| 97 | Int** m_aaiCodedScale; |
---|
[872] | 98 | |
---|
[1200] | 99 | const TComVPS* m_vps; |
---|
[872] | 100 | Int** m_receivedIdc; |
---|
| 101 | Int m_lastPoc; |
---|
| 102 | Int m_firstReceivedPoc; |
---|
[608] | 103 | |
---|
[872] | 104 | |
---|
[2] | 105 | Bool m_bCamParsVaryOverTime; |
---|
[296] | 106 | |
---|
| 107 | UInt m_uiBitDepthForLUT; |
---|
| 108 | UInt m_iLog2Precision; |
---|
| 109 | UInt m_uiInputBitDepth; |
---|
[608] | 110 | |
---|
[296] | 111 | // look-up tables |
---|
| 112 | Double**** m_adBaseViewShiftLUT; ///< Disparity LUT |
---|
| 113 | Int**** m_aiBaseViewShiftLUT; ///< Disparity LUT |
---|
| 114 | Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT); |
---|
| 115 | Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT); |
---|
| 116 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ); |
---|
| 117 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2 ); |
---|
| 118 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize ); |
---|
| 119 | |
---|
[2] | 120 | }; |
---|
| 121 | |
---|
[296] | 122 | template <class T> |
---|
| 123 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ) |
---|
| 124 | { |
---|
| 125 | if( rpt ) |
---|
| 126 | { |
---|
| 127 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
| 128 | { |
---|
| 129 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
| 130 | { |
---|
| 131 | for( UInt uiM = 0; uiM < uiSize3; uiM++ ) |
---|
| 132 | { |
---|
| 133 | delete[] rpt[ uiK ][ uiL ][ uiM ]; |
---|
| 134 | } |
---|
| 135 | delete[] rpt[ uiK ][ uiL ]; |
---|
| 136 | } |
---|
| 137 | delete[] rpt[ uiK ]; |
---|
| 138 | } |
---|
| 139 | delete[] rpt; |
---|
| 140 | } |
---|
| 141 | rpt = NULL; |
---|
| 142 | }; |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | template <class T> |
---|
| 146 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 ) |
---|
| 147 | { |
---|
| 148 | if( rpt ) |
---|
| 149 | { |
---|
| 150 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
| 151 | { |
---|
| 152 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
| 153 | { |
---|
| 154 | delete[] rpt[ uiK ][ uiL ]; |
---|
| 155 | } |
---|
| 156 | delete[] rpt[ uiK ]; |
---|
| 157 | } |
---|
| 158 | delete[] rpt; |
---|
| 159 | } |
---|
| 160 | rpt = NULL; |
---|
| 161 | }; |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | template <class T> |
---|
| 165 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize ) |
---|
| 166 | { |
---|
| 167 | if( rpt ) |
---|
| 168 | { |
---|
| 169 | for( UInt uiK = 0; uiK < uiSize; uiK++ ) |
---|
| 170 | { |
---|
| 171 | delete[] rpt[ uiK ]; |
---|
| 172 | } |
---|
| 173 | delete[] rpt; |
---|
| 174 | } |
---|
| 175 | rpt = NULL; |
---|
| 176 | }; |
---|
| 177 | |
---|
[608] | 178 | #endif //H_3D |
---|
[2] | 179 | /// decoder class |
---|
| 180 | class TDecTop |
---|
| 181 | { |
---|
| 182 | private: |
---|
[608] | 183 | Int m_iMaxRefPicNum; |
---|
[1200] | 184 | |
---|
[655] | 185 | NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture |
---|
[56] | 186 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
| 187 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
[2] | 188 | |
---|
| 189 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
[1200] | 190 | #if NH_MV |
---|
[738] | 191 | Bool* m_layerInitilizedFlag; // initialization Layers |
---|
[1200] | 192 | static ParameterSetManager m_parameterSetManager; // storage for parameter sets |
---|
| 193 | Int m_targetOlsIdx; |
---|
[608] | 194 | #else |
---|
[1200] | 195 | ParameterSetManager m_parameterSetManager; // storage for parameter sets |
---|
[608] | 196 | #endif |
---|
[2] | 197 | TComSlice* m_apcSlicePilot; |
---|
| 198 | |
---|
[1200] | 199 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs... |
---|
| 200 | |
---|
[2] | 201 | // functional classes |
---|
| 202 | TComPrediction m_cPrediction; |
---|
| 203 | TComTrQuant m_cTrQuant; |
---|
| 204 | TDecGop m_cGopDecoder; |
---|
| 205 | TDecSlice m_cSliceDecoder; |
---|
| 206 | TDecCu m_cCuDecoder; |
---|
| 207 | TDecEntropy m_cEntropyDecoder; |
---|
| 208 | TDecCavlc m_cCavlcDecoder; |
---|
| 209 | TDecSbac m_cSbacDecoder; |
---|
| 210 | TDecBinCABAC m_cBinCABAC; |
---|
[608] | 211 | SEIReader m_seiReader; |
---|
[2] | 212 | TComLoopFilter m_cLoopFilter; |
---|
| 213 | TComSampleAdaptiveOffset m_cSAO; |
---|
[56] | 214 | |
---|
[608] | 215 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
[1200] | 216 | #if NH_MV |
---|
| 217 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay, const TComVPS* vps); |
---|
| 218 | #else |
---|
[2] | 219 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
[1200] | 220 | #endif |
---|
[2] | 221 | TComPic* m_pcPic; |
---|
| 222 | UInt m_uiSliceIdx; |
---|
[56] | 223 | Int m_prevPOC; |
---|
[1200] | 224 | Int m_prevTid0POC; |
---|
[2] | 225 | Bool m_bFirstSliceInPicture; |
---|
| 226 | Bool m_bFirstSliceInSequence; |
---|
[655] | 227 | Bool m_prevSliceSkipped; |
---|
| 228 | Int m_skippedPOC; |
---|
[964] | 229 | Bool m_bFirstSliceInBitstream; |
---|
| 230 | Int m_lastPOCNoOutputPriorPics; |
---|
| 231 | Bool m_isNoOutputPriorPics; |
---|
| 232 | Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic |
---|
[1200] | 233 | #if O0043_BEST_EFFORT_DECODING |
---|
| 234 | UInt m_forceDecodeBitDepth; |
---|
[964] | 235 | #endif |
---|
[1200] | 236 | std::ostream *m_pDecodedSEIOutputStream; |
---|
| 237 | |
---|
| 238 | Bool m_warningMessageSkipPicture; |
---|
| 239 | #if NH_MV |
---|
[964] | 240 | Bool m_isLastNALWasEos; |
---|
| 241 | #endif |
---|
[655] | 242 | |
---|
[1200] | 243 | #if NH_MV |
---|
| 244 | // For NH_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer |
---|
[608] | 245 | Int m_layerId; |
---|
[56] | 246 | Int m_viewId; |
---|
[608] | 247 | TComPicLists* m_ivPicLists; |
---|
[622] | 248 | std::vector<TComPic*> m_refPicSetInterLayer0; |
---|
| 249 | std::vector<TComPic*> m_refPicSetInterLayer1; |
---|
[1200] | 250 | #if NH_3D |
---|
[608] | 251 | Int m_viewIndex; |
---|
[56] | 252 | Bool m_isDepth; |
---|
[57] | 253 | CamParsCollector* m_pcCamParsCollector; |
---|
[1179] | 254 | Int m_profileIdc; |
---|
[608] | 255 | #endif |
---|
[1179] | 256 | #endif |
---|
[56] | 257 | |
---|
[1200] | 258 | std::list<InputNALUnit*> m_prefixSEINALUs; /// Buffered up prefix SEI NAL Units. |
---|
[2] | 259 | public: |
---|
| 260 | TDecTop(); |
---|
| 261 | virtual ~TDecTop(); |
---|
[1200] | 262 | |
---|
[2] | 263 | Void create (); |
---|
| 264 | Void destroy (); |
---|
| 265 | |
---|
[1200] | 266 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
[608] | 267 | |
---|
| 268 | Void init(); |
---|
[1200] | 269 | #if NH_MV |
---|
[738] | 270 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag ); |
---|
[608] | 271 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer ); |
---|
| 272 | #else |
---|
[56] | 273 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
[608] | 274 | #endif |
---|
[56] | 275 | Void deletePicBuffer(); |
---|
[1200] | 276 | |
---|
| 277 | #if NH_MV |
---|
| 278 | const TComVPS* getActiveVPS() { return m_parameterSetManager.getActiveVPS( ); } |
---|
| 279 | const TComSPS* getActiveSPS() { return m_parameterSetManager.getActiveSPS( m_layerId ); } |
---|
[964] | 280 | #endif |
---|
[608] | 281 | |
---|
[1200] | 282 | #if NH_MV |
---|
[608] | 283 | Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet); |
---|
[1200] | 284 | #else |
---|
| 285 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
[210] | 286 | #endif |
---|
[1200] | 287 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
[964] | 288 | |
---|
| 289 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
[1200] | 290 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
| 291 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
| 292 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
| 293 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
| 294 | #if O0043_BEST_EFFORT_DECODING |
---|
| 295 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
[964] | 296 | #endif |
---|
[1200] | 297 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
| 298 | UInt getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); } |
---|
| 299 | #if NH_MV |
---|
[608] | 300 | TComPic* getPic ( Int poc ); |
---|
| 301 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 302 | Void setIvPicLists ( TComPicLists* picLists) { m_ivPicLists = picLists; } |
---|
[738] | 303 | Void setLayerInitilizedFlags( Bool* val ) { m_layerInitilizedFlag = val; } |
---|
[1200] | 304 | Void setTargetOlsIdx ( Int targetOlsIdx ) { m_targetOlsIdx = targetOlsIdx; } |
---|
| 305 | Int getTargetOlsIdx ( ) { return m_targetOlsIdx; } |
---|
[608] | 306 | Int getCurrPoc () { return m_apcSlicePilot->getPOC(); } |
---|
| 307 | Void setLayerId ( Int layer) { m_layerId = layer; } |
---|
| 308 | Int getLayerId () { return m_layerId; } |
---|
| 309 | Void setViewId ( Int viewId ) { m_viewId = viewId; } |
---|
| 310 | Int getViewId () { return m_viewId; } |
---|
[1200] | 311 | Void initFromActiveVps ( const TComVPS* vps ); |
---|
| 312 | #if NH_3D |
---|
[608] | 313 | Void setViewIndex ( Int viewIndex ) { m_viewIndex = viewIndex; } |
---|
| 314 | Int getViewIndex () { return m_viewIndex; } |
---|
| 315 | Void setIsDepth ( Bool isDepth ) { m_isDepth = isDepth; } |
---|
| 316 | Bool getIsDepth () { return m_isDepth; } |
---|
| 317 | Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; } |
---|
[1179] | 318 | |
---|
[1200] | 319 | |
---|
[1179] | 320 | Bool decProcAnnexI() { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); } |
---|
[21] | 321 | #endif |
---|
[1179] | 322 | #endif |
---|
[1200] | 323 | |
---|
[2] | 324 | protected: |
---|
[1200] | 325 | Void xGetNewPicBuffer (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
[56] | 326 | Void xCreateLostPicture (Int iLostPOC); |
---|
[5] | 327 | |
---|
[56] | 328 | Void xActivateParameterSets(); |
---|
[1200] | 329 | #if NH_MV |
---|
[608] | 330 | TComPic* xGetPic( Int layerId, Int poc ); |
---|
[738] | 331 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); |
---|
[622] | 332 | Void xResetPocInPicBuffer(); |
---|
[738] | 333 | Void xCeckNoClrasOutput(); |
---|
| 334 | |
---|
[1200] | 335 | Bool xAllRefLayersInitilized( const TComVPS* vps ); |
---|
[608] | 336 | #else |
---|
[56] | 337 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
[608] | 338 | #endif |
---|
[1200] | 339 | Void xDecodeVPS(const std::vector<UChar> &naluData); |
---|
| 340 | Void xDecodeSPS(const std::vector<UChar> &naluData); |
---|
| 341 | Void xDecodePPS(const std::vector<UChar> &naluData); |
---|
| 342 | 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(); } } |
---|
[56] | 343 | |
---|
[1200] | 344 | Void xParsePrefixSEImessages(); |
---|
| 345 | Void xParsePrefixSEIsForUnknownVCLNal(); |
---|
| 346 | |
---|
[2] | 347 | };// END CLASS DEFINITION TDecTop |
---|
| 348 | |
---|
| 349 | |
---|
[56] | 350 | //! \} |
---|
| 351 | |
---|
[2] | 352 | #endif // __TDECTOP__ |
---|
| 353 | |
---|