source: SHVCSoftware/branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.h @ 794

Last change on this file since 794 was 747, checked in by qualcomm, 11 years ago

Implementation of adoption JCTVC_Q0177 related to EOS
MACRO: Q0177_EOS_CHECKS
Checks include:

  • LayerId of EOS NALU should be 0, gives warning if not and ignore the NAL.
  • An EOS NALU shall be the last NALU except an EOB NALU
  • After EOS, the next AU must be IRAP AU

Submitted by Hendry (fhendry@…)

  • Property svn:eol-style set to native
File size: 14.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-2014, 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 Q0048_CGS_3D_ASYMLUT
48#include "TLibCommon/TCom3DAsymLUT.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 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
111/// decoder class
112class TDecTop
113{
114private:
115  Int                     m_iMaxRefPicNum;
116 
117  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
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;
124
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;
129#if Q0048_CGS_3D_ASYMLUT
130  TCom3DAsymLUT           m_c3DAsymLUTPPS;
131  TComPicYuv*             m_pColorMappedPic;
132#endif
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
156  Bool                    m_prevSliceSkipped;
157  Int                     m_skippedPOC;
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
164#if Q0177_EOS_CHECKS
165  Bool                    m_isLastNALWasEos;
166#endif
167
168#if SVC_EXTENSION
169  static UInt             m_prevPOC;        // POC of the previous slice
170  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
171  static Bool             m_bFirstSliceInSequence;
172  UInt                    m_layerId;     
173  UInt                    m_numLayer;
174  TDecTop**               m_ppcTDecTop;
175#if AVC_BASE
176  fstream*                m_pBLReconFile;
177#if !REPN_FORMAT_IN_VPS
178  Int                     m_iBLSourceWidth;
179  Int                     m_iBLSourceHeight;
180#endif
181#endif
182#if VPS_EXTN_DIRECT_REF_LAYERS
183  Int                     m_numDirectRefLayers;
184  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
185  Int                     m_numSamplePredRefLayers;
186  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
187  Int                     m_numMotionPredRefLayers;
188  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
189  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
190  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
191#endif
192  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
193#endif
194#if OUTPUT_LAYER_SET_INDEX
195  CommonDecoderParams*    m_commonDecoderParams;
196#endif
197#if AVC_SYNTAX || SYNTAX_OUTPUT
198  fstream*               m_pBLSyntaxFile;
199#endif
200
201#if NO_CLRAS_OUTPUT_FLAG 
202  Bool                    m_noClrasOutputFlag;
203  Bool                    m_layerInitializedFlag;
204  Bool                    m_firstPicInLayerDecodedFlag;
205#endif
206#if RESOLUTION_BASED_DPB
207  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
208                                           // When new VPS is activated, this should be re-initialized to -1
209#endif
210public:
211#if Q0074_SEI_COLOR_MAPPING
212  TDecColorMapping* m_ColorMapping;
213#endif
214
215  TDecTop();
216  virtual ~TDecTop();
217 
218  Void  create  ();
219  Void  destroy ();
220
221  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
222
223  Void  init();
224#if SVC_EXTENSION
225  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
226#else
227  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
228#endif
229 
230  Void  deletePicBuffer();
231
232 
233  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
234
235
236  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
237#if SETTING_NO_OUT_PIC_PRIOR 
238  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
239  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
240  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
241#endif
242
243#if SVC_EXTENSION
244#if EARLY_REF_PIC_MARKING
245  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
246#endif
247  UInt      getLayerId            () { return m_layerId;              }
248  Void      setLayerId            (UInt layer) { m_layerId = layer; }
249  UInt      getNumLayer           () { return m_numLayer;             }
250  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
251  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
252  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
253  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
254#if VPS_EXTN_DIRECT_REF_LAYERS
255  TDecTop*  getRefLayerDec(UInt refLayerIdc);
256  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
257  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
258
259  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
260  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
261
262  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
263  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
264
265  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
266  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
267
268  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
269  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
270
271  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
272  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
273
274  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
275  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
276
277  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
278  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
279
280  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
281  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
282
283  Void      setRefLayerParams( TComVPS* vps );
284#endif
285#if AVC_BASE
286  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
287  fstream*  getBLReconFile() { return m_pBLReconFile; }
288#if !REPN_FORMAT_IN_VPS
289  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
290  Int       getBLWidth() { return  m_iBLSourceWidth; }
291  Int       getBLHeight() { return  m_iBLSourceHeight; }
292#endif
293#endif
294#if REPN_FORMAT_IN_VPS
295  Void      xInitILRP(TComSlice *slice);
296#else
297  Void      xInitILRP(TComSPS *pcSPS);
298#endif
299#if OUTPUT_LAYER_SET_INDEX
300  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
301  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
302  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
303#endif
304#if SCALINGLIST_INFERRING
305  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
306#endif
307#if RESOLUTION_BASED_DPB
308  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
309  Int  getSubDpbIdx()           { return m_subDpbIdx; }
310  Void assignSubDpbs(TComVPS *vps);
311#endif
312#endif //SVC_EXTENSION
313#if AVC_SYNTAX || SYNTAX_OUTPUT
314  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
315  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
316#endif
317protected:
318  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
319  Void  xCreateLostPicture (Int iLostPOC);
320
321  Void      xActivateParameterSets();
322#if SVC_EXTENSION
323#if POC_RESET_FLAG
324  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
325#else
326  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
327#endif
328#else
329  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
330#endif
331  Void      xDecodeVPS();
332  Void      xDecodeSPS();
333  Void      xDecodePPS(
334#if Q0048_CGS_3D_ASYMLUT
335    TCom3DAsymLUT * pc3DAsymLUT
336#endif
337    );
338  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
339
340#if NO_CLRAS_OUTPUT_FLAG
341  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
342  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
343  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
344  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
345  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
346  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
347#endif
348#if Q0048_CGS_3D_ASYMLUT
349  Void initAsymLut(TComSlice *pcSlice);
350#endif
351};// END CLASS DEFINITION TDecTop
352
353
354//! \}
355
356#endif // __TDECTOP__
357
Note: See TracBrowser for help on using the repository browser.