source: 3DVCSoftware/branches/HTM-14.1-update-dev2-Orange/source/Lib/TLibDecoder/TDecTop.h @ 1232

Last change on this file since 1232 was 1200, checked in by tech, 10 years ago

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

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