source: 3DVCSoftware/branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecTop.h @ 1417

Last change on this file since 1417 was 795, checked in by mediatek-htm, 11 years ago

Integration of DDD (JCT3V-G0063)

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