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

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

commit the patch implementing JCTVC-Q0074 provided by Bordes Philippe <philippe.bordes@…>

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