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

Last change on this file since 789 was 773, checked in by tech, 11 years ago

Merged branch/9.2-dev0@722.

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