source: SHVCSoftware/trunk/source/Lib/TLibDecoder/TDecTop.h @ 757

Last change on this file since 757 was 713, checked in by seregin, 11 years ago

merge with SHM-6-dev

  • Property svn:eol-style set to native
File size: 13.9 KB
RevLine 
[313]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 *
[595]6 * Copyright (c) 2010-2014, ITU/ISO/IEC
[313]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"
[713]47#if Q0048_CGS_3D_ASYMLUT
48#include "TLibCommon/TCom3DAsymLUT.h"
49#endif
[313]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
[713]66#if Q0074_SEI_COLOR_MAPPING
67class TDecColorMapping
68{
69  Int   m_colorMapId;
70  Bool  m_colorMapCancelFlag;
71  Bool  m_colorMapPersistenceFlag;
72  Bool  m_colorMap_video_signal_type_present_flag;
73  Bool  m_colorMap_video_full_range_flag;
74  Int   m_colorMap_primaries;
75  Int   m_colorMap_transfer_characteristics;
76  Int   m_colorMap_matrix_coeffs;
77  Int   m_colorMapModelId;
78
79  Int   m_colour_map_coded_data_bit_depth;
80  Int   m_colour_map_target_bit_depth;
81
82  Int   m_num_input_pivots[3];
83  Int*  m_coded_input_pivot_value[3];
84  Int*  m_target_input_pivot_value[3];
85 
86  Bool  m_matrix_flag;
87  Int   m_log2_matrix_denom;
88  Int   m_matrix_coef[3][3];
89
90  Int   m_num_output_pivots[3];
91  Int*  m_coded_output_pivot_value[3];
92  Int*  m_target_output_pivot_value[3];
93
94  Bool  m_lut1d_computed[3];
95  Int*  m_lut1d_input[3];
96  Int*  m_lut1d_output[3];
97  TComPicYuv* m_pcColorMappingPic[2];
98
99public:
100  TDecColorMapping();
101  ~TDecColorMapping();
102
103  Bool        getColorMappingFlag()                     { return(!m_colorMapCancelFlag);};
104
105  Void        setColorMapping( SEIMessages m_SEIs );
106  Void        setColorMapping( Int bitDepthY, Int bitDepthC );
107  TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );
108};// END CLASS DEFINITION TDecColorMapping
109#endif
110
[313]111/// decoder class
112class TDecTop
113{
114private:
115  Int                     m_iMaxRefPicNum;
116 
[442]117  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
[313]118  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
119  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
120
121  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
122  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
123  TComSlice*              m_apcSlicePilot;
[442]124
[313]125  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
126
127  // functional classes
128  TComPrediction          m_cPrediction;
[713]129#if Q0048_CGS_3D_ASYMLUT
130  TCom3DAsymLUT           m_c3DAsymLUTPPS;
131  TComPicYuv*             m_pColorMappedPic;
132#endif
[313]133  TComTrQuant             m_cTrQuant;
134  TDecGop                 m_cGopDecoder;
135  TDecSlice               m_cSliceDecoder;
136  TDecCu                  m_cCuDecoder;
137  TDecEntropy             m_cEntropyDecoder;
138  TDecCavlc               m_cCavlcDecoder;
139  TDecSbac                m_cSbacDecoder;
140  TDecBinCABAC            m_cBinCABAC;
141  SEIReader               m_seiReader;
142  TComLoopFilter          m_cLoopFilter;
143  TComSampleAdaptiveOffset m_cSAO;
144
145  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
146  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
147  TComPic*                m_pcPic;
148  UInt                    m_uiSliceIdx;
149#if !SVC_EXTENSION
150  Int                     m_prevPOC;
151#endif
152  Bool                    m_bFirstSliceInPicture;
153#if !SVC_EXTENSION
154  Bool                    m_bFirstSliceInSequence;
155#endif
[442]156  Bool                    m_prevSliceSkipped;
157  Int                     m_skippedPOC;
[713]158#if SETTING_NO_OUT_PIC_PRIOR 
159  Bool                    m_bFirstSliceInBitstream;
160  Int                     m_lastPOCNoOutputPriorPics;
161  Bool                    m_isNoOutputPriorPics;
162  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
163#endif
[313]164
165#if SVC_EXTENSION
166  static UInt             m_prevPOC;        // POC of the previous slice
167  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
168  static Bool             m_bFirstSliceInSequence;
169  UInt                    m_layerId;     
170  UInt                    m_numLayer;
171  TDecTop**               m_ppcTDecTop;
172#if AVC_BASE
173  fstream*                m_pBLReconFile;
[713]174#if !REPN_FORMAT_IN_VPS
[313]175  Int                     m_iBLSourceWidth;
[713]176  Int                     m_iBLSourceHeight;
[313]177#endif
[713]178#endif
[588]179#if VPS_EXTN_DIRECT_REF_LAYERS
[313]180  Int                     m_numDirectRefLayers;
181  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
182  Int                     m_numSamplePredRefLayers;
183  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
184  Int                     m_numMotionPredRefLayers;
185  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
186  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
187  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
188#endif
[442]189  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
[313]190#endif
[540]191#if OUTPUT_LAYER_SET_INDEX
192  CommonDecoderParams*    m_commonDecoderParams;
193#endif
[313]194#if AVC_SYNTAX || SYNTAX_OUTPUT
195  fstream*               m_pBLSyntaxFile;
196#endif
197
[713]198#if NO_CLRAS_OUTPUT_FLAG 
[540]199  Bool                    m_noClrasOutputFlag;
200  Bool                    m_layerInitializedFlag;
201  Bool                    m_firstPicInLayerDecodedFlag;
202#endif
[588]203#if RESOLUTION_BASED_DPB
[713]204  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
205                                           // When new VPS is activated, this should be re-initialized to -1
[588]206#endif
[313]207public:
[713]208#if Q0074_SEI_COLOR_MAPPING
209  TDecColorMapping* m_ColorMapping;
210#endif
211
[313]212  TDecTop();
213  virtual ~TDecTop();
214 
215  Void  create  ();
216  Void  destroy ();
217
218  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
219
220  Void  init();
221#if SVC_EXTENSION
222  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
223#else
224  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
225#endif
226 
227  Void  deletePicBuffer();
228
[713]229 
230  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
231
232
[313]233  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
[713]234#if SETTING_NO_OUT_PIC_PRIOR 
235  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
236  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
237  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
238#endif
239
[313]240#if SVC_EXTENSION
[442]241#if EARLY_REF_PIC_MARKING
242  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
243#endif
[313]244  UInt      getLayerId            () { return m_layerId;              }
245  Void      setLayerId            (UInt layer) { m_layerId = layer; }
246  UInt      getNumLayer           () { return m_numLayer;             }
247  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
248  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
249  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
250  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
251#if VPS_EXTN_DIRECT_REF_LAYERS
252  TDecTop*  getRefLayerDec(UInt refLayerIdc);
253  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
254  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
255
256  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
257  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
258
259  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
260  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
261
262  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
263  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
264
265  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
266  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
267
268  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
269  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
270
271  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
272  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
273
274  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
275  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
276
277  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
278  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
279
280  Void      setRefLayerParams( TComVPS* vps );
281#endif
282#if AVC_BASE
283  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
284  fstream*  getBLReconFile() { return m_pBLReconFile; }
[713]285#if !REPN_FORMAT_IN_VPS
[313]286  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
287  Int       getBLWidth() { return  m_iBLSourceWidth; }
288  Int       getBLHeight() { return  m_iBLSourceHeight; }
289#endif
[713]290#endif
[442]291#if REPN_FORMAT_IN_VPS
292  Void      xInitILRP(TComSlice *slice);
293#else
294  Void      xInitILRP(TComSPS *pcSPS);
[313]295#endif
[595]296#if OUTPUT_LAYER_SET_INDEX
297  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
298  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
299  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
[442]300#endif
[595]301#if SCALINGLIST_INFERRING
302  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
303#endif
304#if RESOLUTION_BASED_DPB
305  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
306  Int  getSubDpbIdx()           { return m_subDpbIdx; }
307  Void assignSubDpbs(TComVPS *vps);
308#endif
309#endif //SVC_EXTENSION
[313]310#if AVC_SYNTAX || SYNTAX_OUTPUT
311  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
312  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
313#endif
314protected:
315  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
316  Void  xCreateLostPicture (Int iLostPOC);
317
318  Void      xActivateParameterSets();
319#if SVC_EXTENSION
[442]320#if POC_RESET_FLAG
321  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
322#else
[313]323  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
[442]324#endif
[313]325#else
326  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
327#endif
328  Void      xDecodeVPS();
329  Void      xDecodeSPS();
[713]330  Void      xDecodePPS(
331#if Q0048_CGS_3D_ASYMLUT
332    TCom3DAsymLUT * pc3DAsymLUT
333#endif
334    );
[313]335  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
336
[540]337#if NO_CLRAS_OUTPUT_FLAG
338  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
339  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
340  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
341  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
342  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
343  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
344#endif
[713]345#if Q0048_CGS_3D_ASYMLUT
346  Void initAsymLut(TComSlice *pcSlice);
[644]347#endif
[313]348};// END CLASS DEFINITION TDecTop
349
350
351//! \}
352
353#endif // __TDECTOP__
354
Note: See TracBrowser for help on using the repository browser.