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

Last change on this file since 1296 was 1196, checked in by tech, 10 years ago

Merged 14.0-dev0@1187.

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