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

Last change on this file since 1313 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
Line 
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-2015, 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/TComPrediction.h"
47#include "TLibCommon/SEI.h"
48
49#include "TDecGop.h"
50#include "TDecEntropy.h"
51#include "TDecSbac.h"
52#include "TDecCAVLC.h"
53#include "SEIread.h"
54
55class InputNALUnit;
56
57//! \ingroup TLibDecoder
58//! \{
59
60// ====================================================================================================================
61// Class definition
62// ====================================================================================================================
63
64#if NH_MV
65class TAppDecTop;
66#endif
67#if NH_3D
68class CamParsCollector
69{
70public:
71  CamParsCollector  ();
72  ~CamParsCollector ();
73
74  Void  init        ( const TComVPS* vps );
75  Void  setCodeScaleOffsetFile( FILE* pCodedScaleOffsetFile ) { m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; };     
76
77  Void  uninit      ();
78  Void setSlice ( const TComSlice* pcSlice );
79
80  Bool  isInitialized() const     { return m_bInitialized; }
81  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
82
83#if !NH_3D_FIX_TICKET_101
84#if NH_3D_IV_MERGE
85  Void  copyCamParamForSlice( TComSlice* pcSlice );
86#endif
87#endif
88
89private:
90  Void xResetReceivedIdc( Bool overWriteFlag ); 
91  Void  xOutput     ( Int iPOC );
92
93private:
94  Bool    m_bInitialized;
95  FILE*   m_pCodedScaleOffsetFile;
96
97  Int**   m_aaiCodedOffset;
98  Int**   m_aaiCodedScale;
99 
100  const TComVPS* m_vps; 
101  Int**    m_receivedIdc; 
102  Int      m_lastPoc; 
103  Int      m_firstReceivedPoc; 
104
105 
106  Bool    m_bCamParsVaryOverTime;
107
108  UInt    m_uiBitDepthForLUT;
109  UInt    m_iLog2Precision;
110  // UInt    m_uiInputBitDepth;
111
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
121};
122
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
179#endif //NH_3D
180/// decoder class
181class TDecTop
182{
183private:
184  Int                     m_iMaxRefPicNum;
185
186  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
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)
189
190  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
191#if NH_MV
192  Bool*                    m_layerInitilizedFlag; // initialization Layers
193  static ParameterSetManager m_parameterSetManager;  // storage for parameter sets
194  Int                      m_targetOlsIdx; 
195#else
196  ParameterSetManager     m_parameterSetManager;  // storage for parameter sets
197#endif
198  TComSlice*              m_apcSlicePilot;
199
200  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs...
201
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;
212  SEIReader               m_seiReader;
213  TComLoopFilter          m_cLoopFilter;
214  TComSampleAdaptiveOffset m_cSAO;
215
216  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
217#if NH_MV
218  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay, const TComVPS* vps);
219#else
220  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
221#endif
222  TComPic*                m_pcPic;
223  UInt                    m_uiSliceIdx;
224  Int                     m_prevPOC;
225  Int                     m_prevTid0POC;
226  Bool                    m_bFirstSliceInPicture;
227  Bool                    m_bFirstSliceInSequence;
228  Bool                    m_prevSliceSkipped;
229  Int                     m_skippedPOC;
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
234#if O0043_BEST_EFFORT_DECODING
235  UInt                    m_forceDecodeBitDepth;
236#endif
237  std::ostream           *m_pDecodedSEIOutputStream;
238
239  Bool                    m_warningMessageSkipPicture;
240#if NH_MV
241  Bool                    m_isLastNALWasEos;
242#endif
243
244#if NH_MV
245  // For NH_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
246  Int                     m_layerId;
247  Int                     m_viewId;
248  TComPicLists*           m_ivPicLists;
249  std::vector<TComPic*>   m_refPicSetInterLayer0; 
250  std::vector<TComPic*>   m_refPicSetInterLayer1; 
251#if NH_3D
252  Int                     m_viewIndex; 
253  Bool                    m_isDepth;
254  CamParsCollector*       m_pcCamParsCollector;
255  Int                     m_profileIdc;
256#endif
257#endif
258
259  std::list<InputNALUnit*> m_prefixSEINALUs; /// Buffered up prefix SEI NAL Units.
260public:
261  TDecTop();
262  virtual ~TDecTop();
263
264  Void  create  ();
265  Void  destroy ();
266
267  Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
268
269  Void  init();
270#if NH_MV 
271  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
272  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
273#else 
274  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
275#endif
276  Void  deletePicBuffer();
277
278#if NH_MV
279  const TComVPS* getActiveVPS() { return m_parameterSetManager.getActiveVPS( ); }
280  const TComSPS* getActiveSPS() { return m_parameterSetManager.getActiveSPS( m_layerId ); }
281#endif
282
283#if NH_MV
284  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
285#else 
286  Void  executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
287#endif
288  Void  checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic);
289
290  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
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; }
297#endif
298  Void  setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; }
299  UInt  getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); }
300#if NH_MV   
301  TComPic*                getPic                ( Int poc );
302  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
303  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
304  Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
305  Void                    setTargetOlsIdx       ( Int targetOlsIdx ) { m_targetOlsIdx = targetOlsIdx; }   
306  Int                     getTargetOlsIdx       ( )                  { return m_targetOlsIdx; }   
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;     } 
312  Void                    initFromActiveVps     ( const TComVPS* vps );
313#if NH_3D   
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; }
319
320
321  Bool                    decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); }   
322#endif
323#endif
324
325protected:
326  Void  xGetNewPicBuffer  (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer);
327  Void  xCreateLostPicture (Int iLostPOC);
328
329  Void      xActivateParameterSets();
330#if NH_MV 
331  TComPic*  xGetPic( Int layerId, Int poc ); 
332  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); 
333  Void      xResetPocInPicBuffer();
334  Void      xCeckNoClrasOutput();
335
336  Bool      xAllRefLayersInitilized( const TComVPS* vps );
337#else
338  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
339#endif
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(); } }
344
345  Void      xParsePrefixSEImessages();
346  Void      xParsePrefixSEIsForUnknownVCLNal();
347
348};// END CLASS DEFINITION TDecTop
349
350
351//! \}
352
353#endif // __TDECTOP__
354
Note: See TracBrowser for help on using the repository browser.