source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h @ 1110

Last change on this file since 1110 was 1107, checked in by seregin, 10 years ago

macro cleanup: R0235_SMALLEST_LAYER_ID

  • Property svn:eol-style set to native
File size: 143.5 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     TComSlice.h
35    \brief    slice header and SPS class (header)
36*/
37
38#ifndef __TCOMSLICE__
39#define __TCOMSLICE__
40
41#include <cstring>
42#include <map>
43#include <vector>
44#include "CommonDef.h"
45#include "TComRom.h"
46#include "TComList.h"
47#include "TComChromaFormat.h"
48
49//! \ingroup TLibCommon
50//! \{
51
52class TComPic;
53class TComTrQuant;
54
55#if SVC_EXTENSION
56class TComPicYuv;
57#endif
58// ====================================================================================================================
59// Constants
60// ====================================================================================================================
61
62static const UInt REF_PIC_LIST_NUM_IDX=32;
63
64// ====================================================================================================================
65// Class definition
66// ====================================================================================================================
67
68/// Reference Picture Set class
69class TComReferencePictureSet
70{
71private:
72  Int  m_numberOfPictures;
73  Int  m_numberOfNegativePictures;
74  Int  m_numberOfPositivePictures;
75  Int  m_numberOfLongtermPictures;
76  Int  m_deltaPOC[MAX_NUM_REF_PICS];
77  Int  m_POC[MAX_NUM_REF_PICS];
78  Bool m_used[MAX_NUM_REF_PICS];
79  Bool m_interRPSPrediction;
80  Int  m_deltaRIdxMinus1;
81  Int  m_deltaRPS;
82  Int  m_numRefIdc;
83  Int  m_refIdc[MAX_NUM_REF_PICS+1];
84  Bool m_bCheckLTMSB[MAX_NUM_REF_PICS];
85  Int  m_pocLSBLT[MAX_NUM_REF_PICS];
86  Int  m_deltaPOCMSBCycleLT[MAX_NUM_REF_PICS];
87  Bool m_deltaPocMSBPresentFlag[MAX_NUM_REF_PICS];
88
89public:
90  TComReferencePictureSet();
91  virtual ~TComReferencePictureSet();
92  Int   getPocLSBLT(Int i)                       { return m_pocLSBLT[i]; }
93  Void  setPocLSBLT(Int i, Int x)                { m_pocLSBLT[i] = x; }
94  Int   getDeltaPocMSBCycleLT(Int i)             { return m_deltaPOCMSBCycleLT[i]; }
95  Void  setDeltaPocMSBCycleLT(Int i, Int x)      { m_deltaPOCMSBCycleLT[i] = x; }
96  Bool  getDeltaPocMSBPresentFlag(Int i)         { return m_deltaPocMSBPresentFlag[i]; }
97  Void  setDeltaPocMSBPresentFlag(Int i, Bool x) { m_deltaPocMSBPresentFlag[i] = x;    }
98  Void setUsed(Int bufferNum, Bool used);
99  Void setDeltaPOC(Int bufferNum, Int deltaPOC);
100  Void setPOC(Int bufferNum, Int deltaPOC);
101  Void setNumberOfPictures(Int numberOfPictures);
102  Void setCheckLTMSBPresent(Int bufferNum, Bool b );
103  Bool getCheckLTMSBPresent(Int bufferNum);
104
105  Int  getUsed(Int bufferNum);
106  Int  getDeltaPOC(Int bufferNum);
107  Int  getPOC(Int bufferNum);
108  Int  getNumberOfPictures();
109
110  Void setNumberOfNegativePictures(Int number)  { m_numberOfNegativePictures = number; }
111  Int  getNumberOfNegativePictures()            { return m_numberOfNegativePictures; }
112  Void setNumberOfPositivePictures(Int number)  { m_numberOfPositivePictures = number; }
113  Int  getNumberOfPositivePictures()            { return m_numberOfPositivePictures; }
114  Void setNumberOfLongtermPictures(Int number)  { m_numberOfLongtermPictures = number; }
115  Int  getNumberOfLongtermPictures()            { return m_numberOfLongtermPictures; }
116
117  Void setInterRPSPrediction(Bool flag)         { m_interRPSPrediction = flag; }
118  Bool getInterRPSPrediction()                  { return m_interRPSPrediction; }
119  Void setDeltaRIdxMinus1(Int x)                { m_deltaRIdxMinus1 = x; }
120  Int  getDeltaRIdxMinus1()                     { return m_deltaRIdxMinus1; }
121  Void setDeltaRPS(Int x)                       { m_deltaRPS = x; }
122  Int  getDeltaRPS()                            { return m_deltaRPS; }
123  Void setNumRefIdc(Int x)                      { m_numRefIdc = x; }
124  Int  getNumRefIdc()                           { return m_numRefIdc; }
125
126  Void setRefIdc(Int bufferNum, Int refIdc);
127  Int  getRefIdc(Int bufferNum);
128
129  Void sortDeltaPOC();
130  Void printDeltaPOC();
131};
132
133/// Reference Picture Set set class
134class TComRPSList
135{
136private:
137  Int  m_numberOfReferencePictureSets;
138  TComReferencePictureSet* m_referencePictureSets;
139
140public:
141  TComRPSList();
142  virtual ~TComRPSList();
143
144  Void  create  (Int numberOfEntries);
145  Void  destroy ();
146
147
148  TComReferencePictureSet* getReferencePictureSet(Int referencePictureSetNum);
149  Int getNumberOfReferencePictureSets();
150  Void setNumberOfReferencePictureSets(Int numberOfReferencePictureSets);
151};
152
153/// SCALING_LIST class
154class TComScalingList
155{
156public:
157  TComScalingList();
158  virtual ~TComScalingList();
159  Void     setScalingListPresentFlag      (Bool b)                             { m_scalingListPresentFlag = b;    }
160  Bool     getScalingListPresentFlag      ()                                   { return m_scalingListPresentFlag; }
161  Int*           getScalingListAddress    (UInt sizeId, UInt listId)           { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient
162  const Int*     getScalingListAddress    (UInt sizeId, UInt listId) const     { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient
163  Bool     checkPredMode                  (UInt sizeId, UInt listId);
164  Void     setRefMatrixId                 (UInt sizeId, UInt listId, UInt u)   { m_refMatrixId[sizeId][listId] = u;    }     //!< set reference matrix ID
165  UInt     getRefMatrixId                 (UInt sizeId, UInt listId)           { return m_refMatrixId[sizeId][listId]; }     //!< get reference matrix ID
166  Int*     getScalingListDefaultAddress   (UInt sizeId, UInt listId);                                                        //!< get default matrix coefficient
167  Void     processDefaultMatrix           (UInt sizeId, UInt listId);
168  Void     setScalingListDC               (UInt sizeId, UInt listId, UInt u)   { m_scalingListDC[sizeId][listId] = u; }      //!< set DC value
169
170  Int      getScalingListDC               (UInt sizeId, UInt listId) const     { return m_scalingListDC[sizeId][listId]; }   //!< get DC value
171  Void     checkDcOfMatrix                ();
172  Void     processRefMatrix               (UInt sizeId, UInt listId , UInt refListId );
173  Bool     xParseScalingList              (Char* pchFile);
174
175private:
176  Void     init                    ();
177  Void     destroy                 ();
178  Void     outputScalingLists(std::ostream &os) const;
179  Int      m_scalingListDC               [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< the DC value of the matrix coefficient for 16x16
180  Bool     m_useDefaultScalingMatrixFlag [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< UseDefaultScalingMatrixFlag
181  UInt     m_refMatrixId                 [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< RefMatrixID
182  Bool     m_scalingListPresentFlag;                                                //!< flag for using default matrix
183  UInt     m_predMatrixId                [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index
184  Int      *m_scalingListCoef            [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix
185};
186
187class ProfileTierLevel
188{
189  Int               m_profileSpace;
190  Level::Tier       m_tierFlag;
191  Profile::Name     m_profileIdc;
192  Bool              m_profileCompatibilityFlag[32];
193  Level::Name       m_levelIdc;
194
195  Bool              m_progressiveSourceFlag;
196  Bool              m_interlacedSourceFlag;
197  Bool              m_nonPackedConstraintFlag;
198  Bool              m_frameOnlyConstraintFlag;
199  UInt              m_bitDepthConstraintValue;
200  ChromaFormat      m_chromaFormatConstraintValue;
201  Bool              m_intraConstraintFlag;
202  Bool              m_lowerBitRateConstraintFlag;
203
204public:
205  ProfileTierLevel();
206
207  Int  getProfileSpace() const                     { return m_profileSpace; }
208  Void setProfileSpace(Int x)                      { m_profileSpace = x; }
209
210  Level::Tier  getTierFlag() const                 { return m_tierFlag; }
211  Void setTierFlag(Level::Tier x)                  { m_tierFlag = x; }
212
213  Profile::Name   getProfileIdc() const            { return m_profileIdc; }
214  Void setProfileIdc(Profile::Name x)              { m_profileIdc = x; }
215
216  Bool getProfileCompatibilityFlag(Int i) const    { return m_profileCompatibilityFlag[i]; }
217  Void setProfileCompatibilityFlag(Int i, Bool x)  { m_profileCompatibilityFlag[i] = x; }
218
219  Level::Name   getLevelIdc() const                { return m_levelIdc; }
220  Void setLevelIdc(Level::Name x)                  { m_levelIdc = x; }
221
222  Bool getProgressiveSourceFlag() const            { return m_progressiveSourceFlag; }
223  Void setProgressiveSourceFlag(Bool b)            { m_progressiveSourceFlag = b; }
224
225  Bool getInterlacedSourceFlag() const             { return m_interlacedSourceFlag; }
226  Void setInterlacedSourceFlag(Bool b)             { m_interlacedSourceFlag = b; }
227
228  Bool getNonPackedConstraintFlag() const          { return m_nonPackedConstraintFlag; }
229  Void setNonPackedConstraintFlag(Bool b)          { m_nonPackedConstraintFlag = b; }
230
231  Bool getFrameOnlyConstraintFlag() const          { return m_frameOnlyConstraintFlag; }
232  Void setFrameOnlyConstraintFlag(Bool b)          { m_frameOnlyConstraintFlag = b; }
233
234  UInt getBitDepthConstraint() const               { return m_bitDepthConstraintValue; }
235  Void setBitDepthConstraint(UInt bitDepth)        { m_bitDepthConstraintValue=bitDepth; }
236
237  ChromaFormat getChromaFormatConstraint() const   { return m_chromaFormatConstraintValue; }
238  Void setChromaFormatConstraint(ChromaFormat fmt) { m_chromaFormatConstraintValue=fmt; }
239
240  Bool getIntraConstraintFlag() const              { return m_intraConstraintFlag; }
241  Void setIntraConstraintFlag(Bool b)              { m_intraConstraintFlag = b; }
242
243  Bool getLowerBitRateConstraintFlag() const       { return m_lowerBitRateConstraintFlag; }
244  Void setLowerBitRateConstraintFlag(Bool b)       { m_lowerBitRateConstraintFlag = b; }
245
246#if VPS_EXTN_PROFILE_INFO
247  Void copyProfileInfo(ProfileTierLevel *ptl);
248#endif
249};
250
251
252class TComPTL
253{
254  ProfileTierLevel m_generalPTL;
255  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 (= 6)
256  Bool m_subLayerProfilePresentFlag [MAX_TLAYER-1];
257  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER-1];
258
259public:
260  TComPTL();
261  Bool getSubLayerProfilePresentFlag(Int i) const { return m_subLayerProfilePresentFlag[i]; }
262  Void setSubLayerProfilePresentFlag(Int i, Bool x) { m_subLayerProfilePresentFlag[i] = x; }
263
264  Bool getSubLayerLevelPresentFlag(Int i) const { return m_subLayerLevelPresentFlag[i]; }
265  Void setSubLayerLevelPresentFlag(Int i, Bool x) { m_subLayerLevelPresentFlag[i] = x; }
266
267  ProfileTierLevel* getGeneralPTL()  { return &m_generalPTL; }
268  ProfileTierLevel* getSubLayerPTL(Int i)  { return &m_subLayerPTL[i]; }
269
270#if VPS_EXTN_PROFILE_INFO
271  Void copyProfileInfo(TComPTL *ptl);
272#endif
273};
274
275/// VPS class
276
277struct HrdSubLayerInfo
278{
279  Bool fixedPicRateFlag;
280  Bool fixedPicRateWithinCvsFlag;
281  UInt picDurationInTcMinus1;
282  Bool lowDelayHrdFlag;
283  UInt cpbCntMinus1;
284  UInt bitRateValueMinus1[MAX_CPB_CNT][2];
285  UInt cpbSizeValue      [MAX_CPB_CNT][2];
286  UInt ducpbSizeValue    [MAX_CPB_CNT][2];
287  UInt cbrFlag           [MAX_CPB_CNT][2];
288  UInt duBitRateValue    [MAX_CPB_CNT][2];
289};
290
291class TComHRD
292{
293private:
294  Bool m_nalHrdParametersPresentFlag;
295  Bool m_vclHrdParametersPresentFlag;
296  Bool m_subPicCpbParamsPresentFlag;
297  UInt m_tickDivisorMinus2;
298  UInt m_duCpbRemovalDelayLengthMinus1;
299  Bool m_subPicCpbParamsInPicTimingSEIFlag;
300  UInt m_dpbOutputDelayDuLengthMinus1;
301  UInt m_bitRateScale;
302  UInt m_cpbSizeScale;
303  UInt m_ducpbSizeScale;
304  UInt m_initialCpbRemovalDelayLengthMinus1;
305  UInt m_cpbRemovalDelayLengthMinus1;
306  UInt m_dpbOutputDelayLengthMinus1;
307  UInt m_numDU;
308  HrdSubLayerInfo m_HRD[MAX_TLAYER];
309
310public:
311  TComHRD()
312  :m_nalHrdParametersPresentFlag(0)
313  ,m_vclHrdParametersPresentFlag(0)
314  ,m_subPicCpbParamsPresentFlag(false)
315  ,m_tickDivisorMinus2(0)
316  ,m_duCpbRemovalDelayLengthMinus1(0)
317  ,m_subPicCpbParamsInPicTimingSEIFlag(false)
318  ,m_dpbOutputDelayDuLengthMinus1(0)
319  ,m_bitRateScale(0)
320  ,m_cpbSizeScale(0)
321  ,m_initialCpbRemovalDelayLengthMinus1(23)
322  ,m_cpbRemovalDelayLengthMinus1(23)
323  ,m_dpbOutputDelayLengthMinus1(23)
324  {}
325
326  virtual ~TComHRD() {}
327
328  Void setNalHrdParametersPresentFlag       ( Bool flag )  { m_nalHrdParametersPresentFlag = flag;         }
329  Bool getNalHrdParametersPresentFlag       ( )            { return m_nalHrdParametersPresentFlag;         }
330
331  Void setVclHrdParametersPresentFlag       ( Bool flag )  { m_vclHrdParametersPresentFlag = flag;         }
332  Bool getVclHrdParametersPresentFlag       ( )            { return m_vclHrdParametersPresentFlag;         }
333
334  Void setSubPicCpbParamsPresentFlag        ( Bool flag )  { m_subPicCpbParamsPresentFlag = flag;          }
335  Bool getSubPicCpbParamsPresentFlag        ( )            { return m_subPicCpbParamsPresentFlag;          }
336
337  Void setTickDivisorMinus2                 ( UInt value ) { m_tickDivisorMinus2 = value;                  }
338  UInt getTickDivisorMinus2                 ( )            { return m_tickDivisorMinus2;                   }
339
340  Void setDuCpbRemovalDelayLengthMinus1     ( UInt value ) { m_duCpbRemovalDelayLengthMinus1 = value;      }
341  UInt getDuCpbRemovalDelayLengthMinus1     ( )            { return m_duCpbRemovalDelayLengthMinus1;       }
342
343  Void setSubPicCpbParamsInPicTimingSEIFlag ( Bool flag)   { m_subPicCpbParamsInPicTimingSEIFlag = flag;   }
344  Bool getSubPicCpbParamsInPicTimingSEIFlag ()             { return m_subPicCpbParamsInPicTimingSEIFlag;   }
345
346  Void setDpbOutputDelayDuLengthMinus1      (UInt value )  { m_dpbOutputDelayDuLengthMinus1 = value;       }
347  UInt getDpbOutputDelayDuLengthMinus1      ()             { return m_dpbOutputDelayDuLengthMinus1;        }
348
349  Void setBitRateScale                      ( UInt value ) { m_bitRateScale = value;                       }
350  UInt getBitRateScale                      ( )            { return m_bitRateScale;                        }
351
352  Void setCpbSizeScale                      ( UInt value ) { m_cpbSizeScale = value;                       }
353  UInt getCpbSizeScale                      ( )            { return m_cpbSizeScale;                        }
354  Void setDuCpbSizeScale                    ( UInt value ) { m_ducpbSizeScale = value;                     }
355  UInt getDuCpbSizeScale                    ( )            { return m_ducpbSizeScale;                      }
356
357  Void setInitialCpbRemovalDelayLengthMinus1( UInt value ) { m_initialCpbRemovalDelayLengthMinus1 = value; }
358  UInt getInitialCpbRemovalDelayLengthMinus1( )            { return m_initialCpbRemovalDelayLengthMinus1;  }
359
360  Void setCpbRemovalDelayLengthMinus1       ( UInt value ) { m_cpbRemovalDelayLengthMinus1 = value;        }
361  UInt getCpbRemovalDelayLengthMinus1       ( )            { return m_cpbRemovalDelayLengthMinus1;         }
362
363  Void setDpbOutputDelayLengthMinus1        ( UInt value ) { m_dpbOutputDelayLengthMinus1 = value;         }
364  UInt getDpbOutputDelayLengthMinus1        ( )            { return m_dpbOutputDelayLengthMinus1;          }
365
366  Void setFixedPicRateFlag       ( Int layer, Bool flag )  { m_HRD[layer].fixedPicRateFlag = flag;         }
367  Bool getFixedPicRateFlag       ( Int layer            )  { return m_HRD[layer].fixedPicRateFlag;         }
368
369  Void setFixedPicRateWithinCvsFlag       ( Int layer, Bool flag )  { m_HRD[layer].fixedPicRateWithinCvsFlag = flag;         }
370  Bool getFixedPicRateWithinCvsFlag       ( Int layer            )  { return m_HRD[layer].fixedPicRateWithinCvsFlag;         }
371
372  Void setPicDurationInTcMinus1  ( Int layer, UInt value ) { m_HRD[layer].picDurationInTcMinus1 = value;   }
373  UInt getPicDurationInTcMinus1  ( Int layer             ) { return m_HRD[layer].picDurationInTcMinus1;    }
374
375  Void setLowDelayHrdFlag        ( Int layer, Bool flag )  { m_HRD[layer].lowDelayHrdFlag = flag;          }
376  Bool getLowDelayHrdFlag        ( Int layer            )  { return m_HRD[layer].lowDelayHrdFlag;          }
377
378  Void setCpbCntMinus1           ( Int layer, UInt value ) { m_HRD[layer].cpbCntMinus1 = value; }
379  UInt getCpbCntMinus1           ( Int layer            )  { return m_HRD[layer].cpbCntMinus1; }
380
381  Void setBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl] = value; }
382  UInt getBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl             ) { return m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl];  }
383
384  Void setCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl] = value;       }
385  UInt getCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl            )  { return m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl];        }
386  Void setDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl] = value;       }
387  UInt getDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl            )  { return m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl];        }
388  Void setDuBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl] = value;       }
389  UInt getDuBitRateValueMinus1     (Int layer, Int cpbcnt, Int nalOrVcl )              { return m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl];        }
390  Void setCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl] = value;            }
391  Bool getCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl             ) { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl];             }
392
393  Void setNumDU                              ( UInt value ) { m_numDU = value;                            }
394  UInt getNumDU                              ( )            { return m_numDU;          }
395  Bool getCpbDpbDelaysPresentFlag() { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
396
397#if VPS_VUI_BSP_HRD_PARAMS
398Void copyCommonInformation( TComHRD *refHrd )
399{
400  m_nalHrdParametersPresentFlag         = refHrd->getNalHrdParametersPresentFlag();
401  m_vclHrdParametersPresentFlag         = refHrd->getVclHrdParametersPresentFlag();
402  m_subPicCpbParamsPresentFlag          = refHrd->getSubPicCpbParamsPresentFlag();
403  m_tickDivisorMinus2                   = refHrd->getTickDivisorMinus2();
404  m_duCpbRemovalDelayLengthMinus1       = refHrd->getDuCpbRemovalDelayLengthMinus1();
405  m_subPicCpbParamsInPicTimingSEIFlag   = refHrd->getSubPicCpbParamsInPicTimingSEIFlag();
406  m_dpbOutputDelayDuLengthMinus1        = refHrd->getDpbOutputDelayDuLengthMinus1();
407  m_bitRateScale                        = refHrd->getBitRateScale();
408  m_cpbSizeScale                        = refHrd->getCpbSizeScale();
409  m_ducpbSizeScale                      = refHrd->getDuCpbSizeScale();
410  m_initialCpbRemovalDelayLengthMinus1  = refHrd->getInitialCpbRemovalDelayLengthMinus1();
411  m_cpbRemovalDelayLengthMinus1         = refHrd->getCpbRemovalDelayLengthMinus1();
412  m_dpbOutputDelayLengthMinus1          = refHrd->getDpbOutputDelayLengthMinus1();
413}
414#endif
415};
416
417class TimingInfo
418{
419  Bool m_timingInfoPresentFlag;
420  UInt m_numUnitsInTick;
421  UInt m_timeScale;
422  Bool m_pocProportionalToTimingFlag;
423  Int  m_numTicksPocDiffOneMinus1;
424public:
425  TimingInfo()
426  : m_timingInfoPresentFlag(false)
427  , m_numUnitsInTick(1001)
428  , m_timeScale(60000)
429  , m_pocProportionalToTimingFlag(false)
430  , m_numTicksPocDiffOneMinus1(0) {}
431
432  Void setTimingInfoPresentFlag             ( Bool flag )  { m_timingInfoPresentFlag = flag;               }
433  Bool getTimingInfoPresentFlag             ( )            { return m_timingInfoPresentFlag;               }
434
435  Void setNumUnitsInTick                    ( UInt value ) { m_numUnitsInTick = value;                     }
436  UInt getNumUnitsInTick                    ( )            { return m_numUnitsInTick;                      }
437
438  Void setTimeScale                         ( UInt value ) { m_timeScale = value;                          }
439  UInt getTimeScale                         ( )            { return m_timeScale;                           }
440
441  Bool getPocProportionalToTimingFlag       ( )            { return m_pocProportionalToTimingFlag;         }
442  Void setPocProportionalToTimingFlag       (Bool x      ) { m_pocProportionalToTimingFlag = x;            }
443
444  Int  getNumTicksPocDiffOneMinus1          ( )            { return m_numTicksPocDiffOneMinus1;            }
445  Void setNumTicksPocDiffOneMinus1          (Int x       ) { m_numTicksPocDiffOneMinus1 = x;               }
446};
447
448struct ChromaQpAdj
449{
450  union
451  {
452    struct {
453      Int CbOffset;
454      Int CrOffset;
455    } comp;
456    Int offset[2]; /* two chroma components */
457  } u;
458};
459
460
461class Window
462{
463private:
464  Bool          m_enabledFlag;
465  Int           m_winLeftOffset;
466  Int           m_winRightOffset;
467  Int           m_winTopOffset;
468  Int           m_winBottomOffset;
469
470public:
471  Window()
472  : m_enabledFlag (false)
473  , m_winLeftOffset     (0)
474  , m_winRightOffset    (0)
475  , m_winTopOffset      (0)
476  , m_winBottomOffset   (0)
477  { }
478
479  Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
480  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; }
481  Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
482  Void          setWindowLeftOffset(Int val)      { m_winLeftOffset = val; m_enabledFlag = true; }
483  Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
484  Void          setWindowRightOffset(Int val)     { m_winRightOffset = val; m_enabledFlag = true; }
485  Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
486  Void          setWindowTopOffset(Int val)       { m_winTopOffset = val; m_enabledFlag = true; }
487  Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
488  Void          setWindowBottomOffset(Int val)    { m_winBottomOffset = val; m_enabledFlag = true; }
489
490#if SVC_EXTENSION
491  Bool          hasEqualOffset(const Window& ref) const
492  {
493    return (    this->getWindowLeftOffset()   == ref.getWindowLeftOffset()
494             && this->getWindowTopOffset()    == ref.getWindowTopOffset()
495             && this->getWindowRightOffset()  == ref.getWindowRightOffset()
496             && this->getWindowBottomOffset() == ref.getWindowBottomOffset() );
497  }
498#endif
499
500  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
501  {
502    m_enabledFlag       = true;
503    m_winLeftOffset     = offsetLeft;
504    m_winRightOffset    = offsetLRight;
505    m_winTopOffset      = offsetLTop;
506    m_winBottomOffset   = offsetLBottom;
507  }
508};
509
510#if REPN_FORMAT_IN_VPS
511class RepFormat
512{
513#if REPN_FORMAT_CONTROL_FLAG
514  Bool m_chromaAndBitDepthVpsPresentFlag;
515#endif
516#if AUXILIARY_PICTURES
517  ChromaFormat m_chromaFormatVpsIdc;
518#else
519  Int  m_chromaFormatVpsIdc;
520#endif
521  Bool m_separateColourPlaneVpsFlag;
522  Int  m_picWidthVpsInLumaSamples;
523  Int  m_picHeightVpsInLumaSamples;
524  Int  m_bitDepthVpsLuma;               // coded as minus8
525  Int  m_bitDepthVpsChroma;             // coded as minus8
526
527#if R0156_CONF_WINDOW_IN_REP_FORMAT
528  Window m_conformanceWindowVps;
529#endif
530
531public:
532  RepFormat();
533#if REPN_FORMAT_CONTROL_FLAG
534  Bool getChromaAndBitDepthVpsPresentFlag() { return m_chromaAndBitDepthVpsPresentFlag; }
535  void setChromaAndBitDepthVpsPresentFlag(Bool x) { m_chromaAndBitDepthVpsPresentFlag = x; }
536#endif
537
538#if AUXILIARY_PICTURES
539  ChromaFormat getChromaFormatVpsIdc()        { return m_chromaFormatVpsIdc; }
540  Void setChromaFormatVpsIdc(ChromaFormat x)  { m_chromaFormatVpsIdc = x;    }
541#else
542  Int  getChromaFormatVpsIdc()        { return m_chromaFormatVpsIdc; }
543  Void setChromaFormatVpsIdc(Int x)   { m_chromaFormatVpsIdc = x;    }
544#endif
545
546  Bool getSeparateColourPlaneVpsFlag()        { return m_separateColourPlaneVpsFlag; }
547  Void setSeparateColourPlaneVpsFlag(Bool x)  { m_separateColourPlaneVpsFlag = x;    }
548
549  Int  getPicWidthVpsInLumaSamples()        { return m_picWidthVpsInLumaSamples; }
550  Void setPicWidthVpsInLumaSamples(Int x)   { m_picWidthVpsInLumaSamples = x;    }
551
552  Int  getPicHeightVpsInLumaSamples()        { return m_picHeightVpsInLumaSamples; }
553  Void setPicHeightVpsInLumaSamples(Int x)   { m_picHeightVpsInLumaSamples = x;    }
554
555  Int  getBitDepthVpsLuma()           { return m_bitDepthVpsLuma;   }
556  Void setBitDepthVpsLuma(Int x)      { m_bitDepthVpsLuma = x;      }
557   
558  Int  getBitDepthVpsChroma()           { return m_bitDepthVpsChroma;   }
559  Void setBitDepthVpsChroma(Int x)      { m_bitDepthVpsChroma = x;      }
560
561  Int  getBitDepthVps(ChannelType type)           { return isLuma(type) ? m_bitDepthVpsLuma : m_bitDepthVpsChroma;   }
562
563#if R0156_CONF_WINDOW_IN_REP_FORMAT
564  Window& getConformanceWindowVps()                           { return  m_conformanceWindowVps;             }
565  Void    setConformanceWindowVps(Window& conformanceWindow ) { m_conformanceWindowVps = conformanceWindow; }
566#endif
567};
568#endif
569
570class TComVPS
571{
572private:
573  Int         m_VPSId;
574#if VPS_RESERVED_FLAGS
575  Bool        m_baseLayerInternalFlag;
576  Bool        m_baseLayerAvailableFlag;
577#endif
578  UInt        m_uiMaxTLayers;
579  UInt        m_uiMaxLayers;
580  Bool        m_bTemporalIdNestingFlag;
581
582  UInt        m_numReorderPics[MAX_TLAYER];
583  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER];
584  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER]; // Really max latency increase plus 1 (value 0 expresses no limit)
585
586  UInt        m_numHrdParameters;
587#if !SVC_EXTENSION
588  UInt        m_maxNuhReservedZeroLayerId;
589#endif
590  TComHRD*    m_hrdParameters;
591  UInt*       m_hrdOpSetIdx;
592  Bool*       m_cprmsPresentFlag;
593#if !SVC_EXTENSION
594  UInt        m_numOpSets;
595  Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
596#endif
597#if !MULTIPLE_PTL_SUPPORT
598  TComPTL     m_pcPTL;
599#endif
600  TimingInfo  m_timingInfo;
601
602#if SVC_EXTENSION
603#if MULTIPLE_PTL_SUPPORT
604  TComPTL     m_pcPTLList[MAX_NUM_LAYER_IDS + 1];
605#endif
606#if DERIVE_LAYER_ID_LIST_VARIABLES
607#if Q0078_ADD_LAYER_SETS
608#if NECESSARY_LAYER_FLAG
609  std::vector< std::vector<Int> >     m_layerSetLayerIdList;
610  std::vector<Int>                    m_numLayerInIdList;
611#else
612  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_IDX_PLUS1];
613  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
614#endif
615#else
616  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
617  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
618#endif
619#endif
620  UInt        m_maxLayerId;
621  UInt        m_numLayerSets;
622#if Q0078_ADD_LAYER_SETS
623  UInt        m_vpsNumLayerSetsMinus1;
624  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_NUM_LAYER_IDS];
625#else
626  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
627#endif
628
629  // ------------------------------------------
630  // Variables related to VPS extensions
631  // ------------------------------------------
632#if VPS_EXTN_MASK_AND_DIM_INFO
633#if VPS_AVC_BL_FLAG_REMOVAL
634  Bool       m_nonHEVCBaseLayerFlag; 
635#else
636  Bool       m_avcBaseLayerFlag;                                // For now, always set to true.
637#endif
638  Bool       m_splittingFlag;
639  Bool       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES];
640  UInt       m_dimensionIdLen[MAX_VPS_NUM_SCALABILITY_TYPES];
641  Bool       m_nuhLayerIdPresentFlag;
642  UInt       m_layerIdInNuh[MAX_VPS_LAYER_IDX_PLUS1];            // Maps layer ID in the VPS with layer_id_in_nuh
643  UInt       m_dimensionId[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_NUM_SCALABILITY_TYPES];
644
645  // Below are derived variables
646  UInt       m_numScalabilityTypes;
647  UInt       m_layerIdxInVps[MAX_NUM_LAYER_IDS];            // Maps layer_id_in_nuh with the layer ID in the VPS
648#endif
649#if BITRATE_PICRATE_SIGNALLING
650#if Q0078_ADD_LAYER_SETS
651  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
652#else
653  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1];
654#endif
655#endif
656   
657  Bool       m_ilpSshSignalingEnabledFlag;
658#if VPS_EXTN_PROFILE_INFO
659  // Profile-tier-level signalling related
660  Bool       m_profilePresentFlag[MAX_VPS_LAYER_SETS_PLUS1];    // The value with index 0 will not be used.
661#if !MULTIPLE_PTL_SUPPORT
662  std::vector<TComPTL>    m_pcPTLForExtn; 
663#endif
664#endif
665#if VPS_EXTN_OP_LAYER_SETS
666  // .. More declarations here
667  // Target output layer signalling related
668  UInt       m_numOutputLayerSets;
669#if Q0078_ADD_LAYER_SETS
670  UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
671  Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_IDX_PLUS1];
672#else
673  UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1];
674  Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
675#endif
676#endif
677#if VPS_EXTN_DIRECT_REF_LAYERS
678  Bool       m_directDependencyFlag[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
679  UInt       m_numDirectRefLayers[MAX_VPS_LAYER_IDX_PLUS1];
680  UInt       m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
681  UInt       m_directDepTypeLen;
682#if O0096_DEFAULT_DEPENDENCY_TYPE
683  Bool       m_defaultDirectDependencyTypeFlag;
684  UInt       m_defaultDirectDependencyType;
685#endif
686  UInt       m_directDependencyType[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
687#endif
688  UInt       m_numProfileTierLevel;
689#if !VPS_EXTN_UEV_CODING
690  Bool       m_moreOutputLayerSetsThanDefaultFlag;
691#endif
692  Int        m_numAddOutputLayerSets;
693#if P0295_DEFAULT_OUT_LAYER_IDC
694  UInt       m_defaultTargetOutputLayerIdc;
695#else
696#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
697  UInt       m_defaultOneTargetOutputLayerIdc;
698#else
699  Bool       m_defaultOneTargetOutputLayerFlag;
700#endif
701#endif
702#if PER_LAYER_PTL
703  std::vector< std::vector<Int> >  m_profileLevelTierIdx;
704#else
705  Int        m_profileLevelTierIdx[64];     
706#endif
707  Bool       m_maxOneActiveRefLayerFlag;
708#if O0062_POC_LSB_NOT_PRESENT_FLAG
709  Bool       m_pocLsbNotPresentFlag[MAX_VPS_LAYER_IDX_PLUS1];
710#endif
711#if O0223_PICTURE_TYPES_ALIGN_FLAG
712  Bool       m_crossLayerPictureTypeAlignFlag;
713#endif
714  Bool       m_crossLayerIrapAlignFlag;
715#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
716  Bool       m_crossLayerAlignedIdrOnlyFlag;
717#endif
718  UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_IDX_PLUS1 - 1][MAX_VPS_LAYER_IDX_PLUS1];
719  Bool       m_maxTidRefPresentFlag;
720#if VPS_TSLAYERS
721  Bool       m_maxTSLayersPresentFlag;
722  UInt       m_maxTSLayerMinus1[MAX_LAYERS];
723#endif
724#if M0040_ADAPTIVE_RESOLUTION_CHANGE
725  Bool       m_singleLayerForNonIrapFlag;
726#endif
727#if HIGHER_LAYER_IRAP_SKIP_FLAG
728  Bool       m_higherLayerIrapSkipFlag;
729#endif
730#if VPS_VUI_TILES_NOT_IN_USE__FLAG
731  Bool       m_tilesNotInUseFlag;
732  Bool       m_tilesInUseFlag[MAX_VPS_LAYER_IDX_PLUS1];
733  Bool       m_loopFilterNotAcrossTilesFlag[MAX_VPS_LAYER_IDX_PLUS1];
734#endif
735  Bool       m_tileBoundariesAlignedFlag[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
736#if VPS_VUI_WPP_NOT_IN_USE__FLAG
737  Bool       m_wppNotInUseFlag;
738  Bool       m_wppInUseFlag[MAX_VPS_LAYER_IDX_PLUS1];
739#endif
740#if N0160_VUI_EXT_ILP_REF   
741  Bool       m_ilpRestrictedRefLayersFlag;
742  Int        m_minSpatialSegmentOffsetPlus1[MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
743  Bool       m_ctuBasedOffsetEnabledFlag   [MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
744  Int        m_minHorizontalCtuOffsetPlus1 [MAX_VPS_LAYER_IDX_PLUS1][MAX_VPS_LAYER_IDX_PLUS1];
745#endif
746#if VPS_VUI_VIDEO_SIGNAL
747  Bool       m_vidSigPresentVpsFlag;
748  Int        m_vpsVidSigInfo;
749  Int        m_vpsVidSigIdx[MAX_VPS_LAYER_IDX_PLUS1];
750  Int        m_vpsVidFormat[16];
751  Bool       m_vpsFullRangeFlag[16];
752  Int        m_vpsColorPrimaries[16];
753  Int        m_vpsTransChar[16];
754  Int        m_vpsMatCoeff[16];
755#endif
756
757  Bool       m_bitRatePresentVpsFlag;
758  Bool       m_picRatePresentVpsFlag;
759  Bool       m_bitRatePresentFlag  [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
760  Bool       m_picRatePresentFlag  [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
761  Int        m_avgBitRate          [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
762  Int        m_maxBitRate          [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
763  Int        m_constPicRateIdc     [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
764  Int        m_avgPicRate          [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
765
766#if P0300_ALT_OUTPUT_LAYER_FLAG
767#if Q0078_ADD_LAYER_SETS
768  Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
769#else
770  Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1];
771#endif
772#else
773#if O0153_ALT_OUTPUT_LAYER_FLAG
774  Bool       m_altOutputLayerFlag;
775#endif
776#endif
777#if REPN_FORMAT_IN_VPS
778  Bool       m_repFormatIdxPresentFlag;
779  Int        m_vpsNumRepFormats;            // coded as minus1
780  RepFormat  m_vpsRepFormat[16];
781  Int        m_vpsRepFormatIdx[16];
782#endif
783#if VIEW_ID_RELATED_SIGNALING
784#if O0109_VIEW_ID_LEN
785  Int        m_viewIdLen;
786#else
787  Int        m_viewIdLenMinus1;
788#endif
789  Int        m_viewIdVal                [MAX_LAYERS];
790#endif
791
792#if O0092_0094_DEPENDENCY_CONSTRAINT
793  Int        m_numberRefLayers[MAX_NUM_LAYER_IDS];  // number of direct and indirect reference layers of a coding layer
794  Bool       m_recursiveRefLayerFlag[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];  // flag to indicate if j-th layer is a direct or indirect reference layer of i-th layer
795#endif
796#if Q0078_ADD_LAYER_SETS
797  Int        m_numAddLayerSets;
798  UInt       m_highestLayerIdxPlus1[MAX_NUM_ADD_LAYER_SETS][MAX_NUM_LAYER_IDS];
799  UInt       m_predictedLayerId[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
800  UInt       m_numPredictedLayers[MAX_NUM_LAYER_IDS];
801  Int        m_numIndependentLayers;
802  Int        m_numLayersInTreePartition[MAX_LAYERS];
803  UInt       m_treePartitionLayerIdList[MAX_LAYERS][MAX_LAYERS];
804#endif
805#if SPS_DPB_PARAMS
806  Int        m_TolsIdx;
807#endif
808#if VPS_DPB_SIZE_TABLE
809  Bool       m_subLayerFlagInfoPresentFlag [MAX_VPS_OP_LAYER_SETS_PLUS1];
810  Bool       m_subLayerDpbInfoPresentFlag  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
811  Int        m_maxVpsDecPicBufferingMinus1 [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS][MAX_TLAYER];
812  Int        m_maxVpsNumReorderPics        [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
813  Int        m_maxVpsLatencyIncreasePlus1  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
814#if CHANGE_NUMSUBDPB_IDX
815#if Q0078_ADD_LAYER_SETS
816  Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
817#else
818  Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1];
819#endif
820#else
821  Int        m_numSubDpbs                  [MAX_VPS_OP_LAYER_SETS_PLUS1];
822#endif
823#endif
824
825#if O0109_MOVE_VPS_VUI_FLAG
826  Bool       m_vpsVuiPresentFlag;
827#endif
828  Bool       m_vpsExtensionFlag;
829
830#if O0164_MULTI_LAYER_HRD
831  Bool       m_vpsVuiBspHrdPresentFlag;
832#if VPS_VUI_BSP_HRD_PARAMS
833  Int                 m_vpsNumAddHrdParams;
834  std::vector<Bool>   m_cprmsAddPresentFlag;
835  std::vector<Int>    m_numSubLayerHrdMinus1;
836  std::vector<TComHRD> m_bspHrd;
837  Int    m_numSignalledPartitioningSchemes[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
838  Int    m_numPartitionsInSchemeMinus1    [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16];
839  Int    m_layerIncludedInPartitionFlag   [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_LAYERS][MAX_LAYERS];
840  Int    m_numBspSchedulesMinus1          [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER];
841  Int    m_bspHrdIdx                      [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER][31][MAX_LAYERS];
842  Int    m_bspSchedIdx                    [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER][31][MAX_LAYERS];
843#else
844  UInt       m_vpsNumBspHrdParametersMinus1;
845  Bool       m_bspCprmsPresentFlag[MAX_VPS_LAYER_SETS_PLUS1];
846  TComHRD    *m_bspHrd;
847  UInt       m_numBitstreamPartitions[MAX_VPS_LAYER_SETS_PLUS1];
848  Bool       m_layerInBspFlag[MAX_VPS_LAYER_SETS_PLUS1][8][MAX_LAYERS];
849  UInt       m_numBspSchedCombinations[MAX_VPS_LAYER_SETS_PLUS1];
850  UInt       m_bspCombHrdIdx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
851  UInt       m_bspCombSchedIdx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
852#endif
853#endif
854
855#if P0182_VPS_VUI_PS_FLAG
856  UInt       m_baseLayerPSCompatibilityFlag[MAX_LAYERS];
857#endif
858
859#if !P0307_REMOVE_VPS_VUI_OFFSET
860#if VPS_VUI_OFFSET
861  Int        m_vpsVuiOffset;
862#endif
863#endif
864#if P0307_VPS_NON_VUI_EXTENSION
865  Int        m_vpsNonVuiExtLength;
866#endif
867#if P0297_VPS_POC_LSB_ALIGNED_FLAG
868  Bool       m_vpsPocLsbAlignedFlag;
869#endif
870#if NECESSARY_LAYER_FLAG
871  std::vector< std::vector<Bool> > m_necessaryLayerFlag;
872  std::vector<Int>               m_numNecessaryLayers;
873#endif
874#endif //SVC_EXTENSION
875public:
876  TComVPS();
877  virtual ~TComVPS();
878
879#if VPS_RESERVED_FLAGS
880  Void        setBaseLayerInternalFlag(Bool x) { m_baseLayerInternalFlag = x; }
881  Bool        getBaseLayerInternalFlag()         { return m_baseLayerInternalFlag; }
882  Void        setBaseLayerAvailableFlag(Bool x) { m_baseLayerAvailableFlag = x; }
883  Bool        getBaseLayerAvailableFlag()         { return m_baseLayerAvailableFlag; }
884#endif
885
886  Void    createHrdParamBuffer()
887  {
888    m_hrdParameters    = new TComHRD[ getNumHrdParameters() ];
889    m_hrdOpSetIdx      = new UInt   [ getNumHrdParameters() ];
890    m_cprmsPresentFlag = new Bool   [ getNumHrdParameters() ];
891  }
892
893#if O0164_MULTI_LAYER_HRD
894  Void    createBspHrdParamBuffer(UInt numHrds)
895  {
896#if VPS_VUI_BSP_HRD_PARAMS
897    m_bspHrd.resize( numHrds );
898    m_cprmsAddPresentFlag.resize( numHrds );
899    m_numSubLayerHrdMinus1.resize( numHrds );
900#else
901    m_bspHrd    = new TComHRD[ numHrds ];
902#endif
903//    m_hrdOpSetIdx      = new UInt   [ getNumHrdParameters() ];
904//    m_cprmsPresentFlag = new Bool   [ getNumHrdParameters() ];
905  }
906#endif
907#if HRD_BPB
908  Int getBspHrdParamBufferCpbCntMinus1(UInt i, UInt sl)
909  {
910#if VPS_VUI_BSP_HRD_PARAMS
911    return m_bspHrd[i].getCpbCntMinus1(sl);
912#else
913    return m_bspHrd->getCpbCntMinus1(sl);
914#endif
915  }
916#endif
917
918  TComHRD* getHrdParameters   ( UInt i )             { return &m_hrdParameters[ i ]; }
919  UInt    getHrdOpSetIdx      ( UInt i )             { return m_hrdOpSetIdx[ i ]; }
920  Void    setHrdOpSetIdx      ( UInt val, UInt i )   { m_hrdOpSetIdx[ i ] = val;  }
921  Bool    getCprmsPresentFlag ( UInt i )             { return m_cprmsPresentFlag[ i ]; }
922  Void    setCprmsPresentFlag ( Bool val, UInt i )   { m_cprmsPresentFlag[ i ] = val;  }
923
924  Int     getVPSId       ()                   { return m_VPSId;          }
925  Void    setVPSId       (Int i)              { m_VPSId = i;             }
926
927  UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
928  Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
929
930  UInt    getMaxLayers   ()                   { return m_uiMaxLayers;   }
931  Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
932
933  Bool    getTemporalNestingFlag   ()         { return m_bTemporalIdNestingFlag;   }
934  Void    setTemporalNestingFlag   (Bool t)   { m_bTemporalIdNestingFlag = t; }
935
936  Void    setNumReorderPics(UInt v, UInt tLayer)                { m_numReorderPics[tLayer] = v;    }
937  UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
938
939  Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { assert(tLayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tLayer] = v;    }
940  UInt    getMaxDecPicBuffering(UInt tLayer)                    { return m_uiMaxDecPicBuffering[tLayer]; }
941
942  Void    setMaxLatencyIncrease(UInt v, UInt tLayer)            { m_uiMaxLatencyIncrease[tLayer] = v;    }
943  UInt    getMaxLatencyIncrease(UInt tLayer)                    { return m_uiMaxLatencyIncrease[tLayer]; }
944
945  UInt    getNumHrdParameters()                                 { return m_numHrdParameters; }
946  Void    setNumHrdParameters(UInt v)                           { m_numHrdParameters = v;    }
947 
948#if !SVC_EXTENSION
949  UInt    getMaxNuhReservedZeroLayerId()                        { return m_maxNuhReservedZeroLayerId; }
950  Void    setMaxNuhReservedZeroLayerId(UInt v)                  { m_maxNuhReservedZeroLayerId = v;    }
951
952  UInt    getMaxOpSets()                                        { return m_numOpSets; }
953  Void    setMaxOpSets(UInt v)                                  { m_numOpSets = v;    }
954#endif
955  Bool    getLayerIdIncludedFlag(UInt opsIdx, UInt id)          { return m_layerIdIncludedFlag[opsIdx][id]; }
956  Void    setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)  { m_layerIdIncludedFlag[opsIdx][id] = v;    }
957
958#if !MULTIPLE_PTL_SUPPORT
959  TComPTL* getPTL() { return &m_pcPTL; }
960#endif
961
962  TimingInfo* getTimingInfo() { return &m_timingInfo; }
963
964#if SVC_EXTENSION
965#if MULTIPLE_PTL_SUPPORT
966  TComPTL* getPTL() { return &m_pcPTLList[0]; }
967  TComPTL* getPTL(UInt idx) { return &m_pcPTLList[idx]; }
968#endif
969#if DERIVE_LAYER_ID_LIST_VARIABLES
970  Int     getLayerSetLayerIdList(Int set, Int layerId)          { return m_layerSetLayerIdList[set][layerId]; }
971  Void    setLayerSetLayerIdList(Int set, Int layerId, Int x)   { m_layerSetLayerIdList[set][layerId] = x;    }
972
973  Int     getNumLayersInIdList(Int set)                          { return m_numLayerInIdList[set]; }
974  Void    setNumLayersInIdList(Int set, Int x)                   { m_numLayerInIdList[set] = x;    }
975
976  Void    deriveLayerIdListVariables();
977#endif
978#if VPS_DPB_SIZE_TABLE
979Void      deriveNumberOfSubDpbs();
980#endif
981
982#if O0092_0094_DEPENDENCY_CONSTRAINT
983  Void    setRefLayersFlags(Int currLayerId);
984  Bool    getRecursiveRefLayerFlag(Int currLayerId, Int refLayerId)              { return m_recursiveRefLayerFlag[currLayerId][refLayerId];}
985  Void    setRecursiveRefLayerFlag(Int currLayerId, Int refLayerId, Bool x)      { m_recursiveRefLayerFlag[currLayerId][refLayerId] = x;   }
986  Int     getNumRefLayers(Int currLayerId)                                       { return m_numberRefLayers[currLayerId];                  }
987  Void    setNumRefLayers();
988#endif
989#if Q0078_ADD_LAYER_SETS
990#if FIX_LAYER_ID_INIT
991  void    deriveLayerIdListVariablesForAddLayerSets();
992#else
993  void    setLayerIdIncludedFlagsForAddLayerSets();
994#endif
995  UInt    getVpsNumLayerSetsMinus1()                                             { return m_vpsNumLayerSetsMinus1; }
996  Void    setVpsNumLayerSetsMinus1(UInt x)                                       { m_vpsNumLayerSetsMinus1 = x; }
997  UInt    getNumAddLayerSets()                                                   { return m_numAddLayerSets; }
998  Void    setNumAddLayerSets(UInt x)                                             { m_numAddLayerSets = x; }
999  UInt    getHighestLayerIdxPlus1(UInt set, UInt idx)                            { return m_highestLayerIdxPlus1[set][idx]; }
1000  Void    setHighestLayerIdxPlus1(UInt set, UInt idx, UInt layerIdx)             { m_highestLayerIdxPlus1[set][idx] = layerIdx; }
1001  Void    setPredictedLayerIds();
1002  UInt    getPredictedLayerId(UInt layerId, UInt predIdx)                        { return m_predictedLayerId[layerId][predIdx]; }
1003  Void    setPredictedLayerId(UInt layerId, UInt predIdx, UInt x)                { m_predictedLayerId[layerId][predIdx] = x; }
1004  UInt    getNumPredictedLayers(UInt layerId)                                    { return m_numPredictedLayers[layerId]; }
1005  Void    setNumPredictedLayers(UInt layerId, UInt x)                            { m_numPredictedLayers[layerId] = x; }
1006  Void    setTreePartitionLayerIdList();
1007  Int     getNumIndependentLayers()                                              { return m_numIndependentLayers; }
1008  Void    setNumIndependentLayers(Int x)                                         { m_numIndependentLayers = x; }
1009  Int     getNumLayersInTreePartition(Int idx)                                   { return m_numLayersInTreePartition[idx]; }
1010  Void    setNumLayersInTreePartition(Int idx, Int x)                            { m_numLayersInTreePartition[idx] = x; }
1011  UInt    getTreePartitionLayerId(Int idx, Int layerIdx)                         { return m_treePartitionLayerIdList[idx][layerIdx]; }
1012  Void    setTreePartitionLayerId(Int idx, Int layerIdx, UInt layerId)           { m_treePartitionLayerIdList[idx][layerIdx] = layerId; }
1013#endif
1014  UInt    getMaxLayerId()                                       { return m_maxLayerId;   }
1015  Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;      }
1016  UInt    getNumLayerSets()                                     { return m_numLayerSets; }
1017  Void    setNumLayerSets(UInt v)                               { m_numLayerSets = v;    }
1018#if VPS_EXTN_MASK_AND_DIM_INFO
1019#if VPS_AVC_BL_FLAG_REMOVAL
1020  Bool   getNonHEVCBaseLayerFlag()                              { return m_nonHEVCBaseLayerFlag;   }
1021  Void   setNonHEVCBaseLayerFlag(Bool x)                        { m_nonHEVCBaseLayerFlag = x;      }
1022#else
1023  Bool   getAvcBaseLayerFlag()                                  { return m_avcBaseLayerFlag;       }
1024  Void   setAvcBaseLayerFlag(Bool x)                            { m_avcBaseLayerFlag = x;          }
1025#endif
1026
1027  Bool   getSplittingFlag()                                     { return m_splittingFlag;          }
1028  Void   setSplittingFlag(Bool x)                               { m_splittingFlag = x;             }
1029
1030  Bool   getScalabilityMask(Int id)                             { return m_scalabilityMask[id];    }
1031  Void   setScalabilityMask(Int id, Bool x)                     { m_scalabilityMask[id] = x;       }
1032
1033  UInt   getDimensionIdLen(Int id)                              { return m_dimensionIdLen[id];     }
1034  Void   setDimensionIdLen(Int id, UInt x)                      { m_dimensionIdLen[id] = x;        }
1035
1036  Bool   getNuhLayerIdPresentFlag()                             { return m_nuhLayerIdPresentFlag;  }
1037  Void   setNuhLayerIdPresentFlag(Bool x)                       { m_nuhLayerIdPresentFlag = x;     }
1038
1039  UInt   getLayerIdInNuh(Int layerIdx)                          { return m_layerIdInNuh[layerIdx];    }
1040  Void   setLayerIdInNuh(Int layerIdx, UInt layerId)            { m_layerIdInNuh[layerIdx] = layerId; }
1041
1042  UInt   getDimensionId(Int layerIdx, Int id)                   { return m_dimensionId[layerIdx][id]; }
1043  Void   setDimensionId(Int layerIdx, Int id, UInt x)           { m_dimensionId[layerIdx][id] = x;    }
1044
1045  UInt   getNumScalabilityTypes()                               { return m_numScalabilityTypes;    }
1046  Void   setNumScalabilityTypes(UInt x)                         { m_numScalabilityTypes = x;       }
1047
1048  UInt   getLayerIdxInVps(Int layerId)                          { return m_layerIdxInVps[layerId];     }
1049  Void   setLayerIdxInVps(Int layerId, UInt layerIdx)           { m_layerIdxInVps[layerId] = layerIdx; }
1050#endif
1051#if BITRATE_PICRATE_SIGNALLING
1052  UInt   getMaxSLayersInLayerSetMinus1(Int ls)                  { return m_maxSLInLayerSetMinus1[ls]; }
1053  Void   setMaxSLayersInLayerSetMinus1(Int ls, Int x)           { m_maxSLInLayerSetMinus1[ls] = x;    }
1054#endif
1055  Bool   getIlpSshSignalingEnabledFlag()                        { return m_ilpSshSignalingEnabledFlag;}
1056  Void   setIlpSshSignalingEnabledFlag(Bool x)                  { m_ilpSshSignalingEnabledFlag = x;}
1057#if VPS_EXTN_PROFILE_INFO
1058  Bool   getProfilePresentFlag(Int id)                          { return m_profilePresentFlag[id]; }
1059  Void   setProfilePresentFlag(Int id, Bool x)                  { m_profilePresentFlag[id] = x;    }
1060
1061#if !MULTIPLE_PTL_SUPPORT
1062  std::vector<TComPTL>* getPTLForExtnPtr()                      { return &m_pcPTLForExtn;          }
1063  TComPTL* getPTLForExtn(Int id)                                { return &m_pcPTLForExtn[id];      }
1064#endif
1065#endif
1066#if VPS_EXTN_OP_LAYER_SETS
1067  // Target output layer signalling related
1068  UInt   getNumOutputLayerSets()                                { return m_numOutputLayerSets;     } 
1069  Void   setNumOutputLayerSets(Int x)                           { m_numOutputLayerSets = x;        }
1070 
1071  UInt   getOutputLayerSetIdx(Int idx)                          { return m_outputLayerSetIdx[idx]; }
1072  Void   setOutputLayerSetIdx(Int idx, UInt x)                  { m_outputLayerSetIdx[idx] = x;    }
1073
1074  Bool   getOutputLayerFlag(Int layerSet, Int layerIdx)          { return m_outputLayerFlag[layerSet][layerIdx]; }
1075  Void   setOutputLayerFlag(Int layerSet, Int layerIdx, Bool x)  { m_outputLayerFlag[layerSet][layerIdx] = x;    }
1076#endif
1077#if VPS_EXTN_DIRECT_REF_LAYERS
1078  // Direct dependency of layers
1079  Bool   getDirectDependencyFlag(Int currLayerIdx, Int refLayerIdx)             { return m_directDependencyFlag[currLayerIdx][refLayerIdx]; }
1080  Void   setDirectDependencyFlag(Int currLayerIdx, Int refLayerIdx, Bool x)     { m_directDependencyFlag[currLayerIdx][refLayerIdx] = x;    }
1081 
1082  UInt   getNumDirectRefLayers(Int layerId)                                     { return m_numDirectRefLayers[layerId];                   }
1083  Void   setNumDirectRefLayers(Int layerId, UInt refLayerNum)                   { m_numDirectRefLayers[layerId] = refLayerNum;            }
1084
1085  UInt   getRefLayerId(Int layerId, Int refLayerIdc)                            { return m_refLayerId[layerId][refLayerIdc];              }
1086  Void   setRefLayerId(Int layerId, Int refLayerIdc, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdc] = refLayerId;        }
1087
1088  UInt   getDirectDepTypeLen()                                                  { return m_directDepTypeLen;                              }
1089  Void   setDirectDepTypeLen(UInt x)                                            { m_directDepTypeLen = x;                                 }
1090#if O0096_DEFAULT_DEPENDENCY_TYPE
1091  Bool   getDefaultDirectDependencyTypeFlag()                                   { return m_defaultDirectDependencyTypeFlag;               }
1092  Void   setDefaultDirectDependecyTypeFlag(Bool x)                              { m_defaultDirectDependencyTypeFlag = x;                  }
1093  UInt   getDefaultDirectDependencyType()                                       { return m_defaultDirectDependencyType;                   }
1094  Void   setDefaultDirectDependecyType(UInt x)                                  { m_defaultDirectDependencyType = x;                      }
1095#endif
1096  UInt   getDirectDependencyType(Int currLayerIdx, Int refLayerIdx)             { return m_directDependencyType[currLayerIdx][refLayerIdx]; }
1097  Void   setDirectDependencyType(Int currLayerIdx, Int refLayerIdx, UInt x)     { m_directDependencyType[currLayerIdx][refLayerIdx] = x;    }
1098  Bool   isSamplePredictionType(Int currLayerIdx, Int refLayerIdx)              { assert(currLayerIdx != refLayerIdx); return ( ( m_directDependencyType[currLayerIdx][refLayerIdx] + 1 ) & 1 ) ? true : false; }
1099  Bool   isMotionPredictionType(Int currLayerIdx, Int refLayerIdx)              { assert(currLayerIdx != refLayerIdx); return ( ( ( m_directDependencyType[currLayerIdx][refLayerIdx] + 1 ) & 2 ) >> 1 ) ? true : false; }
1100#endif
1101  UInt   getNumProfileTierLevel()                                { return m_numProfileTierLevel; }
1102  Void   setNumProfileTierLevel(Int x)                           { m_numProfileTierLevel = x;    }
1103
1104#if !VPS_EXTN_UEV_CODING
1105  Bool   getMoreOutputLayerSetsThanDefaultFlag()                 { return m_moreOutputLayerSetsThanDefaultFlag;}
1106  Void   setMoreOutputLayerSetsThanDefaultFlag(Bool x)           { m_moreOutputLayerSetsThanDefaultFlag = x   ;}
1107#endif
1108
1109  Int    getNumAddOutputLayerSets()                              { return m_numAddOutputLayerSets; }
1110  Void   setNumAddOutputLayerSets(Int x)                         { m_numAddOutputLayerSets = x   ; }
1111
1112#if P0295_DEFAULT_OUT_LAYER_IDC
1113  UInt   getDefaultTargetOutputLayerIdc()                 { return m_defaultTargetOutputLayerIdc;}
1114  Void   setDefaultTargetOutputLayerIdc(UInt x)           { m_defaultTargetOutputLayerIdc = x    ;}
1115#else
1116#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
1117  UInt   getDefaultOneTargetOutputLayerIdc()                 { return m_defaultOneTargetOutputLayerIdc;}
1118  Void   setDefaultOneTargetOutputLayerIdc(UInt x)           { m_defaultOneTargetOutputLayerIdc= x    ;}
1119#else
1120  Bool   getDefaultOneTargetOutputLayerFlag()                 { return m_defaultOneTargetOutputLayerFlag;}
1121  Void   setDefaultOneTargetOutputLayerFlag(Bool x)           { m_defaultOneTargetOutputLayerFlag= x    ;}
1122#endif
1123#endif
1124#if PER_LAYER_PTL
1125  Bool getNecessaryLayerFlag(Int const i, Int const j) { return m_necessaryLayerFlag[i][j]; }
1126  std::vector< std::vector<Int> >* getProfileLevelTierIdx() { return &m_profileLevelTierIdx; }
1127  std::vector<Int>* getProfileLevelTierIdx(Int const olsIdx) { return &m_profileLevelTierIdx[olsIdx]; }
1128  Int    getProfileLevelTierIdx(Int const olsIdx, Int const layerIdx)     { return m_profileLevelTierIdx[olsIdx][layerIdx]; }
1129  Void   setProfileLevelTierIdx(Int const olsIdx, Int const layerIdx, Int const ptlIdx)     { m_profileLevelTierIdx[olsIdx][layerIdx] = ptlIdx; }
1130#if MULTIPLE_PTL_SUPPORT
1131  Void   addProfileLevelTierIdx(Int const olsIdx, Int const ptlIdx)     { m_profileLevelTierIdx[olsIdx].push_back(ptlIdx); }
1132#endif
1133  Int    calculateLenOfSyntaxElement( Int const numVal );
1134#else
1135  Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
1136  Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
1137#endif
1138  Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
1139  Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
1140#if O0062_POC_LSB_NOT_PRESENT_FLAG
1141  UInt   getPocLsbNotPresentFlag(Int i)                                         { return m_pocLsbNotPresentFlag[i]; }
1142  Void   setPocLsbNotPresentFlag(Int i, Bool x)                                 { m_pocLsbNotPresentFlag[i] = x;    }
1143#endif
1144#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1145  Bool   getVpsPocLsbAlignedFlag()                                              { return m_vpsPocLsbAlignedFlag; }
1146  Void   setVpsPocLsbAlignedFlag(Bool x)                                        { m_vpsPocLsbAlignedFlag = x; }
1147#endif
1148#if O0223_PICTURE_TYPES_ALIGN_FLAG
1149  Bool   getCrossLayerPictureTypeAlignFlag()                                    { return m_crossLayerPictureTypeAlignFlag;                      }
1150  Void   setCrossLayerPictureTypeAlignFlag(Bool x)                              { m_crossLayerPictureTypeAlignFlag = x;                         }
1151#endif
1152#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
1153  Bool   getCrossLayerAlignedIdrOnlyFlag()                                    { return m_crossLayerAlignedIdrOnlyFlag;                      }
1154  Void   setCrossLayerAlignedIdrOnlyFlag(Bool x)                              { m_crossLayerAlignedIdrOnlyFlag = x;                         }
1155#endif
1156  Bool   getCrossLayerIrapAlignFlag()                                           { return m_crossLayerIrapAlignFlag;                      }
1157  Void   setCrossLayerIrapAlignFlag(Bool x)                                     { m_crossLayerIrapAlignFlag = x;                         }
1158  UInt   getMaxTidIlRefPicsPlus1(Int refLayerIdx, Int layerIdx)                     { return m_maxTidIlRefPicsPlus1[refLayerIdx][layerIdx];           }
1159  Void   setMaxTidIlRefPicsPlus1(Int refLayerIdx, Int layerIdx, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[refLayerIdx][layerIdx] = maxSublayer;    }
1160  Bool   getMaxTidRefPresentFlag()                                  { return m_maxTidRefPresentFlag ;}
1161  Void   setMaxTidRefPresentFlag(Bool x)                            { m_maxTidRefPresentFlag = x;}
1162#if VPS_TSLAYERS
1163  Bool   getMaxTSLayersPresentFlag()                                  { return m_maxTSLayersPresentFlag ;}
1164  Void   setMaxTSLayersPresentFlag(Bool x)                            { m_maxTSLayersPresentFlag = x;}
1165  UInt   getMaxTSLayersMinus1(Int layerIdx)                            { return m_maxTSLayerMinus1[layerIdx];}
1166  Void   setMaxTSLayersMinus1(Int layerIdx, UInt maxTSublayer)         { m_maxTSLayerMinus1[layerIdx] = maxTSublayer;}
1167#endif
1168#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1169  Bool   getSingleLayerForNonIrapFlag()                             { return m_singleLayerForNonIrapFlag; }
1170  Void   setSingleLayerForNonIrapFlag(Bool x)                       { m_singleLayerForNonIrapFlag = x;    }
1171#endif
1172#if HIGHER_LAYER_IRAP_SKIP_FLAG
1173  Bool   getHigherLayerIrapSkipFlag()                             { return m_higherLayerIrapSkipFlag; }
1174  Void   setHigherLayerIrapSkipFlag(Bool x)                       { m_higherLayerIrapSkipFlag = x;    }
1175#endif
1176#if VPS_VUI_TILES_NOT_IN_USE__FLAG 
1177  Bool   getTilesNotInUseFlag()         { return m_tilesNotInUseFlag; }
1178  Void   setTilesNotInUseFlag(Bool x); 
1179  Bool   getTilesInUseFlag(Int currLayerId)    { return m_tilesInUseFlag[currLayerId]; }
1180  Void   setTilesInUseFlag(Int currLayerId, Bool x)    { m_tilesInUseFlag[currLayerId] = x; } 
1181  Bool   getLoopFilterNotAcrossTilesFlag(Int currLayerId)    { return m_loopFilterNotAcrossTilesFlag[currLayerId]; }
1182  Void   setLoopFilterNotAcrossTilesFlag(Int currLayerId, Bool x)    { m_loopFilterNotAcrossTilesFlag[currLayerId] = x; } 
1183#endif
1184  Bool   getTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId)           { return m_tileBoundariesAlignedFlag[currLayerId][refLayerId]; }
1185  Void   setTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId, Bool x)   { m_tileBoundariesAlignedFlag[currLayerId][refLayerId] = x; } 
1186#if VPS_VUI_WPP_NOT_IN_USE__FLAG 
1187  Bool   getWppNotInUseFlag()         { return m_wppNotInUseFlag; }
1188  Void   setWppNotInUseFlag(Bool x); 
1189  Bool   getWppInUseFlag(Int currLayerId)    { return m_wppInUseFlag[currLayerId]; }
1190  Void   setWppInUseFlag(Int currLayerId, Bool x)    { m_wppInUseFlag[currLayerId] = x; } 
1191#endif
1192#if N0160_VUI_EXT_ILP_REF 
1193  Bool   getIlpRestrictedRefLayersFlag   ( )                                        { return m_ilpRestrictedRefLayersFlag        ;}
1194  Void   setIlpRestrictedRefLayersFlag   ( Int val )                                { m_ilpRestrictedRefLayersFlag         = val;}
1195 
1196  Int    getMinSpatialSegmentOffsetPlus1( Int currLayerId, Int refLayerId )          { return m_minSpatialSegmentOffsetPlus1[currLayerId][refLayerId];}
1197  Void   setMinSpatialSegmentOffsetPlus1( Int currLayerId, Int refLayerId, Int val ) { m_minSpatialSegmentOffsetPlus1[currLayerId][refLayerId] = val;}
1198 
1199  Bool   getCtuBasedOffsetEnabledFlag   ( Int currLayerId, Int refLayerId )            { return m_ctuBasedOffsetEnabledFlag[currLayerId][refLayerId];}
1200  Void   setCtuBasedOffsetEnabledFlag   ( Int currLayerId, Int refLayerId, Bool flag ) { m_ctuBasedOffsetEnabledFlag[currLayerId][refLayerId] = flag;}
1201 
1202  Int    getMinHorizontalCtuOffsetPlus1 ( Int currLayerId, Int refLayerId )            { return m_minHorizontalCtuOffsetPlus1[currLayerId][refLayerId];}
1203  Void   setMinHorizontalCtuOffsetPlus1 ( Int currLayerId, Int refLayerId, Int val )   { m_minHorizontalCtuOffsetPlus1[currLayerId][refLayerId] = val;} 
1204#endif
1205#if VPS_VUI_VIDEO_SIGNAL
1206  Bool   getVideoSigPresentVpsFlag()           { return m_vidSigPresentVpsFlag; }
1207  Void   setVideoSigPresentVpsFlag(Bool x)     { m_vidSigPresentVpsFlag = x;    }
1208  Int    getNumVideoSignalInfo()               { return m_vpsVidSigInfo;        }
1209  Void   setNumVideoSignalInfo(Int x)          { m_vpsVidSigInfo = x;           }
1210  Int    getVideoSignalInfoIdx(Int idx)        { return m_vpsVidSigIdx[idx];    }
1211  Void   setVideoSignalInfoIdx(Int idx, Int x) { m_vpsVidSigIdx[idx] = x;       }
1212  Int    getVideoVPSFormat(Int idx)            { return m_vpsVidFormat[idx];    }
1213  Void   setVideoVPSFormat(Int idx, Int x)     { m_vpsVidFormat[idx] = x;       }
1214  Bool   getVideoFullRangeVpsFlag(Int idx)     { return m_vpsFullRangeFlag[idx];}
1215  Void   setVideoFullRangeVpsFlag(Int idx, Bool x) { m_vpsFullRangeFlag[idx] = x;   }
1216  Int    getColorPrimaries(Int idx)            { return m_vpsColorPrimaries[idx];   }
1217  Void   setColorPrimaries(Int idx, Int x)     { m_vpsColorPrimaries[idx] = x;      }
1218  Int    getTransCharacter(Int idx)            { return m_vpsTransChar[idx];    }
1219  Void   setTransCharacter(Int idx, Int x)     { m_vpsTransChar[idx] = x;       }
1220  Int    getMaxtrixCoeff(Int idx)              { return m_vpsMatCoeff[idx];     }
1221  Void   setMaxtrixCoeff(Int idx, Int x)       { m_vpsMatCoeff[idx] = x;        }
1222#endif
1223  Bool   getBitRatePresentVpsFlag()       { return m_bitRatePresentVpsFlag; }
1224  Void   setBitRatePresentVpsFlag(Bool x) { m_bitRatePresentVpsFlag = x;    }
1225  Bool   getPicRatePresentVpsFlag()       { return m_picRatePresentVpsFlag; }
1226  Void   setPicRatePresentVpsFlag(Bool x) { m_picRatePresentVpsFlag = x;    }
1227         
1228  Bool   getBitRatePresentFlag(Int i, Int j)          { return m_bitRatePresentFlag[i][j]; }
1229  Void   setBitRatePresentFlag(Int i, Int j, Bool x)  { m_bitRatePresentFlag[i][j] = x;    }
1230  Bool   getPicRatePresentFlag(Int i, Int j)          { return m_picRatePresentFlag[i][j]; }
1231  Void   setPicRatePresentFlag(Int i, Int j, Bool x)  { m_picRatePresentFlag[i][j] = x;    }
1232         
1233  Int    getAvgBitRate(Int i, Int j)          { return m_avgBitRate[i][j]; }
1234  Void   setAvgBitRate(Int i, Int j, Int x)   { m_avgBitRate[i][j] = x;    }
1235  Int    getMaxBitRate(Int i, Int j)          { return m_maxBitRate[i][j]; }
1236  Void   setMaxBitRate(Int i, Int j, Int x)   { m_maxBitRate[i][j] = x;    }
1237         
1238  Int    getConstPicRateIdc(Int i, Int j)          { return m_constPicRateIdc[i][j]; }
1239  Void   setConstPicRateIdc(Int i, Int j, Int x)   { m_constPicRateIdc[i][j] = x;    }
1240  Int    getAvgPicRate(Int i, Int j)          { return m_avgPicRate[i][j]; }
1241  Void   setAvgPicRate(Int i, Int j, Int x)   { m_avgPicRate[i][j] = x;    }
1242#if O0164_MULTI_LAYER_HRD
1243  Bool     getVpsVuiBspHrdPresentFlag()                         { return m_vpsVuiBspHrdPresentFlag;      }
1244  Void     setVpsVuiBspHrdPresentFlag(Bool x)                   { m_vpsVuiBspHrdPresentFlag = x;         }
1245#if VPS_VUI_BSP_HRD_PARAMS
1246  Int      getVpsNumAddHrdParams()                              { return m_vpsNumAddHrdParams; }
1247  Void     setVpsNumAddHrdParams(Int  i)                   { m_vpsNumAddHrdParams = i;    }
1248
1249  Bool     getCprmsAddPresentFlag(Int i)                        { return m_cprmsAddPresentFlag[i];       }
1250  Void     setCprmsAddPresentFlag(Int  i, Bool  val)  { m_cprmsAddPresentFlag[i] = val;        }
1251
1252  Int      getNumSubLayerHrdMinus1(Int i)           { return m_numSubLayerHrdMinus1[i]; }
1253  Void     setNumSubLayerHrdMinus1(Int i, Int val)  { m_numSubLayerHrdMinus1[i] = val; }
1254
1255  TComHRD*  getBspHrd(Int i)           {return &m_bspHrd[i];}
1256
1257  Int      getNumSignalledPartitioningSchemes(Int  i)                    { return m_numSignalledPartitioningSchemes[i];    }
1258  Void     setNumSignalledPartitioningSchemes(Int  i, Int  val)          { m_numSignalledPartitioningSchemes[i] = val;     }
1259
1260  Int      getNumPartitionsInSchemeMinus1(Int  i, Int j)  { return m_numPartitionsInSchemeMinus1[i][j];}
1261  Void     setNumPartitionsInSchemeMinus1(Int i, Int j, Int val) { m_numPartitionsInSchemeMinus1[i][j] = val; }
1262
1263  Int      getLayerIncludedInPartitionFlag(Int  i, Int j, Int k, Int l)  { return m_layerIncludedInPartitionFlag[i][j][k][l];}
1264  Void     setLayerIncludedInPartitionFlag(Int i, Int j, Int k, Int l, Int val) { m_layerIncludedInPartitionFlag[i][j][k][l] = val; }
1265
1266  Int      getNumBspSchedulesMinus1(Int  i, Int j, Int k)         { return m_numBspSchedulesMinus1[i][j][k];}
1267  Void     setNumBspSchedulesMinus1(Int i, Int j, Int k, Int val) { m_numBspSchedulesMinus1[i][j][k] = val; }
1268
1269  Int      getBspSchedIdx(Int  i, Int j, Int k, Int l, Int m)  { return m_bspSchedIdx[i][j][k][l][m];}
1270  Void     setBspSchedIdx(Int  i, Int j, Int k, Int l, Int m, Int val) { m_bspSchedIdx[i][j][k][l][m] = val; }
1271
1272  Int      getBspHrdIdx(Int  i, Int j, Int k, Int l, Int m)  { return m_bspHrdIdx[i][j][k][l][m];}
1273  Void     setBspHrdIdx(Int  i, Int j, Int k, Int l, Int m, Int val) { m_bspHrdIdx[i][j][k][l][m] = val; }
1274#else
1275  UInt     getVpsNumBspHrdParametersMinus1()                    { return m_vpsNumBspHrdParametersMinus1; }
1276  Void     setVpsNumBspHrdParametersMinus1(UInt i)              { m_vpsNumBspHrdParametersMinus1 = i;    }
1277  Bool     getBspCprmsPresentFlag(UInt i)                       { return m_bspCprmsPresentFlag[i];       }
1278  Void     setBspCprmsPresentFlag(UInt i, Bool val)             { m_bspCprmsPresentFlag[i] = val;        }
1279  TComHRD* getBspHrd(UInt i)                                    { return &m_bspHrd[i];                    }
1280  UInt     getNumBitstreamPartitions(UInt i)                    { return m_numBitstreamPartitions[i];    }
1281  Void     setNumBitstreamPartitions(UInt i, UInt val)          { m_numBitstreamPartitions[i] = val;     }
1282  UInt     getLayerInBspFlag(UInt h, UInt i, UInt j)            { return m_layerInBspFlag[h][i][j];      }
1283  Void     setLayerInBspFlag(UInt h, UInt i, UInt j, UInt val)  { m_layerInBspFlag[h][i][j] = val;       }
1284  UInt     getNumBspSchedCombinations(UInt i)                   { return m_numBspSchedCombinations[i];   }
1285  Void     setNumBspSchedCombinations(UInt i, UInt val)         { m_numBspSchedCombinations[i] = val;    }
1286  UInt     getBspCombHrdIdx(UInt h, UInt i, UInt j)             { return m_bspCombHrdIdx[h][i][j];       }
1287  Void     setBspCombHrdIdx(UInt h, UInt i, UInt j, UInt val)   { m_bspCombHrdIdx[h][i][j] = val;        }
1288  UInt     getBspCombSchedIdx(UInt h, UInt i, UInt j)           { return m_bspCombSchedIdx[h][i][j];     }
1289  Void     setBspCombSchedIdx(UInt h, UInt i, UInt j, UInt val) { m_bspCombSchedIdx[h][i][j] = val;      }
1290#endif
1291#endif
1292#if P0182_VPS_VUI_PS_FLAG
1293  Void   setBaseLayerPSCompatibilityFlag (Int layer, int val)        { m_baseLayerPSCompatibilityFlag[layer] = val; }
1294  Int    getBaseLayerPSCompatibilityFlag (Int layer)   { return m_baseLayerPSCompatibilityFlag[layer];}
1295#endif
1296
1297#if P0300_ALT_OUTPUT_LAYER_FLAG
1298  Bool   getAltOuputLayerFlag(Int idx)         { return m_altOutputLayerFlag[idx]; }
1299  Void   setAltOuputLayerFlag(Int idx, Bool x) { m_altOutputLayerFlag[idx] = x;    }
1300#else
1301#if O0153_ALT_OUTPUT_LAYER_FLAG
1302  Bool   getAltOuputLayerFlag()             { return m_altOutputLayerFlag; }
1303  Void   setAltOuputLayerFlag(Bool x)       { m_altOutputLayerFlag = x;    }
1304#endif
1305#endif
1306#if REPN_FORMAT_IN_VPS
1307  Bool   getRepFormatIdxPresentFlag()       { return m_repFormatIdxPresentFlag; }
1308  Void   setRepFormatIdxPresentFlag(Bool x) { m_repFormatIdxPresentFlag = x;    }
1309
1310  Int    getVpsNumRepFormats()              { return m_vpsNumRepFormats;        }
1311  Void   setVpsNumRepFormats(Int x)         { m_vpsNumRepFormats = x;           }
1312
1313  RepFormat* getVpsRepFormat(Int idx)       { return &m_vpsRepFormat[idx];      }
1314
1315  Int    getVpsRepFormatIdx(Int idx)        { return m_vpsRepFormatIdx[idx];    }
1316  Void   setVpsRepFormatIdx(Int idx, Int x) { m_vpsRepFormatIdx[idx] = x;       }         
1317#endif
1318#if VIEW_ID_RELATED_SIGNALING
1319#if O0109_VIEW_ID_LEN
1320  Void   setViewIdLen( Int  val )                                   { m_viewIdLen = val;  } 
1321  Int    getViewIdLen(  )                                           { return m_viewIdLen; } 
1322#else
1323  Void   setViewIdLenMinus1( Int  val )                             { m_viewIdLenMinus1 = val;  } 
1324  Int    getViewIdLenMinus1(  )                                     { return m_viewIdLenMinus1; } 
1325#endif
1326
1327  Void   setViewIdVal( Int viewOrderIndex, Int  val )               { m_viewIdVal[viewOrderIndex] = val;  } 
1328  Int    getViewIdVal( Int viewOrderIndex )                         { return m_viewIdVal[viewOrderIndex]; } 
1329  Int    getScalabilityId(Int, ScalabilityType scalType );
1330
1331  Int    getViewIndex    ( Int layerIdInNuh )                       { return getScalabilityId( getLayerIdxInVps(layerIdInNuh), VIEW_ORDER_INDEX  ); }   
1332
1333  Int    getNumViews();
1334  Int    scalTypeToScalIdx( ScalabilityType scalType );
1335#endif
1336#if VPS_DPB_SIZE_TABLE
1337  Bool   getSubLayerFlagInfoPresentFlag(Int olsIdx)         { return m_subLayerFlagInfoPresentFlag[olsIdx]; }
1338  Void   setSubLayerFlagInfoPresentFlag(Int olsIdx, Bool x) { m_subLayerFlagInfoPresentFlag[olsIdx] = x;    }
1339
1340  Bool   getSubLayerDpbInfoPresentFlag(Int olsIdx, Int subLayerIdx)         { return m_subLayerDpbInfoPresentFlag[olsIdx][subLayerIdx]; }
1341  Void   setSubLayerDpbInfoPresentFlag(Int olsIdx, Int subLayerIdx, Bool x) { m_subLayerDpbInfoPresentFlag[olsIdx][subLayerIdx] = x;    }
1342
1343  // For the 0-th output layer set, use the date from the active SPS for base layer.
1344  Int    getMaxVpsDecPicBufferingMinus1(Int olsIdx, Int subDpbIdx, Int subLayerIdx)        { assert(olsIdx != 0); return m_maxVpsDecPicBufferingMinus1[olsIdx][subDpbIdx][subLayerIdx]; }
1345  Void   setMaxVpsDecPicBufferingMinus1(Int olsIdx, Int subDpbIdx, Int subLayerIdx, Int x) { m_maxVpsDecPicBufferingMinus1[olsIdx][subDpbIdx][subLayerIdx] = x;    }
1346  Int    getLayerIdcForOls( Int olsIdx, Int layerId );
1347
1348  Int    getMaxVpsNumReorderPics(Int olsIdx, Int subLayerIdx)        { assert(olsIdx != 0); return m_maxVpsNumReorderPics[olsIdx][subLayerIdx]; }
1349  Void   setMaxVpsNumReorderPics(Int olsIdx, Int subLayerIdx, Int x) { m_maxVpsNumReorderPics[olsIdx][subLayerIdx] = x;    }
1350
1351  Int    getMaxVpsLatencyIncreasePlus1(Int olsIdx, Int subLayerIdx)        { assert(olsIdx != 0); return m_maxVpsLatencyIncreasePlus1[olsIdx][subLayerIdx]; }
1352  Void   setMaxVpsLatencyIncreasePlus1(Int olsIdx, Int subLayerIdx, Int x) { m_maxVpsLatencyIncreasePlus1[olsIdx][subLayerIdx] = x;    }
1353
1354  Int    getNumSubDpbs(Int olsIdx)                          { return m_numSubDpbs[olsIdx]; }
1355  Void   setNumSubDpbs(Int olsIdx, Int x)                   { m_numSubDpbs[olsIdx] = x;    }
1356  Void   determineSubDpbInfoFlags();
1357#endif
1358
1359#if O0109_MOVE_VPS_VUI_FLAG
1360  Bool   getVpsVuiPresentFlag()                        { return m_vpsVuiPresentFlag; }
1361  Void   setVpsVuiPresentFlag(Bool x)                  { m_vpsVuiPresentFlag = x;    }
1362#endif
1363  Bool   getVpsExtensionFlag()                         { return m_vpsExtensionFlag;  }
1364  Void   setVpsExtensionFlag(Bool x)                   { m_vpsExtensionFlag = x;     }
1365
1366#if !P0307_REMOVE_VPS_VUI_OFFSET
1367#if VPS_VUI_OFFSET
1368  Int    getVpsVuiOffset()         { return m_vpsVuiOffset; }
1369  Void   setVpsVuiOffset(Int x)    { m_vpsVuiOffset = x; }
1370#endif
1371#endif
1372#if P0307_VPS_NON_VUI_EXTENSION
1373  Int    getVpsNonVuiExtLength()         { return m_vpsNonVuiExtLength; }
1374  Void   setVpsNonVuiExtLength(Int x)    { m_vpsNonVuiExtLength = x; }
1375#endif
1376#if O0164_MULTI_LAYER_HRD
1377  Void setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess );
1378#endif
1379#if NECESSARY_LAYER_FLAG
1380  Void  deriveNecessaryLayerFlag();
1381  Void  deriveNecessaryLayerFlag(Int const olsIdx);
1382  Void  checkNecessaryLayerFlagCondition();
1383#endif
1384#if SUB_LAYERS_IN_LAYER_SET
1385  Void  calculateMaxSLInLayerSets();
1386#endif
1387#endif //SVC_EXTENSION
1388};
1389
1390class TComVUI
1391{
1392private:
1393  Bool m_aspectRatioInfoPresentFlag;
1394  Int  m_aspectRatioIdc;
1395  Int  m_sarWidth;
1396  Int  m_sarHeight;
1397  Bool m_overscanInfoPresentFlag;
1398  Bool m_overscanAppropriateFlag;
1399  Bool m_videoSignalTypePresentFlag;
1400  Int  m_videoFormat;
1401  Bool m_videoFullRangeFlag;
1402  Bool m_colourDescriptionPresentFlag;
1403  Int  m_colourPrimaries;
1404  Int  m_transferCharacteristics;
1405  Int  m_matrixCoefficients;
1406  Bool m_chromaLocInfoPresentFlag;
1407  Int  m_chromaSampleLocTypeTopField;
1408  Int  m_chromaSampleLocTypeBottomField;
1409  Bool m_neutralChromaIndicationFlag;
1410  Bool m_fieldSeqFlag;
1411  Window m_defaultDisplayWindow;
1412  Bool m_frameFieldInfoPresentFlag;
1413  Bool m_hrdParametersPresentFlag;
1414  Bool m_bitstreamRestrictionFlag;
1415  Bool m_tilesFixedStructureFlag;
1416  Bool m_motionVectorsOverPicBoundariesFlag;
1417  Bool m_restrictedRefPicListsFlag;
1418  Int  m_minSpatialSegmentationIdc;
1419  Int  m_maxBytesPerPicDenom;
1420  Int  m_maxBitsPerMinCuDenom;
1421  Int  m_log2MaxMvLengthHorizontal;
1422  Int  m_log2MaxMvLengthVertical;
1423  TComHRD m_hrdParameters;
1424  TimingInfo m_timingInfo;
1425
1426public:
1427  TComVUI()
1428    :m_aspectRatioInfoPresentFlag(false) //TODO: This initialiser list contains magic numbers
1429    ,m_aspectRatioIdc(0)
1430    ,m_sarWidth(0)
1431    ,m_sarHeight(0)
1432    ,m_overscanInfoPresentFlag(false)
1433    ,m_overscanAppropriateFlag(false)
1434    ,m_videoSignalTypePresentFlag(false)
1435    ,m_videoFormat(5)
1436    ,m_videoFullRangeFlag(false)
1437    ,m_colourDescriptionPresentFlag(false)
1438    ,m_colourPrimaries(2)
1439    ,m_transferCharacteristics(2)
1440    ,m_matrixCoefficients(2)
1441    ,m_chromaLocInfoPresentFlag(false)
1442    ,m_chromaSampleLocTypeTopField(0)
1443    ,m_chromaSampleLocTypeBottomField(0)
1444    ,m_neutralChromaIndicationFlag(false)
1445    ,m_fieldSeqFlag(false)
1446    ,m_frameFieldInfoPresentFlag(false)
1447    ,m_hrdParametersPresentFlag(false)
1448    ,m_bitstreamRestrictionFlag(false)
1449    ,m_tilesFixedStructureFlag(false)
1450    ,m_motionVectorsOverPicBoundariesFlag(true)
1451    ,m_restrictedRefPicListsFlag(1)
1452    ,m_minSpatialSegmentationIdc(0)
1453    ,m_maxBytesPerPicDenom(2)
1454    ,m_maxBitsPerMinCuDenom(1)
1455    ,m_log2MaxMvLengthHorizontal(15)
1456    ,m_log2MaxMvLengthVertical(15)
1457  {}
1458
1459  virtual ~TComVUI() {}
1460
1461  Bool getAspectRatioInfoPresentFlag() { return m_aspectRatioInfoPresentFlag; }
1462  Void setAspectRatioInfoPresentFlag(Bool i) { m_aspectRatioInfoPresentFlag = i; }
1463
1464  Int getAspectRatioIdc() { return m_aspectRatioIdc; }
1465  Void setAspectRatioIdc(Int i) { m_aspectRatioIdc = i; }
1466
1467  Int getSarWidth() { return m_sarWidth; }
1468  Void setSarWidth(Int i) { m_sarWidth = i; }
1469
1470  Int getSarHeight() { return m_sarHeight; }
1471  Void setSarHeight(Int i) { m_sarHeight = i; }
1472
1473  Bool getOverscanInfoPresentFlag() { return m_overscanInfoPresentFlag; }
1474  Void setOverscanInfoPresentFlag(Bool i) { m_overscanInfoPresentFlag = i; }
1475
1476  Bool getOverscanAppropriateFlag() { return m_overscanAppropriateFlag; }
1477  Void setOverscanAppropriateFlag(Bool i) { m_overscanAppropriateFlag = i; }
1478
1479  Bool getVideoSignalTypePresentFlag() { return m_videoSignalTypePresentFlag; }
1480  Void setVideoSignalTypePresentFlag(Bool i) { m_videoSignalTypePresentFlag = i; }
1481
1482  Int getVideoFormat() { return m_videoFormat; }
1483  Void setVideoFormat(Int i) { m_videoFormat = i; }
1484
1485  Bool getVideoFullRangeFlag() { return m_videoFullRangeFlag; }
1486  Void setVideoFullRangeFlag(Bool i) { m_videoFullRangeFlag = i; }
1487
1488  Bool getColourDescriptionPresentFlag() { return m_colourDescriptionPresentFlag; }
1489  Void setColourDescriptionPresentFlag(Bool i) { m_colourDescriptionPresentFlag = i; }
1490
1491  Int getColourPrimaries() { return m_colourPrimaries; }
1492  Void setColourPrimaries(Int i) { m_colourPrimaries = i; }
1493
1494  Int getTransferCharacteristics() { return m_transferCharacteristics; }
1495  Void setTransferCharacteristics(Int i) { m_transferCharacteristics = i; }
1496
1497  Int getMatrixCoefficients() { return m_matrixCoefficients; }
1498  Void setMatrixCoefficients(Int i) { m_matrixCoefficients = i; }
1499
1500  Bool getChromaLocInfoPresentFlag() { return m_chromaLocInfoPresentFlag; }
1501  Void setChromaLocInfoPresentFlag(Bool i) { m_chromaLocInfoPresentFlag = i; }
1502
1503  Int getChromaSampleLocTypeTopField() { return m_chromaSampleLocTypeTopField; }
1504  Void setChromaSampleLocTypeTopField(Int i) { m_chromaSampleLocTypeTopField = i; }
1505
1506  Int getChromaSampleLocTypeBottomField() { return m_chromaSampleLocTypeBottomField; }
1507  Void setChromaSampleLocTypeBottomField(Int i) { m_chromaSampleLocTypeBottomField = i; }
1508
1509  Bool getNeutralChromaIndicationFlag() { return m_neutralChromaIndicationFlag; }
1510  Void setNeutralChromaIndicationFlag(Bool i) { m_neutralChromaIndicationFlag = i; }
1511
1512  Bool getFieldSeqFlag() { return m_fieldSeqFlag; }
1513  Void setFieldSeqFlag(Bool i) { m_fieldSeqFlag = i; }
1514
1515  Bool getFrameFieldInfoPresentFlag() { return m_frameFieldInfoPresentFlag; }
1516  Void setFrameFieldInfoPresentFlag(Bool i) { m_frameFieldInfoPresentFlag = i; }
1517
1518  Window& getDefaultDisplayWindow()                              { return m_defaultDisplayWindow;                }
1519  Void    setDefaultDisplayWindow(Window& defaultDisplayWindow ) { m_defaultDisplayWindow = defaultDisplayWindow; }
1520
1521  Bool getHrdParametersPresentFlag() { return m_hrdParametersPresentFlag; }
1522  Void setHrdParametersPresentFlag(Bool i) { m_hrdParametersPresentFlag = i; }
1523
1524  Bool getBitstreamRestrictionFlag() { return m_bitstreamRestrictionFlag; }
1525  Void setBitstreamRestrictionFlag(Bool i) { m_bitstreamRestrictionFlag = i; }
1526
1527  Bool getTilesFixedStructureFlag() { return m_tilesFixedStructureFlag; }
1528  Void setTilesFixedStructureFlag(Bool i) { m_tilesFixedStructureFlag = i; }
1529
1530  Bool getMotionVectorsOverPicBoundariesFlag() { return m_motionVectorsOverPicBoundariesFlag; }
1531  Void setMotionVectorsOverPicBoundariesFlag(Bool i) { m_motionVectorsOverPicBoundariesFlag = i; }
1532
1533  Bool getRestrictedRefPicListsFlag() { return m_restrictedRefPicListsFlag; }
1534  Void setRestrictedRefPicListsFlag(Bool b) { m_restrictedRefPicListsFlag = b; }
1535
1536  Int getMinSpatialSegmentationIdc() { return m_minSpatialSegmentationIdc; }
1537  Void setMinSpatialSegmentationIdc(Int i) { m_minSpatialSegmentationIdc = i; }
1538
1539  Int getMaxBytesPerPicDenom() { return m_maxBytesPerPicDenom; }
1540  Void setMaxBytesPerPicDenom(Int i) { m_maxBytesPerPicDenom = i; }
1541
1542  Int getMaxBitsPerMinCuDenom() { return m_maxBitsPerMinCuDenom; }
1543  Void setMaxBitsPerMinCuDenom(Int i) { m_maxBitsPerMinCuDenom = i; }
1544
1545  Int getLog2MaxMvLengthHorizontal() { return m_log2MaxMvLengthHorizontal; }
1546  Void setLog2MaxMvLengthHorizontal(Int i) { m_log2MaxMvLengthHorizontal = i; }
1547
1548  Int getLog2MaxMvLengthVertical() { return m_log2MaxMvLengthVertical; }
1549  Void setLog2MaxMvLengthVertical(Int i) { m_log2MaxMvLengthVertical = i; }
1550
1551  TComHRD* getHrdParameters                 ()             { return &m_hrdParameters; }
1552
1553  TimingInfo* getTimingInfo() { return &m_timingInfo; }
1554};
1555
1556/// SPS class
1557class TComSPS
1558{
1559private:
1560  Int          m_SPSId;
1561  Int          m_VPSId;
1562  ChromaFormat m_chromaFormatIdc;
1563
1564  UInt        m_uiMaxTLayers;           // maximum number of temporal layers
1565
1566#if R0279_REP_FORMAT_INBL
1567  Bool        m_bV1CompatibleSPSFlag;
1568#endif
1569
1570  // Structure
1571  UInt        m_picWidthInLumaSamples;
1572  UInt        m_picHeightInLumaSamples;
1573
1574  Int         m_log2MinCodingBlockSize;
1575  Int         m_log2DiffMaxMinCodingBlockSize;
1576  UInt        m_uiMaxCUWidth;
1577  UInt        m_uiMaxCUHeight;
1578  UInt        m_uiMaxCUDepth;
1579
1580  Window      m_conformanceWindow;
1581
1582  TComRPSList m_RPSList;
1583  Bool        m_bLongTermRefsPresent;
1584  Bool        m_TMVPFlagsPresent;
1585  Int         m_numReorderPics[MAX_TLAYER];
1586
1587  // Tool list
1588  UInt        m_uiQuadtreeTULog2MaxSize;
1589  UInt        m_uiQuadtreeTULog2MinSize;
1590  UInt        m_uiQuadtreeTUMaxDepthInter;
1591  UInt        m_uiQuadtreeTUMaxDepthIntra;
1592  Bool        m_usePCM;
1593  UInt        m_pcmLog2MaxSize;
1594  UInt        m_uiPCMLog2MinSize;
1595  Bool        m_useAMP;
1596
1597  // Parameter
1598  Int         m_uiBitDepth[MAX_NUM_CHANNEL_TYPE];
1599  Int         m_qpBDOffset[MAX_NUM_CHANNEL_TYPE];
1600  Bool        m_useExtendedPrecision;
1601  Bool        m_useHighPrecisionPredictionWeighting;
1602  Bool        m_useResidualRotation;
1603  Bool        m_useSingleSignificanceMapContext;
1604  Bool        m_useGolombRiceParameterAdaptation;
1605  Bool        m_alignCABACBeforeBypass;
1606  Bool        m_useResidualDPCM[NUMBER_OF_RDPCM_SIGNALLING_MODES];
1607  UInt        m_uiPCMBitDepth[MAX_NUM_CHANNEL_TYPE];
1608  Bool        m_bPCMFilterDisableFlag;
1609  Bool        m_disableIntraReferenceSmoothing;
1610
1611  UInt        m_uiBitsForPOC;
1612  UInt        m_numLongTermRefPicSPS;
1613  UInt        m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
1614  Bool        m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS];
1615  // Max physical transform size
1616  UInt        m_uiMaxTrSize;
1617
1618  Int m_iAMPAcc[MAX_CU_DEPTH];
1619  Bool        m_bUseSAO;
1620
1621  Bool        m_bTemporalIdNestingFlag; // temporal_id_nesting_flag
1622
1623  Bool        m_scalingListEnabledFlag;
1624  Bool        m_scalingListPresentFlag;
1625  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
1626  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER];
1627  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
1628
1629  Bool        m_useDF;
1630  Bool        m_useStrongIntraSmoothing;
1631
1632  Bool        m_vuiParametersPresentFlag;
1633  TComVUI     m_vuiParameters;
1634
1635  static const Int   m_winUnitX[MAX_CHROMA_FORMAT_IDC+1];
1636  static const Int   m_winUnitY[MAX_CHROMA_FORMAT_IDC+1];
1637  TComPTL     m_pcPTL;
1638
1639#if O0043_BEST_EFFORT_DECODING
1640  UInt        m_forceDecodeBitDepth; // 0 = do not force the decoder's bit depth, other = force the decoder's bit depth to this value (best effort decoding)
1641#endif
1642
1643#if SVC_EXTENSION
1644  UInt        m_layerId;
1645  Bool        m_extensionFlag;
1646  UInt        m_numScaledRefLayerOffsets;
1647  Bool        m_multiLayerExtSpsFlag;
1648#if R0042_PROFILE_INDICATION 
1649  Int         m_NumDirectRefLayers;
1650#endif
1651#if REPN_FORMAT_IN_VPS
1652  Bool m_updateRepFormatFlag;
1653#if O0096_REP_FORMAT_INDEX
1654  UInt        m_updateRepFormatIndex;
1655#endif
1656#endif
1657#if SCALINGLIST_INFERRING
1658  Bool        m_inferScalingListFlag;
1659  UInt        m_scalingListRefLayerId;
1660#endif
1661#endif //SVC_EXTENSION
1662
1663public:
1664  TComSPS();
1665  virtual ~TComSPS();
1666#if O0043_BEST_EFFORT_DECODING
1667  Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; }
1668  UInt getForceDecodeBitDepth()        const { return m_forceDecodeBitDepth;     }
1669#endif
1670
1671  Int  getVPSId       ()         { return m_VPSId;          }
1672  Void setVPSId       (Int i)    { m_VPSId = i;             }
1673  Int  getSPSId       ()         { return m_SPSId;          }
1674  Void setSPSId       (Int i)    { m_SPSId = i;             }
1675  ChromaFormat  getChromaFormatIdc ()         { return m_chromaFormatIdc;       }
1676  Void setChromaFormatIdc (ChromaFormat i)    { m_chromaFormatIdc = i;          }
1677
1678  static Int getWinUnitX (Int chromaFormatIdc) { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitX[chromaFormatIdc];      }
1679  static Int getWinUnitY (Int chromaFormatIdc) { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc];      }
1680
1681#if R0279_REP_FORMAT_INBL //These two functions shall be used / called when the syntax element sps_ext_or_max_sub_layers_minus1 and V1CompatibleSPSFlag are implemented
1682  Bool getV1CompatibleSPSFlag()        {return m_bV1CompatibleSPSFlag;}
1683  Void setV1CompatibleSPSFlag(Bool x)       { m_bV1CompatibleSPSFlag = x;}
1684#endif
1685
1686  // structure
1687  Void setPicWidthInLumaSamples       ( UInt u ) { m_picWidthInLumaSamples = u;        }
1688  UInt getPicWidthInLumaSamples       ()         { return  m_picWidthInLumaSamples;    }
1689  Void setPicHeightInLumaSamples      ( UInt u ) { m_picHeightInLumaSamples = u;       }
1690  UInt getPicHeightInLumaSamples      ()         { return  m_picHeightInLumaSamples;   }
1691
1692  Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
1693  Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
1694
1695  UInt  getNumLongTermRefPicSPS()             { return m_numLongTermRefPicSPS; }
1696  Void  setNumLongTermRefPicSPS(UInt val)     { m_numLongTermRefPicSPS = val; }
1697
1698  UInt  getLtRefPicPocLsbSps(UInt index)             { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); return m_ltRefPicPocLsbSps[index]; }
1699  Void  setLtRefPicPocLsbSps(UInt index, UInt val)   { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); m_ltRefPicPocLsbSps[index] = val; }
1700
1701  Bool getUsedByCurrPicLtSPSFlag(Int i)              { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); return m_usedByCurrPicLtSPSFlag[i];}
1702  Void setUsedByCurrPicLtSPSFlag(Int i, Bool x)      { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); m_usedByCurrPicLtSPSFlag[i] = x;}
1703
1704  Int  getLog2MinCodingBlockSize() const           { return m_log2MinCodingBlockSize; }
1705  Void setLog2MinCodingBlockSize(Int val)          { m_log2MinCodingBlockSize = val; }
1706  Int  getLog2DiffMaxMinCodingBlockSize() const    { return m_log2DiffMaxMinCodingBlockSize; }
1707  Void setLog2DiffMaxMinCodingBlockSize(Int val)   { m_log2DiffMaxMinCodingBlockSize = val; }
1708
1709  Void setMaxCUWidth  ( UInt u ) { m_uiMaxCUWidth = u;      }
1710  UInt getMaxCUWidth  ()         { return  m_uiMaxCUWidth;  }
1711  Void setMaxCUHeight ( UInt u ) { m_uiMaxCUHeight = u;     }
1712  UInt getMaxCUHeight ()         { return  m_uiMaxCUHeight; }
1713  Void setMaxCUDepth  ( UInt u ) { m_uiMaxCUDepth = u;      }
1714  UInt getMaxCUDepth  ()         { return  m_uiMaxCUDepth;  }
1715  Void setUsePCM      ( Bool b ) { m_usePCM = b;           }
1716  Bool getUsePCM      ()         { return m_usePCM;        }
1717  Void setPCMLog2MaxSize  ( UInt u ) { m_pcmLog2MaxSize = u;      }
1718  UInt getPCMLog2MaxSize  ()         { return  m_pcmLog2MaxSize;  }
1719  Void setPCMLog2MinSize  ( UInt u ) { m_uiPCMLog2MinSize = u;      }
1720  UInt getPCMLog2MinSize  ()         { return  m_uiPCMLog2MinSize;  }
1721  Void setBitsForPOC  ( UInt u ) { m_uiBitsForPOC = u;      }
1722  UInt getBitsForPOC  ()         { return m_uiBitsForPOC;   }
1723  Bool getUseAMP() { return m_useAMP; }
1724  Void setUseAMP( Bool b ) { m_useAMP = b; }
1725  Void setQuadtreeTULog2MaxSize( UInt u ) { m_uiQuadtreeTULog2MaxSize = u;    }
1726  UInt getQuadtreeTULog2MaxSize()         { return m_uiQuadtreeTULog2MaxSize; }
1727  Void setQuadtreeTULog2MinSize( UInt u ) { m_uiQuadtreeTULog2MinSize = u;    }
1728  UInt getQuadtreeTULog2MinSize()         { return m_uiQuadtreeTULog2MinSize; }
1729  Void setQuadtreeTUMaxDepthInter( UInt u ) { m_uiQuadtreeTUMaxDepthInter = u;    }
1730  Void setQuadtreeTUMaxDepthIntra( UInt u ) { m_uiQuadtreeTUMaxDepthIntra = u;    }
1731  UInt getQuadtreeTUMaxDepthInter()         { return m_uiQuadtreeTUMaxDepthInter; }
1732  UInt getQuadtreeTUMaxDepthIntra()         { return m_uiQuadtreeTUMaxDepthIntra; }
1733  Void setNumReorderPics(Int i, UInt tlayer)              { m_numReorderPics[tlayer] = i;    }
1734  Int  getNumReorderPics(UInt tlayer)                     { return m_numReorderPics[tlayer]; }
1735  Void         createRPSList( Int numRPS );
1736  TComRPSList* getRPSList()                      { return &m_RPSList;          }
1737  Bool      getLongTermRefsPresent()         { return m_bLongTermRefsPresent; }
1738  Void      setLongTermRefsPresent(Bool b)   { m_bLongTermRefsPresent=b;      }
1739  Bool      getTMVPFlagsPresent()         { return m_TMVPFlagsPresent; }
1740  Void      setTMVPFlagsPresent(Bool b)   { m_TMVPFlagsPresent=b;      }
1741  // physical transform
1742  Void setMaxTrSize   ( UInt u ) { m_uiMaxTrSize = u;       }
1743  UInt getMaxTrSize   ()         { return  m_uiMaxTrSize;   }
1744
1745  // AMP accuracy
1746  Int       getAMPAcc   ( UInt uiDepth ) { return m_iAMPAcc[uiDepth]; }
1747  Void      setAMPAcc   ( UInt uiDepth, Int iAccu ) { assert( uiDepth < g_uiMaxCUDepth);  m_iAMPAcc[uiDepth] = iAccu; }
1748
1749  // Bit-depth
1750  Int       getBitDepth     (ChannelType type)         { return m_uiBitDepth[type];   }
1751  Void      setBitDepth     (ChannelType type, Int u ) { m_uiBitDepth[type] = u;      }
1752  Int       getDifferentialLumaChromaBitDepth() const  { return Int(m_uiBitDepth[CHANNEL_TYPE_LUMA]) - Int(m_uiBitDepth[CHANNEL_TYPE_CHROMA]); }
1753  Int       getQpBDOffset   (ChannelType type) const   { return m_qpBDOffset[type];   }
1754  Void      setQpBDOffset   (ChannelType type, Int i)  { m_qpBDOffset[type] = i;      }
1755  Bool      getUseExtendedPrecision()          const   { return m_useExtendedPrecision;  }
1756  Void      setUseExtendedPrecision(Bool value)        { m_useExtendedPrecision = value; }
1757  Bool      getUseHighPrecisionPredictionWeighting() const { return m_useHighPrecisionPredictionWeighting; }
1758  Void      setUseHighPrecisionPredictionWeighting(Bool value) { m_useHighPrecisionPredictionWeighting = value; }
1759
1760  Void      setUseSAO                  (Bool bVal)  {m_bUseSAO = bVal;}
1761  Bool      getUseSAO                  ()           {return m_bUseSAO;}
1762
1763  Bool      getUseResidualRotation            ()                 const { return m_useResidualRotation;  }
1764  Void      setUseResidualRotation            (const Bool value)       { m_useResidualRotation = value; }
1765
1766  Bool      getUseSingleSignificanceMapContext()                 const { return m_useSingleSignificanceMapContext;  }
1767  Void      setUseSingleSignificanceMapContext(const Bool value)       { m_useSingleSignificanceMapContext = value; }
1768
1769  Bool      getUseGolombRiceParameterAdaptation()                 const { return m_useGolombRiceParameterAdaptation;  }
1770  Void      setUseGolombRiceParameterAdaptation(const Bool value)       { m_useGolombRiceParameterAdaptation = value; }
1771
1772  Bool      getAlignCABACBeforeBypass         ()                 const { return m_alignCABACBeforeBypass;  }
1773  Void      setAlignCABACBeforeBypass         (const Bool value)       { m_alignCABACBeforeBypass = value; }
1774
1775  Bool      getUseResidualDPCM (const RDPCMSignallingMode signallingMode)        const      { return m_useResidualDPCM[signallingMode];  }
1776  Void      setUseResidualDPCM (const RDPCMSignallingMode signallingMode, const Bool value) { m_useResidualDPCM[signallingMode] = value; }
1777
1778  UInt      getMaxTLayers()                           { return m_uiMaxTLayers; }
1779  Void      setMaxTLayers( UInt uiMaxTLayers )        { assert( uiMaxTLayers <= MAX_TLAYER ); m_uiMaxTLayers = uiMaxTLayers; }
1780
1781  Bool      getTemporalIdNestingFlag()                { return m_bTemporalIdNestingFlag; }
1782  Void      setTemporalIdNestingFlag( Bool bValue )   { m_bTemporalIdNestingFlag = bValue; }
1783  UInt      getPCMBitDepth         (ChannelType type) const   { return m_uiPCMBitDepth[type]; }
1784  Void      setPCMBitDepth         (ChannelType type, UInt u) { m_uiPCMBitDepth[type] = u;    }
1785  Void      setPCMFilterDisableFlag     ( Bool   bValue  )    { m_bPCMFilterDisableFlag = bValue; }
1786  Bool      getPCMFilterDisableFlag     ()                    { return m_bPCMFilterDisableFlag;   }
1787  Void      setDisableIntraReferenceSmoothing (Bool bValue)   { m_disableIntraReferenceSmoothing=bValue; }
1788  Bool      getDisableIntraReferenceSmoothing ()        const { return m_disableIntraReferenceSmoothing; }
1789
1790  Bool getScalingListFlag       ()         { return m_scalingListEnabledFlag;     }
1791  Void setScalingListFlag       ( Bool b ) { m_scalingListEnabledFlag  = b;       }
1792  Bool getScalingListPresentFlag()         { return m_scalingListPresentFlag;     }
1793  Void setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag  = b;       }
1794
1795#if SCALINGLIST_INFERRING
1796  Void setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
1797#else
1798  Void setScalingList      ( TComScalingList *scalingList);
1799#endif
1800  TComScalingList* getScalingList ()       { return m_scalingList; }               //!< get ScalingList class pointer in SPS
1801  UInt getMaxDecPicBuffering  (UInt tlayer)            { return m_uiMaxDecPicBuffering[tlayer]; }
1802  Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { assert(tlayer < MAX_TLAYER);  m_uiMaxDecPicBuffering[tlayer] = ui;   }
1803  UInt getMaxLatencyIncrease  (UInt tlayer)            { return m_uiMaxLatencyIncrease[tlayer];   }
1804  Void setMaxLatencyIncrease  ( UInt ui , UInt tlayer) { m_uiMaxLatencyIncrease[tlayer] = ui;      }
1805
1806  Void setUseStrongIntraSmoothing (Bool bVal)  {m_useStrongIntraSmoothing = bVal;}
1807  Bool getUseStrongIntraSmoothing ()           {return m_useStrongIntraSmoothing;}
1808
1809  Bool getVuiParametersPresentFlag() { return m_vuiParametersPresentFlag; }
1810  Void setVuiParametersPresentFlag(Bool b) { m_vuiParametersPresentFlag = b; }
1811  TComVUI* getVuiParameters() { return &m_vuiParameters; }
1812  Void setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess );
1813
1814  TComPTL* getPTL()     { return &m_pcPTL; }
1815
1816#if SVC_EXTENSION
1817  Void     setLayerId(UInt layerId)                 { m_layerId = layerId;           }
1818  UInt     getLayerId()                             { return m_layerId;              }
1819  Int      getExtensionFlag()                       { return m_extensionFlag;        }
1820  Void     setExtensionFlag(Int n)                  { m_extensionFlag = n;           }
1821  Bool     getMultiLayerExtSpsFlag()                { return m_multiLayerExtSpsFlag; }
1822  Void     setMultiLayerExtSpsFlag(Bool flag)       { m_multiLayerExtSpsFlag = flag; }
1823#if R0042_PROFILE_INDICATION
1824  Int      getNumDirectRefLayers()                  { return  m_NumDirectRefLayers;  }
1825  Void     setNumDirectRefLayers(Int n)             {  m_NumDirectRefLayers = n;     }
1826#endif
1827#if REPN_FORMAT_IN_VPS
1828  Bool     getUpdateRepFormatFlag()       { return m_updateRepFormatFlag; }
1829  Void     setUpdateRepFormatFlag(Bool x) { m_updateRepFormatFlag = x;    }
1830#if O0096_REP_FORMAT_INDEX
1831  Int      getUpdateRepFormatIndex()      { return m_updateRepFormatIndex; }
1832  Void     setUpdateRepFormatIndex(UInt index)  { m_updateRepFormatIndex = index; }
1833#endif
1834#endif
1835#if SCALINGLIST_INFERRING
1836  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
1837  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
1838  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
1839  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
1840#endif
1841#endif //SVC_EXTENSION
1842};
1843
1844/// Reference Picture Lists class
1845
1846class TComRefPicListModification
1847{
1848private:
1849  UInt      m_bRefPicListModificationFlagL0;
1850  UInt      m_bRefPicListModificationFlagL1;
1851  UInt      m_RefPicSetIdxL0[REF_PIC_LIST_NUM_IDX];
1852  UInt      m_RefPicSetIdxL1[REF_PIC_LIST_NUM_IDX];
1853
1854public:
1855  TComRefPicListModification();
1856  virtual ~TComRefPicListModification();
1857
1858  Void  create                    ();
1859  Void  destroy                   ();
1860
1861  Bool       getRefPicListModificationFlagL0() { return m_bRefPicListModificationFlagL0; }
1862  Void       setRefPicListModificationFlagL0(Bool flag) { m_bRefPicListModificationFlagL0 = flag; }
1863  Bool       getRefPicListModificationFlagL1() { return m_bRefPicListModificationFlagL1; }
1864  Void       setRefPicListModificationFlagL1(Bool flag) { m_bRefPicListModificationFlagL1 = flag; }
1865  Void       setRefPicSetIdxL0(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL0[idx] = refPicSetIdx; }
1866  UInt       getRefPicSetIdxL0(UInt idx) { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL0[idx]; }
1867  Void       setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
1868  UInt       getRefPicSetIdxL1(UInt idx) { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL1[idx]; }
1869};
1870
1871/// PPS class
1872class TComPPS
1873{
1874private:
1875  Int         m_PPSId;                    // pic_parameter_set_id
1876  Int         m_SPSId;                    // seq_parameter_set_id
1877  Int         m_picInitQPMinus26;
1878  Bool        m_useDQP;
1879  Bool        m_bConstrainedIntraPred;    // constrained_intra_pred_flag
1880  Bool        m_bSliceChromaQpFlag;       // slicelevel_chroma_qp_flag
1881
1882  // access channel
1883  TComSPS*    m_pcSPS;
1884  UInt        m_uiMaxCuDQPDepth;
1885  UInt        m_uiMinCuDQPSize;
1886
1887  /* Chroma QP Adjustments*/
1888  Int         m_MaxCuChromaQpAdjDepth;
1889  Int         m_MinCuChromaQpAdjSize;
1890  Int         m_ChromaQpAdjTableSize;
1891  ChromaQpAdj m_ChromaQpAdjTable[7];
1892
1893  Int         m_chromaCbQpOffset;
1894  Int         m_chromaCrQpOffset;
1895
1896  UInt        m_numRefIdxL0DefaultActive;
1897  UInt        m_numRefIdxL1DefaultActive;
1898
1899  Bool        m_bUseWeightPred;           // Use of Weighting Prediction (P_SLICE)
1900  Bool        m_useWeightedBiPred;        // Use of Weighting Bi-Prediction (B_SLICE)
1901  Bool        m_OutputFlagPresentFlag;   // Indicates the presence of output_flag in slice header
1902  Bool        m_useCrossComponentPrediction;
1903  UInt        m_saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE];
1904  Bool        m_TransquantBypassEnableFlag; // Indicates presence of cu_transquant_bypass_flag in CUs.
1905  Bool        m_useTransformSkip;
1906  Int         m_transformSkipLog2MaxSize;
1907  Bool        m_dependentSliceSegmentsEnabledFlag;     //!< Indicates the presence of dependent slices
1908  Bool        m_tilesEnabledFlag;              //!< Indicates the presence of tiles
1909  Bool        m_entropyCodingSyncEnabledFlag;  //!< Indicates the presence of wavefronts
1910
1911  Bool             m_loopFilterAcrossTilesEnabledFlag;
1912  Bool             m_uniformSpacingFlag;
1913  Int              m_numTileColumnsMinus1;
1914  Int              m_numTileRowsMinus1;
1915  std::vector<Int> m_tileColumnWidth;
1916  std::vector<Int> m_tileRowHeight;
1917
1918  Int      m_numSubstreams;
1919
1920  Int      m_signHideFlag;
1921
1922  Bool     m_cabacInitPresentFlag;
1923  UInt     m_encCABACTableIdx;           // Used to transmit table selection across slices
1924
1925  Bool     m_sliceHeaderExtensionPresentFlag;
1926  Bool     m_loopFilterAcrossSlicesEnabledFlag;
1927  Bool     m_deblockingFilterControlPresentFlag;
1928  Bool     m_deblockingFilterOverrideEnabledFlag;
1929  Bool     m_picDisableDeblockingFilterFlag;
1930  Int      m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
1931  Int      m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
1932  Bool     m_scalingListPresentFlag;
1933  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
1934  Bool     m_listsModificationPresentFlag;
1935  UInt     m_log2ParallelMergeLevelMinus2;
1936  Int      m_numExtraSliceHeaderBits;
1937
1938#if SVC_EXTENSION
1939  Bool     m_extensionFlag;
1940#if SCALINGLIST_INFERRING
1941  UInt     m_layerId;
1942  Bool     m_inferScalingListFlag;
1943  UInt     m_scalingListRefLayerId;
1944#endif
1945#if POC_RESET_IDC
1946  Bool     m_pocResetInfoPresentFlag;
1947#endif
1948  UInt     m_numRefLayerLocationOffsets;
1949#if O0098_SCALED_REF_LAYER_ID
1950  UInt     m_refLocationOffsetLayerId[MAX_LAYERS];
1951#endif
1952  Window   m_scaledRefLayerWindow[MAX_LAYERS];
1953  Window   m_refLayerWindow[MAX_LAYERS];
1954  Bool     m_scaledRefLayerOffsetPresentFlag[MAX_LAYERS];
1955  Bool     m_refRegionOffsetPresentFlag[MAX_LAYERS];
1956  Int      m_phaseHorLuma[MAX_LAYERS];
1957  Int      m_phaseVerLuma[MAX_LAYERS];
1958  Int      m_phaseHorChroma[MAX_LAYERS];
1959  Int      m_phaseVerChroma[MAX_LAYERS];
1960  Bool     m_resamplePhaseSetPresentFlag[MAX_LAYERS];
1961#if Q0048_CGS_3D_ASYMLUT
1962  Int      m_nCGSFlag;
1963  Int      m_nCGSOutputBitDepthY; // not for syntax
1964  Int      m_nCGSOutputBitDepthC; // not for syntax
1965#endif
1966#endif
1967
1968public:
1969  TComPPS();
1970  virtual ~TComPPS();
1971
1972  Int       getPPSId ()      { return m_PPSId; }
1973  Void      setPPSId (Int i) { m_PPSId = i; }
1974  Int       getSPSId ()      { return m_SPSId; }
1975  Void      setSPSId (Int i) { m_SPSId = i; }
1976
1977  Int       getPicInitQPMinus26 ()         { return  m_picInitQPMinus26; }
1978  Void      setPicInitQPMinus26 ( Int i )  { m_picInitQPMinus26 = i;     }
1979  Bool      getUseDQP ()                   { return m_useDQP;        }
1980  Void      setUseDQP ( Bool b )           { m_useDQP   = b;         }
1981  Bool      getConstrainedIntraPred ()         { return  m_bConstrainedIntraPred; }
1982  Void      setConstrainedIntraPred ( Bool b ) { m_bConstrainedIntraPred = b;     }
1983  Bool      getSliceChromaQpFlag ()         { return  m_bSliceChromaQpFlag; }
1984  Void      setSliceChromaQpFlag ( Bool b ) { m_bSliceChromaQpFlag = b;     }
1985
1986  Void      setSPS              ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
1987  TComSPS*  getSPS              ()         { return m_pcSPS;          }
1988  Void      setMaxCuDQPDepth    ( UInt u ) { m_uiMaxCuDQPDepth = u;   }
1989  UInt      getMaxCuDQPDepth    ()         { return m_uiMaxCuDQPDepth;}
1990  Void      setMinCuDQPSize     ( UInt u ) { m_uiMinCuDQPSize = u;    }
1991  UInt      getMinCuDQPSize     ()         { return m_uiMinCuDQPSize; }
1992
1993  Void      setQpOffset(ComponentID compID, Int i ) { if (compID==COMPONENT_Cb) m_chromaCbQpOffset = i; else if (compID==COMPONENT_Cr) m_chromaCrQpOffset = i; else assert(0); }
1994  Int       getQpOffset(ComponentID compID) const { return (compID==COMPONENT_Y) ? 0 : (compID==COMPONENT_Cb ? m_chromaCbQpOffset : m_chromaCrQpOffset ); }
1995
1996  Void      setMaxCuChromaQpAdjDepth ( UInt u ) { m_MaxCuChromaQpAdjDepth = u; }
1997  UInt      getMaxCuChromaQpAdjDepth ()         { return m_MaxCuChromaQpAdjDepth; }
1998  Void      setMinCuChromaQpAdjSize ( UInt u ) { m_MinCuChromaQpAdjSize = u; }
1999  UInt      getMinCuChromaQpAdjSize ()         { return m_MinCuChromaQpAdjSize; }
2000  Void      clearChromaQpAdjTable() { m_ChromaQpAdjTableSize = 0; }
2001  Int       getChromaQpAdjTableSize() { return m_ChromaQpAdjTableSize; }
2002  const ChromaQpAdj& getChromaQpAdjTableAt( Int idx ) const { return m_ChromaQpAdjTable[idx]; }
2003  Void      setChromaQpAdjTableAt( Int idx, Int cbOffset, Int crOffset )
2004  {
2005    m_ChromaQpAdjTable[idx].u.comp.CbOffset = cbOffset;
2006    m_ChromaQpAdjTable[idx].u.comp.CrOffset = crOffset;
2007    m_ChromaQpAdjTableSize = max(m_ChromaQpAdjTableSize, idx);
2008  }
2009
2010  Void      setNumRefIdxL0DefaultActive(UInt ui)    { m_numRefIdxL0DefaultActive=ui;     }
2011  UInt      getNumRefIdxL0DefaultActive()           { return m_numRefIdxL0DefaultActive; }
2012  Void      setNumRefIdxL1DefaultActive(UInt ui)    { m_numRefIdxL1DefaultActive=ui;     }
2013  UInt      getNumRefIdxL1DefaultActive()           { return m_numRefIdxL1DefaultActive; }
2014
2015  Bool getUseWP                     ()          { return m_bUseWeightPred;  }
2016  Bool getWPBiPred                  ()          { return m_useWeightedBiPred;     }
2017  Void setUseWP                     ( Bool b )  { m_bUseWeightPred = b;     }
2018  Void setWPBiPred                  ( Bool b )  { m_useWeightedBiPred = b;  }
2019
2020  Bool      getUseCrossComponentPrediction()         const { return m_useCrossComponentPrediction;  }
2021  Void      setUseCrossComponentPrediction(Bool value)     { m_useCrossComponentPrediction = value; }
2022
2023  UInt      getSaoOffsetBitShift(ChannelType type) const            { return m_saoOffsetBitShift[type];       }
2024  Void      setSaoOffsetBitShift(ChannelType type, UInt uiBitShift) { m_saoOffsetBitShift[type] = uiBitShift; }
2025
2026  Void      setOutputFlagPresentFlag( Bool b )  { m_OutputFlagPresentFlag = b;    }
2027  Bool      getOutputFlagPresentFlag()          { return m_OutputFlagPresentFlag; }
2028  Void      setTransquantBypassEnableFlag( Bool b ) { m_TransquantBypassEnableFlag = b; }
2029  Bool      getTransquantBypassEnableFlag()         { return m_TransquantBypassEnableFlag; }
2030
2031  Bool      getUseTransformSkip       ()         { return m_useTransformSkip;     }
2032  Void      setUseTransformSkip       ( Bool b ) { m_useTransformSkip  = b;       }
2033  UInt      getTransformSkipLog2MaxSize ()         { return m_transformSkipLog2MaxSize;     }
2034  Void      setTransformSkipLog2MaxSize ( UInt u ) { m_transformSkipLog2MaxSize  = u;       }
2035
2036  Void    setLoopFilterAcrossTilesEnabledFlag  (Bool b)    { m_loopFilterAcrossTilesEnabledFlag = b; }
2037  Bool    getLoopFilterAcrossTilesEnabledFlag  ()          { return m_loopFilterAcrossTilesEnabledFlag;   }
2038  Bool    getDependentSliceSegmentsEnabledFlag() const     { return m_dependentSliceSegmentsEnabledFlag; }
2039  Void    setDependentSliceSegmentsEnabledFlag(Bool val)   { m_dependentSliceSegmentsEnabledFlag = val; }
2040  Bool    getEntropyCodingSyncEnabledFlag() const          { return m_entropyCodingSyncEnabledFlag; }
2041  Void    setEntropyCodingSyncEnabledFlag(Bool val)        { m_entropyCodingSyncEnabledFlag = val; }
2042
2043  Void     setTilesEnabledFlag       (Bool val)                             { m_tilesEnabledFlag = val; }
2044  Bool     getTilesEnabledFlag       () const                               { return m_tilesEnabledFlag; }
2045  Void     setTileUniformSpacingFlag (Bool b)                               { m_uniformSpacingFlag = b; }
2046  Bool     getTileUniformSpacingFlag () const                               { return m_uniformSpacingFlag; }
2047  Void     setNumTileColumnsMinus1   (Int i)                                { m_numTileColumnsMinus1 = i; }
2048  Int      getNumTileColumnsMinus1   () const                               { return m_numTileColumnsMinus1; }
2049  Void     setTileColumnWidth        (const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; }
2050  UInt     getTileColumnWidth        (UInt columnIdx) const                 { return  m_tileColumnWidth[columnIdx]; }
2051  Void     setNumTileRowsMinus1      (Int i)                                { m_numTileRowsMinus1 = i; }
2052  Int      getNumTileRowsMinus1      () const                               { return m_numTileRowsMinus1; }
2053  Void     setTileRowHeight          (const std::vector<Int>& rowHeight)    { m_tileRowHeight = rowHeight;  }
2054  UInt     getTileRowHeight          (UInt rowIdx) const                    { return m_tileRowHeight[rowIdx]; }
2055
2056  Void     setNumSubstreams    (Int numSubstreams)                     { m_numSubstreams = numSubstreams; }
2057  Int      getNumSubstreams    ()                                      { return m_numSubstreams; }
2058
2059  Void      setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; }
2060  Int       getSignHideFlag()                    { return m_signHideFlag; }
2061
2062  Void     setCabacInitPresentFlag( Bool flag )     { m_cabacInitPresentFlag = flag;    }
2063  Void     setEncCABACTableIdx( Int idx )           { m_encCABACTableIdx = idx;         }
2064  Bool     getCabacInitPresentFlag()                { return m_cabacInitPresentFlag;    }
2065  UInt     getEncCABACTableIdx()                    { return m_encCABACTableIdx;        }
2066  Void     setDeblockingFilterControlPresentFlag( Bool val )  { m_deblockingFilterControlPresentFlag = val; }
2067  Bool     getDeblockingFilterControlPresentFlag()            { return m_deblockingFilterControlPresentFlag; }
2068  Void     setDeblockingFilterOverrideEnabledFlag( Bool val ) { m_deblockingFilterOverrideEnabledFlag = val; }
2069  Bool     getDeblockingFilterOverrideEnabledFlag()           { return m_deblockingFilterOverrideEnabledFlag; }
2070  Void     setPicDisableDeblockingFilterFlag(Bool val)        { m_picDisableDeblockingFilterFlag = val; }       //!< set offset for deblocking filter disabled
2071  Bool     getPicDisableDeblockingFilterFlag()                { return m_picDisableDeblockingFilterFlag; }      //!< get offset for deblocking filter disabled
2072  Void     setDeblockingFilterBetaOffsetDiv2(Int val)         { m_deblockingFilterBetaOffsetDiv2 = val; }       //!< set beta offset for deblocking filter
2073  Int      getDeblockingFilterBetaOffsetDiv2()                { return m_deblockingFilterBetaOffsetDiv2; }      //!< get beta offset for deblocking filter
2074  Void     setDeblockingFilterTcOffsetDiv2(Int val)           { m_deblockingFilterTcOffsetDiv2 = val; }               //!< set tc offset for deblocking filter
2075  Int      getDeblockingFilterTcOffsetDiv2()                  { return m_deblockingFilterTcOffsetDiv2; }              //!< get tc offset for deblocking filter
2076  Bool     getScalingListPresentFlag()         { return m_scalingListPresentFlag;     }
2077  Void     setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag  = b;       }
2078
2079#if SCALINGLIST_INFERRING
2080  Void     setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
2081#else
2082  Void     setScalingList      ( TComScalingList *scalingList);
2083#endif
2084  TComScalingList* getScalingList ()          { return m_scalingList; }         //!< get ScalingList class pointer in PPS
2085  Bool getListsModificationPresentFlag ()          { return m_listsModificationPresentFlag; }
2086  Void setListsModificationPresentFlag ( Bool b )  { m_listsModificationPresentFlag = b;    }
2087  UInt getLog2ParallelMergeLevelMinus2      ()                    { return m_log2ParallelMergeLevelMinus2; }
2088  Void setLog2ParallelMergeLevelMinus2      (UInt mrgLevel)       { m_log2ParallelMergeLevelMinus2 = mrgLevel; }
2089  Int getNumExtraSliceHeaderBits() { return m_numExtraSliceHeaderBits; }
2090  Void setNumExtraSliceHeaderBits(Int i) { m_numExtraSliceHeaderBits = i; }
2091  Void      setLoopFilterAcrossSlicesEnabledFlag ( Bool   bValue  )    { m_loopFilterAcrossSlicesEnabledFlag = bValue; }
2092  Bool      getLoopFilterAcrossSlicesEnabledFlag ()                    { return m_loopFilterAcrossSlicesEnabledFlag;   }
2093    Bool getSliceHeaderExtensionPresentFlag   ()                    { return m_sliceHeaderExtensionPresentFlag; }
2094  Void setSliceHeaderExtensionPresentFlag   (Bool val)            { m_sliceHeaderExtensionPresentFlag = val; }
2095#if SVC_EXTENSION
2096  Int     getExtensionFlag()                { return m_extensionFlag;  }
2097  Void    setExtensionFlag(Int n)           { m_extensionFlag = n;     }
2098#if SCALINGLIST_INFERRING
2099  UInt     getLayerId() { return m_layerId; }
2100  Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
2101  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
2102  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
2103  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
2104  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
2105#endif
2106#if POC_RESET_IDC
2107  Bool getPocResetInfoPresentFlag   ()                    { return m_pocResetInfoPresentFlag; }
2108  Void setPocResetInfoPresentFlag   (const Bool val)      { m_pocResetInfoPresentFlag = val; }
2109#endif
2110  UInt     getNumRefLayerLocationOffsets()       { return m_numRefLayerLocationOffsets; }
2111  Void     setNumRefLayerLocationOffsets(Int x)  { m_numRefLayerLocationOffsets = x;    }
2112#if O0098_SCALED_REF_LAYER_ID
2113  UInt     getRefLocationOffsetLayerId(Int x)          { return m_refLocationOffsetLayerId[x]; }
2114  Void     setRefLocationOffsetLayerId(Int x, UInt id) { m_refLocationOffsetLayerId[x] = id;   }
2115  Window&  getScaledRefLayerWindowForLayer( Int layerId );
2116#endif
2117  Window&  getScaledRefLayerWindow( Int x )   { return m_scaledRefLayerWindow[x]; }
2118  Window&  getRefLayerWindowForLayer( Int layerId );
2119  Window&  getRefLayerWindow( Int x )   { return m_refLayerWindow[x]; }
2120  Bool getScaledRefLayerOffsetPresentFlag(Int x) { return m_scaledRefLayerOffsetPresentFlag[x]; }
2121  Void setScaledRefLayerOffsetPresentFlag(Int x, Bool b) { m_scaledRefLayerOffsetPresentFlag[x] = b; }
2122  Bool getRefRegionOffsetPresentFlag(Int x) { return m_refRegionOffsetPresentFlag[x]; }
2123  Void setRefRegionOffsetPresentFlag(Int x, Bool b) { m_refRegionOffsetPresentFlag[x] = b; }
2124  Int getPhaseHorLuma(Int x) { return m_phaseHorLuma[x]; }
2125  Int getPhaseVerLuma(Int x) { return m_phaseVerLuma[x]; }
2126  Int getPhaseHorChroma(Int x) { return m_phaseHorChroma[x]; }
2127  Int getPhaseVerChroma(Int x) { return m_phaseVerChroma[x]; }
2128  Void setPhaseHorLuma(Int x, Int val) { m_phaseHorLuma[x] = val; }
2129  Void setPhaseVerLuma(Int x, Int val) { m_phaseVerLuma[x] = val; }
2130  Void setPhaseHorChroma(Int x, Int val) { m_phaseHorChroma[x] = val; }
2131  Void setPhaseVerChroma(Int x, Int val) { m_phaseVerChroma[x] = val; }
2132  Bool getResamplePhaseSetPresentFlag(Int x) { return m_resamplePhaseSetPresentFlag[x]; }
2133  Void setResamplePhaseSetPresentFlag(Int x, Bool b) { m_resamplePhaseSetPresentFlag[x] = b; }
2134  Bool hasZeroResamplingPhase(Int refLayerId);
2135  Void getResamplingPhase(Int refLayerId, Bool& phaseSetPresentFlag, Int& phaseHorLuma, Int& phaseVerLuma, Int& phaseHorChroma, Int& phaseVerChroma);
2136#if Q0048_CGS_3D_ASYMLUT
2137  Int     getCGSFlag()                { return m_nCGSFlag;  }
2138  Void    setCGSFlag(Int n)           { m_nCGSFlag = n;     }
2139  Int     getCGSOutputBitDepthY()     { return m_nCGSOutputBitDepthY;  }
2140  Void    setCGSOutputBitDepthY(Int n){ m_nCGSOutputBitDepthY = n;     }
2141  Int     getCGSOutputBitDepthC()     { return m_nCGSOutputBitDepthC;  }
2142  Void    setCGSOutputBitDepthC(Int n){ m_nCGSOutputBitDepthC = n;     }
2143#endif
2144#endif //SVC_EXTENSION
2145};
2146
2147struct WPScalingParam
2148{
2149  // Explicit weighted prediction parameters parsed in slice header,
2150  // or Implicit weighted prediction parameters (8 bits depth values).
2151  Bool bPresentFlag;
2152  UInt uiLog2WeightDenom;
2153  Int  iWeight;
2154  Int  iOffset;
2155
2156  // Weighted prediction scaling values built from above parameters (bitdepth scaled):
2157  Int  w;
2158  Int  o;
2159  Int  offset;
2160  Int  shift;
2161  Int  round;
2162};
2163
2164struct WPACDCParam
2165{
2166  Int64 iAC;
2167  Int64 iDC;
2168#if O0194_WEIGHTED_PREDICTION_CGS
2169  Int iSamples;
2170#endif
2171};
2172
2173/// slice header class
2174class TComSlice
2175{
2176 
2177private:
2178  //  Bitstream writing
2179  Bool        m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
2180  Int         m_iPPSId;               ///< picture parameter set ID
2181  Bool        m_PicOutputFlag;        ///< pic_output_flag
2182  Int         m_iPOC;
2183  Int         m_iLastIDR;
2184  Int         m_iAssociatedIRAP;
2185#if POC_RESET_IDC_ENCODER
2186  Int         m_associatedIrapPocBeforeReset;
2187#endif
2188  NalUnitType m_iAssociatedIRAPType;
2189  static Int  m_prevTid0POC;
2190  TComReferencePictureSet *m_pcRPS;
2191  TComReferencePictureSet m_LocalRPS;
2192  Int         m_iBDidx;
2193  TComRefPicListModification m_RefPicListModification;
2194  NalUnitType m_eNalUnitType;         ///< Nal unit type for the slice
2195  SliceType   m_eSliceType;
2196  Int         m_iSliceQp;
2197  Bool        m_dependentSliceSegmentFlag;
2198#if ADAPTIVE_QP_SELECTION
2199  Int         m_iSliceQpBase;
2200#endif
2201  Bool        m_ChromaQpAdjEnabled;
2202  Bool        m_deblockingFilterDisable;
2203  Bool        m_deblockingFilterOverrideFlag;      //< offsets for deblocking filter inherit from PPS
2204  Int         m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
2205  Int         m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
2206  Int         m_list1IdxToList0Idx[MAX_NUM_REF];
2207  Int         m_aiNumRefIdx   [NUM_REF_PIC_LIST_01];    //  for multiple reference of current slice
2208
2209  Bool        m_bCheckLDC;
2210
2211  //  Data
2212  Int         m_iSliceQpDelta;
2213  Int         m_iSliceChromaQpDelta[MAX_NUM_COMPONENT];
2214  TComPic*    m_apcRefPicList [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2215  Int         m_aiRefPOCList  [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2216  Bool        m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2217  Int         m_iDepth;
2218
2219  // referenced slice?
2220  Bool        m_bRefenced;
2221
2222  // access channel
2223  TComVPS*    m_pcVPS;
2224  TComSPS*    m_pcSPS;
2225  TComPPS*    m_pcPPS;
2226  TComPic*    m_pcPic;
2227#if ADAPTIVE_QP_SELECTION
2228  TComTrQuant* m_pcTrQuant;
2229#endif
2230  UInt        m_colFromL0Flag;  // collocated picture from List0 flag
2231
2232  Bool        m_noOutputPriorPicsFlag;
2233  Bool        m_noRaslOutputFlag;
2234  Bool        m_handleCraAsBlaFlag;
2235 
2236  UInt        m_colRefIdx;
2237  UInt        m_maxNumMergeCand;
2238
2239  Double      m_lambdas[MAX_NUM_COMPONENT];
2240
2241  Bool        m_abEqualRef  [NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_REF];
2242  UInt        m_uiTLayer;
2243  Bool        m_bTLayerSwitchingFlag;
2244
2245  SliceConstraint m_sliceMode;
2246  UInt        m_sliceArgument;
2247  UInt        m_sliceCurStartCtuTsAddr;
2248  UInt        m_sliceCurEndCtuTsAddr;
2249  UInt        m_sliceIdx;
2250  SliceConstraint m_sliceSegmentMode;
2251  UInt        m_sliceSegmentArgument;
2252  UInt        m_sliceSegmentCurStartCtuTsAddr;
2253  UInt        m_sliceSegmentCurEndCtuTsAddr;
2254  Bool        m_nextSlice;
2255  Bool        m_nextSliceSegment;
2256  UInt        m_sliceBits;
2257  UInt        m_sliceSegmentBits;
2258  Bool        m_bFinalized;
2259
2260  WPScalingParam  m_weightPredTable[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
2261  WPACDCParam    m_weightACDCParam[MAX_NUM_COMPONENT];
2262
2263  std::vector<UInt> m_substreamSizes;
2264
2265  TComScalingList*     m_scalingList;                 //!< pointer of quantization matrix
2266  Bool        m_cabacInitFlag;
2267
2268  Bool       m_bLMvdL1Zero;
2269  Bool       m_temporalLayerNonReferenceFlag;
2270  Bool       m_LFCrossSliceBoundaryFlag;
2271
2272  Bool       m_enableTMVPFlag;
2273
2274#if SVC_EXTENSION
2275  Bool        m_firstSliceInPic;
2276#if R0226_SLICE_TMVP
2277  Bool        m_availableForTMVPRefFlag;
2278#endif
2279  UInt        m_layerId;
2280  TComPic*    m_pcBaseColPic[MAX_LAYERS];
2281  TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS];
2282  Int         m_numMotionPredRefLayers;
2283#if REF_IDX_MFM
2284  Bool        m_bMFMEnabledFlag;
2285  Int         m_colRefLayerIdx;
2286  Bool        m_altColIndicationFlag;
2287  TComPic*    m_pcIlpPic;
2288#endif
2289
2290  Bool        m_interLayerPredEnabledFlag;
2291  Int         m_activeNumILRRefIdx;        //< Active inter-layer reference pictures
2292  Int         m_interLayerPredLayerIdc  [MAX_VPS_LAYER_IDX_PLUS1];
2293  Bool        m_bDiscardableFlag;
2294#if O0149_CROSS_LAYER_BLA_FLAG
2295  Bool        m_bCrossLayerBLAFlag;
2296#endif
2297#if POC_RESET_IDC_SIGNALLING
2298  Int         m_pocResetIdc;
2299  Int         m_pocResetPeriodId;
2300  Bool        m_fullPocResetFlag;
2301  Int         m_pocLsbVal;
2302  Int         m_pocMsbVal;
2303  Bool        m_pocMsbValRequiredFlag;
2304  Bool        m_pocMsbValPresentFlag;
2305#if P0297_VPS_POC_LSB_ALIGNED_FLAG
2306  Bool        m_pocMsbValNeeded;
2307  Int         m_pocResetDeltaPoc;
2308#endif
2309#endif
2310#if POC_RESET_IDC_ENCODER
2311  Int         m_pocValueBeforeReset;
2312#endif
2313#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
2314  Int         m_picOrderCntLsb;
2315#endif
2316#if Q0048_CGS_3D_ASYMLUT
2317  Int        m_nCGSOverWritePPS;  // for optimization, not output to bitstream
2318#endif
2319#endif //SVC_EXTENSION
2320
2321public:
2322  TComSlice();
2323  virtual ~TComSlice();
2324#if SVC_EXTENSION
2325  Void      initSlice       ( UInt layerId );
2326#else
2327  Void      initSlice       ();
2328#endif
2329  Void      initTiles();
2330
2331  Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
2332  TComVPS*  getVPS          () { return m_pcVPS; }
2333  Void      setSPS          ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
2334  TComSPS*  getSPS          () { return m_pcSPS; }
2335  const TComSPS*  getSPS() const  { return m_pcSPS; }
2336
2337  Void      setPPS          ( TComPPS* pcPPS )         { assert(pcPPS!=NULL); m_pcPPS = pcPPS; m_iPPSId = pcPPS->getPPSId(); }
2338  TComPPS*  getPPS          () { return m_pcPPS; }
2339  const TComPPS*  getPPS() const { return m_pcPPS; }
2340
2341#if ADAPTIVE_QP_SELECTION
2342  Void          setTrQuant          ( TComTrQuant* pcTrQuant ) { m_pcTrQuant = pcTrQuant; }
2343  TComTrQuant*  getTrQuant          () { return m_pcTrQuant; }
2344#endif
2345
2346  Void      setPPSId        ( Int PPSId )         { m_iPPSId = PPSId; }
2347  Int       getPPSId        () { return m_iPPSId; }
2348  Void      setPicOutputFlag( Bool b )         { m_PicOutputFlag = b;    }
2349  Bool      getPicOutputFlag()                 { return m_PicOutputFlag; }
2350  Void      setSaoEnabledFlag(ChannelType chType, Bool s) {m_saoEnabledFlag[chType] =s; }
2351  Bool      getSaoEnabledFlag(ChannelType chType) { return m_saoEnabledFlag[chType]; }
2352  Void      setRPS          ( TComReferencePictureSet *pcRPS ) { m_pcRPS = pcRPS; }
2353  TComReferencePictureSet*  getRPS          () { return m_pcRPS; }
2354  TComReferencePictureSet*  getLocalRPS     () { return &m_LocalRPS; }
2355
2356  Void      setRPSidx          ( Int iBDidx ) { m_iBDidx = iBDidx; }
2357  Int       getRPSidx          () { return m_iBDidx; }
2358  Int       getPrevTid0POC      ()                        { return  m_prevTid0POC;       }
2359  TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; }
2360  Void      setLastIDR(Int iIDRPOC)                       { m_iLastIDR = iIDRPOC; }
2361  Int       getLastIDR()                                  { return m_iLastIDR; }
2362  Void      setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)             { m_iAssociatedIRAP = iAssociatedIRAPPOC; }
2363  Int       getAssociatedIRAPPOC()                        { return m_iAssociatedIRAP; }
2364  Void      setAssociatedIRAPType(NalUnitType associatedIRAPType)    { m_iAssociatedIRAPType = associatedIRAPType; }
2365  NalUnitType getAssociatedIRAPType()                        { return m_iAssociatedIRAPType; }
2366  SliceType getSliceType    ()                          { return  m_eSliceType;         }
2367  Int       getPOC          ()                          { return  m_iPOC;           }
2368  Int       getSliceQp      ()                          { return  m_iSliceQp;           }
2369  Bool      getDependentSliceSegmentFlag()             const { return m_dependentSliceSegmentFlag; }
2370  Void      setDependentSliceSegmentFlag(Bool val)           { m_dependentSliceSegmentFlag = val; }
2371#if ADAPTIVE_QP_SELECTION
2372  Int       getSliceQpBase  ()                         const { return  m_iSliceQpBase;       }
2373#endif
2374  Int       getSliceQpDelta ()                         const { return  m_iSliceQpDelta;      }
2375  Int       getSliceChromaQpDelta (ComponentID compID) const { return  isLuma(compID) ? 0 : m_iSliceChromaQpDelta[compID]; }
2376  Bool      getUseChromaQpAdj()                        const { return m_ChromaQpAdjEnabled; }
2377  Bool      getDeblockingFilterDisable()               const { return  m_deblockingFilterDisable; }
2378  Bool      getDeblockingFilterOverrideFlag()          const { return  m_deblockingFilterOverrideFlag; }
2379  Int       getDeblockingFilterBetaOffsetDiv2()        const { return  m_deblockingFilterBetaOffsetDiv2; }
2380  Int       getDeblockingFilterTcOffsetDiv2()          const { return  m_deblockingFilterTcOffsetDiv2; }
2381
2382  Int       getNumRefIdx        ( RefPicList e )       const    { return  m_aiNumRefIdx[e];             }
2383  TComPic*  getPic              ()                              { return  m_pcPic;                      }
2384  TComPic*  getRefPic           ( RefPicList e, Int iRefIdx)    { return  m_apcRefPicList[e][iRefIdx];  }
2385  Int       getRefPOC           ( RefPicList e, Int iRefIdx)    { return  m_aiRefPOCList[e][iRefIdx];   }
2386  Int       getDepth            ()                              { return  m_iDepth;                     }
2387  UInt      getColFromL0Flag    ()                              { return  m_colFromL0Flag;              }
2388  UInt      getColRefIdx        ()                              { return  m_colRefIdx;                  }
2389  Void      checkColRefIdx      (UInt curSliceIdx, TComPic* pic);
2390  Bool      getIsUsedAsLongTerm (Int i, Int j)                  { return m_bIsUsedAsLongTerm[i][j]; }
2391  Void      setIsUsedAsLongTerm (Int i, Int j, Bool value)      { m_bIsUsedAsLongTerm[i][j] = value; }
2392  Bool      getCheckLDC     ()                                  { return m_bCheckLDC; }
2393  Bool      getMvdL1ZeroFlag ()                                 { return m_bLMvdL1Zero;    }
2394  Int       getNumRpsCurrTempList();
2395  Int       getList1IdxToList0Idx ( Int list1Idx )              { return m_list1IdxToList0Idx[list1Idx]; }
2396  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
2397  Bool      isReferenced()                                      { return m_bRefenced; }
2398  Bool      isReferenceNalu()                                   { return ((getNalUnitType() <= NAL_UNIT_RESERVED_VCL_R15) && (getNalUnitType()%2 != 0)) || ((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_RESERVED_IRAP_VCL23) ); }
2399  Void      setPOC              ( Int i )                       { m_iPOC              = i; if ((getTLayer()==0) && (isReferenceNalu() && (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) {m_prevTid0POC=i;} }
2400  Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
2401  NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
2402  Bool      getRapPicFlag       ();
2403  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
2404  Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); }
2405  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
2406#if NO_CLRAS_OUTPUT_FLAG
2407  Void      decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, UInt smallestLayerId = 0 );
2408  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag);
2409#else
2410  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic);
2411#endif
2412  Void      setSliceType        ( SliceType e )                 { m_eSliceType        = e;      }
2413  Void      setSliceQp          ( Int i )                       { m_iSliceQp          = i;      }
2414#if ADAPTIVE_QP_SELECTION
2415  Void      setSliceQpBase      ( Int i )                       { m_iSliceQpBase      = i;      }
2416#endif
2417  Void      setSliceQpDelta     ( Int i )                       { m_iSliceQpDelta     = i;      }
2418  Void      setSliceChromaQpDelta( ComponentID compID, Int i )  { m_iSliceChromaQpDelta[compID] = isLuma(compID) ? 0 : i;  }
2419  Void      setUseChromaQpAdj   ( Bool b )                      { m_ChromaQpAdjEnabled = b;     }
2420  Void      setDeblockingFilterDisable( Bool b )                { m_deblockingFilterDisable= b;      }
2421  Void      setDeblockingFilterOverrideFlag( Bool b )           { m_deblockingFilterOverrideFlag = b; }
2422  Void      setDeblockingFilterBetaOffsetDiv2( Int i )          { m_deblockingFilterBetaOffsetDiv2 = i; }
2423  Void      setDeblockingFilterTcOffsetDiv2( Int i )            { m_deblockingFilterTcOffsetDiv2 = i; }
2424
2425  Void      setRefPic           ( TComPic* p, RefPicList e, Int iRefIdx ) { m_apcRefPicList[e][iRefIdx] = p; }
2426  Void      setRefPOC           ( Int i, RefPicList e, Int iRefIdx ) { m_aiRefPOCList[e][iRefIdx] = i; }
2427  Void      setNumRefIdx        ( RefPicList e, Int i )         { m_aiNumRefIdx[e]    = i;      }
2428  Void      setPic              ( TComPic* p )                  { m_pcPic             = p;      }
2429  Void      setDepth            ( Int iDepth )                  { m_iDepth            = iDepth; }
2430
2431#if SVC_EXTENSION
2432#if POC_RESET_IDC_DECODER
2433  Void      setPrevTid0POC( Int x ) { m_prevTid0POC = x; }
2434#endif
2435#if POC_RESET_IDC_ENCODER
2436  Void      setAssociatedIrapPocBeforeReset(Int x) { m_associatedIrapPocBeforeReset = x; }
2437  Int       getAssociatedIrapPocBeforeReset(     ) { return m_associatedIrapPocBeforeReset; }
2438#endif
2439
2440  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false, TComPic** ilpPic = NULL );
2441#if Q0048_CGS_3D_ASYMLUT
2442  Int       getCGSOverWritePPS()              { return m_nCGSOverWritePPS;    }
2443  Void      setCGSOverWritePPS(Int n)         { m_nCGSOverWritePPS = n;       }
2444#endif
2445#else
2446  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
2447#endif
2448  Void      setRefPOCList       ();
2449  Void      setColFromL0Flag    ( UInt colFromL0 ) { m_colFromL0Flag = colFromL0; }
2450  Void      setColRefIdx        ( UInt refIdx) { m_colRefIdx = refIdx; }
2451  Void      setCheckLDC         ( Bool b )                      { m_bCheckLDC = b; }
2452  Void      setMvdL1ZeroFlag     ( Bool b)                       { m_bLMvdL1Zero = b; }
2453
2454  Bool      isIntra         ()                          { return  m_eSliceType == I_SLICE;  }
2455  Bool      isInterB        ()                          { return  m_eSliceType == B_SLICE;  }
2456  Bool      isInterP        ()                          { return  m_eSliceType == P_SLICE;  }
2457
2458  Void      setLambdas ( const Double lambdas[MAX_NUM_COMPONENT] ) { for (Int component = 0; component < MAX_NUM_COMPONENT; component++) m_lambdas[component] = lambdas[component]; }
2459  const Double* getLambdas() const { return m_lambdas; }
2460
2461  Void      initEqualRef();
2462  Bool      isEqualRef  ( RefPicList e, Int iRefIdx1, Int iRefIdx2 )
2463  {
2464    assert(e<NUM_REF_PIC_LIST_01);
2465    if (iRefIdx1 < 0 || iRefIdx2 < 0) return false;
2466    return m_abEqualRef[e][iRefIdx1][iRefIdx2];
2467  }
2468
2469  Void setEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2, Bool b)
2470  {
2471    assert(e<NUM_REF_PIC_LIST_01);
2472    m_abEqualRef[e][iRefIdx1][iRefIdx2] = m_abEqualRef[e][iRefIdx2][iRefIdx1] = b;
2473  }
2474
2475  static Void      sortPicList         ( TComList<TComPic*>& rcListPic );
2476  Void setList1IdxToList0Idx();
2477
2478  UInt getTLayer             ()                            { return m_uiTLayer;                      }
2479  Void setTLayer             ( UInt uiTLayer )             { m_uiTLayer = uiTLayer;                  }
2480
2481  Void setTLayerInfo( UInt uiTLayer );
2482  Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
2483#if POC_RESET_IDC_ENCODER
2484  Void checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset = false);
2485#else
2486  Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
2487#endif
2488  Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
2489  Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
2490  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
2491#if ALLOW_RECOVERY_POINT_AS_RAP
2492  Int  checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
2493  Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
2494#else
2495  Int  checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
2496  Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP);
2497#endif
2498  Void setMaxNumMergeCand               (UInt val )          { m_maxNumMergeCand = val;                 }
2499  UInt getMaxNumMergeCand               ()                   { return m_maxNumMergeCand;                }
2500
2501  Void setNoOutputPriorPicsFlag         ( Bool val )         { m_noOutputPriorPicsFlag = val;           }
2502  Bool getNoOutputPriorPicsFlag         ()                   { return m_noOutputPriorPicsFlag;          }
2503
2504  Void setNoRaslOutputFlag              ( Bool val )         { m_noRaslOutputFlag = val;                }
2505  Bool getNoRaslOutputFlag              ()                   { return m_noRaslOutputFlag;               }
2506
2507  Void setHandleCraAsBlaFlag            ( Bool val )         { m_handleCraAsBlaFlag = val;              }
2508  Bool getHandleCraAsBlaFlag            ()                   { return m_handleCraAsBlaFlag;             }
2509
2510  Void setSliceMode                     ( SliceConstraint mode ) { m_sliceMode = mode;                  }
2511  SliceConstraint getSliceMode          () const            { return m_sliceMode;                       }
2512  Void setSliceArgument                 ( UInt uiArgument ) { m_sliceArgument = uiArgument;             }
2513  UInt getSliceArgument                 ()                  { return m_sliceArgument;                   }
2514  Void setSliceCurStartCtuTsAddr        ( UInt ctuTsAddr )  { m_sliceCurStartCtuTsAddr = ctuTsAddr;     } // CTU Tile-scan address (as opposed to raster-scan)
2515  UInt getSliceCurStartCtuTsAddr        () const            { return m_sliceCurStartCtuTsAddr;          } // CTU Tile-scan address (as opposed to raster-scan)
2516  Void setSliceCurEndCtuTsAddr          ( UInt ctuTsAddr )  { m_sliceCurEndCtuTsAddr = ctuTsAddr;       } // CTU Tile-scan address (as opposed to raster-scan)
2517  UInt getSliceCurEndCtuTsAddr          () const            { return m_sliceCurEndCtuTsAddr;            } // CTU Tile-scan address (as opposed to raster-scan)
2518  Void setSliceIdx                      ( UInt i)           { m_sliceIdx = i;                           }
2519  UInt getSliceIdx                      ()                  { return  m_sliceIdx;                       }
2520  Void copySliceInfo                    (TComSlice *pcSliceSrc);
2521  Void setSliceSegmentMode              ( SliceConstraint mode ) { m_sliceSegmentMode = mode;           }
2522  SliceConstraint getSliceSegmentMode   () const            { return m_sliceSegmentMode;                }
2523  Void setSliceSegmentArgument          ( UInt uiArgument ) { m_sliceSegmentArgument = uiArgument;      }
2524  UInt getSliceSegmentArgument          ()                  { return m_sliceSegmentArgument;            }
2525  Void setSliceSegmentCurStartCtuTsAddr ( UInt ctuTsAddr )  { m_sliceSegmentCurStartCtuTsAddr = ctuTsAddr; } // CTU Tile-scan address (as opposed to raster-scan)
2526  UInt getSliceSegmentCurStartCtuTsAddr () const            { return m_sliceSegmentCurStartCtuTsAddr;      } // CTU Tile-scan address (as opposed to raster-scan)
2527  Void setSliceSegmentCurEndCtuTsAddr   ( UInt ctuTsAddr )  { m_sliceSegmentCurEndCtuTsAddr = ctuTsAddr;   } // CTU Tile-scan address (as opposed to raster-scan)
2528  UInt getSliceSegmentCurEndCtuTsAddr   () const            { return m_sliceSegmentCurEndCtuTsAddr;        } // CTU Tile-scan address (as opposed to raster-scan)
2529  Void setSliceBits                     ( UInt uiVal )      { m_sliceBits = uiVal;                      }
2530  UInt getSliceBits                     ()                  { return m_sliceBits;                       }
2531  Void setSliceSegmentBits              ( UInt uiVal )      { m_sliceSegmentBits = uiVal;            }
2532  UInt getSliceSegmentBits              ()                  { return m_sliceSegmentBits;             }
2533  Void setFinalized                     ( Bool uiVal )      { m_bFinalized = uiVal;                       }
2534  Bool getFinalized                     ()                  { return m_bFinalized;                        }
2535  Void  setWpScaling    ( WPScalingParam  wp[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT] ) { memcpy(m_weightPredTable, wp, sizeof(WPScalingParam)*NUM_REF_PIC_LIST_01*MAX_NUM_REF*MAX_NUM_COMPONENT); }
2536  Void  getWpScaling    ( RefPicList e, Int iRefIdx, WPScalingParam *&wp);
2537
2538  Void  resetWpScaling  ();
2539  Void  initWpScaling   ();
2540  inline Bool applyWP   () { return( (m_eSliceType==P_SLICE && m_pcPPS->getUseWP()) || (m_eSliceType==B_SLICE && m_pcPPS->getWPBiPred()) ); }
2541
2542  Void  setWpAcDcParam  ( WPACDCParam wp[MAX_NUM_COMPONENT] ) { memcpy(m_weightACDCParam, wp, sizeof(WPACDCParam)*MAX_NUM_COMPONENT); }
2543  Void  getWpAcDcParam  ( WPACDCParam *&wp );
2544  Void  initWpAcDcParam ();
2545
2546  Void clearSubstreamSizes       ( )                        { return m_substreamSizes.clear();        }
2547  UInt getNumberOfSubstreamSizes ( )                        { return (UInt) m_substreamSizes.size();  }
2548  Void addSubstreamSize          ( UInt size )              { m_substreamSizes.push_back(size);       }
2549  UInt getSubstreamSize          ( Int idx )                { assert(idx<getNumberOfSubstreamSizes()); return m_substreamSizes[idx]; }
2550
2551  Void  setScalingList              ( TComScalingList* scalingList ) { m_scalingList = scalingList; }
2552  TComScalingList*   getScalingList ()                               { return m_scalingList; }
2553  Void  setDefaultScalingList       ();
2554  Bool  checkDefaultScalingList     ();
2555  Void      setCabacInitFlag  ( Bool val ) { m_cabacInitFlag = val;      }  //!< set CABAC initial flag
2556  Bool      getCabacInitFlag  ()           { return m_cabacInitFlag;     }  //!< get CABAC initial flag
2557  Bool      getTemporalLayerNonReferenceFlag()       { return m_temporalLayerNonReferenceFlag;}
2558  Void      setTemporalLayerNonReferenceFlag(Bool x) { m_temporalLayerNonReferenceFlag = x;}
2559  Void      setLFCrossSliceBoundaryFlag     ( Bool   val )    { m_LFCrossSliceBoundaryFlag = val; }
2560  Bool      getLFCrossSliceBoundaryFlag     ()                { return m_LFCrossSliceBoundaryFlag;}
2561
2562  Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
2563  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
2564
2565#if SVC_EXTENSION
2566  Void      setFirstSliceInPic               ( Bool val )        { m_firstSliceInPic = val;                    }
2567  Bool      getFirstSliceInPic               ()                  { return m_firstSliceInPic;                   }
2568#if R0226_SLICE_TMVP
2569  Void      setAvailableForTMVPRefFlag     ( Bool   b )    { m_availableForTMVPRefFlag = b; }
2570  Bool      getAvailableForTMVPRefFlag     ()              { return m_availableForTMVPRefFlag;}
2571#endif
2572  Bool      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt refLayerIdc );
2573  Void      setBaseColPic       (UInt refLayerIdc, TComPic* p)     { m_pcBaseColPic[refLayerIdc] = p; }
2574  TComPic*  getBaseColPic       (UInt refLayerIdc)                { return m_pcBaseColPic[refLayerIdc]; }
2575  TComPic** getBaseColPic       ()                { return &m_pcBaseColPic[0]; }
2576#if MFM_ENCCONSTRAINT
2577  TComPic*  getBaseColPic( TComList<TComPic*>& rcListPic );
2578#endif
2579
2580  Void      setLayerId (UInt layerId)   { m_layerId = layerId; }
2581  UInt      getLayerId ()               { return m_layerId;    }
2582  UInt      getLayerIdx()               { return m_pcVPS->getLayerIdxInVps(m_layerId); }
2583
2584  Void        setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
2585  TComPicYuv* getFullPelBaseRec   (UInt refLayerIdc)               { return  m_pcFullPelBaseRec[refLayerIdc];  }
2586
2587  Void      setRefPicListModificationSvc();
2588  Int       getNumILRRefIdx     ( )                     { return  m_pcVPS->getNumDirectRefLayers( m_layerId ); }
2589
2590  Int       getActiveNumILRRefIdx     ( )               { return  m_activeNumILRRefIdx; }
2591  Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     } 
2592
2593  Int       getInterLayerPredLayerIdc (UInt layerIdc)                        { return  m_interLayerPredLayerIdc[layerIdc];}
2594  Void      setInterLayerPredLayerIdc (UInt refLayerIdc, UInt layerIdc)      { m_interLayerPredLayerIdc[layerIdc] = refLayerIdc;  }
2595
2596  Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
2597  Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;}
2598
2599  Void      setNumMotionPredRefLayers(int i)            { m_numMotionPredRefLayers = i; }
2600  Int       getNumMotionPredRefLayers()                 { return m_numMotionPredRefLayers; }
2601#if REF_IDX_MFM
2602  Void      setMFMEnabledFlag(Bool flag)                { m_bMFMEnabledFlag = flag; }
2603  Bool      getMFMEnabledFlag()                         { return m_bMFMEnabledFlag; }
2604#endif
2605
2606  TComPic* getRefPic(TComList<TComPic*>& rcListPic, Int poc) { return xGetRefPic( rcListPic, poc ); } 
2607
2608  Bool     isRADL()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); }
2609  Bool     isRASL()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_R); }
2610
2611#if POC_RESET_RESTRICTIONS
2612  Bool     isIDR()    { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
2613                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP); }
2614  Bool     isCRA()    { return m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA; }
2615  Bool     isBLA()    { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
2616                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
2617                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP ); }
2618  Bool     isSLNR()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
2619                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
2620                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_STSA_N
2621                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_N
2622                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N
2623                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N10
2624                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N12
2625                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N14 ); }
2626#endif
2627  Bool      getDiscardableFlag  ()                           { return m_bDiscardableFlag;    }
2628  Void      setDiscardableFlag  (Bool b)                     { m_bDiscardableFlag = b;       }
2629#if O0149_CROSS_LAYER_BLA_FLAG
2630  Bool      getCrossLayerBLAFlag  ()                         { return m_bCrossLayerBLAFlag;  }
2631  Void      setCrossLayerBLAFlag  (Bool b)                   { m_bCrossLayerBLAFlag = b;     }
2632#endif
2633
2634#if RPL_INIT_N0316_N0082
2635  Int       getNumNegativeRpsCurrTempList();
2636#endif
2637
2638#if REPN_FORMAT_IN_VPS
2639  UInt getPicWidthInLumaSamples();
2640  UInt getPicHeightInLumaSamples();
2641#if AUXILIARY_PICTURES
2642  ChromaFormat getChromaFormatIdc();
2643#else
2644  UInt getChromaFormatIdc();
2645#endif
2646  UInt getBitDepthY();
2647  UInt getBitDepthC();
2648  Int  getQpBDOffsetY();
2649  Int  getQpBDOffsetC();
2650
2651#if R0156_CONF_WINDOW_IN_REP_FORMAT
2652  Window& getConformanceWindow();
2653#endif
2654#endif
2655
2656  Void setILRPic(TComPic **pcIlpPic);
2657#if POC_RESET_IDC_SIGNALLING
2658  Int       getPocResetIdc       ()                              { return m_pocResetIdc;       }
2659  Void      setPocResetIdc       (Int b)                         { m_pocResetIdc = b;          }
2660  Int       getPocResetPeriodId  ()                              { return m_pocResetPeriodId;       }
2661  Void      setPocResetPeriodId  (Int b)                         { m_pocResetPeriodId = b;          }
2662  Bool      getFullPocResetFlag  ()                              { return m_fullPocResetFlag;       }
2663  Void      setFullPocResetFlag  (Bool b)                        { m_fullPocResetFlag = b;          }
2664  Int       getPocLsbVal         ()                              { return m_pocLsbVal;       }
2665  Void      setPocLsbVal       (Int b)                           { m_pocLsbVal = b;          }
2666#if P0297_VPS_POC_LSB_ALIGNED_FLAG
2667  Void      setPocMsbNeeded      (Bool x)                        { m_pocMsbValNeeded = x; }
2668  Bool      getPocMsbNeeded      ()                              { return m_pocMsbValNeeded; }
2669  Int       getPocResetDeltaPoc  ()                              { return m_pocResetDeltaPoc; }
2670  Void      setPocResetDeltaPoc  (Int x)                         { m_pocResetDeltaPoc = x; }
2671#endif
2672  Int       getPocMsbVal         ()                              { return m_pocMsbVal;       }
2673  Void      setPocMsbVal       (Int b)                           { m_pocMsbVal = b;          }
2674  Bool      getPocMsbValPresentFlag ()                           { return m_pocMsbValPresentFlag; }
2675  Void      setPocMsbValPresentFlag (Bool x)                     { m_pocMsbValPresentFlag = x; }
2676  Bool      getPocMsbValRequiredFlag ()                           { return m_pocMsbValRequiredFlag; }
2677  Void      setPocMsbValRequiredFlag (Bool x)                     { m_pocMsbValRequiredFlag = x; }
2678#endif
2679
2680#if NO_OUTPUT_OF_PRIOR_PICS
2681  Bool      getBlaPicFlag       ();
2682  Bool      getCraPicFlag       ();
2683#endif
2684#if POC_RESET_IDC_DECODER
2685  Bool      getRaslPicFlag      ();
2686  Bool      getRadlPicFlag      ();
2687#endif
2688#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
2689  Int       getPicOrderCntLsb() { return m_picOrderCntLsb; }
2690  Void      setPicOrderCntLsb(Int x) { m_picOrderCntLsb = x; }
2691#endif
2692
2693#if POC_RESET_IDC_ENCODER
2694  Int       getPocValueBeforeReset ()                        { return m_pocValueBeforeReset; }
2695  Void      setPocValueBeforeReset (Int x)                   { m_pocValueBeforeReset = x ;   }
2696  Void      decrementRefPocValues(Int const decrementValue);
2697  Int       getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal );
2698#endif
2699  Int       getReferenceLayerIdc( UInt refLayerId );
2700
2701#endif //SVC_EXTENSION
2702protected:
2703  TComPic*  xGetRefPic        (TComList<TComPic*>& rcListPic, Int poc);
2704  TComPic*  xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
2705};// END CLASS DEFINITION TComSlice
2706
2707
2708template <class T> class ParameterSetMap
2709{
2710public:
2711  ParameterSetMap(Int maxId)
2712  :m_maxId (maxId)
2713  {}
2714
2715  ~ParameterSetMap()
2716  {
2717    for (typename std::map<Int,T *>::iterator i = m_paramsetMap.begin(); i!= m_paramsetMap.end(); i++)
2718    {
2719      delete (*i).second;
2720    }
2721  }
2722
2723  Void storePS(Int psId, T *ps)
2724  {
2725    assert ( psId < m_maxId );
2726    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
2727    {
2728      delete m_paramsetMap[psId];
2729    }
2730    m_paramsetMap[psId] = ps;
2731  }
2732
2733  Void mergePSList(ParameterSetMap<T> &rPsList)
2734  {
2735    for (typename std::map<Int,T *>::iterator i = rPsList.m_paramsetMap.begin(); i!= rPsList.m_paramsetMap.end(); i++)
2736    {
2737      storePS(i->first, i->second);
2738    }
2739    rPsList.m_paramsetMap.clear();
2740  }
2741
2742
2743  T* getPS(Int psId)
2744  {
2745    return ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) ? NULL : m_paramsetMap[psId];
2746  }
2747
2748  T* getFirstPS()
2749  {
2750    return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second;
2751  }
2752
2753private:
2754  std::map<Int,T *> m_paramsetMap;
2755  Int               m_maxId;
2756};
2757
2758class ParameterSetManager
2759{
2760public:
2761  ParameterSetManager();
2762  virtual ~ParameterSetManager();
2763
2764  //! store sequence parameter set and take ownership of it
2765  Void storeVPS(TComVPS *vps) { m_vpsMap.storePS( vps->getVPSId(), vps); };
2766  //! get pointer to existing video parameter set
2767  TComVPS* getVPS(Int vpsId)  { return m_vpsMap.getPS(vpsId); };
2768  TComVPS* getFirstVPS()      { return m_vpsMap.getFirstPS(); };
2769
2770  //! store sequence parameter set and take ownership of it
2771  Void storeSPS(TComSPS *sps) { m_spsMap.storePS( sps->getSPSId(), sps); };
2772  //! get pointer to existing sequence parameter set
2773  TComSPS* getSPS(Int spsId)  { return m_spsMap.getPS(spsId); };
2774  TComSPS* getFirstSPS()      { return m_spsMap.getFirstPS(); };
2775
2776  //! store picture parameter set and take ownership of it
2777  Void storePPS(TComPPS *pps) { m_ppsMap.storePS( pps->getPPSId(), pps); };
2778  //! get pointer to existing picture parameter set
2779  TComPPS* getPPS(Int ppsId)  { return m_ppsMap.getPS(ppsId); };
2780  TComPPS* getFirstPPS()      { return m_ppsMap.getFirstPS(); };
2781
2782  //! activate a SPS from a active parameter sets SEI message
2783  //! \returns true, if activation is successful
2784  Bool activateSPSWithSEI(Int SPSId);
2785
2786  //! activate a PPS and depending on isIDR parameter also SPS and VPS
2787  //! \returns true, if activation is successful
2788  Bool activatePPS(Int ppsId, Bool isIRAP);
2789
2790  TComVPS* getActiveVPS(){ return m_vpsMap.getPS(m_activeVPSId); };
2791  TComSPS* getActiveSPS(){ return m_spsMap.getPS(m_activeSPSId); };
2792  TComPPS* getActivePPS(){ return m_ppsMap.getPS(m_activePPSId); };
2793
2794protected:
2795
2796#if SVC_EXTENSION
2797  static ParameterSetMap<TComVPS> m_vpsMap;
2798  static ParameterSetMap<TComSPS> m_spsMap; 
2799  static ParameterSetMap<TComPPS> m_ppsMap;
2800#else
2801  ParameterSetMap<TComVPS> m_vpsMap;
2802  ParameterSetMap<TComSPS> m_spsMap;
2803  ParameterSetMap<TComPPS> m_ppsMap;
2804#endif
2805
2806#if SVC_EXTENSION
2807  static Int m_activeVPSId;
2808#else
2809  Int m_activeVPSId;
2810#endif
2811  Int m_activeSPSId;
2812  Int m_activePPSId;
2813};
2814
2815//! \}
2816
2817#endif // __TCOMSLICE__
Note: See TracBrowser for help on using the repository browser.