source: 3DVCSoftware/trunk/source/Lib/TLibDecoder/TDecTop.h @ 1314

Last change on this file since 1314 was 1313, checked in by tech, 9 years ago

Merged 14.1-update-dev1@1312.

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