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

Last change on this file since 1502 was 1502, checked in by seregin, 8 years ago

infer parameters in SPS after activation, fixing chroma scaling for non 4:2:0

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