source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.h @ 476

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

Integration of 3D-HEVC merge related coding tools:
Inter-view motion merge candidate
HHI_INTER_VIEW_MOTION_PRED
SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
QC_MRG_CANS_B0048 , JCT3V-B0048, B0086, B0069
OL_DISMV_POS_B0069 , different pos for disparity MV candidate, B0069
MTK_INTERVIEW_MERGE_A0049 , second part
QC_AMVP_MRG_UNIFY_IVCAN_C0051
TEXTURE MERGING CANDIDATE , JCT3V-C0137

Notes: Two configurations are added:
PredDepthMapGen : 1
MultiviewMvPred : 7

From: yiwen.chen@… (MediaTek)

  • Property svn:eol-style set to native
File size: 10.0 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-2013, 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#if H_3D_IV_MERGE
48#include "TLibCommon/TComDepthMapGenerator.h"
49#endif
50
51#include "TDecGop.h"
52#include "TDecEntropy.h"
53#include "TDecSbac.h"
54#include "TDecCAVLC.h"
55#include "SEIread.h"
56
57struct InputNALUnit;
58
59//! \ingroup TLibDecoder
60//! \{
61
62// ====================================================================================================================
63// Class definition
64// ====================================================================================================================
65
66#if H_MV
67class TAppDecTop;
68#endif
69#if H_3D
70class CamParsCollector
71{
72public:
73  CamParsCollector  ();
74  ~CamParsCollector ();
75
76  Void  init        ( FILE* pCodedScaleOffsetFile );
77  Void  uninit      ();
78  Void  setSlice    ( TComSlice* pcSlice );
79
80  Bool  isInitialized() const     { return m_bInitialized; }
81  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
82
83private:
84  Bool  xIsComplete ();
85  Void  xOutput     ( Int iPOC );
86
87private:
88  Bool    m_bInitialized;
89  FILE*   m_pCodedScaleOffsetFile;
90
91  Int**   m_aaiCodedOffset;
92  Int**   m_aaiCodedScale;
93  Int*    m_aiViewId; 
94  Int*    m_aiLayerIdx;
95
96  Bool*   m_bViewReceived;
97  UInt    m_uiCamParsCodedPrecision;
98  Bool    m_bCamParsVaryOverTime;
99  Int     m_iLastViewIndex;
100  Int     m_iLastPOC;
101  UInt    m_uiMaxViewIndex;
102
103
104  UInt    m_uiBitDepthForLUT;
105  UInt    m_iLog2Precision;
106  UInt    m_uiInputBitDepth;
107
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
117};
118
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
175#endif //H_3D
176/// decoder class
177class TDecTop
178{
179private:
180  Int                     m_iMaxRefPicNum;
181 
182  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
183  Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
184  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
185
186  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
187#if H_MV
188  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
189#else
190  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
191#endif
192  TComSlice*              m_apcSlicePilot;
193 
194  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
195
196  // functional classes
197  TComPrediction          m_cPrediction;
198  TComTrQuant             m_cTrQuant;
199  TDecGop                 m_cGopDecoder;
200  TDecSlice               m_cSliceDecoder;
201  TDecCu                  m_cCuDecoder;
202  TDecEntropy             m_cEntropyDecoder;
203  TDecCavlc               m_cCavlcDecoder;
204  TDecSbac                m_cSbacDecoder;
205  TDecBinCABAC            m_cBinCABAC;
206  SEIReader               m_seiReader;
207  TComLoopFilter          m_cLoopFilter;
208  TComSampleAdaptiveOffset m_cSAO;
209
210  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
211  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
212  TComPic*                m_pcPic;
213  UInt                    m_uiSliceIdx;
214  Int                     m_prevPOC;
215  Bool                    m_bFirstSliceInPicture;
216  Bool                    m_bFirstSliceInSequence;
217#if H_MV
218  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
219  Int                     m_layerId;
220  Int                     m_viewId;
221  TComPicLists*           m_ivPicLists;
222  std::vector<TComPic*>   m_refPicSetInterLayer; 
223#if H_3D
224  Int                     m_viewIndex; 
225  Bool                    m_isDepth;
226  CamParsCollector*       m_pcCamParsCollector;
227#if H_3D_IV_MERGE
228  TComDepthMapGenerator   m_cDepthMapGenerator;
229  TAppDecTop*             m_tAppDecTop;
230#endif
231#endif
232#endif
233
234public:
235  TDecTop();
236  virtual ~TDecTop();
237 
238  Void  create  ();
239  Void  destroy ();
240
241  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
242
243#if H_3D_IV_MERGE
244  Void  init(TAppDecTop* pcTAppDecTop);
245#else
246  Void  init();
247#endif
248#if H_MV 
249  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
250#else 
251  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
252#endif
253 
254  Void  deletePicBuffer();
255
256#if H_MV
257  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
258#else
259  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
260#endif
261 
262#if H_MV   
263  TComPic*                getPic                ( Int poc );
264  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
265  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
266 
267  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
268  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
269  Int                     getLayerId            ()               { return m_layerId;    }
270  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
271  Int                     getViewId             ()               { return m_viewId;     } 
272#if H_3D   
273  Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
274  Int                     getViewIndex          ()               { return m_viewIndex;     } 
275  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
276  Bool                    getIsDepth            ()               { return m_isDepth;    }
277  Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
278#if H_3D_IV_MERGE
279  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
280#endif
281#endif
282#endif
283protected:
284  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
285  Void  xCreateLostPicture (Int iLostPOC);
286
287  Void      xActivateParameterSets();
288#if H_MV 
289  TComPic*  xGetPic( Int layerId, Int poc ); 
290  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag ); 
291#else
292  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
293#endif
294  Void      xDecodeVPS();
295  Void      xDecodeSPS();
296  Void      xDecodePPS();
297  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
298
299};// END CLASS DEFINITION TDecTop
300
301
302//! \}
303
304#endif // __TDECTOP__
305
Note: See TracBrowser for help on using the repository browser.