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

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

Merged branch 13.1-dev0@1178.

  • Property svn:eol-style set to native
File size: 12.4 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/SEI.h"
47
48#include "TDecGop.h"
49#include "TDecEntropy.h"
50#include "TDecSbac.h"
51#include "TDecCAVLC.h"
52#include "SEIread.h"
53
54struct InputNALUnit;
55
56//! \ingroup TLibDecoder
57//! \{
58
59// ====================================================================================================================
60// Class definition
61// ====================================================================================================================
62
63#if H_MV
64class TAppDecTop;
65#endif
66#if H_3D
67class CamParsCollector
68{
69public:
70  CamParsCollector  ();
71  ~CamParsCollector ();
72
73  Void  init        ( FILE* pCodedScaleOffsetFile, TComVPS* vps );
74
75  Void  uninit      ();
76  Void  setSlice    ( TComSlice* pcSlice );
77
78  Bool  isInitialized() const     { return m_bInitialized; }
79  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
80
81#if H_3D_IV_MERGE
82  Void  copyCamParamForSlice( TComSlice* pcSlice );
83#endif
84
85
86private:
87  Void xResetReceivedIdc( Bool overWriteFlag ); 
88  Void  xOutput     ( Int iPOC );
89
90private:
91  Bool    m_bInitialized;
92  FILE*   m_pCodedScaleOffsetFile;
93
94  Int**   m_aaiCodedOffset;
95  Int**   m_aaiCodedScale;
96 
97  TComVPS* m_vps; 
98  Int**    m_receivedIdc; 
99#if!HHI_CAM_PARA_K0052
100  Int      m_uiMaxViewIndex; 
101#endif
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 //H_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 H_MV
192  Bool*                    m_layerInitilizedFlag; // initialization Layers
193  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
194  Int                      m_targetOptLayerSetIdx; 
195#else
196  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // 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
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  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
218  TComPic*                m_pcPic;
219  UInt                    m_uiSliceIdx;
220  Int                     m_prevPOC;
221  Bool                    m_bFirstSliceInPicture;
222  Bool                    m_bFirstSliceInSequence;
223  Bool                    m_prevSliceSkipped;
224  Int                     m_skippedPOC;
225#if SETTING_NO_OUT_PIC_PRIOR 
226  Bool                    m_bFirstSliceInBitstream;
227  Int                     m_lastPOCNoOutputPriorPics;
228  Bool                    m_isNoOutputPriorPics;
229  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
230#endif
231#if H_MV
232  Bool                    m_isLastNALWasEos;
233#endif
234
235#if H_MV
236  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
237  Int                     m_layerId;
238  Int                     m_viewId;
239  TComPicLists*           m_ivPicLists;
240  std::vector<TComPic*>   m_refPicSetInterLayer0; 
241  std::vector<TComPic*>   m_refPicSetInterLayer1; 
242#if H_3D
243  Int                     m_viewIndex; 
244  Bool                    m_isDepth;
245  CamParsCollector*       m_pcCamParsCollector;
246#endif
247#if H_3D_ANNEX_SELECTION_FIX
248  Int                     m_profileIdc;
249#endif
250#endif
251
252public:
253  TDecTop();
254  virtual ~TDecTop();
255 
256  Void  create  ();
257  Void  destroy ();
258
259  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
260
261  Void  init();
262#if H_MV 
263  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
264  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
265#else 
266  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
267#endif
268 
269  Void  deletePicBuffer();
270#if H_MV
271  TComVPS* getActiveVPS() { return m_parameterSetManagerDecoder.getActiveVPS( ); }
272  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS( m_layerId ); }
273#else
274  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
275#endif
276
277#if H_MV
278  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
279#else
280  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
281#endif
282 
283#if SETTING_NO_OUT_PIC_PRIOR 
284  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
285
286  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
287  Void  setNoOutputPriorPicsFlag (bool val) { m_isNoOutputPriorPics = val; }
288#endif
289#if H_MV   
290  TComPic*                getPic                ( Int poc );
291  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
292  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
293  Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
294  Void                    setTargetOptLayerSetIdx( Int targetOptLayerSetIdx ) { m_targetOptLayerSetIdx = targetOptLayerSetIdx; }   
295  TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present.
296  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
297  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
298  Int                     getLayerId            ()               { return m_layerId;    }
299  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
300  Int                     getViewId             ()               { return m_viewId;     } 
301#if H_3D   
302  Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
303  Int                     getViewIndex          ()               { return m_viewIndex;     } 
304  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
305  Bool                    getIsDepth            ()               { return m_isDepth;    }
306  Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
307#endif
308#if H_3D_ANNEX_SELECTION_FIX
309  Void                    setProfileIdc()
310  {       
311    if (m_targetOptLayerSetIdx != -1 )
312    {   
313      TComVPS* vps = getPrefetchedVPS(); 
314      Int lsIdx = vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
315      Int lIdx = -1; 
316      for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
317      {
318        if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
319        {
320          lIdx = j; 
321          break; 
322        }       
323      }
324      assert( lIdx != -1 ); 
325
326      Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOptLayerSetIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
327      assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 ); 
328      m_profileIdc = profileIdc;   
329    };
330  }
331  Bool                    decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); }   
332#endif
333
334#endif
335protected:
336  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
337  Void  xCreateLostPicture (Int iLostPOC);
338
339  Void      xActivateParameterSets();
340#if H_MV 
341  TComPic*  xGetPic( Int layerId, Int poc ); 
342  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); 
343  Void      xResetPocInPicBuffer();
344  Void      xCeckNoClrasOutput();
345
346  Bool      xAllRefLayersInitilized();
347#else
348  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
349#endif
350  Void      xDecodeVPS();
351  Void      xDecodeSPS();
352  Void      xDecodePPS();
353  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
354
355};// END CLASS DEFINITION TDecTop
356
357
358//! \}
359
360#endif // __TDECTOP__
361
Note: See TracBrowser for help on using the repository browser.