source: 3DVCSoftware/branches/HTM-14.1-update-dev3/source/Lib/TLibCommon/TComSlice.h @ 1270

Last change on this file since 1270 was 1270, checked in by tech, 9 years ago

Merged 14.1-update-dev4-Qualcomm@1266

  • Property svn:eol-style set to native
File size: 223.0 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-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#if NH_MV
55class TComPicLists; 
56class TComVPS; 
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#if NH_MV
134  Void checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) const;
135#endif
136
137};
138
139/// Reference Picture Set set class
140class TComRPSList
141{
142private:
143  std::vector<TComReferencePictureSet> m_referencePictureSets;
144
145public:
146                                 TComRPSList()                                            { }
147  virtual                        ~TComRPSList()                                           { }
148
149  Void                           create  (Int numberOfEntries)                            { m_referencePictureSets.resize(numberOfEntries);         }
150  Void                           destroy ()                                               { }
151
152
153  TComReferencePictureSet*       getReferencePictureSet(Int referencePictureSetNum)       { return &m_referencePictureSets[referencePictureSetNum]; }
154  const TComReferencePictureSet* getReferencePictureSet(Int referencePictureSetNum) const { return &m_referencePictureSets[referencePictureSetNum]; }
155
156  Int                            getNumberOfReferencePictureSets() const                  { return Int(m_referencePictureSets.size());              }
157};
158
159/// SCALING_LIST class
160class TComScalingList
161{
162public:
163             TComScalingList();
164  virtual    ~TComScalingList()                                                 { }
165  Int*       getScalingListAddress(UInt sizeId, UInt listId)                    { return &(m_scalingListCoef[sizeId][listId][0]);            } //!< get matrix coefficient
166  const Int* getScalingListAddress(UInt sizeId, UInt listId) const              { return &(m_scalingListCoef[sizeId][listId][0]);            } //!< get matrix coefficient
167  Void       checkPredMode(UInt sizeId, UInt listId);
168
169  Void       setRefMatrixId(UInt sizeId, UInt listId, UInt u)                   { m_refMatrixId[sizeId][listId] = u;                         } //!< set reference matrix ID
170  UInt       getRefMatrixId(UInt sizeId, UInt listId) const                     { return m_refMatrixId[sizeId][listId];                      } //!< get reference matrix ID
171
172  const Int* getScalingListDefaultAddress(UInt sizeId, UInt listId);                                                                           //!< get default matrix coefficient
173  Void       processDefaultMatrix(UInt sizeId, UInt listId);
174
175  Void       setScalingListDC(UInt sizeId, UInt listId, UInt u)                 { m_scalingListDC[sizeId][listId] = u;                       } //!< set DC value
176  Int        getScalingListDC(UInt sizeId, UInt listId) const                   { return m_scalingListDC[sizeId][listId];                    } //!< get DC value
177
178  Void       setScalingListPredModeFlag(UInt sizeId, UInt listId, Bool bIsDPCM) { m_scalingListPredModeFlagIsDPCM[sizeId][listId] = bIsDPCM; }
179  Bool       getScalingListPredModeFlag(UInt sizeId, UInt listId) const         { return m_scalingListPredModeFlagIsDPCM[sizeId][listId];    }
180
181  Void       checkDcOfMatrix();
182  Void       processRefMatrix(UInt sizeId, UInt listId , UInt refListId );
183  Bool       xParseScalingList(Char* pchFile);
184#if NH_MV
185  Void       inferFrom                      ( const TComScalingList& srcScLi );
186#endif
187  Void       setDefaultScalingList();
188  Bool       checkDefaultScalingList();
189
190private:
191  Void       outputScalingLists(std::ostream &os) const;
192  Bool             m_scalingListPredModeFlagIsDPCM [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index
193  Int              m_scalingListDC                 [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< the DC value of the matrix coefficient for 16x16
194  UInt             m_refMatrixId                   [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< RefMatrixID
195  std::vector<Int> m_scalingListCoef               [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix
196};
197
198class ProfileTierLevel
199{
200  Int               m_profileSpace;
201  Level::Tier       m_tierFlag;
202  Profile::Name     m_profileIdc;
203  Bool              m_profileCompatibilityFlag[32];
204  Level::Name       m_levelIdc;
205
206  Bool              m_progressiveSourceFlag;
207  Bool              m_interlacedSourceFlag;
208  Bool              m_nonPackedConstraintFlag;
209  Bool              m_frameOnlyConstraintFlag;
210  UInt              m_bitDepthConstraintValue;
211  ChromaFormat      m_chromaFormatConstraintValue;
212  Bool              m_intraConstraintFlag;
213  Bool              m_onePictureOnlyConstraintFlag;
214  Bool              m_lowerBitRateConstraintFlag;
215#if NH_MV
216  Bool              m_max12bitConstraintFlag;
217  Bool              m_max10bitConstraintFlag;
218  Bool              m_max8bitConstraintFlag;
219  Bool              m_max422chromaConstraintFlag;
220  Bool              m_max420chromaConstraintFlag;
221  Bool              m_maxMonochromeConstraintFlag;
222  Bool              m_inbldFlag;
223#endif
224public:
225                ProfileTierLevel();
226
227  Int           getProfileSpace() const                     { return m_profileSpace;                }
228  Void          setProfileSpace(Int x)                      { m_profileSpace = x;                   }
229
230  Level::Tier   getTierFlag() const                         { return m_tierFlag;                    }
231  Void          setTierFlag(Level::Tier x)                  { m_tierFlag = x;                       }
232
233  Profile::Name getProfileIdc() const                       { return m_profileIdc;                  }
234  Void          setProfileIdc(Profile::Name x)              { m_profileIdc = x;                     }
235
236  Bool          getProfileCompatibilityFlag(Int i) const    { return m_profileCompatibilityFlag[i]; }
237  Void          setProfileCompatibilityFlag(Int i, Bool x)  { m_profileCompatibilityFlag[i] = x;    }
238
239  Level::Name   getLevelIdc() const                         { return m_levelIdc;                    }
240  Void          setLevelIdc(Level::Name x)                  { m_levelIdc = x;                       }
241
242  Bool          getProgressiveSourceFlag() const            { return m_progressiveSourceFlag;       }
243  Void          setProgressiveSourceFlag(Bool b)            { m_progressiveSourceFlag = b;          }
244
245  Bool          getInterlacedSourceFlag() const             { return m_interlacedSourceFlag;        }
246  Void          setInterlacedSourceFlag(Bool b)             { m_interlacedSourceFlag = b;           }
247
248  Bool          getNonPackedConstraintFlag() const          { return m_nonPackedConstraintFlag;     }
249  Void          setNonPackedConstraintFlag(Bool b)          { m_nonPackedConstraintFlag = b;        }
250
251  Bool          getFrameOnlyConstraintFlag() const          { return m_frameOnlyConstraintFlag;     }
252  Void          setFrameOnlyConstraintFlag(Bool b)          { m_frameOnlyConstraintFlag = b;        }
253
254  UInt          getBitDepthConstraint() const               { return m_bitDepthConstraintValue;     }
255  Void          setBitDepthConstraint(UInt bitDepth)        { m_bitDepthConstraintValue=bitDepth;   }
256
257  ChromaFormat  getChromaFormatConstraint() const           { return m_chromaFormatConstraintValue; }
258  Void          setChromaFormatConstraint(ChromaFormat fmt) { m_chromaFormatConstraintValue=fmt;    }
259
260  Bool          getIntraConstraintFlag() const              { return m_intraConstraintFlag;         }
261  Void          setIntraConstraintFlag(Bool b)              { m_intraConstraintFlag = b;            }
262
263  Bool          getOnePictureOnlyConstraintFlag() const     { return m_onePictureOnlyConstraintFlag;}
264  Void          setOnePictureOnlyConstraintFlag(Bool b)     { m_onePictureOnlyConstraintFlag = b;   }
265
266  Bool          getLowerBitRateConstraintFlag() const       { return m_lowerBitRateConstraintFlag;  }
267  Void          setLowerBitRateConstraintFlag(Bool b)       { m_lowerBitRateConstraintFlag = b;     }
268
269#if NH_MV
270  Void          setMax12bitConstraintFlag( Bool flag )      { m_max12bitConstraintFlag = flag;      }
271  Bool          getMax12bitConstraintFlag(  ) const         { return m_max12bitConstraintFlag;      }
272
273  Void          setMax10bitConstraintFlag( Bool flag )      { m_max10bitConstraintFlag = flag;      }
274  Bool          getMax10bitConstraintFlag(  ) const         { return m_max10bitConstraintFlag;      }
275
276  Void          setMax8bitConstraintFlag( Bool flag )       { m_max8bitConstraintFlag = flag;       }
277  Bool          getMax8bitConstraintFlag(  ) const          { return m_max8bitConstraintFlag;       }
278
279  Void          setMax422chromaConstraintFlag( Bool flag )  { m_max422chromaConstraintFlag = flag;  }
280  Bool          getMax422chromaConstraintFlag(  ) const     { return m_max422chromaConstraintFlag;  }
281
282  Void          setMax420chromaConstraintFlag( Bool flag )  { m_max420chromaConstraintFlag = flag;  }
283  Bool          getMax420chromaConstraintFlag(  ) const     { return m_max420chromaConstraintFlag;  }
284
285  Void          setMaxMonochromeConstraintFlag( Bool flag ) { m_maxMonochromeConstraintFlag = flag; }
286  Bool          getMaxMonochromeConstraintFlag(  ) const    { return m_maxMonochromeConstraintFlag; }
287
288  Void          setInbldFlag( Bool flag )                   { m_inbldFlag = flag;                   }
289  Bool          getInbldFlag(  ) const                      { return m_inbldFlag;                   }
290
291  Bool          getV2ConstraintsPresentFlag() const;
292  Bool          getInbldPresentFlag() const;
293
294  Void          copyV2ConstraintFlags( ProfileTierLevel* ptlRef );
295  Void          copyProfile( ProfileTierLevel* ptlRef );
296#endif
297
298};
299
300
301class TComPTL
302{
303  ProfileTierLevel m_generalPTL;
304  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 (= 6)
305  Bool m_subLayerProfilePresentFlag [MAX_TLAYER-1];
306  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER-1];
307
308public:
309                          TComPTL();
310  Bool                    getSubLayerProfilePresentFlag(Int i) const   { return m_subLayerProfilePresentFlag[i]; }
311  Void                    setSubLayerProfilePresentFlag(Int i, Bool x) { m_subLayerProfilePresentFlag[i] = x;    }
312
313  Bool                    getSubLayerLevelPresentFlag(Int i) const     { return m_subLayerLevelPresentFlag[i];   }
314  Void                    setSubLayerLevelPresentFlag(Int i, Bool x)   { m_subLayerLevelPresentFlag[i] = x;      }
315
316  ProfileTierLevel*       getGeneralPTL()                              { return &m_generalPTL;                   }
317  const ProfileTierLevel* getGeneralPTL() const                        { return &m_generalPTL;                   }
318  ProfileTierLevel*       getSubLayerPTL(Int i)                        { return &m_subLayerPTL[i];               }
319  const ProfileTierLevel* getSubLayerPTL(Int i) const                  { return &m_subLayerPTL[i];               }
320
321#if NH_MV
322  Void                    inferGeneralValues ( Bool profilePresentFlag  , Int k, TComPTL* refPTL );; 
323  Void                    inferSubLayerValues( Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL );; 
324#endif
325
326};
327
328/// VPS class
329
330struct HrdSubLayerInfo
331{
332  Bool fixedPicRateFlag;
333  Bool fixedPicRateWithinCvsFlag;
334  UInt picDurationInTcMinus1;
335  Bool lowDelayHrdFlag;
336  UInt cpbCntMinus1;
337  UInt bitRateValueMinus1[MAX_CPB_CNT][2];
338  UInt cpbSizeValue      [MAX_CPB_CNT][2];
339  UInt ducpbSizeValue    [MAX_CPB_CNT][2];
340  Bool cbrFlag           [MAX_CPB_CNT][2];
341  UInt duBitRateValue    [MAX_CPB_CNT][2];
342};
343
344class TComHRD
345{
346private:
347  Bool m_nalHrdParametersPresentFlag;
348  Bool m_vclHrdParametersPresentFlag;
349  Bool m_subPicCpbParamsPresentFlag;
350  UInt m_tickDivisorMinus2;
351  UInt m_duCpbRemovalDelayLengthMinus1;
352  Bool m_subPicCpbParamsInPicTimingSEIFlag;
353  UInt m_dpbOutputDelayDuLengthMinus1;
354  UInt m_bitRateScale;
355  UInt m_cpbSizeScale;
356  UInt m_ducpbSizeScale;
357  UInt m_initialCpbRemovalDelayLengthMinus1;
358  UInt m_cpbRemovalDelayLengthMinus1;
359  UInt m_dpbOutputDelayLengthMinus1;
360  HrdSubLayerInfo m_HRD[MAX_TLAYER];
361
362public:
363  TComHRD()
364  :m_nalHrdParametersPresentFlag       (0)
365  ,m_vclHrdParametersPresentFlag       (0)
366  ,m_subPicCpbParamsPresentFlag        (false)
367  ,m_tickDivisorMinus2                 (0)
368  ,m_duCpbRemovalDelayLengthMinus1     (0)
369  ,m_subPicCpbParamsInPicTimingSEIFlag (false)
370  ,m_dpbOutputDelayDuLengthMinus1      (0)
371  ,m_bitRateScale                      (0)
372  ,m_cpbSizeScale                      (0)
373  ,m_initialCpbRemovalDelayLengthMinus1(23)
374  ,m_cpbRemovalDelayLengthMinus1       (23)
375  ,m_dpbOutputDelayLengthMinus1        (23)
376  {}
377
378  virtual ~TComHRD() {}
379
380  Void    setNalHrdParametersPresentFlag( Bool flag )                                { m_nalHrdParametersPresentFlag = flag;                      }
381  Bool    getNalHrdParametersPresentFlag( ) const                                    { return m_nalHrdParametersPresentFlag;                      }
382
383  Void    setVclHrdParametersPresentFlag( Bool flag )                                { m_vclHrdParametersPresentFlag = flag;                      }
384  Bool    getVclHrdParametersPresentFlag( ) const                                    { return m_vclHrdParametersPresentFlag;                      }
385
386  Void    setSubPicCpbParamsPresentFlag( Bool flag )                                 { m_subPicCpbParamsPresentFlag = flag;                       }
387  Bool    getSubPicCpbParamsPresentFlag( ) const                                     { return m_subPicCpbParamsPresentFlag;                       }
388
389  Void    setTickDivisorMinus2( UInt value )                                         { m_tickDivisorMinus2 = value;                               }
390  UInt    getTickDivisorMinus2( ) const                                              { return m_tickDivisorMinus2;                                }
391
392  Void    setDuCpbRemovalDelayLengthMinus1( UInt value )                             { m_duCpbRemovalDelayLengthMinus1 = value;                   }
393  UInt    getDuCpbRemovalDelayLengthMinus1( ) const                                  { return m_duCpbRemovalDelayLengthMinus1;                    }
394
395  Void    setSubPicCpbParamsInPicTimingSEIFlag( Bool flag)                           { m_subPicCpbParamsInPicTimingSEIFlag = flag;                }
396  Bool    getSubPicCpbParamsInPicTimingSEIFlag( ) const                              { return m_subPicCpbParamsInPicTimingSEIFlag;                }
397
398  Void    setDpbOutputDelayDuLengthMinus1(UInt value )                               { m_dpbOutputDelayDuLengthMinus1 = value;                    }
399  UInt    getDpbOutputDelayDuLengthMinus1( ) const                                   { return m_dpbOutputDelayDuLengthMinus1;                     }
400
401  Void    setBitRateScale( UInt value )                                              { m_bitRateScale = value;                                    }
402  UInt    getBitRateScale( ) const                                                   { return m_bitRateScale;                                     }
403
404  Void    setCpbSizeScale( UInt value )                                              { m_cpbSizeScale = value;                                    }
405  UInt    getCpbSizeScale( ) const                                                   { return m_cpbSizeScale;                                     }
406  Void    setDuCpbSizeScale( UInt value )                                            { m_ducpbSizeScale = value;                                  }
407  UInt    getDuCpbSizeScale( ) const                                                 { return m_ducpbSizeScale;                                   }
408
409  Void    setInitialCpbRemovalDelayLengthMinus1( UInt value )                        { m_initialCpbRemovalDelayLengthMinus1 = value;              }
410  UInt    getInitialCpbRemovalDelayLengthMinus1( ) const                             { return m_initialCpbRemovalDelayLengthMinus1;               }
411
412  Void    setCpbRemovalDelayLengthMinus1( UInt value )                               { m_cpbRemovalDelayLengthMinus1 = value;                     }
413  UInt    getCpbRemovalDelayLengthMinus1( ) const                                    { return m_cpbRemovalDelayLengthMinus1;                      }
414
415  Void    setDpbOutputDelayLengthMinus1( UInt value )                                { m_dpbOutputDelayLengthMinus1 = value;                      }
416  UInt    getDpbOutputDelayLengthMinus1( ) const                                     { return m_dpbOutputDelayLengthMinus1;                       }
417
418  Void    setFixedPicRateFlag( Int layer, Bool flag )                                { m_HRD[layer].fixedPicRateFlag = flag;                      }
419  Bool    getFixedPicRateFlag( Int layer ) const                                     { return m_HRD[layer].fixedPicRateFlag;                      }
420
421  Void    setFixedPicRateWithinCvsFlag( Int layer, Bool flag )                       { m_HRD[layer].fixedPicRateWithinCvsFlag = flag;             }
422  Bool    getFixedPicRateWithinCvsFlag( Int layer ) const                            { return m_HRD[layer].fixedPicRateWithinCvsFlag;             }
423
424  Void    setPicDurationInTcMinus1( Int layer, UInt value )                          { m_HRD[layer].picDurationInTcMinus1 = value;                }
425  UInt    getPicDurationInTcMinus1( Int layer ) const                                { return m_HRD[layer].picDurationInTcMinus1;                 }
426
427  Void    setLowDelayHrdFlag( Int layer, Bool flag )                                 { m_HRD[layer].lowDelayHrdFlag = flag;                       }
428  Bool    getLowDelayHrdFlag( Int layer ) const                                      { return m_HRD[layer].lowDelayHrdFlag;                       }
429
430  Void    setCpbCntMinus1( Int layer, UInt value )                                   { m_HRD[layer].cpbCntMinus1 = value;                         }
431  UInt    getCpbCntMinus1( Int layer ) const                                         { return m_HRD[layer].cpbCntMinus1;                          }
432
433  Void    setBitRateValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl, UInt value )   { m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl] = value; }
434  UInt    getBitRateValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl ) const         { return m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl];  }
435
436  Void    setCpbSizeValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl, UInt value )   { m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl] = value;       }
437  UInt    getCpbSizeValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl ) const         { return m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl];        }
438  Void    setDuCpbSizeValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl] = value;     }
439  UInt    getDuCpbSizeValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl ) const       { return m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl];      }
440  Void    setDuBitRateValueMinus1( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl] = value;     }
441  UInt    getDuBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl ) const        { return m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl];      }
442  Void    setCbrFlag( Int layer, Int cpbcnt, Int nalOrVcl, Bool value )              { m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl] = value;            }
443  Bool    getCbrFlag( Int layer, Int cpbcnt, Int nalOrVcl ) const                    { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl];             }
444
445  Bool    getCpbDpbDelaysPresentFlag( ) const                      { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
446};
447
448class TimingInfo
449{
450  Bool m_timingInfoPresentFlag;
451  UInt m_numUnitsInTick;
452  UInt m_timeScale;
453  Bool m_pocProportionalToTimingFlag;
454  Int  m_numTicksPocDiffOneMinus1;
455public:
456  TimingInfo()
457  : m_timingInfoPresentFlag      (false)
458  , m_numUnitsInTick             (1001)
459  , m_timeScale                  (60000)
460  , m_pocProportionalToTimingFlag(false)
461  , m_numTicksPocDiffOneMinus1   (0)
462  {}
463
464  Void setTimingInfoPresentFlag( Bool flag )   { m_timingInfoPresentFlag = flag;       }
465  Bool getTimingInfoPresentFlag( ) const       { return m_timingInfoPresentFlag;       }
466
467  Void setNumUnitsInTick( UInt value )         { m_numUnitsInTick = value;             }
468  UInt getNumUnitsInTick( ) const              { return m_numUnitsInTick;              }
469
470  Void setTimeScale( UInt value )              { m_timeScale = value;                  }
471  UInt getTimeScale( ) const                   { return m_timeScale;                   }
472
473  Void setPocProportionalToTimingFlag(Bool x)  { m_pocProportionalToTimingFlag = x;    }
474  Bool getPocProportionalToTimingFlag( ) const { return m_pocProportionalToTimingFlag; }
475
476  Void setNumTicksPocDiffOneMinus1(Int x)      { m_numTicksPocDiffOneMinus1 = x;       }
477  Int  getNumTicksPocDiffOneMinus1( ) const    { return m_numTicksPocDiffOneMinus1;    }
478};
479
480struct ChromaQpAdj
481{
482  union
483  {
484    struct {
485      Int CbOffset;
486      Int CrOffset;
487    } comp;
488    Int offset[2]; /* two chroma components */
489  } u;
490};
491
492#if NH_MV
493
494class TComVideoSignalInfo
495{
496private: 
497  Int  m_videoVpsFormat;
498  Bool m_videoFullRangeVpsFlag;
499  Int  m_colourPrimariesVps;
500  Int  m_transferCharacteristicsVps;
501  Int  m_matrixCoeffsVps;
502public: 
503  Void    setVideoVpsFormat( Int  val )                                              { m_videoVpsFormat = val;                                    }
504  Int     getVideoVpsFormat(  ) const                                                { return m_videoVpsFormat;                                   }
505
506  Void    setVideoFullRangeVpsFlag( Bool flag )                                      { m_videoFullRangeVpsFlag = flag;                            }
507  Bool    getVideoFullRangeVpsFlag(  ) const                                         { return m_videoFullRangeVpsFlag;                            }
508
509  Void    setColourPrimariesVps( Int  val )                                          { m_colourPrimariesVps = val;                                }
510  Int     getColourPrimariesVps(  ) const                                            { return m_colourPrimariesVps;                               }
511
512  Void    setTransferCharacteristicsVps( Int  val )                                  { m_transferCharacteristicsVps = val;                        }
513  Int     getTransferCharacteristicsVps(  ) const                                    { return m_transferCharacteristicsVps;                       }
514
515  Void    setMatrixCoeffsVps( Int  val )                                             { m_matrixCoeffsVps = val;                                   }
516  Int     getMatrixCoeffsVps(  ) const                                               { return m_matrixCoeffsVps;                                  }
517};
518
519class TComVpsVuiBspHrdParameters
520{
521  /* Not yet tested */
522private: 
523
524  Int       m_vpsNumAddHrdParams;
525  BoolAry1d m_cprmsAddPresentFlag;
526  std::vector<TComHRD> m_hrdParameters; 
527  IntAry1d  m_numSubLayerHrdMinus1;
528  IntAry1d  m_numSignalledPartitioningSchemes;
529  IntAry2d  m_numPartitionsInSchemeMinus1;
530
531  BoolAry4d m_layerIncludedInPartitionFlag;
532  IntAry3d  m_numBspSchedulesMinus1;
533  IntAry5d  m_bspHrdIdx;
534  IntAry5d  m_bspSchedIdx;
535   
536  // Array sizes
537  Int      m_offsetHrdParamIdx;
538  Int      m_numHrdParam; 
539  Int      m_numOls; 
540  TComVPS* m_vps; 
541public:     
542 
543  Void    createAfterVpsNumAddHrdParams( const TComVPS* vps );
544  Void    createAfterNumSignalledPartitioningSchemes(const TComVPS* vps, Int h );
545  Void    createAfterNumPartitionsInSchemeMinus1(const TComVPS* vps, Int h, Int j);
546  Void    createAfterNumBspSchedulesMinus1(const TComVPS* vps, Int h, Int i, Int t);
547
548  Void    setVpsNumAddHrdParams( Int  val )                                          { m_vpsNumAddHrdParams = val;                                }
549  Int     getVpsNumAddHrdParams(  ) const                                            { return m_vpsNumAddHrdParams;                               }
550
551  Void    setCprmsAddPresentFlag( Int i, Bool flag )                                 { m_cprmsAddPresentFlag[i - m_offsetHrdParamIdx] = flag;     }
552  Bool    getCprmsAddPresentFlag( Int i ) const                                      { return m_cprmsAddPresentFlag[- m_offsetHrdParamIdx];    }
553
554  Void    setNumSubLayerHrdMinus1( Int i, Int  val )                                 { m_numSubLayerHrdMinus1[- m_offsetHrdParamIdx] = val;    }
555  Int     getNumSubLayerHrdMinus1( Int i ) const                                     { return m_numSubLayerHrdMinus1[- m_offsetHrdParamIdx];   }
556
557  Void    setNumSignalledPartitioningSchemes( Int h, Int  val )                      { m_numSignalledPartitioningSchemes[h] = val;                }
558  Int     getNumSignalledPartitioningSchemes( Int h ) const                          { return m_numSignalledPartitioningSchemes[h];               }
559
560  Void    setNumPartitionsInSchemeMinus1( Int h, Int j, Int  val )                   { m_numPartitionsInSchemeMinus1[h][j] = val;                 }
561  Int     getNumPartitionsInSchemeMinus1( Int h, Int j ) const                       { return m_numPartitionsInSchemeMinus1[h][j];                }
562
563  Void    setLayerIncludedInPartitionFlag( Int h, Int j, Int k, Int r, Bool flag )   { m_layerIncludedInPartitionFlag[h][j][k][r] = flag;         }
564  Bool    getLayerIncludedInPartitionFlag( Int h, Int j, Int k, Int r ) const        { return m_layerIncludedInPartitionFlag[h][j][k][r];         }
565
566  Void    setNumBspSchedulesMinus1( Int h, Int i, Int t, Int  val )                  { m_numBspSchedulesMinus1[h][i][t] = val;                    }
567  Int     getNumBspSchedulesMinus1( Int h, Int i, Int t ) const                      { return m_numBspSchedulesMinus1[h][i][t];                   }
568
569  Void    setBspHrdIdx( Int h, Int i, Int t, Int j, Int k, Int  val )                { m_bspHrdIdx[h][- m_offsetHrdParamIdx][t][j][k] = val;   }
570  Int     getBspHrdIdx( Int h, Int i, Int t, Int j, Int k ) const                    { return m_bspHrdIdx[h][- m_offsetHrdParamIdx][t][j][k];  }
571
572  Int     getBspHrdIdxLen ( const TComVPS* vps ) const ;
573
574  Void    setBspSchedIdx( Int h, Int i, Int t, Int j, Int k, Int  val )              { m_bspSchedIdx[h][i - m_offsetHrdParamIdx][t][j][k] = val;  }
575  Int     getBspSchedIdx( Int h, Int i, Int t, Int j, Int k ) const                  { return m_bspSchedIdx[h][i - m_offsetHrdParamIdx][t][j][k]; }
576
577  Void    setHrdParametermeters( Int k, TComHRD val  )                               {  m_hrdParameters[k] = val;                                 }
578  const   TComHRD* getHrdParametermeters( Int k ) const                              {  return &m_hrdParameters[k];                               }
579};
580
581class TComVPSVUI
582{
583private:
584  Bool                               m_crossLayerPicTypeAlignedFlag          ;
585  Bool                               m_crossLayerIrapAlignedFlag             ;
586  Bool                               m_allLayersIdrAlignedFlag               ;
587  Bool                               m_bitRatePresentVpsFlag                 ;
588  Bool                               m_picRatePresentVpsFlag                 ;                                     
589  BoolAry2d                          m_bitRatePresentFlag                    ;
590  BoolAry2d                          m_picRatePresentFlag                    ;
591  IntAry2d                           m_avgBitRate                            ;
592  IntAry2d                           m_maxBitRate                            ;
593  IntAry2d                           m_constantPicRateIdc                    ;
594  IntAry2d                           m_avgPicRate                            ;
595  Bool                               m_videoSignalInfoIdxPresentFlag         ;
596  Int                                m_vpsNumVideoSignalInfoMinus1           ;
597  std::vector< TComVideoSignalInfo > m_videoSignalInfo                       ;
598  IntAry1d                           m_vpsVideoSignalInfoIdx                 ;
599  Bool                               m_tilesNotInUseFlag;                    ;
600  BoolAry1d                          m_tilesInUseFlag                        ; 
601  BoolAry1d                          m_loopFilterNotAcrossTilesFlag          ; 
602  BoolAry2d                          m_tileBoundariesAlignedFlag             ;
603  Bool                               m_wppNotInUseFlag                       ;             
604  BoolAry1d                          m_wppInUseFlag                          ;               
605  Bool                               m_singleLayerForNonIrapFlag             ;
606  Bool                               m_higherLayerIrapSkipFlag               ;
607  Bool                               m_ilpRestrictedRefLayersFlag            ;
608  IntAry2d                           m_minSpatialSegmentOffsetPlus1          ;
609  BoolAry2d                          m_ctuBasedOffsetEnabledFlag             ;
610  IntAry2d                           m_minHorizontalCtuOffsetPlus1           ;
611  Bool                               m_vpsVuiBspHrdPresentFlag               ;
612  TComVpsVuiBspHrdParameters         m_vpsVuiBspHrdParameters                ; 
613  BoolAry1d                          m_baseLayerParameterSetCompatibilityFlag;
614
615public: 
616
617  Void    init( Int numLayerSets, Int maxNumSubLayers, Int maxNumLayers );
618
619  Void    setCrossLayerPicTypeAlignedFlag( Bool flag )                               { m_crossLayerPicTypeAlignedFlag = flag;                     }
620  Bool    getCrossLayerPicTypeAlignedFlag(  ) const                                  { return m_crossLayerPicTypeAlignedFlag;                     }
621
622  Void    setCrossLayerIrapAlignedFlag( Bool flag )                                  { m_crossLayerIrapAlignedFlag = flag;                        }
623  Bool    getCrossLayerIrapAlignedFlag(  ) const                                     { return m_crossLayerIrapAlignedFlag;                        }
624
625  Void    setAllLayersIdrAlignedFlag( Bool flag )                                    { m_allLayersIdrAlignedFlag = flag;                          }
626  Bool    getAllLayersIdrAlignedFlag(  ) const                                       { return m_allLayersIdrAlignedFlag;                          }
627
628  Void    setBitRatePresentVpsFlag( Bool flag )                                      { m_bitRatePresentVpsFlag = flag;                            }
629  Bool    getBitRatePresentVpsFlag(  ) const                                         { return m_bitRatePresentVpsFlag;                            }
630
631  Void    setPicRatePresentVpsFlag( Bool flag )                                      { m_picRatePresentVpsFlag = flag;                            }
632  Bool    getPicRatePresentVpsFlag(  ) const                                         { return m_picRatePresentVpsFlag;                            }
633
634  Void    setBitRatePresentFlag( Int i, Int j, Bool flag )                           { m_bitRatePresentFlag[i][j] = flag;                         }
635  Bool    getBitRatePresentFlag( Int i, Int j ) const                                { return m_bitRatePresentFlag[i][j];                         }
636
637  Void    setPicRatePresentFlag( Int i, Int j, Bool flag )                           { m_picRatePresentFlag[i][j] = flag;                         }
638  Bool    getPicRatePresentFlag( Int i, Int j ) const                                { return m_picRatePresentFlag[i][j];                         }
639
640  Void    setAvgBitRate( Int i, Int j, Int  val )                                    { m_avgBitRate[i][j] = val;                                  }
641  Int     getAvgBitRate( Int i, Int j ) const                                        { return m_avgBitRate[i][j];                                 }
642
643  Void    setMaxBitRate( Int i, Int j, Int  val )                                    { m_maxBitRate[i][j] = val;                                  }
644  Int     getMaxBitRate( Int i, Int j ) const                                        { return m_maxBitRate[i][j];                                 }
645
646  Void    setConstantPicRateIdc( Int i, Int j, Int  val )                            { m_constantPicRateIdc[i][j] = val;                          }
647  Int     getConstantPicRateIdc( Int i, Int j ) const                                { return m_constantPicRateIdc[i][j];                         }
648
649  Void    setAvgPicRate( Int i, Int j, Int  val )                                    { m_avgPicRate[i][j] = val;                                  }
650  Int     getAvgPicRate( Int i, Int j ) const                                        { return m_avgPicRate[i][j];                                 }
651
652  Void    setVideoSignalInfoIdxPresentFlag( Bool flag )                              { m_videoSignalInfoIdxPresentFlag = flag;                    }
653  Bool    getVideoSignalInfoIdxPresentFlag(  ) const                                 { return m_videoSignalInfoIdxPresentFlag;                    }
654
655  Void    setVideoSignalInfo( std::vector<TComVideoSignalInfo> val )                  { m_videoSignalInfo = val;                                  }
656  const   TComVideoSignalInfo* getVideoSignalInfo( Int i ) const                      { return &m_videoSignalInfo[i];                             }
657
658  Void    setVpsNumVideoSignalInfoMinus1( Int  val )                                 { m_vpsNumVideoSignalInfoMinus1 = val;                       }
659  Int     getVpsNumVideoSignalInfoMinus1(  ) const                                   { return m_vpsNumVideoSignalInfoMinus1;                      }
660
661  Void    setVpsVideoSignalInfoIdx( Int i, Int  val )                                { m_vpsVideoSignalInfoIdx[i] = val;                          }
662  Int     getVpsVideoSignalInfoIdx( Int i ) const                                    { return m_vpsVideoSignalInfoIdx[i];                         }
663
664  Void    setTilesNotInUseFlag( Bool flag )                                          { m_tilesNotInUseFlag = flag;                                }
665  Bool    getTilesNotInUseFlag(  ) const                                             { return m_tilesNotInUseFlag;                                }
666
667  Void    setTilesInUseFlag( Int i, Bool flag )                                      { m_tilesInUseFlag[i] = flag;                                }
668  Bool    getTilesInUseFlag( Int i ) const                                           { return m_tilesInUseFlag[i];                                }
669
670  Void    setLoopFilterNotAcrossTilesFlag( Int i, Int  val )                         { m_loopFilterNotAcrossTilesFlag[i] = val;                   }
671  Bool    getLoopFilterNotAcrossTilesFlag( Int i ) const                             { return m_loopFilterNotAcrossTilesFlag[i];                  }
672
673  Void    setTileBoundariesAlignedFlag( Int i, Int j, Bool flag )                    { m_tileBoundariesAlignedFlag[i][j] = flag;                  }
674  Bool    getTileBoundariesAlignedFlag( Int i, Int j ) const                         { return m_tileBoundariesAlignedFlag[i][j];                  }
675
676  Void    setWppNotInUseFlag( Bool flag )                                            { m_wppNotInUseFlag = flag;                                  }
677  Bool    getWppNotInUseFlag(  ) const                                               { return m_wppNotInUseFlag;                                  }
678
679  Void    setWppInUseFlag( Int i, Bool flag )                                        { m_wppInUseFlag[i] = flag;                                  }
680  Bool    getWppInUseFlag( Int i ) const                                             { return m_wppInUseFlag[i];                                  }
681
682  Void    setSingleLayerForNonIrapFlag( Bool flag )                                  { m_singleLayerForNonIrapFlag = flag;                        }
683  Bool    getSingleLayerForNonIrapFlag(  ) const                                     { return m_singleLayerForNonIrapFlag;                        }
684
685  Void    setHigherLayerIrapSkipFlag( Bool flag )                                    { m_higherLayerIrapSkipFlag = flag;                          }
686  Bool    getHigherLayerIrapSkipFlag(  ) const                                       { return m_higherLayerIrapSkipFlag;                          }
687
688  Void    setIlpRestrictedRefLayersFlag( Bool flag )                                 { m_ilpRestrictedRefLayersFlag = flag;                       }
689  Bool    getIlpRestrictedRefLayersFlag(  ) const                                    { return m_ilpRestrictedRefLayersFlag;                       }
690
691  Void    setMinSpatialSegmentOffsetPlus1( Int i, Int j, Int  val )                  { m_minSpatialSegmentOffsetPlus1[i][j] = val;                }
692  Int     getMinSpatialSegmentOffsetPlus1( Int i, Int j ) const                      { return m_minSpatialSegmentOffsetPlus1[i][j];               }
693
694  Void    setCtuBasedOffsetEnabledFlag( Int i, Int j, Bool flag )                    { m_ctuBasedOffsetEnabledFlag[i][j] = flag;                  }
695  Bool    getCtuBasedOffsetEnabledFlag( Int i, Int j ) const                         { return m_ctuBasedOffsetEnabledFlag[i][j];                  }
696
697  Void    setMinHorizontalCtuOffsetPlus1( Int i, Int j, Int  val )                   { m_minHorizontalCtuOffsetPlus1[i][j] = val;                 }
698  Int     getMinHorizontalCtuOffsetPlus1( Int i, Int j ) const                       { return m_minHorizontalCtuOffsetPlus1[i][j];                }
699
700  Void    setVpsVuiBspHrdPresentFlag( Bool flag )                                    { m_vpsVuiBspHrdPresentFlag = flag;                          }
701  Bool    getVpsVuiBspHrdPresentFlag(  ) const                                       { return m_vpsVuiBspHrdPresentFlag;                          }
702
703  Void    setVpsVuiBspHrdParameters( TComVpsVuiBspHrdParameters val)                 {  m_vpsVuiBspHrdParameters = val;                           }
704  const   TComVpsVuiBspHrdParameters* getVpsVuiBspHrdParameters(  ) const            { return &m_vpsVuiBspHrdParameters;                          }
705
706  Void    setBaseLayerParameterSetCompatibilityFlag( Int i, Bool flag )              { m_baseLayerParameterSetCompatibilityFlag[i] = flag;        }
707  Bool    getBaseLayerParameterSetCompatibilityFlag( Int i ) const                   { return m_baseLayerParameterSetCompatibilityFlag[i];        }
708};
709
710class TComRepFormat
711{
712private:
713  Bool m_chromaAndBitDepthVpsPresentFlag;
714  Int  m_chromaFormatVpsIdc;
715  Bool m_separateColourPlaneVpsFlag;
716  Int  m_picWidthVpsInLumaSamples;
717  Int  m_picHeightVpsInLumaSamples;
718  Int  m_bitDepthVpsLumaMinus8;
719  Int  m_bitDepthVpsChromaMinus8;
720  Bool m_conformanceWindowVpsFlag;
721  Int  m_confWinVpsLeftOffset;
722  Int  m_confWinVpsRightOffset;
723  Int  m_confWinVpsTopOffset;
724  Int  m_confWinVpsBottomOffset;
725
726public: 
727
728  TComRepFormat()
729  { 
730    m_conformanceWindowVpsFlag = 0;
731    m_confWinVpsLeftOffset     = 0;
732    m_confWinVpsRightOffset    = 0;
733    m_confWinVpsTopOffset      = 0;
734    m_confWinVpsBottomOffset   = 0;
735  }; 
736
737  Void    setChromaAndBitDepthVpsPresentFlag( Bool flag )                            { m_chromaAndBitDepthVpsPresentFlag = flag;                  }
738  Bool    getChromaAndBitDepthVpsPresentFlag(  ) const                               { return m_chromaAndBitDepthVpsPresentFlag;                  }
739  Void    checkChromaAndBitDepthVpsPresentFlag( Int i ) const                        { assert( i != 0 || m_chromaAndBitDepthVpsPresentFlag );     } // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1.
740
741  Void    inferChromaAndBitDepth     ( const TComRepFormat* prevRepFormat );
742  Void    checkInferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) const;
743
744  Void    setChromaFormatVpsIdc( Int  val )                                          { m_chromaFormatVpsIdc = val;                                }
745  Int     getChromaFormatVpsIdc(  ) const                                            { return m_chromaFormatVpsIdc;                               }
746
747  Void    setSeparateColourPlaneVpsFlag( Bool flag )                                 { m_separateColourPlaneVpsFlag = flag;                       }
748  Bool    getSeparateColourPlaneVpsFlag(  ) const                                    { return m_separateColourPlaneVpsFlag;                       }
749
750  Void    setPicWidthVpsInLumaSamples( Int  val )                                    { m_picWidthVpsInLumaSamples = val;                          }
751  Int     getPicWidthVpsInLumaSamples(  ) const                                      { return m_picWidthVpsInLumaSamples;                         }
752
753  Void    setPicHeightVpsInLumaSamples( Int  val )                                   { m_picHeightVpsInLumaSamples = val;                         }
754  Int     getPicHeightVpsInLumaSamples(  ) const                                     { return m_picHeightVpsInLumaSamples;                        }
755
756  Void    setBitDepthVpsLumaMinus8( Int  val )                                       { m_bitDepthVpsLumaMinus8 = val;                             }
757  Int     getBitDepthVpsLumaMinus8(  ) const                                         { return m_bitDepthVpsLumaMinus8;                            }
758
759  Void    setBitDepthVpsChromaMinus8( Int  val )                                     { m_bitDepthVpsChromaMinus8 = val;                           }
760  Int     getBitDepthVpsChromaMinus8(  ) const                                       { return m_bitDepthVpsChromaMinus8;                          }
761
762  Void    setConformanceWindowVpsFlag( Bool flag )                                   { m_conformanceWindowVpsFlag = flag;                         }
763  Bool    getConformanceWindowVpsFlag(  ) const                                      { return m_conformanceWindowVpsFlag;                         }
764
765  Void    setConfWinVpsLeftOffset( Int  val )                                        { m_confWinVpsLeftOffset = val;                              }
766  Int     getConfWinVpsLeftOffset(  ) const                                          { return m_confWinVpsLeftOffset;                             }
767
768  Void    setConfWinVpsRightOffset( Int  val )                                       { m_confWinVpsRightOffset = val;                             }
769  Int     getConfWinVpsRightOffset(  ) const                                         { return m_confWinVpsRightOffset;                            }
770
771  Void    setConfWinVpsTopOffset( Int  val )                                         { m_confWinVpsTopOffset = val;                               }
772  Int     getConfWinVpsTopOffset(  ) const                                           { return m_confWinVpsTopOffset;                              }
773
774  Void    setConfWinVpsBottomOffset( Int  val )                                      { m_confWinVpsBottomOffset = val;                            }
775  Int     getConfWinVpsBottomOffset(  ) const                                        { return m_confWinVpsBottomOffset;                           }
776};
777
778
779class TComDpbSize
780{
781private:
782  BoolAry1d  m_subLayerFlagInfoPresentFlag;
783  BoolAry2d  m_subLayerDpbInfoPresentFlag ;
784  IntAry3d   m_maxVpsDecPicBufferingMinus1;
785  IntAry2d   m_maxVpsNumReorderPics       ;
786  IntAry2d   m_maxVpsLatencyIncreasePlus1 ;
787
788public: 
789  TComDpbSize() {}; 
790
791  Void          init( Int numOutputLayerSets, Int maxNumLayerIds, Int maxNumSubLayers );
792
793  Void          setSubLayerFlagInfoPresentFlag( Int i, Bool flag )                   { m_subLayerFlagInfoPresentFlag[i] = flag;                   }
794  Bool          getSubLayerFlagInfoPresentFlag( Int i ) const                        { return m_subLayerFlagInfoPresentFlag[i];                   }
795
796  Void          setSubLayerDpbInfoPresentFlag( Int i, Int j, Bool flag )             { m_subLayerDpbInfoPresentFlag[i][j] = flag;                 }
797  Bool          getSubLayerDpbInfoPresentFlag( Int i, Int j ) const                  { return m_subLayerDpbInfoPresentFlag[i][j];                 }
798
799  Void          setMaxVpsDecPicBufferingMinus1( Int i, Int k, Int j, Int  val )      { m_maxVpsDecPicBufferingMinus1[i][k][j] = val;              }
800  Int           getMaxVpsDecPicBufferingMinus1( Int i, Int k, Int j ) const          { assert( m_maxVpsDecPicBufferingMinus1[i][k][j] >= 0 ); return m_maxVpsDecPicBufferingMinus1[i][k][j]; }
801
802  Void          setMaxVpsNumReorderPics( Int i, Int j, Int  val )                    { m_maxVpsNumReorderPics[i][j] = val;                        }
803  Int           getMaxVpsNumReorderPics( Int i, Int j ) const                        { return m_maxVpsNumReorderPics[i][j];                       }
804
805  Void          setMaxVpsLatencyIncreasePlus1( Int i, Int j, Int  val )              { m_maxVpsLatencyIncreasePlus1[i][j] = val;                  }
806  Int           getMaxVpsLatencyIncreasePlus1( Int i, Int j ) const                  { return m_maxVpsLatencyIncreasePlus1[i][j];                 }
807};
808#endif
809
810class TComVPS
811{
812private:
813  Int                   m_VPSId;
814#if NH_MV
815  Bool                  m_vpsBaseLayerInternalFlag;
816  Bool                  m_vpsBaseLayerAvailableFlag;
817#endif
818
819  UInt                  m_uiMaxTLayers;
820
821#if NH_MV
822  UInt                  m_uiMaxLayersMinus1;
823#else
824  UInt                  m_uiMaxLayers;
825#endif
826  Bool                  m_bTemporalIdNestingFlag;
827
828  UInt                  m_numReorderPics[MAX_TLAYER];
829  UInt                  m_uiMaxDecPicBuffering[MAX_TLAYER];
830  UInt                  m_uiMaxLatencyIncrease[MAX_TLAYER]; // Really max latency increase plus 1 (value 0 expresses no limit)
831
832  UInt                  m_numHrdParameters;
833#if NH_MV
834  UInt                  m_maxLayerId;
835#else
836  UInt                  m_maxNuhReservedZeroLayerId;
837#endif
838  std::vector<TComHRD>  m_hrdParameters;
839  std::vector<UInt>     m_hrdOpSetIdx;
840  std::vector<Bool>     m_cprmsPresentFlag;
841#if NH_MV
842  UInt                  m_vpsNumLayerSetsMinus1;
843  Bool                  m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_LAYER_ID_PLUS1];
844#else
845  UInt                  m_numOpSets;
846  Bool                  m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
847#endif
848
849#if NH_MV
850  TComPTL               m_pcPTL[MAX_VPS_OP_SETS_PLUS1];
851#else
852  TComPTL               m_pcPTL;
853#endif
854  TimingInfo            m_timingInfo;
855#if NH_MV
856  Bool                  m_vpsExtensionFlag;
857
858  /// VPS EXTENSION SYNTAX ELEMENTS
859  Int         m_vpsNonVuiExtensionLength;
860  Bool        m_splittingFlag;
861  Bool        m_scalabilityMaskFlag          [MAX_NUM_SCALABILITY_TYPES];
862  Int         m_dimensionIdLen           [MAX_NUM_SCALABILITY_TYPES];
863  Bool        m_vpsNuhLayerIdPresentFlag;
864  Int         m_layerIdInNuh             [MAX_NUM_LAYER_IDS];
865  Int         m_dimensionId              [MAX_NUM_LAYER_IDS][MAX_NUM_SCALABILITY_TYPES]; 
866
867  Int         m_viewIdLen;
868  Int         m_viewIdVal                [MAX_NUM_LAYERS];
869  Bool        m_directDependencyFlag     [MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
870  Bool        m_vpsSubLayersMaxMinus1PresentFlag;
871  Int         m_subLayersVpsMaxMinus1    [MAX_NUM_LAYERS];
872  Bool        m_maxTidRefPresentFlag;
873  Int         m_maxTidIlRefPicsPlus1     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
874  Bool        m_allRefLayersActiveFlag;
875  Int         m_vpsNumProfileTierLevelMinus1;   
876  Bool        m_vpsProfilePresentFlag    [MAX_VPS_OP_SETS_PLUS1];
877
878  Int         m_numAddLayerSets;   
879  Int         m_highestLayerIdxPlus1     [MAX_VPS_ADD_OUTPUT_LAYER_SETS][MAX_NUM_LAYERS];
880  Int         m_numAddOlss;
881
882  Int         m_defaultOutputLayerIdc;
883
884  Int         m_layerSetIdxForOlsMinus1  [MAX_VPS_OUTPUTLAYER_SETS]; 
885  Bool        m_outputLayerFlag          [MAX_VPS_OUTPUTLAYER_SETS][MAX_VPS_NUH_LAYER_ID_PLUS1];
886  Int         m_profileTierLevelIdx      [MAX_VPS_OUTPUTLAYER_SETS ][MAX_NUM_LAYERS];
887  Bool        m_altOutputLayerFlag       [MAX_VPS_OUTPUTLAYER_SETS];
888  Bool        m_repFormatIdxPresentFlag;
889
890  Int         m_vpsNumRepFormatsMinus1;
891  Int         m_vpsRepFormatIdx          [MAX_NUM_LAYERS];
892
893  std::vector<TComRepFormat> m_repFormat; 
894  Bool        m_maxOneActiveRefLayerFlag;       
895  Bool        m_vpsPocLsbAlignedFlag;
896  Bool        m_pocLsbNotPresentFlag     [MAX_NUM_LAYERS];
897
898  TComDpbSize m_dpbSize; 
899  Int         m_directDepTypeLenMinus2;         
900  Bool        m_defaultDirectDependencyFlag;
901  Int         m_defaultDirectDependencyType;
902 
903#if H_MV_HLS7_GEN
904  Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
905#endif
906  Bool        m_vpsVuiPresentFlag;
907  TComVPSVUI  m_vpsVUI; 
908#if !H_MV_HLS7_GEN
909  Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
910#endif
911
912  // VPS EXTENSION SEMANTICS VARIABLES
913  Int         m_layerIdInVps             [MAX_NUM_LAYERS   ];
914  Int         m_dependencyFlag           [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
915
916  Int         m_numViews; 
917  Int         m_numDirectRefLayers       [MAX_NUM_LAYERS];
918  Int         m_idDirectRefLayer         [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
919#if NH_3D
920  Int         m_numRefListLayers         [MAX_NUM_LAYERS];
921  Int         m_idRefListLayer           [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
922#endif
923
924
925  Int         m_numRefLayers             [MAX_NUM_LAYER_IDS]; 
926  Int         m_idRefLayer               [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
927
928
929  Int         m_numPredictedLayers       [MAX_NUM_LAYERS ]; 
930  Int         m_idPredictedLayer         [MAX_NUM_LAYERS][MAX_NUM_LAYER_IDS];
931  Int         m_numIndependentLayers; 
932  Int         m_numLayersInTreePartition [MAX_NUM_LAYER_IDS];
933  Int         m_treePartitionLayerIdList [MAX_NUM_LAYERS][MAX_NUM_LAYER_IDS];
934  Bool        m_recursiveRefLayerFlag    [MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS]; 
935  Int         m_viewIndex                [MAX_NUM_LAYERS   ];
936 
937  IntAry2d    m_targetDecLayerIdLists;   //[TargetOptLayerSetIdx][i]
938  IntAry2d    m_targetOptLayerIdLists; 
939  IntAry2d    m_layerSetLayerIdList; 
940
941  Int         m_numNecessaryLayers        [MAX_VPS_OUTPUTLAYER_SETS];
942  Bool        m_necessaryLayerFlag        [MAX_VPS_OUTPUTLAYER_SETS][MAX_NUM_LAYERS]; 
943
944  Int         xGetDimBitOffset( Int j ) const;
945  Void        xSetRefLayerFlags( Int currLayerId );
946
947  // VPS EXTENSION 2 SYNTAX ELEMENTS
948#if NH_3D
949  IntAry1d       m_numCp; 
950  IntAry2d       m_cpRefVoi;
951  BoolAry2d      m_cpPresentFlag; 
952  Int            m_cpPrecision;
953  BoolAry1d      m_cpInSliceSegmentHeaderFlag;
954  IntAry3d       m_aaaiCodedScale ;
955  IntAry3d       m_aaaiCodedOffset;
956
957  IntAry1d       m_viewOIdxList;
958  BoolAry2d      m_viewCompLayerPresentFlag;
959  IntAry2d       m_viewCompLayerId;
960#endif
961
962#endif
963
964public:
965                    TComVPS();
966
967  virtual           ~TComVPS();
968
969  Void              createHrdParamBuffer()
970  {
971    m_hrdParameters.resize(getNumHrdParameters());
972    m_hrdOpSetIdx.resize(getNumHrdParameters());
973    m_cprmsPresentFlag.resize(getNumHrdParameters());
974  }
975
976  TComHRD*          getHrdParameters( UInt i )                           { return &m_hrdParameters[ i ];                                    }
977  const TComHRD*    getHrdParameters( UInt i ) const                     { return &m_hrdParameters[ i ];                                    }
978  UInt              getHrdOpSetIdx( UInt i ) const                       { return m_hrdOpSetIdx[ i ];                                       }
979  Void              setHrdOpSetIdx( UInt val, UInt i )                   { m_hrdOpSetIdx[ i ] = val;                                        }
980  Bool              getCprmsPresentFlag( UInt i ) const                  { return m_cprmsPresentFlag[ i ];                                  }
981  Void              setCprmsPresentFlag( Bool val, UInt i )              { m_cprmsPresentFlag[ i ] = val;                                   }
982
983  Int               getVPSId() const                                     { return m_VPSId;                                                  }
984  Void              setVPSId(Int i)                                      { m_VPSId = i;                                                     }
985#if NH_MV
986  Void              setVpsBaseLayerInternalFlag( Bool flag )             { m_vpsBaseLayerInternalFlag = flag;                               } 
987  Bool              getVpsBaseLayerInternalFlag(  )           const      { return m_vpsBaseLayerInternalFlag;                               } 
988  Void              setVpsBaseLayerAvailableFlag( Bool flag )            { m_vpsBaseLayerAvailableFlag = flag;                              } 
989  Bool              getVpsBaseLayerAvailableFlag(  )          const      { return m_vpsBaseLayerAvailableFlag;                              } 
990#endif
991
992  UInt              getMaxTLayers() const                                { return m_uiMaxTLayers;                                           }
993  Void              setMaxTLayers(UInt t)                                { m_uiMaxTLayers = t;                                              }
994#if NH_MV   
995  UInt              getMaxSubLayersMinus1()            const             { return m_uiMaxTLayers - 1;   }  // For consistency with draft spec
996  Void              setMaxSubLayersMinus1(UInt val)                      { m_uiMaxTLayers = (val + 1);  }
997  UInt              getMaxLayersMinus1()               const             { return m_uiMaxLayersMinus1;  } 
998  Void              setMaxLayersMinus1(UInt l)                           { m_uiMaxLayersMinus1 = l;     }
999#else
1000
1001  UInt              getMaxLayers() const                                 { return m_uiMaxLayers;                                            }
1002  Void              setMaxLayers(UInt l)                                 { m_uiMaxLayers = l;                                               }
1003#endif
1004
1005  Bool              getTemporalNestingFlag() const                       { return m_bTemporalIdNestingFlag;                                 }
1006  Void              setTemporalNestingFlag(Bool t)                       { m_bTemporalIdNestingFlag = t;                                    }
1007
1008  Void              setNumReorderPics(UInt v, UInt tLayer)               { m_numReorderPics[tLayer] = v;                                    }
1009  UInt              getNumReorderPics(UInt tLayer) const                 { return m_numReorderPics[tLayer];                                 }
1010
1011  Void              setMaxDecPicBuffering(UInt v, UInt tLayer)           { assert(tLayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tLayer] = v; }
1012  UInt              getMaxDecPicBuffering(UInt tLayer) const             { return m_uiMaxDecPicBuffering[tLayer];                           }
1013
1014  Void              setMaxLatencyIncrease(UInt v, UInt tLayer)           { m_uiMaxLatencyIncrease[tLayer] = v;                              }
1015  UInt              getMaxLatencyIncrease(UInt tLayer) const             { return m_uiMaxLatencyIncrease[tLayer];                           }
1016
1017  UInt              getNumHrdParameters() const                          { return m_numHrdParameters;                                       }
1018  Void              setNumHrdParameters(UInt v)                          { m_numHrdParameters = v;                                          }
1019#if NH_MV
1020  UInt              getVpsMaxLayerId()                           const   { return m_maxLayerId; }
1021  Void              setVpsMaxLayerId(UInt v)                             { m_maxLayerId = v;    }
1022                   
1023  UInt              getVpsNumLayerSetsMinus1()                   const   { return m_vpsNumLayerSetsMinus1; }
1024  Void              setVpsNumLayerSetsMinus1(UInt v)                     { m_vpsNumLayerSetsMinus1 = v;    }
1025#else 
1026  UInt              getMaxNuhReservedZeroLayerId() const                 { return m_maxNuhReservedZeroLayerId;                              }
1027  Void              setMaxNuhReservedZeroLayerId(UInt v)                 { m_maxNuhReservedZeroLayerId = v;                                 }
1028
1029  UInt              getMaxOpSets() const                                 { return m_numOpSets;                                              }
1030  Void              setMaxOpSets(UInt v)                                 { m_numOpSets = v;                                                 }
1031#endif
1032  Bool              getLayerIdIncludedFlag(UInt opsIdx, UInt id) const   { return m_layerIdIncludedFlag[opsIdx][id];                        }
1033  Void              setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id) { m_layerIdIncludedFlag[opsIdx][id] = v;                           }
1034
1035#if NH_MV
1036  TComPTL*          getPTL( Int idx = 0 )                                { return &m_pcPTL[idx];                                            }
1037  const TComPTL*    getPTL( Int idx = 0 ) const                          { return &m_pcPTL[idx];                                            }
1038#else
1039  TComPTL*          getPTL()                                             { return &m_pcPTL;                                                 }
1040  const TComPTL*    getPTL() const                                       { return &m_pcPTL;                                                 }
1041#endif
1042  TimingInfo*       getTimingInfo()                                      { return &m_timingInfo;                                            }
1043  const TimingInfo* getTimingInfo() const                                { return &m_timingInfo;                                            }
1044
1045#if NH_MV
1046  Void    setVpsExtensionFlag( Bool flag )                                      { m_vpsExtensionFlag = flag; } 
1047  Bool    getVpsExtensionFlag(  )                                   const       { return m_vpsExtensionFlag; } 
1048
1049  Void    setVpsNonVuiExtensionLength( Int  val )                               { m_vpsNonVuiExtensionLength = val; } 
1050  Int     getVpsNonVuiExtensionLength(  )                           const       { return m_vpsNonVuiExtensionLength; } 
1051 
1052  // VPS Extension
1053  Void    setSplittingFlag( Bool val )                                          { m_splittingFlag = val;  }
1054  Bool    getSplittingFlag()                                        const       { return m_splittingFlag; }
1055
1056  Void    setScalabilityMaskFlag( UInt val );
1057  Void    setScalabilityMaskFlag( Int scalType, Bool val )                          { m_scalabilityMaskFlag[scalType] = val;  }
1058  Bool    getScalabilityMaskFlag( Int scalType )                    const           { return m_scalabilityMaskFlag[scalType]; }
1059 
1060  Int     getNumScalabilityTypes( ) const;                               
1061
1062  Void    setDimensionIdLen( Int sIdx, Int val )                                { m_dimensionIdLen[sIdx] = val;  }
1063  Int     getDimensionIdLen( Int sIdx )                             const       { assert( m_dimensionIdLen[sIdx] > 0) ; return m_dimensionIdLen[sIdx]; } 
1064
1065  Void    setVpsNuhLayerIdPresentFlag( Bool val )                               { m_vpsNuhLayerIdPresentFlag = val; }
1066  Bool    getVpsNuhLayerIdPresentFlag()                             const       { return m_vpsNuhLayerIdPresentFlag; }
1067
1068  Void    setLayerIdInNuh( Int layerIdInVps, Int val )                          { m_layerIdInNuh[layerIdInVps] = val;  }
1069  Int     getLayerIdInNuh( Int layerIdInVps )                       const       { assert( m_layerIdInNuh[layerIdInVps] >= 0 ); return m_layerIdInNuh[layerIdInVps]; }
1070
1071  Bool    nuhLayerIdIncluded( Int layerIdinNuh )                    const       { return ( m_layerIdInVps[ layerIdinNuh ] > 0 );  }
1072
1073  Void    setDimensionId( Int layerIdInVps, Int scalIdx, Int val )              { m_dimensionId[layerIdInVps][scalIdx] = val;  }
1074  Int     getDimensionId( Int layerIdInVps, Int scalIdx )           const       { return m_dimensionId[layerIdInVps][scalIdx]; }
1075
1076  Void    setViewIdLen( Int  val )                                              { m_viewIdLen = val; } 
1077  Int     getViewIdLen(  )                                          const       { return m_viewIdLen; } 
1078
1079  Void    setViewIdVal( Int viewOrderIndex, Int  val )                          { m_viewIdVal[viewOrderIndex] = val; } 
1080  Int     getViewIdVal( Int viewOrderIndex )                        const       { return m_viewIdVal[viewOrderIndex]; } 
1081 
1082  Void    setDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Bool val )       { m_directDependencyFlag[depLayeridInVps][refLayeridInVps] = val;  }
1083  Bool    getDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps )           const { return m_directDependencyFlag[depLayeridInVps][refLayeridInVps]; }
1084 
1085  Void    setVpsSubLayersMaxMinus1PresentFlag( Bool flag )                      { m_vpsSubLayersMaxMinus1PresentFlag = flag; } 
1086  Bool    getVpsSubLayersMaxMinus1PresentFlag(  )                    const      { return m_vpsSubLayersMaxMinus1PresentFlag; } 
1087 
1088  Void    setSubLayersVpsMaxMinus1( Int i, Int  val )                           { m_subLayersVpsMaxMinus1[i] = val; } 
1089  Int     getSubLayersVpsMaxMinus1( Int i )                          const      { return m_subLayersVpsMaxMinus1[i]; } 
1090  Void    checkSubLayersVpsMaxMinus1( Int i )                        const      { assert( m_subLayersVpsMaxMinus1[i] >= 0 && m_subLayersVpsMaxMinus1[i] <= m_uiMaxTLayers - 1 ); }
1091
1092  Void    setMaxTidRefPresentFlag( Bool flag )                                  { m_maxTidRefPresentFlag = flag; } 
1093  Bool    getMaxTidRefPresentFlag(  )                                const      { return m_maxTidRefPresentFlag; } 
1094
1095  Void    setMaxTidIlRefPicsPlus1( Int i, Int j, Int  val )                     { m_maxTidIlRefPicsPlus1[i][j] = val; } 
1096  Int     getMaxTidIlRefPicsPlus1( Int i, Int j )                    const      { return m_maxTidIlRefPicsPlus1[i][j]; } 
1097 
1098  Void    setAllRefLayersActiveFlag( Bool flag )                                { m_allRefLayersActiveFlag = flag; } 
1099  Bool    getAllRefLayersActiveFlag(  )                              const      { return m_allRefLayersActiveFlag; } 
1100 
1101  Void    setVpsNumProfileTierLevelMinus1( Int val )                            { m_vpsNumProfileTierLevelMinus1 = val;  } 
1102  Int     getVpsNumProfileTierLevelMinus1( )                         const      { return m_vpsNumProfileTierLevelMinus1; } 
1103 
1104  Void    setVpsProfilePresentFlag( Int idx, Bool val )                         { m_vpsProfilePresentFlag[idx] = val;  }
1105  Bool    getVpsProfilePresentFlag( Int idx )                        const      { return m_vpsProfilePresentFlag[idx]; }
1106
1107  Void    setNumAddLayerSets( Int val )                                         { m_numAddLayerSets = val; } 
1108  Int     getNumAddLayerSets( )                                      const      { return m_numAddLayerSets; } 
1109 
1110  Void    setHighestLayerIdxPlus1( Int i, Int j, Int  val )                     { m_highestLayerIdxPlus1[i][j] = val; } 
1111  Int     getHighestLayerIdxPlus1( Int i, Int j )                    const      { return m_highestLayerIdxPlus1[i][j]; } 
1112
1113  Void    setNumAddOlss( Int  val )                                             { m_numAddOlss = val; } 
1114  Int     getNumAddOlss(  )                                          const      { return m_numAddOlss; } 
1115
1116  Void    setDefaultOutputLayerIdc( Int  val )                                  { m_defaultOutputLayerIdc = val; } 
1117  Int     getDefaultOutputLayerIdc(  )                               const      { return m_defaultOutputLayerIdc; }   
1118 
1119  Void    setLayerSetIdxForOlsMinus1( Int outLayerSetIdx, Int val )             { m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]  = val; } 
1120  Int     getLayerSetIdxForOlsMinus1( Int outLayerSetIdx )           const      { return m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]; } 
1121  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() ); } 
1122
1123  Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )            { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
1124  Bool    getOutputLayerFlag( Int outLayerSetIdx, Int i )            const      { return m_outputLayerFlag[ outLayerSetIdx ][ i ]; } 
1125
1126  Bool    inferOutputLayerFlag( Int i, Int j )                       const;
1127
1128  Void    setProfileTierLevelIdx( Int i, Int j, Int val )                       { m_profileTierLevelIdx[ i ][ j ] = val; }
1129  Int     getProfileTierLevelIdx( Int i, Int j )                     const      { return m_profileTierLevelIdx[ i ][ j ]; } 
1130  Int     inferProfileTierLevelIdx( Int i, Int j )                   const; 
1131                                                                     
1132  Void    setAltOutputLayerFlag( Int i, Bool flag )                             { m_altOutputLayerFlag[i] = flag; } 
1133  Bool    getAltOutputLayerFlag( Int i )                             const      { return m_altOutputLayerFlag[i]; } 
1134                                                                     
1135  Void    setRepFormatIdxPresentFlag( Bool flag )                               { m_repFormatIdxPresentFlag = flag; } 
1136  Bool    getRepFormatIdxPresentFlag(  )                             const      { return m_repFormatIdxPresentFlag; } 
1137                                                                     
1138  Void    setVpsNumRepFormatsMinus1( Int  val )                                 { m_vpsNumRepFormatsMinus1 = val; } 
1139  Int     getVpsNumRepFormatsMinus1(  )                              const      { return m_vpsNumRepFormatsMinus1; } 
1140                                                                     
1141  Void    setVpsRepFormatIdx( Int i, Int  val )                                 { m_vpsRepFormatIdx[i] = val; } 
1142  Int     getVpsRepFormatIdx( Int i )                                const      { return m_vpsRepFormatIdx[i]; } 
1143
1144  Int     inferVpsRepFormatIdx( Int i )                              const      { return std::min( i, getVpsNumRepFormatsMinus1()  );  }
1145
1146  Void    setRepFormat( Int i, TComRepFormat val )                              { m_repFormat[i] = val;  }
1147  Void    setRepFormat( std::vector<TComRepFormat> val )                        { m_repFormat = val;  }
1148  const TComRepFormat* getRepFormat( Int i )                         const      { return &m_repFormat[i]; }
1149                                                                     
1150  Void    setMaxOneActiveRefLayerFlag( Bool flag)                               { m_maxOneActiveRefLayerFlag = flag; } 
1151  Bool    getMaxOneActiveRefLayerFlag( )                             const      { return m_maxOneActiveRefLayerFlag; } 
1152                                                                     
1153  Void    setVpsPocLsbAlignedFlag( Bool flag )                                  { m_vpsPocLsbAlignedFlag = flag; } 
1154  Bool    getVpsPocLsbAlignedFlag(  )                                const      { return m_vpsPocLsbAlignedFlag; } 
1155                                                                     
1156  Void    setDpbSize( TComDpbSize val )                                         { m_dpbSize = val; } 
1157  const TComDpbSize * getDpbSize( )                                  const      { return &m_dpbSize; } 
1158                                                                     
1159                                                                     
1160  Void    setPocLsbNotPresentFlag( Int i, Bool flag )                           { m_pocLsbNotPresentFlag[i] = flag; } 
1161  Bool    getPocLsbNotPresentFlag( Int i )                           const      { return m_pocLsbNotPresentFlag[i]; } 
1162                                                                     
1163  Void    setDirectDepTypeLenMinus2( Int val)                                   { m_directDepTypeLenMinus2 = val; } 
1164  Int     getDirectDepTypeLenMinus2( )                               const      { return m_directDepTypeLenMinus2; } 
1165                                                                     
1166  Void    setDefaultDirectDependencyFlag( Bool flag )                           { m_defaultDirectDependencyFlag = flag; } 
1167  Bool    getDefaultDirectDependencyFlag(  )                         const      { return m_defaultDirectDependencyFlag; } 
1168                                                                     
1169  Void    setDefaultDirectDependencyType( Int  val )                            { m_defaultDirectDependencyType = val; } 
1170  Int     getDefaultDirectDependencyType(  )                         const      { return m_defaultDirectDependencyType; } 
1171 
1172  Void    setDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps, Int val) { m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ] = val; } 
1173  Int     getDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps) const { return m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ]; } 
1174
1175  Void    setVpsVuiPresentFlag( Bool flag )                                     { m_vpsVuiPresentFlag = flag; } 
1176  Bool    getVpsVuiPresentFlag(  )                                   const      { return m_vpsVuiPresentFlag; } 
1177                                                         
1178  const TComVPSVUI* getVPSVUI(  )                                    const      { return &m_vpsVUI;  }
1179  Void  setVPSVUI( TComVPSVUI val )                                             { m_vpsVUI = val;  }
1180 
1181 // VPS EXTENSION SEMANTICS VARIABLES
1182  Void    setLayerIdInVps( Int layerIdInNuh, Int val )                          { m_layerIdInVps[layerIdInNuh] = val;  }
1183  Int     getLayerIdInVps( Int layerIdInNuh )                        const      { assert( m_layerIdInVps[layerIdInNuh] >= 0 ); return m_layerIdInVps[layerIdInNuh]; }
1184
1185  Int     getScalabilityId ( Int layerIdInVps, ScalabilityType scalType ) const ;
1186  Int     getViewId        ( Int layerIdInNuh )                 const           { return m_viewIdVal[ getViewIndex( layerIdInNuh )]; }
1187  Void    setRefLayers(); 
1188
1189  // To be aligned with spec naming, getViewIndex will be removed in future versions
1190  Int     getViewOrderIdx ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), VIEW_ORDER_INDEX  ); }   
1191  Int     getViewIndex    ( Int layerIdInNuh ) const                            { return getViewOrderIdx( layerIdInNuh ); }   
1192  Int     getAuxId        ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), AUX_ID  ); }   
1193  Int     getDependencyId ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPENDENCY_ID  ); }   
1194  Int     getNumViews()                        const                            { return m_numViews; }
1195  Void    initNumViews();
1196#if NH_3D
1197  Void    initViewCompLayer( );
1198  Int     getViewOIdxList( Int i )             const                            { return m_viewOIdxList[i]; }
1199  std::vector<Int> getViewOIdxList( )          const                            { return m_viewOIdxList; }
1200
1201  Int     getVoiInVps( Int viewOIdx )          const;
1202
1203  Bool    getViewCompLayerPresentFlag (Int i, Bool d ) const                    { return  m_viewCompLayerPresentFlag[ getVoiInVps(i) ][d]; }
1204  Bool    getViewCompLayerId          (Int i, Bool d ) const                    { return  m_viewCompLayerId         [ getVoiInVps(i) ][d]; }
1205#endif
1206  Bool    getDependencyFlag( Int i, Int j ) const                               { return m_dependencyFlag[i][j]; }
1207  Int     getNumDirectRefLayers( Int layerIdInNuh ) const                       { return m_numDirectRefLayers[ layerIdInNuh ];  };                               
1208#if NH_3D                                                                     
1209  Int     getNumRefListLayers( Int layerIdInNuh )   const                       { return m_numRefListLayers[ layerIdInNuh ];  };                               
1210#endif
1211
1212  Int     getNumRefLayers            ( Int i )      const                       { return m_numRefLayers[i]; } 
1213  Int     getNumPredictedLayers      ( Int i )      const                       { return m_numPredictedLayers[i]; } 
1214                                                                               
1215  Int     getIdRefLayer              ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumRefLayers      ( i )); return m_idRefLayer      [i][j]; } 
1216  Int     getIdPredictedLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumPredictedLayers( i )); return m_idPredictedLayer[i][j]; } 
1217  Int     getIdDirectRefLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumDirectRefLayers( i )); return m_idDirectRefLayer[i][j]; } 
1218#if NH_3D                                                                     
1219  Int     getIdRefListLayer          ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumRefListLayers   ( i )); return m_idRefListLayer[i][j]; } 
1220#endif                                                                         
1221  Int     getNumIndependentLayers    (  )             const                     { return m_numIndependentLayers; } 
1222  Int     getNumLayersInTreePartition( Int i )        const                     { return m_numLayersInTreePartition[i]; } 
1223  Int     getTreePartitionLayerIdList( Int i, Int j ) const                     { return m_treePartitionLayerIdList[i][j]; } 
1224  Bool    getRecursiveRefLayerFlag   ( Int i, Int j ) const                     { return m_recursiveRefLayerFlag[i][j]; } 
1225  Int     getNumLayerSets( )                          const                     { return getVpsNumLayerSetsMinus1() + 1 + getNumAddLayerSets();  }; 
1226                                                                               
1227  Int     getFirstAddLayerSetIdx()                    const                     { return getVpsNumLayerSetsMinus1() + 1; } 
1228  Int     getLastAddLayerSetIdx()                     const                     { return getFirstAddLayerSetIdx() + getNumAddLayerSets() - 1; }
1229  Bool    checkVPSExtensionSyntax(); 
1230  Int     scalTypeToScalIdx   ( ScalabilityType scalType ) const ;
1231
1232  Int     getProfileTierLevelIdxLen()                 const                     { return gCeilLog2( getVpsNumProfileTierLevelMinus1() + 1 ); };       
1233  Int     getVpsRepFormatIdxLen()                     const                     { return gCeilLog2( getVpsNumRepFormatsMinus1() + 1 ); };       
1234
1235  Int     getNumLayersInIdList ( Int lsIdx )          const; 
1236  Int     getLayerSetLayerIdList(Int lsIdx, Int j )   const                     { return m_layerSetLayerIdList[ lsIdx ][ j ]; }; 
1237
1238  Int     getNumOutputLayerSets()                     const; 
1239
1240  Bool    isOutputLayer( Int outLayerSetIdx, Int layerIdInNuh )  const;   
1241  Void    deriveLayerSetLayerIdList();
1242
1243  Int     olsIdxToLsIdx( Int i )                                       const    { return ( i < getNumLayerSets() ) ? i  : getLayerSetIdxForOlsMinus1( i ) + 1 ; };
1244  Void    initTargetLayerIdLists  ( );
1245  Void    deriveTargetLayerIdList ( Int i );
1246  std::vector<Int> getTargetDecLayerIdList( Int targetDecLayerSetIdx ) const     { return m_targetDecLayerIdLists[targetDecLayerSetIdx]; }; 
1247  std::vector<Int> getTargetOptLayerIdList( Int targetOptLayerSetIdx ) const     { return m_targetOptLayerIdLists[targetOptLayerSetIdx]; }; 
1248
1249  Int     getNumOutputLayersInOutputLayerSet( Int i )                  const     { return (Int) getTargetOptLayerIdList( i ).size(); }; 
1250  Int     getOlsHighestOutputLayerId( Int i )                          const     { return getTargetOptLayerIdList( i ).back(); }; 
1251
1252  Void    deriveAddLayerSetLayerIdList( Int i );
1253  Void    deriveNecessaryLayerFlags( Int olsIdx );
1254  Int     getNecessaryLayerFlag( Int i, Int j )                        const     { AOF( i >= 0 && i < getNumOutputLayerSets() ); AOF( j >= 0 && j < getNumLayersInIdList( olsIdxToLsIdx( i ) )  );  return m_necessaryLayerFlag[i][j]; }; 
1255
1256  Int     getMaxSubLayersInLayerSetMinus1( Int i )                     const;
1257  Int     getHighestLayerIdxPlus1Len( Int j )                          const     { return gCeilLog2( getNumLayersInTreePartition( j ) + 1 );   }; 
1258  Bool    getAltOutputLayerFlagVar( Int i )                            const;
1259
1260  // inference
1261  Int     inferDimensionId     ( Int i, Int j )                        const;
1262  Int     inferLastDimsionIdLenMinus1()                                const;
1263
1264  // helpers
1265  Void    printPTL()                                                   const;
1266  Void    printLayerDependencies()                                     const;
1267  Void    printScalabilityId()                                         const;
1268  Void    printLayerSets()                                             const;
1269
1270
1271  /// VPS EXTENSION 2 SYNTAX ELEMENTS
1272  Int     getDepthId                   ( Int layerIdInNuh)             const    { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPTH_ID ); }
1273#if NH_3D                                                             
1274  Bool    getVpsDepthFlag              ( Int layerIdInNuh)             const    { return (getDepthId( layerIdInNuh ) > 0);  }
1275  Int     getLayerIdInNuh              ( Int viewIndex, Bool depthFlag ) const;   
1276         
1277  Void    createCamPars                ( Int iNumViews ); 
1278  Void    initCamParaVPS               ( Int vOIdxInVps, Int numCp, Bool cpInSliceSegmentHeaderFlag, Int* cpRefVoi, Int** aaiScale, Int** aaiOffset );                                               
1279                                       
1280  Void    setCpPrecision               ( Int  val )                             { m_cpPrecision = val;                       }
1281  Int     getCpPrecision               (  )                            const    { return m_cpPrecision;                      }
1282                                                                                                               
1283  Void    setNumCp                     ( Int i, Int  val )                      { m_numCp[i] = val;                          }
1284  Int     getNumCp                     ( Int i )                       const    { return m_numCp[i];                         }
1285                                                                                                               
1286  Void    setCpRefVoi                  ( Int i, Int m, Int  val )               { m_cpRefVoi[i][m] = val;                    }
1287  Int     getCpRefVoi                  ( Int i, Int m )                const    { return m_cpRefVoi[i][m];                   }
1288                                                                                                               
1289  Void    setCpInSliceSegmentHeaderFlag( Int i, Bool flag )                     { m_cpInSliceSegmentHeaderFlag[i] = flag;    }
1290  Bool    getCpInSliceSegmentHeaderFlag( Int i )                       const    { return m_cpInSliceSegmentHeaderFlag[i];    }
1291                                                                                                               
1292  Void    setVpsCpScale                ( Int i, Int j, Int val )                { m_aaaiCodedScale [i][0][j] = val;          }
1293  Int     getVpsCpScale                ( Int i, Int j )                const    { return m_aaaiCodedScale[i][0][j];          }
1294                                                                                                               
1295  Void    setVpsCpOff                  ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][0][j] = val;          }
1296  Int     getVpsCpOff                  ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][0][j];         }
1297                                                                                                               
1298  Void    setVpsCpInvScale             ( Int i, Int j, Int val )                { m_aaaiCodedScale[i][1][j] = val;           }
1299  Int     getVpsCpInvScale             ( Int i, Int j )                const    { return m_aaaiCodedScale[i][1][j];          }
1300                                                                                                               
1301  Void    setVpsCpInvOff               ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][1][j] = val;          }
1302  Int     getVpsCpInvOff               ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][1][j];         }
1303
1304// Derived
1305  Void    deriveCpPresentFlag          ( );                 
1306  Void    setCpPresentFlag             ( Int i, Int m, Bool flag )              { m_cpPresentFlag[i][m] = flag;             } 
1307  Bool    getCpPresentFlag             ( Int i, Int m )                const    { return m_cpPresentFlag[i][m];             }   
1308                                                                       
1309  const IntAry1d& getCodedScale        ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][0];   }
1310  const IntAry1d& getCodedOffset       ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][0];   }
1311  const IntAry1d& getInvCodedScale     ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][1];   }
1312  const IntAry1d& getInvCodedOffset    ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][1];   }
1313#endif
1314
1315  template <typename T, typename S, typename U> Void xPrintArray( const Char* name, Int numElemDim1, U idx, S numElemDim2, T vec, Bool printNumber, Bool printIdx = true ) const
1316  {
1317    std::cout << std::endl; 
1318    for (Int j = 0; j < numElemDim1; j++ )
1319    { 
1320      std::cout << std::right << std::setw(27) << name; 
1321      if (printIdx)
1322      {
1323        std::cout << "[" << std::right << std::setw(3) << idx[ j ] << "]" ; 
1324      }
1325      else
1326      {
1327        std::cout << std::right << std::setw(5) << " "; 
1328      }
1329
1330      if ( printNumber )
1331      {
1332        std::cout << " (" << std::right << std::setw(3) << numElemDim2[j] << ")";       
1333      }         
1334      else
1335      {
1336        std::cout << std::right << std::setw(6) << " ";             
1337      }
1338
1339      std::cout << ":";
1340      for (Int i = 0; i < numElemDim2[j]; i++)
1341      {
1342        std::cout << std::right << std::setw(3) << vec[j][i];
1343      }   
1344      std::cout << std::endl; 
1345    }
1346  }
1347
1348  template <typename T> Void xPrintArray( const char* name, Int numElem, T vec, Bool printNumber  )  const
1349  {
1350    std::vector<Int> numElemDim2(1, numElem);   
1351    std::vector<T>   vec2       (1,  vec    );
1352    std::vector<Int> idx2       (0); 
1353    xPrintArray( name, 1, idx2, numElemDim2, vec2, printNumber, false );
1354  }
1355
1356#endif
1357};
1358
1359#if H_3D
1360class TComDLT
1361{
1362private:
1363  Bool        m_bDltPresentFlag;
1364  Bool        m_bUseDLTFlag              [ MAX_NUM_LAYERS ];
1365  Bool        m_bInterViewDltPredEnableFlag[ MAX_NUM_LAYERS ];
1366
1367  Int         m_iNumDepthmapValues       [ MAX_NUM_LAYERS ];
1368  Int*        m_iDepthValue2Idx          [ MAX_NUM_LAYERS ];
1369  Int*        m_iIdx2DepthValue          [ MAX_NUM_LAYERS ];
1370
1371  Int         m_iNumDepthViews;
1372  UInt        m_uiDepthViewBitDepth;
1373
1374public:
1375  TComDLT();
1376  ~TComDLT(); 
1377
1378  Bool    getDltPresentFlag  ()                           { return m_bDltPresentFlag; }
1379  Void    setDltPresentFlag  ( Bool b )                   { m_bDltPresentFlag = b;    }
1380
1381  Bool    getUseDLTFlag      ( Int layerIdInVps )         { return m_bUseDLTFlag[ layerIdInVps ]; }
1382  Void    setUseDLTFlag      ( Int layerIdInVps, Bool b ) { m_bUseDLTFlag[ layerIdInVps ]  = b;   }
1383 
1384  Bool    getInterViewDltPredEnableFlag( Int layerIdInVps )         { return m_bInterViewDltPredEnableFlag[ layerIdInVps ]; }
1385  Void    setInterViewDltPredEnableFlag( Int layerIdInVps, Bool b ) { m_bInterViewDltPredEnableFlag[ layerIdInVps ] = b;    }
1386
1387  Void    setNumDepthViews   ( Int n )                    { m_iNumDepthViews = n; }
1388  Int     getNumDepthViews   ()                           { return m_iNumDepthViews; }
1389
1390  Void    setDepthViewBitDepth( UInt n )                  { m_uiDepthViewBitDepth = n; }
1391  UInt    getDepthViewBitDepth()                          { return m_uiDepthViewBitDepth; }
1392
1393  Int     getNumDepthValues( Int layerIdInVps )           { return getUseDLTFlag(layerIdInVps)?m_iNumDepthmapValues[layerIdInVps]:((1 << g_bitDepthY)-1); }
1394  Int     depthValue2idx( Int layerIdInVps, Pel value )   { return getUseDLTFlag(layerIdInVps)?m_iDepthValue2Idx[layerIdInVps][value]:value; }
1395  Pel     idx2DepthValue( Int layerIdInVps, UInt uiIdx )  { return getUseDLTFlag(layerIdInVps)?m_iIdx2DepthValue[layerIdInVps][ClipY(uiIdx)]:uiIdx; }
1396  Void    setDepthLUTs( Int layerIdInVps, Int* idx2DepthValue = NULL, Int iNumDepthValues = 0 );
1397  Int*    idx2DepthValue( Int layerIdInVps )  { return m_iIdx2DepthValue[layerIdInVps]; }
1398  Void    getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum );
1399  Void    setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum );
1400};
1401#endif
1402
1403
1404class Window
1405{
1406private:
1407  Bool m_enabledFlag;
1408  Int  m_winLeftOffset;
1409  Int  m_winRightOffset;
1410  Int  m_winTopOffset;
1411  Int  m_winBottomOffset;
1412#if NH_MV
1413  Bool          m_scaledFlag; 
1414#endif
1415public:
1416  Window()
1417  : m_enabledFlag    (false)
1418  , m_winLeftOffset  (0)
1419  , m_winRightOffset (0)
1420  , m_winTopOffset   (0)
1421  , m_winBottomOffset(0)
1422#if NH_MV
1423  , m_scaledFlag(true)
1424#endif
1425  { }
1426
1427  Bool getWindowEnabledFlag() const   { return m_enabledFlag;                          }
1428  Int  getWindowLeftOffset() const    { return m_enabledFlag ? m_winLeftOffset : 0;    }
1429  Void setWindowLeftOffset(Int val)   { m_winLeftOffset = val; m_enabledFlag = true;   }
1430  Int  getWindowRightOffset() const   { return m_enabledFlag ? m_winRightOffset : 0;   }
1431  Void setWindowRightOffset(Int val)  { m_winRightOffset = val; m_enabledFlag = true;  }
1432  Int  getWindowTopOffset() const     { return m_enabledFlag ? m_winTopOffset : 0;     }
1433  Void setWindowTopOffset(Int val)    { m_winTopOffset = val; m_enabledFlag = true;    }
1434  Int  getWindowBottomOffset() const  { return m_enabledFlag ? m_winBottomOffset: 0;   }
1435  Void setWindowBottomOffset(Int val) { m_winBottomOffset = val; m_enabledFlag = true; }
1436
1437#if NH_MV
1438  Void          setScaledFlag(Bool flag)          { m_scaledFlag = flag;  } 
1439  Bool          getScaledFlag() const             { return m_scaledFlag;  } 
1440  Void          scaleOffsets( Int scal );
1441#endif
1442  Void setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
1443  {
1444    m_enabledFlag     = true;
1445    m_winLeftOffset   = offsetLeft;
1446    m_winRightOffset  = offsetLRight;
1447    m_winTopOffset    = offsetLTop;
1448    m_winBottomOffset = offsetLBottom;
1449  }
1450};
1451
1452
1453class TComVUI
1454{
1455private:
1456  Bool       m_aspectRatioInfoPresentFlag;
1457  Int        m_aspectRatioIdc;
1458  Int        m_sarWidth;
1459  Int        m_sarHeight;
1460  Bool       m_overscanInfoPresentFlag;
1461  Bool       m_overscanAppropriateFlag;
1462  Bool       m_videoSignalTypePresentFlag;
1463  Int        m_videoFormat;
1464  Bool       m_videoFullRangeFlag;
1465  Bool       m_colourDescriptionPresentFlag;
1466  Int        m_colourPrimaries;
1467  Int        m_transferCharacteristics;
1468  Int        m_matrixCoefficients;
1469  Bool       m_chromaLocInfoPresentFlag;
1470  Int        m_chromaSampleLocTypeTopField;
1471  Int        m_chromaSampleLocTypeBottomField;
1472  Bool       m_neutralChromaIndicationFlag;
1473  Bool       m_fieldSeqFlag;
1474  Window     m_defaultDisplayWindow;
1475  Bool       m_frameFieldInfoPresentFlag;
1476  Bool       m_hrdParametersPresentFlag;
1477  Bool       m_bitstreamRestrictionFlag;
1478  Bool       m_tilesFixedStructureFlag;
1479  Bool       m_motionVectorsOverPicBoundariesFlag;
1480  Bool       m_restrictedRefPicListsFlag;
1481  Int        m_minSpatialSegmentationIdc;
1482  Int        m_maxBytesPerPicDenom;
1483  Int        m_maxBitsPerMinCuDenom;
1484  Int        m_log2MaxMvLengthHorizontal;
1485  Int        m_log2MaxMvLengthVertical;
1486  TComHRD    m_hrdParameters;
1487  TimingInfo m_timingInfo;
1488
1489public:
1490  TComVUI()
1491    : m_aspectRatioInfoPresentFlag        (false) //TODO: This initialiser list contains magic numbers
1492    , m_aspectRatioIdc                    (0)
1493    , m_sarWidth                          (0)
1494    , m_sarHeight                         (0)
1495    , m_overscanInfoPresentFlag           (false)
1496    , m_overscanAppropriateFlag           (false)
1497    , m_videoSignalTypePresentFlag        (false)
1498    , m_videoFormat                       (5)
1499    , m_videoFullRangeFlag                (false)
1500    , m_colourDescriptionPresentFlag      (false)
1501    , m_colourPrimaries                   (2)
1502    , m_transferCharacteristics           (2)
1503    , m_matrixCoefficients                (2)
1504    , m_chromaLocInfoPresentFlag          (false)
1505    , m_chromaSampleLocTypeTopField       (0)
1506    , m_chromaSampleLocTypeBottomField    (0)
1507    , m_neutralChromaIndicationFlag       (false)
1508    , m_fieldSeqFlag                      (false)
1509    , m_frameFieldInfoPresentFlag         (false)
1510    , m_hrdParametersPresentFlag          (false)
1511    , m_bitstreamRestrictionFlag          (false)
1512    , m_tilesFixedStructureFlag           (false)
1513    , m_motionVectorsOverPicBoundariesFlag(true)
1514    , m_restrictedRefPicListsFlag         (1)
1515    , m_minSpatialSegmentationIdc         (0)
1516    , m_maxBytesPerPicDenom               (2)
1517    , m_maxBitsPerMinCuDenom              (1)
1518    , m_log2MaxMvLengthHorizontal         (15)
1519    , m_log2MaxMvLengthVertical           (15)
1520  {}
1521
1522  virtual           ~TComVUI() {}
1523
1524  Bool              getAspectRatioInfoPresentFlag() const                  { return m_aspectRatioInfoPresentFlag;           }
1525  Void              setAspectRatioInfoPresentFlag(Bool i)                  { m_aspectRatioInfoPresentFlag = i;              }
1526
1527  Int               getAspectRatioIdc() const                              { return m_aspectRatioIdc;                       }
1528  Void              setAspectRatioIdc(Int i)                               { m_aspectRatioIdc = i;                          }
1529
1530  Int               getSarWidth() const                                    { return m_sarWidth;                             }
1531  Void              setSarWidth(Int i)                                     { m_sarWidth = i;                                }
1532
1533  Int               getSarHeight() const                                   { return m_sarHeight;                            }
1534  Void              setSarHeight(Int i)                                    { m_sarHeight = i;                               }
1535
1536  Bool              getOverscanInfoPresentFlag() const                     { return m_overscanInfoPresentFlag;              }
1537  Void              setOverscanInfoPresentFlag(Bool i)                     { m_overscanInfoPresentFlag = i;                 }
1538
1539  Bool              getOverscanAppropriateFlag() const                     { return m_overscanAppropriateFlag;              }
1540  Void              setOverscanAppropriateFlag(Bool i)                     { m_overscanAppropriateFlag = i;                 }
1541
1542  Bool              getVideoSignalTypePresentFlag() const                  { return m_videoSignalTypePresentFlag;           }
1543  Void              setVideoSignalTypePresentFlag(Bool i)                  { m_videoSignalTypePresentFlag = i;              }
1544
1545  Int               getVideoFormat() const                                 { return m_videoFormat;                          }
1546  Void              setVideoFormat(Int i)                                  { m_videoFormat = i;                             }
1547
1548  Bool              getVideoFullRangeFlag() const                          { return m_videoFullRangeFlag;                   }
1549  Void              setVideoFullRangeFlag(Bool i)                          { m_videoFullRangeFlag = i;                      }
1550
1551  Bool              getColourDescriptionPresentFlag() const                { return m_colourDescriptionPresentFlag;         }
1552  Void              setColourDescriptionPresentFlag(Bool i)                { m_colourDescriptionPresentFlag = i;            }
1553
1554  Int               getColourPrimaries() const                             { return m_colourPrimaries;                      }
1555  Void              setColourPrimaries(Int i)                              { m_colourPrimaries = i;                         }
1556
1557  Int               getTransferCharacteristics() const                     { return m_transferCharacteristics;              }
1558  Void              setTransferCharacteristics(Int i)                      { m_transferCharacteristics = i;                 }
1559
1560  Int               getMatrixCoefficients() const                          { return m_matrixCoefficients;                   }
1561  Void              setMatrixCoefficients(Int i)                           { m_matrixCoefficients = i;                      }
1562
1563  Bool              getChromaLocInfoPresentFlag() const                    { return m_chromaLocInfoPresentFlag;             }
1564  Void              setChromaLocInfoPresentFlag(Bool i)                    { m_chromaLocInfoPresentFlag = i;                }
1565
1566  Int               getChromaSampleLocTypeTopField() const                 { return m_chromaSampleLocTypeTopField;          }
1567  Void              setChromaSampleLocTypeTopField(Int i)                  { m_chromaSampleLocTypeTopField = i;             }
1568
1569  Int               getChromaSampleLocTypeBottomField() const              { return m_chromaSampleLocTypeBottomField;       }
1570  Void              setChromaSampleLocTypeBottomField(Int i)               { m_chromaSampleLocTypeBottomField = i;          }
1571
1572  Bool              getNeutralChromaIndicationFlag() const                 { return m_neutralChromaIndicationFlag;          }
1573  Void              setNeutralChromaIndicationFlag(Bool i)                 { m_neutralChromaIndicationFlag = i;             }
1574
1575  Bool              getFieldSeqFlag() const                                { return m_fieldSeqFlag;                         }
1576  Void              setFieldSeqFlag(Bool i)                                { m_fieldSeqFlag = i;                            }
1577
1578  Bool              getFrameFieldInfoPresentFlag() const                   { return m_frameFieldInfoPresentFlag;            }
1579  Void              setFrameFieldInfoPresentFlag(Bool i)                   { m_frameFieldInfoPresentFlag = i;               }
1580
1581  Window&           getDefaultDisplayWindow()                              { return m_defaultDisplayWindow;                 }
1582  const Window&     getDefaultDisplayWindow() const                        { return m_defaultDisplayWindow;                 }
1583  Void              setDefaultDisplayWindow(Window& defaultDisplayWindow ) { m_defaultDisplayWindow = defaultDisplayWindow; }
1584
1585  Bool              getHrdParametersPresentFlag() const                    { return m_hrdParametersPresentFlag;             }
1586  Void              setHrdParametersPresentFlag(Bool i)                    { m_hrdParametersPresentFlag = i;                }
1587
1588  Bool              getBitstreamRestrictionFlag() const                    { return m_bitstreamRestrictionFlag;             }
1589  Void              setBitstreamRestrictionFlag(Bool i)                    { m_bitstreamRestrictionFlag = i;                }
1590
1591  Bool              getTilesFixedStructureFlag() const                     { return m_tilesFixedStructureFlag;              }
1592  Void              setTilesFixedStructureFlag(Bool i)                     { m_tilesFixedStructureFlag = i;                 }
1593
1594  Bool              getMotionVectorsOverPicBoundariesFlag() const          { return m_motionVectorsOverPicBoundariesFlag;   }
1595  Void              setMotionVectorsOverPicBoundariesFlag(Bool i)          { m_motionVectorsOverPicBoundariesFlag = i;      }
1596
1597  Bool              getRestrictedRefPicListsFlag() const                   { return m_restrictedRefPicListsFlag;            }
1598  Void              setRestrictedRefPicListsFlag(Bool b)                   { m_restrictedRefPicListsFlag = b;               }
1599
1600  Int               getMinSpatialSegmentationIdc() const                   { return m_minSpatialSegmentationIdc;            }
1601  Void              setMinSpatialSegmentationIdc(Int i)                    { m_minSpatialSegmentationIdc = i;               }
1602
1603  Int               getMaxBytesPerPicDenom() const                         { return m_maxBytesPerPicDenom;                  }
1604  Void              setMaxBytesPerPicDenom(Int i)                          { m_maxBytesPerPicDenom = i;                     }
1605
1606  Int               getMaxBitsPerMinCuDenom() const                        { return m_maxBitsPerMinCuDenom;                 }
1607  Void              setMaxBitsPerMinCuDenom(Int i)                         { m_maxBitsPerMinCuDenom = i;                    }
1608
1609  Int               getLog2MaxMvLengthHorizontal() const                   { return m_log2MaxMvLengthHorizontal;            }
1610  Void              setLog2MaxMvLengthHorizontal(Int i)                    { m_log2MaxMvLengthHorizontal = i;               }
1611
1612  Int               getLog2MaxMvLengthVertical() const                     { return m_log2MaxMvLengthVertical;              }
1613  Void              setLog2MaxMvLengthVertical(Int i)                      { m_log2MaxMvLengthVertical = i;                 }
1614
1615  TComHRD*          getHrdParameters()                                     { return &m_hrdParameters;                       }
1616  const TComHRD*    getHrdParameters()  const                              { return &m_hrdParameters;                       }
1617
1618  TimingInfo*       getTimingInfo()                                        { return &m_timingInfo;                          }
1619  const TimingInfo* getTimingInfo() const                                  { return &m_timingInfo;                          }
1620#if NH_MV
1621  Void              inferVideoSignalInfo( const TComVPS* vps, Int layerIdCurr );
1622#endif
1623};
1624
1625/// SPS RExt class
1626class TComSPSRExt // Names aligned to text specification
1627{
1628private:
1629  Bool             m_transformSkipRotationEnabledFlag;
1630  Bool             m_transformSkipContextEnabledFlag;
1631  Bool             m_rdpcmEnabledFlag[NUMBER_OF_RDPCM_SIGNALLING_MODES];
1632  Bool             m_extendedPrecisionProcessingFlag;
1633  Bool             m_intraSmoothingDisabledFlag;
1634  Bool             m_highPrecisionOffsetsEnabledFlag;
1635  Bool             m_persistentRiceAdaptationEnabledFlag;
1636  Bool             m_cabacBypassAlignmentEnabledFlag;
1637
1638public:
1639  TComSPSRExt();
1640
1641  Bool settingsDifferFromDefaults() const
1642  {
1643    return getTransformSkipRotationEnabledFlag()
1644        || getTransformSkipContextEnabledFlag()
1645        || getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT)
1646        || getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT)
1647        || getExtendedPrecisionProcessingFlag()
1648        || getIntraSmoothingDisabledFlag()
1649        || getHighPrecisionOffsetsEnabledFlag()
1650        || getPersistentRiceAdaptationEnabledFlag()
1651        || getCabacBypassAlignmentEnabledFlag();
1652  }
1653
1654
1655  Bool getTransformSkipRotationEnabledFlag() const                                     { return m_transformSkipRotationEnabledFlag;     }
1656  Void setTransformSkipRotationEnabledFlag(const Bool value)                           { m_transformSkipRotationEnabledFlag = value;    }
1657
1658  Bool getTransformSkipContextEnabledFlag() const                                      { return m_transformSkipContextEnabledFlag;      }
1659  Void setTransformSkipContextEnabledFlag(const Bool value)                            { m_transformSkipContextEnabledFlag = value;     }
1660
1661  Bool getRdpcmEnabledFlag(const RDPCMSignallingMode signallingMode) const             { return m_rdpcmEnabledFlag[signallingMode];     }
1662  Void setRdpcmEnabledFlag(const RDPCMSignallingMode signallingMode, const Bool value) { m_rdpcmEnabledFlag[signallingMode] = value;    }
1663
1664  Bool getExtendedPrecisionProcessingFlag() const                                      { return m_extendedPrecisionProcessingFlag;      }
1665  Void setExtendedPrecisionProcessingFlag(Bool value)                                  { m_extendedPrecisionProcessingFlag = value;     }
1666
1667  Bool getIntraSmoothingDisabledFlag() const                                           { return m_intraSmoothingDisabledFlag;           }
1668  Void setIntraSmoothingDisabledFlag(Bool bValue)                                      { m_intraSmoothingDisabledFlag=bValue;           }
1669
1670  Bool getHighPrecisionOffsetsEnabledFlag() const                                      { return m_highPrecisionOffsetsEnabledFlag;      }
1671  Void setHighPrecisionOffsetsEnabledFlag(Bool value)                                  { m_highPrecisionOffsetsEnabledFlag = value;     }
1672
1673  Bool getPersistentRiceAdaptationEnabledFlag() const                                  { return m_persistentRiceAdaptationEnabledFlag;  }
1674  Void setPersistentRiceAdaptationEnabledFlag(const Bool value)                        { m_persistentRiceAdaptationEnabledFlag = value; }
1675
1676  Bool getCabacBypassAlignmentEnabledFlag() const                                      { return m_cabacBypassAlignmentEnabledFlag;      }
1677  Void setCabacBypassAlignmentEnabledFlag(const Bool value)                            { m_cabacBypassAlignmentEnabledFlag = value;     }
1678};
1679
1680
1681#if NH_3D
1682class TComSps3dExtension
1683{
1684public:
1685  TComSps3dExtension()
1686  {
1687    for (Int d = 0; d < 2; d++)
1688    {
1689      m_ivMvPredFlag          [d] = false; 
1690      m_ivMvScalingFlag       [d] = false; 
1691      m_log2SubPbSizeMinus3   [d] = 3; 
1692      m_ivResPredFlag         [d] = false; 
1693      m_depthRefinementFlag   [d] = false; 
1694      m_viewSynthesisPredFlag [d] = false; 
1695      m_depthBasedBlkPartFlag [d] = false; 
1696      m_mpiFlag               [d] = false; 
1697      m_log2MpiSubPbSizeMinus3[d] = 3; 
1698      m_intraContourFlag      [d] = false; 
1699      m_intraSdcWedgeFlag     [d] = false; 
1700      m_qtPredFlag            [d] = false; 
1701      m_interSdcFlag          [d] = false; 
1702      m_depthIntraSkipFlag    [d] = false;   
1703    }
1704  }
1705
1706  Void          setIvMvPredFlag( Int d, Bool flag )         { m_ivMvPredFlag[d] = flag;             }
1707  Bool          getIvMvPredFlag( Int d ) const              { return m_ivMvPredFlag[d];             }
1708
1709  Void          setIvMvScalingFlag( Int d, Bool flag )      { m_ivMvScalingFlag[d] = flag;          }
1710  Bool          getIvMvScalingFlag( Int d ) const           { return m_ivMvScalingFlag[d];          }
1711
1712  Void          setLog2SubPbSizeMinus3( Int d, Int  val )   { m_log2SubPbSizeMinus3[d] = val;       }
1713  Int           getLog2SubPbSizeMinus3( Int d ) const       { return m_log2SubPbSizeMinus3[d];      }
1714
1715  Void          setIvResPredFlag( Int d, Bool flag )        { m_ivResPredFlag[d] = flag;            }
1716  Bool          getIvResPredFlag( Int d ) const             { return m_ivResPredFlag[d];            }
1717
1718  Void          setDepthRefinementFlag( Int d, Bool flag )  { m_depthRefinementFlag[d] = flag;      }
1719  Bool          getDepthRefinementFlag( Int d ) const       { return m_depthRefinementFlag[d];      }
1720
1721  Void          setViewSynthesisPredFlag( Int d, Bool flag ) { m_viewSynthesisPredFlag[d] = flag;   }
1722  Bool          getViewSynthesisPredFlag( Int d ) const     { return m_viewSynthesisPredFlag[d];    }
1723
1724  Void          setDepthBasedBlkPartFlag( Int d, Bool flag ) { m_depthBasedBlkPartFlag[d] = flag;   }
1725  Bool          getDepthBasedBlkPartFlag( Int d ) const     { return m_depthBasedBlkPartFlag[d];    }
1726
1727  Void          setMpiFlag( Int d, Bool flag )              { m_mpiFlag[d] = flag;                  }
1728  Bool          getMpiFlag( Int d ) const                   { return m_mpiFlag[d];                  }
1729
1730  Void          setLog2MpiSubPbSizeMinus3( Int d, Int  val ) { m_log2MpiSubPbSizeMinus3[d] = val;   }
1731  Int           getLog2MpiSubPbSizeMinus3( Int d ) const    { return m_log2MpiSubPbSizeMinus3[d];   }
1732
1733  Void          setIntraContourFlag( Int d, Bool flag )     { m_intraContourFlag[d] = flag;         }
1734  Bool          getIntraContourFlag( Int d ) const          { return m_intraContourFlag[d];         }
1735
1736  Void          setIntraSdcWedgeFlag( Int d, Bool flag )    { m_intraSdcWedgeFlag[d] = flag;        }
1737  Bool          getIntraSdcWedgeFlag( Int d ) const         { return m_intraSdcWedgeFlag[d];        }
1738
1739  Void          setQtPredFlag( Int d, Bool flag )           { m_qtPredFlag[d] = flag;               }
1740  Bool          getQtPredFlag( Int d ) const                { return m_qtPredFlag[d];               }
1741
1742  Void          setInterSdcFlag( Int d, Bool flag )         { m_interSdcFlag[d] = flag;             }
1743  Bool          getInterSdcFlag( Int d ) const              { return m_interSdcFlag[d];             }
1744
1745  Void          setDepthIntraSkipFlag( Int d, Bool flag )   { m_depthIntraSkipFlag[d] = flag;       }
1746  Bool          getDepthIntraSkipFlag( Int d ) const        { return m_depthIntraSkipFlag[d];       }
1747private:
1748
1749  Bool        m_ivMvPredFlag          [2];
1750  Bool        m_ivMvScalingFlag       [2];
1751  Int         m_log2SubPbSizeMinus3   [2];
1752  Bool        m_ivResPredFlag         [2];
1753  Bool        m_depthRefinementFlag   [2];
1754  Bool        m_viewSynthesisPredFlag [2];
1755  Bool        m_depthBasedBlkPartFlag [2];
1756  Bool        m_mpiFlag               [2];
1757  Int         m_log2MpiSubPbSizeMinus3[2];
1758  Bool        m_intraContourFlag      [2];
1759  Bool        m_intraSdcWedgeFlag     [2];
1760  Bool        m_qtPredFlag            [2];
1761  Bool        m_interSdcFlag          [2];
1762  Bool        m_depthIntraSkipFlag    [2]; 
1763};
1764
1765#endif
1766
1767
1768/// SPS class
1769class TComSPS
1770{
1771private:
1772  Int              m_SPSId;
1773  Int              m_VPSId;
1774  ChromaFormat     m_chromaFormatIdc;
1775
1776  UInt             m_uiMaxTLayers;           // maximum number of temporal layers
1777
1778  // Structure
1779  UInt             m_picWidthInLumaSamples;
1780  UInt             m_picHeightInLumaSamples;
1781
1782  Int              m_log2MinCodingBlockSize;
1783  Int              m_log2DiffMaxMinCodingBlockSize;
1784  UInt             m_uiMaxCUWidth;
1785  UInt             m_uiMaxCUHeight;
1786  UInt             m_uiMaxTotalCUDepth; ///< Total CU depth, relative to the smallest possible transform block size.
1787
1788  Window           m_conformanceWindow;
1789
1790  TComRPSList      m_RPSList;
1791  Bool             m_bLongTermRefsPresent;
1792  Bool             m_TMVPFlagsPresent;
1793  Int              m_numReorderPics[MAX_TLAYER];
1794
1795  // Tool list
1796  UInt             m_uiQuadtreeTULog2MaxSize;
1797  UInt             m_uiQuadtreeTULog2MinSize;
1798  UInt             m_uiQuadtreeTUMaxDepthInter;
1799  UInt             m_uiQuadtreeTUMaxDepthIntra;
1800  Bool             m_usePCM;
1801  UInt             m_pcmLog2MaxSize;
1802  UInt             m_uiPCMLog2MinSize;
1803  Bool             m_useAMP;
1804
1805  // Parameter
1806  BitDepths        m_bitDepths;
1807  Int              m_qpBDOffset[MAX_NUM_CHANNEL_TYPE];
1808  Int              m_pcmBitDepths[MAX_NUM_CHANNEL_TYPE];
1809  Bool             m_bPCMFilterDisableFlag;
1810
1811  UInt             m_uiBitsForPOC;
1812  UInt             m_numLongTermRefPicSPS;
1813  UInt             m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
1814  Bool             m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS];
1815  // Max physical transform size
1816  UInt             m_uiMaxTrSize;
1817
1818  Bool             m_bUseSAO;
1819
1820  Bool             m_bTemporalIdNestingFlag; // temporal_id_nesting_flag
1821
1822  Bool             m_scalingListEnabledFlag;
1823  Bool             m_scalingListPresentFlag;
1824  TComScalingList  m_scalingList;
1825  UInt             m_uiMaxDecPicBuffering[MAX_TLAYER];
1826  UInt             m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
1827
1828  Bool             m_useStrongIntraSmoothing;
1829
1830  Bool             m_vuiParametersPresentFlag;
1831  TComVUI          m_vuiParameters;
1832
1833  TComSPSRExt      m_spsRangeExtension;
1834
1835  static const Int m_winUnitX[NUM_CHROMA_FORMAT];
1836  static const Int m_winUnitY[NUM_CHROMA_FORMAT];
1837  TComPTL          m_pcPTL;
1838
1839#if O0043_BEST_EFFORT_DECODING
1840  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)
1841#endif
1842#if NH_MV
1843  TComVPS*         m_pcVPS; 
1844  // SPS           
1845  Int              m_spsMaxSubLayersMinus1;
1846  Int              m_spsExtOrMaxSubLayersMinus1;
1847  Bool             m_spsExtensionPresentFlag; 
1848                   
1849  Bool             m_spsRangeExtensionsFlag;
1850  Bool             m_spsMultilayerExtensionFlag;
1851
1852  Bool             m_sps3dExtensionFlag;
1853  Int              m_spsExtension5bits;
1854
1855  Bool             m_spsInferScalingListFlag;
1856  Int              m_spsScalingListRefLayerId;
1857  Bool             m_updateRepFormatFlag;
1858  Int              m_spsRepFormatIdx;
1859  // SPS Extension
1860  Bool             m_interViewMvVertConstraintFlag;
1861#endif
1862#if NH_3D
1863  TComSps3dExtension m_sps3dExtension; 
1864  Int              m_aaiCodedScale [2][MAX_NUM_LAYERS];
1865  Int              m_aaiCodedOffset[2][MAX_NUM_LAYERS];
1866#endif             
1867#if NH_MV           
1868  Int              m_layerId; 
1869#endif
1870
1871public:
1872                         TComSPS();
1873  virtual                ~TComSPS();
1874#if O0043_BEST_EFFORT_DECODING
1875  Void                   setForceDecodeBitDepth(UInt bitDepth)                                           { m_forceDecodeBitDepth = bitDepth;                                    }
1876  UInt                   getForceDecodeBitDepth()        const                                           { return m_forceDecodeBitDepth;                                        }
1877#endif
1878
1879  Int                    getVPSId() const                                                                { return m_VPSId;                                                      }
1880  Void                   setVPSId(Int i)                                                                 { m_VPSId = i;                                                         }
1881  Int                    getSPSId() const                                                                { return m_SPSId;                                                      }
1882  Void                   setSPSId(Int i)                                                                 { m_SPSId = i;                                                         }
1883  ChromaFormat           getChromaFormatIdc () const                                                     { return m_chromaFormatIdc;                                            }
1884  Void                   setChromaFormatIdc (ChromaFormat i)                                             { m_chromaFormatIdc = i;                                               }
1885
1886  static Int             getWinUnitX (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitX[chromaFormatIdc]; }
1887  static Int             getWinUnitY (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitY[chromaFormatIdc]; }
1888
1889  // structure
1890  Void                   setPicWidthInLumaSamples( UInt u )                                              { m_picWidthInLumaSamples = u;                                         }
1891  UInt                   getPicWidthInLumaSamples() const                                                { return  m_picWidthInLumaSamples;                                     }
1892  Void                   setPicHeightInLumaSamples( UInt u )                                             { m_picHeightInLumaSamples = u;                                        }
1893  UInt                   getPicHeightInLumaSamples() const                                               { return  m_picHeightInLumaSamples;                                    }
1894
1895  Window&                getConformanceWindow()                                                          { return  m_conformanceWindow;                                         }
1896  const Window&          getConformanceWindow() const                                                    { return  m_conformanceWindow;                                         }
1897  Void                   setConformanceWindow(Window& conformanceWindow )                                { m_conformanceWindow = conformanceWindow;                             }
1898
1899  UInt                   getNumLongTermRefPicSPS() const                                                 { return m_numLongTermRefPicSPS;                                       }
1900  Void                   setNumLongTermRefPicSPS(UInt val)                                               { m_numLongTermRefPicSPS = val;                                        }
1901
1902  UInt                   getLtRefPicPocLsbSps(UInt index) const                                          { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); return m_ltRefPicPocLsbSps[index]; }
1903  Void                   setLtRefPicPocLsbSps(UInt index, UInt val)                                      { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); m_ltRefPicPocLsbSps[index] = val;  }
1904
1905  Bool                   getUsedByCurrPicLtSPSFlag(Int i) const                                          { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); return m_usedByCurrPicLtSPSFlag[i];    }
1906  Void                   setUsedByCurrPicLtSPSFlag(Int i, Bool x)                                        { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); m_usedByCurrPicLtSPSFlag[i] = x;       }
1907
1908  Int                    getLog2MinCodingBlockSize() const                                               { return m_log2MinCodingBlockSize;                                     }
1909  Void                   setLog2MinCodingBlockSize(Int val)                                              { m_log2MinCodingBlockSize = val;                                      }
1910  Int                    getLog2DiffMaxMinCodingBlockSize() const                                        { return m_log2DiffMaxMinCodingBlockSize;                              }
1911  Void                   setLog2DiffMaxMinCodingBlockSize(Int val)                                       { m_log2DiffMaxMinCodingBlockSize = val;                               }
1912
1913  Void                   setMaxCUWidth( UInt u )                                                         { m_uiMaxCUWidth = u;                                                  }
1914  UInt                   getMaxCUWidth() const                                                           { return  m_uiMaxCUWidth;                                              }
1915  Void                   setMaxCUHeight( UInt u )                                                        { m_uiMaxCUHeight = u;                                                 }
1916  UInt                   getMaxCUHeight() const                                                          { return  m_uiMaxCUHeight;                                             }
1917  Void                   setMaxTotalCUDepth( UInt u )                                                    { m_uiMaxTotalCUDepth = u;                                             }
1918  UInt                   getMaxTotalCUDepth() const                                                      { return  m_uiMaxTotalCUDepth;                                         }
1919  Void                   setUsePCM( Bool b )                                                             { m_usePCM = b;                                                        }
1920  Bool                   getUsePCM() const                                                               { return m_usePCM;                                                     }
1921  Void                   setPCMLog2MaxSize( UInt u )                                                     { m_pcmLog2MaxSize = u;                                                }
1922  UInt                   getPCMLog2MaxSize() const                                                       { return  m_pcmLog2MaxSize;                                            }
1923  Void                   setPCMLog2MinSize( UInt u )                                                     { m_uiPCMLog2MinSize = u;                                              }
1924  UInt                   getPCMLog2MinSize() const                                                       { return  m_uiPCMLog2MinSize;                                          }
1925  Void                   setBitsForPOC( UInt u )                                                         { m_uiBitsForPOC = u;                                                  }
1926  UInt                   getBitsForPOC() const                                                           { return m_uiBitsForPOC;                                               }
1927  Bool                   getUseAMP() const                                                               { return m_useAMP;                                                     }
1928  Void                   setUseAMP( Bool b )                                                             { m_useAMP = b;                                                        }
1929  Void                   setQuadtreeTULog2MaxSize( UInt u )                                              { m_uiQuadtreeTULog2MaxSize = u;                                       }
1930  UInt                   getQuadtreeTULog2MaxSize() const                                                { return m_uiQuadtreeTULog2MaxSize;                                    }
1931  Void                   setQuadtreeTULog2MinSize( UInt u )                                              { m_uiQuadtreeTULog2MinSize = u;                                       }
1932  UInt                   getQuadtreeTULog2MinSize() const                                                { return m_uiQuadtreeTULog2MinSize;                                    }
1933  Void                   setQuadtreeTUMaxDepthInter( UInt u )                                            { m_uiQuadtreeTUMaxDepthInter = u;                                     }
1934  Void                   setQuadtreeTUMaxDepthIntra( UInt u )                                            { m_uiQuadtreeTUMaxDepthIntra = u;                                     }
1935  UInt                   getQuadtreeTUMaxDepthInter() const                                              { return m_uiQuadtreeTUMaxDepthInter;                                  }
1936  UInt                   getQuadtreeTUMaxDepthIntra() const                                              { return m_uiQuadtreeTUMaxDepthIntra;                                  }
1937  Void                   setNumReorderPics(Int i, UInt tlayer)                                           { m_numReorderPics[tlayer] = i;                                        }
1938  Int                    getNumReorderPics(UInt tlayer) const                                            { return m_numReorderPics[tlayer];                                     }
1939  Void                   createRPSList( Int numRPS );
1940  const TComRPSList*     getRPSList() const                                                              { return &m_RPSList;                                                   }
1941  TComRPSList*           getRPSList()                                                                    { return &m_RPSList;                                                   }
1942  Bool                   getLongTermRefsPresent() const                                                  { return m_bLongTermRefsPresent;                                       }
1943  Void                   setLongTermRefsPresent(Bool b)                                                  { m_bLongTermRefsPresent=b;                                            }
1944  Bool                   getTMVPFlagsPresent() const                                                     { return m_TMVPFlagsPresent;                                           }
1945  Void                   setTMVPFlagsPresent(Bool b)                                                     { m_TMVPFlagsPresent=b;                                                }
1946  // physical transform
1947  Void                   setMaxTrSize( UInt u )                                                          { m_uiMaxTrSize = u;                                                   }
1948  UInt                   getMaxTrSize() const                                                            { return  m_uiMaxTrSize;                                               }
1949
1950  // Bit-depth
1951  Int                    getBitDepth(ChannelType type) const                                             { return m_bitDepths.recon[type];                                      }
1952  Void                   setBitDepth(ChannelType type, Int u )                                           { m_bitDepths.recon[type] = u;                                         }
1953#if O0043_BEST_EFFORT_DECODING
1954  Int                    getStreamBitDepth(ChannelType type) const                                       { return m_bitDepths.stream[type];                                     }
1955  Void                   setStreamBitDepth(ChannelType type, Int u )                                     { m_bitDepths.stream[type] = u;                                        }
1956#endif
1957  const BitDepths&       getBitDepths() const                                                            { return m_bitDepths;                                                  }
1958  Int                    getMaxLog2TrDynamicRange(ChannelType channelType) const                         { return getSpsRangeExtension().getExtendedPrecisionProcessingFlag() ? std::max<Int>(15, Int(m_bitDepths.recon[channelType] + 6)) : 15; }
1959
1960  Int                    getDifferentialLumaChromaBitDepth() const                                       { return Int(m_bitDepths.recon[CHANNEL_TYPE_LUMA]) - Int(m_bitDepths.recon[CHANNEL_TYPE_CHROMA]); }
1961  Int                    getQpBDOffset(ChannelType type) const                                           { return m_qpBDOffset[type];                                           }
1962  Void                   setQpBDOffset(ChannelType type, Int i)                                          { m_qpBDOffset[type] = i;                                              }
1963
1964  Void                   setUseSAO(Bool bVal)                                                            { m_bUseSAO = bVal;                                                    }
1965  Bool                   getUseSAO() const                                                               { return m_bUseSAO;                                                    }
1966
1967  UInt                   getMaxTLayers() const                                                           { return m_uiMaxTLayers; }
1968  Void                   setMaxTLayers( UInt uiMaxTLayers )                                              { assert( uiMaxTLayers <= MAX_TLAYER ); m_uiMaxTLayers = uiMaxTLayers; }
1969
1970  Bool                   getTemporalIdNestingFlag() const                                                { return m_bTemporalIdNestingFlag;                                     }
1971  Void                   setTemporalIdNestingFlag( Bool bValue )                                         { m_bTemporalIdNestingFlag = bValue;                                   }
1972  UInt                   getPCMBitDepth(ChannelType type) const                                          { return m_pcmBitDepths[type];                                         }
1973  Void                   setPCMBitDepth(ChannelType type, UInt u)                                        { m_pcmBitDepths[type] = u;                                            }
1974  Void                   setPCMFilterDisableFlag( Bool bValue )                                          { m_bPCMFilterDisableFlag = bValue;                                    }
1975  Bool                   getPCMFilterDisableFlag() const                                                 { return m_bPCMFilterDisableFlag;                                      }
1976
1977  Bool                   getScalingListFlag() const                                                      { return m_scalingListEnabledFlag;                                     }
1978  Void                   setScalingListFlag( Bool b )                                                    { m_scalingListEnabledFlag  = b;                                       }
1979  Bool                   getScalingListPresentFlag() const                                               { return m_scalingListPresentFlag;                                     }
1980  Void                   setScalingListPresentFlag( Bool b )                                             { m_scalingListPresentFlag  = b;                                       }
1981  Void                   setScalingList( TComScalingList *scalingList);
1982  TComScalingList&       getScalingList()                                                                { return m_scalingList;                                                }
1983  const TComScalingList& getScalingList() const                                                          { return m_scalingList;                                                }
1984  UInt                   getMaxDecPicBuffering(UInt tlayer) const                                        { return m_uiMaxDecPicBuffering[tlayer];                               }
1985  Void                   setMaxDecPicBuffering( UInt ui, UInt tlayer )                                   { assert(tlayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tlayer] = ui;    }
1986  UInt                   getMaxLatencyIncrease(UInt tlayer) const                                        { return m_uiMaxLatencyIncrease[tlayer];                               }
1987  Void                   setMaxLatencyIncrease( UInt ui , UInt tlayer)                                   { m_uiMaxLatencyIncrease[tlayer] = ui;                                 }
1988
1989  Void                   setUseStrongIntraSmoothing(Bool bVal)                                           { m_useStrongIntraSmoothing = bVal;                                    }
1990  Bool                   getUseStrongIntraSmoothing() const                                              { return m_useStrongIntraSmoothing;                                    }
1991
1992  Bool                   getVuiParametersPresentFlag() const                                             { return m_vuiParametersPresentFlag;                                   }
1993  Void                   setVuiParametersPresentFlag(Bool b)                                             { m_vuiParametersPresentFlag = b;                                      }
1994  TComVUI*               getVuiParameters()                                                              { return &m_vuiParameters;                                             }
1995  const TComVUI*         getVuiParameters() const                                                        { return &m_vuiParameters;                                             }
1996  const TComPTL*         getPTL() const                                                                  { return &m_pcPTL;                                                     }
1997  TComPTL*               getPTL()                                                                        { return &m_pcPTL;                                                     }
1998
1999  const TComSPSRExt&     getSpsRangeExtension() const                                                    { return m_spsRangeExtension;                                          }
2000  TComSPSRExt&           getSpsRangeExtension()                                                          { return m_spsRangeExtension;                                          }
2001
2002  // Sequence parameter set range extension syntax
2003  // WAS: getUseResidualRotation and setUseResidualRotation
2004  // Now getSpsRangeExtension().getTransformSkipRotationEnabledFlag and getSpsRangeExtension().setTransformSkipRotationEnabledFlag
2005
2006  // WAS: getUseSingleSignificanceMapContext and setUseSingleSignificanceMapContext
2007  // Now: getSpsRangeExtension().getTransformSkipContextEnabledFlag and getSpsRangeExtension().setTransformSkipContextEnabledFlag
2008
2009  // WAS: getUseResidualDPCM and setUseResidualDPCM
2010  // Now: getSpsRangeExtension().getRdpcmEnabledFlag and getSpsRangeExtension().setRdpcmEnabledFlag and
2011
2012  // WAS: getUseExtendedPrecision and setUseExtendedPrecision
2013  // Now: getSpsRangeExtension().getExtendedPrecisionProcessingFlag and getSpsRangeExtension().setExtendedPrecisionProcessingFlag
2014
2015  // WAS: getDisableIntraReferenceSmoothing and setDisableIntraReferenceSmoothing
2016  // Now: getSpsRangeExtension().getIntraSmoothingDisabledFlag and getSpsRangeExtension().setIntraSmoothingDisabledFlag
2017
2018  // WAS: getUseHighPrecisionPredictionWeighting and setUseHighPrecisionPredictionWeighting
2019  // Now: getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag and getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag
2020
2021  // WAS: getUseGolombRiceParameterAdaptation and setUseGolombRiceParameterAdaptation
2022  // Now: getSpsRangeExtension().getPersistentRiceAdaptationEnabledFlag and getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag
2023
2024  // WAS: getAlignCABACBeforeBypass and setAlignCABACBeforeBypass
2025  // Now: getSpsRangeExtension().getCabacBypassAlignmentEnabledFlag and getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag
2026
2027
2028#if NH_MV
2029
2030  UInt                   getSpsMaxSubLayersMinus1() const                                                { return ( m_uiMaxTLayers - 1);                                        }
2031  Void                   setSpsMaxSubLayersMinus1( UInt val )                                            { setMaxTLayers( val + 1 );                                            }
2032
2033  Void                   setSpsExtOrMaxSubLayersMinus1( Int  val )                                       { m_spsExtOrMaxSubLayersMinus1 = val;                                  }
2034  Int                    getSpsExtOrMaxSubLayersMinus1(  )         const                                 { return m_spsExtOrMaxSubLayersMinus1;                                 }
2035  Void                   inferSpsMaxSubLayersMinus1( Bool atPsActivation, TComVPS* vps  );                                                                                     
2036                                                                                                                                                                               
2037  Bool                   getMultiLayerExtSpsFlag()            const { return ( getLayerId() != 0  &&  getSpsExtOrMaxSubLayersMinus1() == 7 );                                   }
2038  Void                   inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder );                                             
2039                                                                                                                                                                               
2040  Void                   setSpsExtensionPresentFlag( Bool flag )                                         { m_spsExtensionPresentFlag = flag;                                    }
2041  Bool                   getSpsExtensionPresentFlag( )           const                                   { return m_spsExtensionPresentFlag;                                    }
2042                                                                                                                                                                               
2043  Void                   setSpsRangeExtensionsFlag( Bool flag )                                          { m_spsRangeExtensionsFlag = flag;                                     }
2044  Bool                   getSpsRangeExtensionsFlag(  )                     const                         { return m_spsRangeExtensionsFlag;                                     }
2045                                                                                                                                                                               
2046  Void                   setSpsMultilayerExtensionFlag( Bool flag )                                      { m_spsMultilayerExtensionFlag = flag;                                 }
2047  Bool                   getSpsMultilayerExtensionFlag( )                  const                         { return m_spsMultilayerExtensionFlag;                                 }
2048
2049  Void                   setSps3dExtensionFlag( Bool flag )                                              { m_sps3dExtensionFlag = flag;                                         }
2050  Bool                   getSps3dExtensionFlag(  )                         const                         { return m_sps3dExtensionFlag;                                         }
2051                                                                                                                                                                               
2052  Void                   setSpsExtension5bits( Int  val )                                                { m_spsExtension5bits = val;                                           }
2053  Int                    getSpsExtension5bits(  )                          const                         { return m_spsExtension5bits;                                          }
2054                                                                                                                                                                               
2055  Void                   setVPS          ( TComVPS* pcVPS )                                              { m_pcVPS = pcVPS;                                                     }
2056  TComVPS*               getVPS          ()                 const                                        { return m_pcVPS;                                                      }
2057                                                                                                                                                                               
2058  Void                   setSpsInferScalingListFlag( Bool flag )                                         { m_spsInferScalingListFlag = flag;                                    }
2059  Bool                   getSpsInferScalingListFlag(  )          const                                   { return m_spsInferScalingListFlag;                                    }
2060                                                                                                                                                                               
2061  Void                   setSpsScalingListRefLayerId( Int  val )                                         { m_spsScalingListRefLayerId = val;                                    }
2062  Int                    getSpsScalingListRefLayerId(  )         const                                   { return m_spsScalingListRefLayerId;                                   }
2063                                                                                                                                                                               
2064  Void                   setUpdateRepFormatFlag( Bool flag )                                             { m_updateRepFormatFlag = flag;                                        }
2065  Bool                   getUpdateRepFormatFlag(  )              const                                   { return m_updateRepFormatFlag;                                        }
2066 
2067  Void                   setSpsRepFormatIdx( Int  val )                                                  { m_spsRepFormatIdx = val;                                             }
2068  Int                    getSpsRepFormatIdx(  )                  const                                   { return m_spsRepFormatIdx;                                            }
2069                                                                                                                                                                               
2070// SPS Extension                                                                                                                                                               
2071  Void                   setInterViewMvVertConstraintFlag(Bool val)                                      { m_interViewMvVertConstraintFlag = val;                               }
2072  Bool                   getInterViewMvVertConstraintFlag()         const                                { return m_interViewMvVertConstraintFlag;                              }
2073                                                                                                                                                                               
2074#if NH_3D
2075  Void                   setSps3dExtension ( TComSps3dExtension& sps3dExtension )                        { m_sps3dExtension = sps3dExtension;                                   }
2076  const TComSps3dExtension* getSps3dExtension ( )  const                                                 { return &m_sps3dExtension;                                            } 
2077#endif                 
2078                       
2079  // Inference         
2080                       
2081  Void                   inferRepFormat( TComVPS* vps, Int layerIdCurr, Bool encoder );
2082  Void                   inferScalingList( const TComSPS* spsSrc );
2083                       
2084  // others             
2085  Void                   checkRpsMaxNumPics( const TComVPS* vps, Int currLayerId ) const;
2086                       
2087  Int                    getLayerId            ()           const                                        { return m_layerId;                                                    }
2088  Void                   setLayerId            ( Int val )                                               { m_layerId = val;                                                     }
2089
2090#endif
2091
2092};
2093
2094
2095/// Reference Picture Lists class
2096
2097class TComRefPicListModification
2098{
2099private:
2100  Bool m_refPicListModificationFlagL0;
2101  Bool m_refPicListModificationFlagL1;
2102  UInt m_RefPicSetIdxL0[REF_PIC_LIST_NUM_IDX];
2103  UInt m_RefPicSetIdxL1[REF_PIC_LIST_NUM_IDX];
2104
2105public:
2106          TComRefPicListModification();
2107  virtual ~TComRefPicListModification();
2108
2109  Void    create();
2110  Void    destroy();
2111
2112  Bool    getRefPicListModificationFlagL0() const        { return m_refPicListModificationFlagL0;                                  }
2113  Void    setRefPicListModificationFlagL0(Bool flag)     { m_refPicListModificationFlagL0 = flag;                                  }
2114  Bool    getRefPicListModificationFlagL1() const        { return m_refPicListModificationFlagL1;                                  }
2115  Void    setRefPicListModificationFlagL1(Bool flag)     { m_refPicListModificationFlagL1 = flag;                                  }
2116  UInt    getRefPicSetIdxL0(UInt idx) const              { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL0[idx];         }
2117  Void    setRefPicSetIdxL0(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL0[idx] = refPicSetIdx; }
2118  UInt    getRefPicSetIdxL1(UInt idx) const              { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL1[idx];         }
2119  Void    setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
2120#if NH_MV
2121  // Why not a listIdx for all members, would avoid code duplication??
2122  Void    setRefPicSetIdxL(UInt li, UInt idx, UInt refPicSetIdx) {( li==0 ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ) = refPicSetIdx;              }
2123  UInt    getRefPicSetIdxL(UInt li, UInt idx )                   { return ( li == 0 ) ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ;                  }
2124  Void    setRefPicListModificationFlagL(UInt li, Bool flag)     { ( li==0  ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1 ) = flag;  }
2125  Bool    getRefPicListModificationFlagL(UInt li )               { return ( li== 0) ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1;   }
2126#endif
2127};
2128
2129/// PPS RExt class
2130class TComPPSRExt // Names aligned to text specification
2131{
2132private:
2133  Int              m_log2MaxTransformSkipBlockSize;
2134  Bool             m_crossComponentPredictionEnabledFlag;
2135
2136  // Chroma QP Adjustments
2137  Int              m_diffCuChromaQpOffsetDepth;
2138  Int              m_chromaQpOffsetListLen; // size (excludes the null entry used in the following array).
2139  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
2140
2141  UInt             m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE];
2142
2143public:
2144  TComPPSRExt();
2145
2146  Bool settingsDifferFromDefaults(const bool bTransformSkipEnabledFlag) const
2147  {
2148    return (bTransformSkipEnabledFlag && (getLog2MaxTransformSkipBlockSize() !=2))
2149        || (getCrossComponentPredictionEnabledFlag() )
2150        || (getChromaQpOffsetListEnabledFlag() )
2151        || (getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA) !=0 )
2152        || (getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) !=0 );
2153  }
2154
2155  UInt                   getLog2MaxTransformSkipBlockSize() const                         { return m_log2MaxTransformSkipBlockSize;         }
2156  Void                   setLog2MaxTransformSkipBlockSize( UInt u )                       { m_log2MaxTransformSkipBlockSize  = u;           }
2157
2158  Bool                   getCrossComponentPredictionEnabledFlag() const                   { return m_crossComponentPredictionEnabledFlag;   }
2159  Void                   setCrossComponentPredictionEnabledFlag(Bool value)               { m_crossComponentPredictionEnabledFlag = value;  }
2160
2161  Void                   clearChromaQpOffsetList()                                        { m_chromaQpOffsetListLen = 0;                    }
2162
2163  UInt                   getDiffCuChromaQpOffsetDepth () const                            { return m_diffCuChromaQpOffsetDepth;             }
2164  Void                   setDiffCuChromaQpOffsetDepth ( UInt u )                          { m_diffCuChromaQpOffsetDepth = u;                }
2165
2166  Bool                   getChromaQpOffsetListEnabledFlag() const                         { return getChromaQpOffsetListLen()>0;            }
2167  Int                    getChromaQpOffsetListLen() const                                 { return m_chromaQpOffsetListLen;                 }
2168
2169  const ChromaQpAdj&     getChromaQpOffsetListEntry( Int cuChromaQpOffsetIdxPlus1 ) const
2170  {
2171    assert(cuChromaQpOffsetIdxPlus1 < m_chromaQpOffsetListLen+1);
2172    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
2173  }
2174
2175  Void                   setChromaQpOffsetListEntry( Int cuChromaQpOffsetIdxPlus1, Int cbOffset, Int crOffset )
2176  {
2177    assert (cuChromaQpOffsetIdxPlus1 != 0 && cuChromaQpOffsetIdxPlus1 <= MAX_QP_OFFSET_LIST_SIZE);
2178    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
2179    m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset;
2180    m_chromaQpOffsetListLen = max(m_chromaQpOffsetListLen, cuChromaQpOffsetIdxPlus1);
2181  }
2182
2183  // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale
2184  UInt                   getLog2SaoOffsetScale(ChannelType type) const                    { return m_log2SaoOffsetScale[type];             }
2185  Void                   setLog2SaoOffsetScale(ChannelType type, UInt uiBitShift)         { m_log2SaoOffsetScale[type] = uiBitShift;       }
2186
2187};
2188
2189
2190/// PPS class
2191class TComPPS
2192{
2193private:
2194  Int              m_PPSId;                    // pic_parameter_set_id
2195  Int              m_SPSId;                    // seq_parameter_set_id
2196  Int              m_picInitQPMinus26;
2197  Bool             m_useDQP;
2198  Bool             m_bConstrainedIntraPred;    // constrained_intra_pred_flag
2199  Bool             m_bSliceChromaQpFlag;       // slicelevel_chroma_qp_flag
2200
2201  // access channel
2202  UInt             m_uiMaxCuDQPDepth;
2203
2204  Int              m_chromaCbQpOffset;
2205  Int              m_chromaCrQpOffset;
2206
2207  UInt             m_numRefIdxL0DefaultActive;
2208  UInt             m_numRefIdxL1DefaultActive;
2209
2210  Bool             m_bUseWeightPred;                    //!< Use of Weighting Prediction (P_SLICE)
2211  Bool             m_useWeightedBiPred;                 //!< Use of Weighting Bi-Prediction (B_SLICE)
2212  Bool             m_OutputFlagPresentFlag;             //!< Indicates the presence of output_flag in slice header
2213  Bool             m_TransquantBypassEnableFlag;        //!< Indicates presence of cu_transquant_bypass_flag in CUs.
2214  Bool             m_useTransformSkip;
2215  Bool             m_dependentSliceSegmentsEnabledFlag; //!< Indicates the presence of dependent slices
2216  Bool             m_tilesEnabledFlag;                  //!< Indicates the presence of tiles
2217  Bool             m_entropyCodingSyncEnabledFlag;      //!< Indicates the presence of wavefronts
2218
2219  Bool             m_loopFilterAcrossTilesEnabledFlag;
2220  Bool             m_uniformSpacingFlag;
2221  Int              m_numTileColumnsMinus1;
2222  Int              m_numTileRowsMinus1;
2223  std::vector<Int> m_tileColumnWidth;
2224  std::vector<Int> m_tileRowHeight;
2225
2226  Bool             m_signHideFlag;
2227
2228  Bool             m_cabacInitPresentFlag;
2229
2230  Bool             m_sliceHeaderExtensionPresentFlag;
2231  Bool             m_loopFilterAcrossSlicesEnabledFlag;
2232  Bool             m_deblockingFilterControlPresentFlag;
2233  Bool             m_deblockingFilterOverrideEnabledFlag;
2234  Bool             m_picDisableDeblockingFilterFlag;
2235  Int              m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
2236  Int              m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
2237  Bool             m_scalingListPresentFlag;
2238  TComScalingList  m_scalingList;                       //!< ScalingList class
2239  Bool             m_listsModificationPresentFlag;
2240  UInt             m_log2ParallelMergeLevelMinus2;
2241  Int              m_numExtraSliceHeaderBits;
2242
2243  TComPPSRExt      m_ppsRangeExtension;
2244
2245#if NH_MV
2246  Int              m_layerId; 
2247  Bool             m_ppsInferScalingListFlag;
2248  Int              m_ppsScalingListRefLayerId;
2249                   
2250  Bool             m_ppsRangeExtensionsFlag;
2251  Bool             m_ppsMultilayerExtensionFlag;
2252  Bool             m_pps3dExtensionFlag;
2253  Int              m_ppsExtension5bits;
2254
2255  Bool             m_pocResetInfoPresentFlag;
2256#endif
2257
2258#if H_3D
2259  TComDLT*         m_pcDLT; 
2260#endif
2261
2262public:
2263                         TComPPS();
2264  virtual                ~TComPPS();
2265
2266  Int                    getPPSId() const                                                 { return m_PPSId;                               }
2267  Void                   setPPSId(Int i)                                                  { m_PPSId = i;                                  }
2268  Int                    getSPSId() const                                                 { return m_SPSId;                               }
2269  Void                   setSPSId(Int i)                                                  { m_SPSId = i;                                  }
2270
2271  Int                    getPicInitQPMinus26() const                                      { return  m_picInitQPMinus26;                   }
2272  Void                   setPicInitQPMinus26( Int i )                                     { m_picInitQPMinus26 = i;                       }
2273  Bool                   getUseDQP() const                                                { return m_useDQP;                              }
2274  Void                   setUseDQP( Bool b )                                              { m_useDQP   = b;                               }
2275  Bool                   getConstrainedIntraPred() const                                  { return  m_bConstrainedIntraPred;              }
2276  Void                   setConstrainedIntraPred( Bool b )                                { m_bConstrainedIntraPred = b;                  }
2277  Bool                   getSliceChromaQpFlag() const                                     { return  m_bSliceChromaQpFlag;                 }
2278  Void                   setSliceChromaQpFlag( Bool b )                                   { m_bSliceChromaQpFlag = b;                     }
2279
2280  Void                   setMaxCuDQPDepth( UInt u )                                       { m_uiMaxCuDQPDepth = u;                        }
2281  UInt                   getMaxCuDQPDepth() const                                         { return m_uiMaxCuDQPDepth;                     }
2282
2283#if H_3D
2284  Void                   setDLT( TComDLT* pcDLT )                                         { m_pcDLT = pcDLT;                             }
2285  TComDLT*               getDLT()                                                         { return m_pcDLT;                              }
2286#endif
2287
2288
2289  Void                   setQpOffset(ComponentID compID, Int i )
2290  {
2291    if      (compID==COMPONENT_Cb)
2292    {
2293      m_chromaCbQpOffset = i;
2294    }
2295    else if (compID==COMPONENT_Cr)
2296    {
2297      m_chromaCrQpOffset = i;
2298    }
2299    else
2300    {
2301      assert(0);
2302    }
2303  }
2304  Int                    getQpOffset(ComponentID compID) const
2305  {
2306    return (compID==COMPONENT_Y) ? 0 : (compID==COMPONENT_Cb ? m_chromaCbQpOffset : m_chromaCrQpOffset );
2307  }
2308
2309  Void                   setNumRefIdxL0DefaultActive(UInt ui)                             { m_numRefIdxL0DefaultActive=ui;                }
2310  UInt                   getNumRefIdxL0DefaultActive() const                              { return m_numRefIdxL0DefaultActive;            }
2311  Void                   setNumRefIdxL1DefaultActive(UInt ui)                             { m_numRefIdxL1DefaultActive=ui;                }
2312  UInt                   getNumRefIdxL1DefaultActive() const                              { return m_numRefIdxL1DefaultActive;            }
2313
2314  Bool                   getUseWP() const                                                 { return m_bUseWeightPred;                      }
2315  Bool                   getWPBiPred() const                                              { return m_useWeightedBiPred;                   }
2316  Void                   setUseWP( Bool b )                                               { m_bUseWeightPred = b;                         }
2317  Void                   setWPBiPred( Bool b )                                            { m_useWeightedBiPred = b;                      }
2318
2319  Void                   setOutputFlagPresentFlag( Bool b )                               { m_OutputFlagPresentFlag = b;                  }
2320  Bool                   getOutputFlagPresentFlag() const                                 { return m_OutputFlagPresentFlag;               }
2321  Void                   setTransquantBypassEnableFlag( Bool b )                          { m_TransquantBypassEnableFlag = b;             }
2322  Bool                   getTransquantBypassEnableFlag() const                            { return m_TransquantBypassEnableFlag;          }
2323
2324  Bool                   getUseTransformSkip() const                                      { return m_useTransformSkip;                    }
2325  Void                   setUseTransformSkip( Bool b )                                    { m_useTransformSkip  = b;                      }
2326
2327  Void                   setLoopFilterAcrossTilesEnabledFlag(Bool b)                      { m_loopFilterAcrossTilesEnabledFlag = b;       }
2328  Bool                   getLoopFilterAcrossTilesEnabledFlag() const                      { return m_loopFilterAcrossTilesEnabledFlag;    }
2329  Bool                   getDependentSliceSegmentsEnabledFlag() const                     { return m_dependentSliceSegmentsEnabledFlag;   }
2330  Void                   setDependentSliceSegmentsEnabledFlag(Bool val)                   { m_dependentSliceSegmentsEnabledFlag = val;    }
2331  Bool                   getEntropyCodingSyncEnabledFlag() const                          { return m_entropyCodingSyncEnabledFlag;        }
2332  Void                   setEntropyCodingSyncEnabledFlag(Bool val)                        { m_entropyCodingSyncEnabledFlag = val;         }
2333
2334  Void                   setTilesEnabledFlag(Bool val)                                    { m_tilesEnabledFlag = val;                     }
2335  Bool                   getTilesEnabledFlag() const                                      { return m_tilesEnabledFlag;                    }
2336  Void                   setTileUniformSpacingFlag(Bool b)                                { m_uniformSpacingFlag = b;                     }
2337  Bool                   getTileUniformSpacingFlag() const                                { return m_uniformSpacingFlag;                  }
2338  Void                   setNumTileColumnsMinus1(Int i)                                   { m_numTileColumnsMinus1 = i;                   }
2339  Int                    getNumTileColumnsMinus1() const                                  { return m_numTileColumnsMinus1;                }
2340  Void                   setTileColumnWidth(const std::vector<Int>& columnWidth )         { m_tileColumnWidth = columnWidth;              }
2341  UInt                   getTileColumnWidth(UInt columnIdx) const                         { return  m_tileColumnWidth[columnIdx];         }
2342  Void                   setNumTileRowsMinus1(Int i)                                      { m_numTileRowsMinus1 = i;                      }
2343  Int                    getNumTileRowsMinus1() const                                     { return m_numTileRowsMinus1;                   }
2344  Void                   setTileRowHeight(const std::vector<Int>& rowHeight)              { m_tileRowHeight = rowHeight;                  }
2345  UInt                   getTileRowHeight(UInt rowIdx) const                              { return m_tileRowHeight[rowIdx];               }
2346
2347  Void                   setSignHideFlag( Bool signHideFlag )                             { m_signHideFlag = signHideFlag;                }
2348  Bool                   getSignHideFlag() const                                          { return m_signHideFlag;                        }
2349
2350  Void                   setCabacInitPresentFlag( Bool flag )                             { m_cabacInitPresentFlag = flag;                }
2351  Bool                   getCabacInitPresentFlag() const                                  { return m_cabacInitPresentFlag;                }
2352  Void                   setDeblockingFilterControlPresentFlag( Bool val )                { m_deblockingFilterControlPresentFlag = val;   }
2353  Bool                   getDeblockingFilterControlPresentFlag() const                    { return m_deblockingFilterControlPresentFlag;  }
2354  Void                   setDeblockingFilterOverrideEnabledFlag( Bool val )               { m_deblockingFilterOverrideEnabledFlag = val;  }
2355  Bool                   getDeblockingFilterOverrideEnabledFlag() const                   { return m_deblockingFilterOverrideEnabledFlag; }
2356  Void                   setPicDisableDeblockingFilterFlag(Bool val)                      { m_picDisableDeblockingFilterFlag = val;       } //!< set offset for deblocking filter disabled
2357  Bool                   getPicDisableDeblockingFilterFlag() const                        { return m_picDisableDeblockingFilterFlag;      } //!< get offset for deblocking filter disabled
2358  Void                   setDeblockingFilterBetaOffsetDiv2(Int val)                       { m_deblockingFilterBetaOffsetDiv2 = val;       } //!< set beta offset for deblocking filter
2359  Int                    getDeblockingFilterBetaOffsetDiv2() const                        { return m_deblockingFilterBetaOffsetDiv2;      } //!< get beta offset for deblocking filter
2360  Void                   setDeblockingFilterTcOffsetDiv2(Int val)                         { m_deblockingFilterTcOffsetDiv2 = val;         } //!< set tc offset for deblocking filter
2361  Int                    getDeblockingFilterTcOffsetDiv2() const                          { return m_deblockingFilterTcOffsetDiv2;        } //!< get tc offset for deblocking filter
2362  Bool                   getScalingListPresentFlag() const                                { return m_scalingListPresentFlag;              }
2363  Void                   setScalingListPresentFlag( Bool b )                              { m_scalingListPresentFlag  = b;                }
2364  TComScalingList&       getScalingList()                                                 { return m_scalingList;                         }
2365  const TComScalingList& getScalingList() const                                           { return m_scalingList;                         }
2366  Bool                   getListsModificationPresentFlag() const                          { return m_listsModificationPresentFlag;        }
2367  Void                   setListsModificationPresentFlag( Bool b )                        { m_listsModificationPresentFlag = b;           }
2368  UInt                   getLog2ParallelMergeLevelMinus2() const                          { return m_log2ParallelMergeLevelMinus2;        }
2369  Void                   setLog2ParallelMergeLevelMinus2(UInt mrgLevel)                   { m_log2ParallelMergeLevelMinus2 = mrgLevel;    }
2370  Int                    getNumExtraSliceHeaderBits() const                               { return m_numExtraSliceHeaderBits;             }
2371  Void                   setNumExtraSliceHeaderBits(Int i)                                { m_numExtraSliceHeaderBits = i;                }
2372  Void                   setLoopFilterAcrossSlicesEnabledFlag( Bool bValue )              { m_loopFilterAcrossSlicesEnabledFlag = bValue; }
2373  Bool                   getLoopFilterAcrossSlicesEnabledFlag() const                     { return m_loopFilterAcrossSlicesEnabledFlag;   }
2374  Bool                   getSliceHeaderExtensionPresentFlag() const                       { return m_sliceHeaderExtensionPresentFlag;     }
2375  Void                   setSliceHeaderExtensionPresentFlag(Bool val)                     { m_sliceHeaderExtensionPresentFlag = val;      }
2376
2377
2378  const TComPPSRExt&     getPpsRangeExtension() const                                     { return m_ppsRangeExtension;                   }
2379  TComPPSRExt&           getPpsRangeExtension()                                           { return m_ppsRangeExtension;                   }
2380
2381  // WAS: getTransformSkipLog2MaxSize and setTransformSkipLog2MaxSize
2382  // Now: getPpsRangeExtension().getLog2MaxTransformSkipBlockSize and getPpsRangeExtension().setLog2MaxTransformSkipBlockSize
2383
2384  // WAS: getUseCrossComponentPrediction and setUseCrossComponentPrediction
2385  // Now: getPpsRangeExtension().getCrossComponentPredictionEnabledFlag and getPpsRangeExtension().setCrossComponentPredictionEnabledFlag
2386
2387  // WAS: clearChromaQpAdjTable
2388  // Now: getPpsRangeExtension().clearChromaQpOffsetList
2389
2390  // WAS: getMaxCuChromaQpAdjDepth and setMaxCuChromaQpAdjDepth
2391  // Now: getPpsRangeExtension().getDiffCuChromaQpOffsetDepth and getPpsRangeExtension().setDiffCuChromaQpOffsetDepth
2392
2393  // WAS: getChromaQpAdjTableSize
2394  // Now: getPpsRangeExtension().getChromaQpOffsetListLen
2395
2396  // WAS: getChromaQpAdjTableAt and setChromaQpAdjTableAt
2397  // Now: getPpsRangeExtension().getChromaQpOffsetListEntry and getPpsRangeExtension().setChromaQpOffsetListEntry
2398
2399  // WAS: getSaoOffsetBitShift and setSaoOffsetBitShift
2400  // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale
2401
2402#if NH_MV
2403  Void    setLayerId( Int  val )                                                     { m_layerId = val;                                           }
2404  Int     getLayerId(  ) const                                                       { return m_layerId;                                          }
2405
2406  Void    setPpsInferScalingListFlag( Bool flag )                                    { m_ppsInferScalingListFlag = flag;                          }
2407  Bool    getPpsInferScalingListFlag(  ) const                                       { return m_ppsInferScalingListFlag;                          }
2408
2409  Void    setPpsScalingListRefLayerId( Int  val )                                    { m_ppsScalingListRefLayerId = val;                          }
2410  Int     getPpsScalingListRefLayerId(  ) const                                      { return m_ppsScalingListRefLayerId;                         }
2411
2412  Void    setPpsRangeExtensionsFlag( Bool flag )                                     { m_ppsRangeExtensionsFlag = flag;                           }
2413  Bool    getPpsRangeExtensionsFlag(  ) const                                        { return m_ppsRangeExtensionsFlag;                           }
2414
2415  Void    setPpsMultilayerExtensionFlag( Bool flag )                                 { m_ppsMultilayerExtensionFlag = flag;                       }
2416  Bool    getPpsMultilayerExtensionFlag(  ) const                                    { return m_ppsMultilayerExtensionFlag;                       }
2417
2418  Void    setPps3dExtensionFlag( Bool flag )                                         { m_pps3dExtensionFlag = flag;                               }
2419  Bool    getPps3dExtensionFlag(  ) const                                            { return m_pps3dExtensionFlag;                               }
2420
2421  Void    setPpsExtension5bits( Int  val )                                           { m_ppsExtension5bits = val;                                 }
2422  Int     getPpsExtension5bits(  ) const                                             { return m_ppsExtension5bits;                                }
2423
2424  Void    setPocResetInfoPresentFlag( Bool flag )                                    { m_pocResetInfoPresentFlag = flag;                          }
2425  Bool    getPocResetInfoPresentFlag(  ) const                                       { return m_pocResetInfoPresentFlag;                          }
2426#endif
2427};
2428struct WPScalingParam
2429{
2430  // Explicit weighted prediction parameters parsed in slice header,
2431  // or Implicit weighted prediction parameters (8 bits depth values).
2432  Bool bPresentFlag;
2433  UInt uiLog2WeightDenom;
2434  Int  iWeight;
2435  Int  iOffset;
2436
2437  // Weighted prediction scaling values built from above parameters (bitdepth scaled):
2438  Int  w;
2439  Int  o;
2440  Int  offset;
2441  Int  shift;
2442  Int  round;
2443};
2444
2445struct WPACDCParam
2446{
2447  Int64 iAC;
2448  Int64 iDC;
2449};
2450
2451/// slice header class
2452class TComSlice
2453{
2454
2455private:
2456  //  Bitstream writing
2457  Bool                       m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
2458  Int                        m_iPPSId;               ///< picture parameter set ID
2459  Bool                       m_PicOutputFlag;        ///< pic_output_flag
2460#if NH_MV
2461  Int                        m_slicePicOrderCntLsb;   
2462#endif 
2463  Int                        m_iPOC;
2464#if NH_MV
2465  Int                        m_iPOCBeforeReset; 
2466#endif
2467  Int                        m_iLastIDR;
2468  Int                        m_iAssociatedIRAP;
2469  NalUnitType                m_iAssociatedIRAPType;
2470  TComReferencePictureSet*   m_pcRPS;
2471  TComReferencePictureSet    m_LocalRPS;
2472  Int                        m_iBDidx;
2473  TComRefPicListModification m_RefPicListModification;
2474  NalUnitType                m_eNalUnitType;         ///< Nal unit type for the slice
2475  SliceType                  m_eSliceType;
2476  Int                        m_iSliceQp;
2477  Bool                       m_dependentSliceSegmentFlag;
2478#if ADAPTIVE_QP_SELECTION
2479  Int                        m_iSliceQpBase;
2480#endif
2481  Bool                       m_ChromaQpAdjEnabled;
2482  Bool                       m_deblockingFilterDisable;
2483  Bool                       m_deblockingFilterOverrideFlag;      //< offsets for deblocking filter inherit from PPS
2484  Int                        m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
2485  Int                        m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
2486  Int                        m_list1IdxToList0Idx[MAX_NUM_REF];
2487  Int                        m_aiNumRefIdx   [NUM_REF_PIC_LIST_01];    //  for multiple reference of current slice
2488
2489  Bool                       m_bCheckLDC;
2490
2491  //  Data
2492  Int                        m_iSliceQpDelta;
2493  Int                        m_iSliceChromaQpDelta[MAX_NUM_COMPONENT];
2494  TComPic*                   m_apcRefPicList [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2495  Int                        m_aiRefPOCList  [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2496#if NH_MV
2497  Int         m_aiRefLayerIdList[2][MAX_NUM_REF+1];
2498#endif
2499  Bool                       m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2500  Int                        m_iDepth;
2501
2502  // referenced slice?
2503  Bool                       m_bRefenced;
2504
2505  // access channel
2506  const TComVPS*             m_pcVPS;
2507  const TComSPS*             m_pcSPS;
2508  const TComPPS*             m_pcPPS;
2509  TComPic*                   m_pcPic;
2510  Bool                       m_colFromL0Flag;  // collocated picture from List0 flag
2511
2512  Bool                       m_noOutputPriorPicsFlag;
2513  Bool                       m_noRaslOutputFlag;
2514  Bool                       m_handleCraAsBlaFlag;
2515
2516  UInt                       m_colRefIdx;
2517  UInt                       m_maxNumMergeCand;
2518
2519  Double                     m_lambdas[MAX_NUM_COMPONENT];
2520
2521  Bool                       m_abEqualRef  [NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_REF];
2522  UInt                       m_uiTLayer;
2523  Bool                       m_bTLayerSwitchingFlag;
2524
2525  SliceConstraint            m_sliceMode;
2526  UInt                       m_sliceArgument;
2527  UInt                       m_sliceCurStartCtuTsAddr;
2528  UInt                       m_sliceCurEndCtuTsAddr;
2529  UInt                       m_sliceIdx;
2530  SliceConstraint            m_sliceSegmentMode;
2531  UInt                       m_sliceSegmentArgument;
2532  UInt                       m_sliceSegmentCurStartCtuTsAddr;
2533  UInt                       m_sliceSegmentCurEndCtuTsAddr;
2534  Bool                       m_nextSlice;
2535  Bool                       m_nextSliceSegment;
2536  UInt                       m_sliceBits;
2537  UInt                       m_sliceSegmentBits;
2538  Bool                       m_bFinalized;
2539
2540  Bool                       m_bTestWeightPred;
2541  Bool                       m_bTestWeightBiPred;
2542  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]
2543  WPACDCParam                m_weightACDCParam[MAX_NUM_COMPONENT];
2544
2545  std::vector<UInt>          m_substreamSizes;
2546
2547  Bool                       m_cabacInitFlag;
2548
2549  Bool                       m_bLMvdL1Zero;
2550  Bool                       m_temporalLayerNonReferenceFlag;
2551  Bool                       m_LFCrossSliceBoundaryFlag;
2552
2553  Bool                       m_enableTMVPFlag;
2554
2555  SliceType                  m_encCABACTableIdx;           // Used to transmit table selection across slices.
2556#if NH_MV
2557  Bool       m_availableForTMVPRefFlag;
2558#endif
2559
2560#if NH_MV
2561  std::vector<TComPic*>* m_refPicSetInterLayer0; 
2562  std::vector<TComPic*>* m_refPicSetInterLayer1; 
2563  Int        m_layerId; 
2564  Int        m_viewId;
2565  Int        m_viewIndex; 
2566#if NH_3D
2567  Bool       m_isDepth;
2568#endif
2569
2570// Additional slice header syntax elements
2571#if !H_MV_HLS7_GEN
2572  Bool       m_pocResetFlag; 
2573#endif
2574  Bool       m_crossLayerBlaFlag;
2575  Bool       m_discardableFlag;
2576  Bool       m_interLayerPredEnabledFlag;
2577  Int        m_numInterLayerRefPicsMinus1;
2578  Int        m_interLayerPredLayerIdc       [MAX_NUM_LAYERS];
2579
2580  Int        m_sliceSegmentHeaderExtensionLength;
2581  Int        m_pocResetIdc;
2582  Int        m_pocResetPeriodId;
2583  Bool       m_fullPocResetFlag;
2584  Int        m_pocLsbVal;
2585  Bool       m_pocMsbValPresentFlag;
2586  Int        m_pocMsbVal;
2587  Bool       m_pocMsbValRequiredFlag;
2588
2589#if NH_3D
2590  IntAry2d   m_aaiCodedScale ;
2591  IntAry2d   m_aaiCodedOffset;
2592#endif
2593#if H_3D_TMVP
2594  Int        m_aiAlterRefIdx   [2]; 
2595#endif
2596#if NH_3D_ARP
2597  Bool       m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
2598  TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
2599  UInt        m_nARPStepNum; 
2600  Int         m_aiFirstTRefIdx    [2];   
2601#endif
2602#if NH_3D
2603  std::vector<Int> m_pocsInCurrRPSs; 
2604#endif
2605#if H_3D_IC
2606  Bool       m_bApplyIC;
2607  Bool       m_icSkipParseFlag;
2608#endif
2609#if NH_3D
2610  std::vector<Int> m_inCmpRefViewIdcs;
2611  Bool       m_inCmpPredAvailFlag; 
2612  Bool       m_inCmpPredFlag; 
2613  Bool       m_cpAvailableFlag; 
2614  Int        m_numViews; 
2615  TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS]; 
2616  Int**      m_depthToDisparityB; 
2617  Int**      m_depthToDisparityF; 
2618  Bool       m_bApplyDIS;
2619#endif
2620#endif
2621#if H_3D_IC
2622  Int*       m_aICEnableCandidate;
2623  Int*       m_aICEnableNum;
2624#endif       
2625#if NH_3D   
2626  Int        m_iDefaultRefViewIdx;
2627  Bool       m_bDefaultRefViewIdxAvailableFlag;
2628             
2629  Bool       m_ivMvPredFlag         ;
2630  Bool       m_ivMvScalingFlag      ;
2631  Bool       m_ivResPredFlag        ;
2632  Bool       m_depthRefinementFlag  ;
2633  Bool       m_viewSynthesisPredFlag;
2634  Bool       m_depthBasedBlkPartFlag;
2635  Bool       m_mpiFlag              ;
2636  Bool       m_intraContourFlag     ;
2637  Bool       m_intraSdcWedgeFlag    ;
2638  Bool       m_qtPredFlag           ;
2639  Bool       m_interSdcFlag         ;
2640  Bool       m_depthIntraSkipFlag   ;
2641  Int        m_mpiSubPbSize         ; 
2642  Int        m_subPbSize            ; 
2643#endif
2644public:
2645                              TComSlice();
2646  virtual                     ~TComSlice();
2647  Void                        initSlice();
2648
2649  Void                        setVPS( TComVPS* pcVPS )                               { m_pcVPS = pcVPS;                                              }
2650  const TComVPS*              getVPS() const                                         { return m_pcVPS;                                               }
2651  Void                        setSPS( const TComSPS* pcSPS )                         { m_pcSPS = pcSPS;                                              }
2652  const TComSPS*              getSPS() const                                         { return m_pcSPS;                                               }
2653
2654  Void                        setPPS( const TComPPS* pcPPS )                         { m_pcPPS = pcPPS; m_iPPSId = (pcPPS) ? pcPPS->getPPSId() : -1; }
2655  const TComPPS*              getPPS() const                                         { return m_pcPPS;                                               }
2656
2657  Void                        setPPSId( Int PPSId )                                  { m_iPPSId = PPSId;                                             }
2658  Int                         getPPSId() const                                       { return m_iPPSId;                                              }
2659  Void                        setPicOutputFlag( Bool b   )                           { m_PicOutputFlag = b;                                          }
2660#if NH_MV
2661  Void                        setSlicePicOrderCntLsb( Int i )                        { m_slicePicOrderCntLsb = i;                                    }
2662  Int                         getSlicePicOrderCntLsb(  )  const                      { return m_slicePicOrderCntLsb;                                 }
2663#endif
2664  Bool                        getPicOutputFlag() const                               { return m_PicOutputFlag;                                       }
2665  Void                        setSaoEnabledFlag(ChannelType chType, Bool s)          {m_saoEnabledFlag[chType] =s;                                   }
2666  Bool                        getSaoEnabledFlag(ChannelType chType) const            { return m_saoEnabledFlag[chType];                              }
2667  Void                        setRPS( TComReferencePictureSet *pcRPS )               { m_pcRPS = pcRPS;                                              }
2668  TComReferencePictureSet*    getRPS()                                               { return m_pcRPS;                                               }
2669  TComReferencePictureSet*    getLocalRPS()                                          { return &m_LocalRPS;                                           }
2670
2671  Void                        setRPSidx( Int iBDidx )                                { m_iBDidx = iBDidx;                                            }
2672  Int                         getRPSidx() const                                      { return m_iBDidx;                                              }
2673  TComRefPicListModification* getRefPicListModification()                            { return &m_RefPicListModification;                             }
2674  Void                        setLastIDR(Int iIDRPOC)                                { m_iLastIDR = iIDRPOC;                                         }
2675  Int                         getLastIDR() const                                     { return m_iLastIDR;                                            }
2676  Void                        setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)           { m_iAssociatedIRAP = iAssociatedIRAPPOC;                       }
2677  Int                         getAssociatedIRAPPOC() const                           { return m_iAssociatedIRAP;                                     }
2678  Void                        setAssociatedIRAPType(NalUnitType associatedIRAPType)  { m_iAssociatedIRAPType = associatedIRAPType;                   }
2679  NalUnitType                 getAssociatedIRAPType() const                          { return m_iAssociatedIRAPType;                                 }
2680  SliceType                   getSliceType() const                                   { return m_eSliceType;                                          }
2681  Int                         getPOC() const                                         { return m_iPOC;                                                }
2682  Int                         getSliceQp() const                                     { return m_iSliceQp;                                            }
2683  Bool                        getDependentSliceSegmentFlag() const                   { return m_dependentSliceSegmentFlag;                           }
2684  Void                        setDependentSliceSegmentFlag(Bool val)                 { m_dependentSliceSegmentFlag = val;                            }
2685#if ADAPTIVE_QP_SELECTION
2686  Int                         getSliceQpBase() const                                 { return m_iSliceQpBase;                                        }
2687#endif
2688  Int                         getSliceQpDelta() const                                { return m_iSliceQpDelta;                                       }
2689  Int                         getSliceChromaQpDelta(ComponentID compID) const        { return isLuma(compID) ? 0 : m_iSliceChromaQpDelta[compID];    }
2690  Bool                        getUseChromaQpAdj() const                              { return m_ChromaQpAdjEnabled;                                  }
2691  Bool                        getDeblockingFilterDisable() const                     { return m_deblockingFilterDisable;                             }
2692  Bool                        getDeblockingFilterOverrideFlag() const                { return m_deblockingFilterOverrideFlag;                        }
2693  Int                         getDeblockingFilterBetaOffsetDiv2()const               { return m_deblockingFilterBetaOffsetDiv2;                      }
2694  Int                         getDeblockingFilterTcOffsetDiv2() const                { return m_deblockingFilterTcOffsetDiv2;                        }
2695
2696  Int                         getNumRefIdx( RefPicList e ) const                     { return m_aiNumRefIdx[e];                                      }
2697  TComPic*                    getPic()                                               { return m_pcPic;                                               }
2698  TComPic*                    getRefPic( RefPicList e, Int iRefIdx)                  { return m_apcRefPicList[e][iRefIdx];                           }
2699  Int                         getRefPOC( RefPicList e, Int iRefIdx)                  { return m_aiRefPOCList[e][iRefIdx];                            }
2700#if NH_3D
2701  Bool                        getInCmpPredAvailFlag( )                 const         { return m_inCmpPredAvailFlag;                                  }
2702  Bool                        getCpAvailableFlag( )                    const         { return m_cpAvailableFlag;                                     }
2703  Bool                        getInCompPredFlag( )                     const         { return m_inCmpPredFlag;                                       }
2704  Void                        setInCompPredFlag( Bool b )                            { m_inCmpPredFlag = b;                                          }
2705  Int                         getInCmpRefViewIdcs( Int i )             const         { return m_inCmpRefViewIdcs  [i];                               }
2706  Int                         getNumCurCmpLIds( )                      const         { return (Int) m_inCmpRefViewIdcs.size();                       }
2707  TComPic*                    getIvPic( Bool depthFlag, Int viewIndex) const         { return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ];    }
2708#endif                                                                                                                                               
2709#if H_3D                                                                                                                                             
2710  TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
2711#endif                           
2712#if NH_3D_IV_MERGE
2713  TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
2714#endif
2715#if H_3D_IC                                                                                                                                         
2716  Void                        setApplyIC( Bool b )                                   { m_bApplyIC = b;                                               }
2717  Bool                        getApplyIC()                                           { return m_bApplyIC;                                            }
2718  Void                        xSetApplyIC();                                                                                                         
2719  Void                        xSetApplyIC(Bool bUseLowLatencyICEnc);                                                                                 
2720  Void                        setIcSkipParseFlag( Bool b )                           { m_icSkipParseFlag = b;                                        }
2721  Bool                        getIcSkipParseFlag()                                   { return m_icSkipParseFlag;                                     }
2722#endif                                                                                                                                               
2723#if NH_3D_ARP                                                                                                                                         
2724  Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                 
2725  Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                             
2726  TComPic*                    getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )     { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
2727  UInt                        getARPStepNum( )                                       { return m_nARPStepNum;                                         } 
2728#endif
2729  Int                         getDepth() const                                       { return m_iDepth;                                              }
2730  Bool                        getColFromL0Flag() const                               { return m_colFromL0Flag;                                       }
2731  UInt                        getColRefIdx() const                                   { return m_colRefIdx;                                           }
2732  Void                        checkColRefIdx(UInt curSliceIdx, TComPic* pic);
2733  Bool                        getIsUsedAsLongTerm(Int i, Int j) const                { return m_bIsUsedAsLongTerm[i][j];                             }
2734  Void                        setIsUsedAsLongTerm(Int i, Int j, Bool value)          { m_bIsUsedAsLongTerm[i][j] = value;                            }
2735  Bool                        getCheckLDC() const                                    { return m_bCheckLDC;                                           }
2736  Bool                        getMvdL1ZeroFlag() const                               { return m_bLMvdL1Zero;                                         }
2737  Int                         getNumRpsCurrTempList() const;
2738  Int                         getList1IdxToList0Idx( Int list1Idx ) const            { return m_list1IdxToList0Idx[list1Idx];                        }
2739  Void                        setReferenced(Bool b)                                  { m_bRefenced = b;                                              }
2740  Bool                        isReferenced() const                                   { return m_bRefenced;                                           }
2741  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) ); }
2742  Void                        setPOC( Int i )                                        { m_iPOC              = i; }
2743  Void                        setNalUnitType( NalUnitType e )                        { m_eNalUnitType      = e;                                      }
2744  NalUnitType                 getNalUnitType() const                                 { return m_eNalUnitType;                                        }
2745  Bool                        getRapPicFlag() const;
2746  Bool                        getIdrPicFlag() const                                  { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
2747  Bool                        isIRAP() const                                         { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23);  }
2748  Void                        checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
2749  Void                        decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled);
2750  Void                        setSliceType( SliceType e )                            { m_eSliceType        = e;                                      }
2751  Void                        setSliceQp( Int i )                                    { m_iSliceQp          = i;                                      }
2752#if ADAPTIVE_QP_SELECTION
2753  Void                        setSliceQpBase( Int i )                                { m_iSliceQpBase      = i;                                      }
2754#endif
2755  Void                        setSliceQpDelta( Int i )                               { m_iSliceQpDelta     = i;                                      }
2756  Void                        setSliceChromaQpDelta( ComponentID compID, Int i )     { m_iSliceChromaQpDelta[compID] = isLuma(compID) ? 0 : i;       }
2757  Void                        setUseChromaQpAdj( Bool b )                            { m_ChromaQpAdjEnabled = b;                                     }
2758  Void                        setDeblockingFilterDisable( Bool b )                   { m_deblockingFilterDisable= b;                                 }
2759  Void                        setDeblockingFilterOverrideFlag( Bool b )              { m_deblockingFilterOverrideFlag = b;                           }
2760  Void                        setDeblockingFilterBetaOffsetDiv2( Int i )             { m_deblockingFilterBetaOffsetDiv2 = i;                         }
2761  Void                        setDeblockingFilterTcOffsetDiv2( Int i )               { m_deblockingFilterTcOffsetDiv2 = i;                           }
2762
2763  Void                        setRefPic( TComPic* p, RefPicList e, Int iRefIdx )     { m_apcRefPicList[e][iRefIdx] = p;                              }
2764  Void                        setRefPOC( Int i, RefPicList e, Int iRefIdx )          { m_aiRefPOCList[e][iRefIdx] = i;                               }
2765  Void                        setNumRefIdx( RefPicList e, Int i )                    { m_aiNumRefIdx[e]    = i;                                      }
2766  Void                        setPic( TComPic* p )                                   { m_pcPic             = p;                                      }
2767  Void                        setDepth( Int iDepth )                                 { m_iDepth            = iDepth;                                 }
2768#if NH_MV
2769  Void                        setPocBeforeReset( Int i )                             { m_iPOCBeforeReset = i;                                        }
2770  Int                         getPocBeforeReset( )                                   { return m_iPOCBeforeReset;                                     }
2771  Int                         getRefLayerId( RefPicList e, Int iRefIdx)              { return  m_aiRefLayerIdList[e][iRefIdx];                       }
2772  Void                        setRefLayerId( Int i, RefPicList e, Int iRefIdx )      { m_aiRefLayerIdList[e][iRefIdx] = i;                        }
2773  Void                        getTempRefPicLists   ( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1,                                     
2774                                                     std::vector<TComPic*> rpsCurrList[2], BoolAry1d usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr = false );
2775                             
2776  Void                        setRefPicList        ( std::vector<TComPic*> rpsCurrList[2], BoolAry1d usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr = false ); 
2777#else
2778  Void                        setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
2779#endif
2780  Void                        setRefPOCList();
2781  Void                        setColFromL0Flag( Bool colFromL0 )                     { m_colFromL0Flag = colFromL0;                                  }
2782  Void                        setColRefIdx( UInt refIdx)                             { m_colRefIdx = refIdx;                                         }
2783  Void                        setCheckLDC( Bool b )                                  { m_bCheckLDC = b;                                              }
2784  Void                        setMvdL1ZeroFlag( Bool b)                              { m_bLMvdL1Zero = b;                                            }
2785
2786  Bool                        isIntra() const                                        { return m_eSliceType == I_SLICE;                               }
2787  Bool                        isInterB() const                                       { return m_eSliceType == B_SLICE;                               }
2788  Bool                        isInterP() const                                       { return m_eSliceType == P_SLICE;                               }
2789
2790  Void                        setLambdas( const Double lambdas[MAX_NUM_COMPONENT] )  { for (Int component = 0; component < MAX_NUM_COMPONENT; component++) m_lambdas[component] = lambdas[component]; }
2791  const Double*               getLambdas() const                                     { return m_lambdas;                                             }
2792
2793  Void                        initEqualRef();
2794  Bool                        isEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2 )
2795  {
2796    assert(e<NUM_REF_PIC_LIST_01);
2797    if (iRefIdx1 < 0 || iRefIdx2 < 0)
2798    {
2799      return false;
2800    }
2801    else
2802    {
2803      return m_abEqualRef[e][iRefIdx1][iRefIdx2];
2804    }
2805  }
2806
2807  Void                        setEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2, Bool b)
2808  {
2809    assert(e<NUM_REF_PIC_LIST_01);
2810    m_abEqualRef[e][iRefIdx1][iRefIdx2] = m_abEqualRef[e][iRefIdx2][iRefIdx1] = b;
2811  }
2812
2813  static Void                 sortPicList( TComList<TComPic*>& rcListPic );
2814  Void                        setList1IdxToList0Idx();
2815
2816  UInt                        getTLayer() const                                      { return m_uiTLayer;                                            }
2817  Void                        setTLayer( UInt uiTLayer )                             { m_uiTLayer = uiTLayer;                                        }
2818#if NH_MV
2819  Int                         getTemporalId          ( )                             { return (Int) m_uiTLayer;                                      }
2820#endif
2821
2822  Void                        setTLayerInfo( UInt uiTLayer );
2823  Void                        decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
2824  Void                        checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
2825  Void                        applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *RPSList);
2826#if NH_MV
2827  Void                        createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 );
2828  static Void                 markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 );
2829  static Void                 markCurrPic                 ( TComPic* currPic );
2830  Void                        printRefPicList();
2831#endif
2832  Bool                        isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
2833  Bool                        isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
2834  Int                         checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
2835  Void                        createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled);
2836  Void                        setMaxNumMergeCand(UInt val )                          { m_maxNumMergeCand = val;                                      }
2837  UInt                        getMaxNumMergeCand() const                             { return m_maxNumMergeCand;                                     }
2838
2839  Void                        setNoOutputPriorPicsFlag( Bool val )                   { m_noOutputPriorPicsFlag = val;                                }
2840  Bool                        getNoOutputPriorPicsFlag() const                       { return m_noOutputPriorPicsFlag;                               }
2841
2842  Void                        setNoRaslOutputFlag( Bool val )                        { m_noRaslOutputFlag = val;                                     }
2843  Bool                        getNoRaslOutputFlag() const                            { return m_noRaslOutputFlag;                                    }
2844
2845  Void                        setHandleCraAsBlaFlag( Bool val )                      { m_handleCraAsBlaFlag = val;                                   }
2846  Bool                        getHandleCraAsBlaFlag() const                          { return m_handleCraAsBlaFlag;                                  }
2847
2848  Void                        setSliceMode( SliceConstraint mode )                   { m_sliceMode = mode;                                           }
2849  SliceConstraint             getSliceMode() const                                   { return m_sliceMode;                                           }
2850  Void                        setSliceArgument( UInt uiArgument )                    { m_sliceArgument = uiArgument;                                 }
2851  UInt                        getSliceArgument() const                               { return m_sliceArgument;                                       }
2852  Void                        setSliceCurStartCtuTsAddr( UInt ctuTsAddr )            { m_sliceCurStartCtuTsAddr = ctuTsAddr;                         } // CTU Tile-scan address (as opposed to raster-scan)
2853  UInt                        getSliceCurStartCtuTsAddr() const                      { return m_sliceCurStartCtuTsAddr;                              } // CTU Tile-scan address (as opposed to raster-scan)
2854  Void                        setSliceCurEndCtuTsAddr( UInt ctuTsAddr )              { m_sliceCurEndCtuTsAddr = ctuTsAddr;                           } // CTU Tile-scan address (as opposed to raster-scan)
2855  UInt                        getSliceCurEndCtuTsAddr() const                        { return m_sliceCurEndCtuTsAddr;                                } // CTU Tile-scan address (as opposed to raster-scan)
2856  Void                        setSliceIdx( UInt i)                                   { m_sliceIdx = i;                                               }
2857  UInt                        getSliceIdx() const                                    { return  m_sliceIdx;                                           }
2858  Void                        copySliceInfo(TComSlice *pcSliceSrc);
2859  Void                        setSliceSegmentMode( SliceConstraint mode )            { m_sliceSegmentMode = mode;                                    }
2860  SliceConstraint             getSliceSegmentMode() const                            { return m_sliceSegmentMode;                                    }
2861  Void                        setSliceSegmentArgument( UInt uiArgument )             { m_sliceSegmentArgument = uiArgument;                          }
2862  UInt                        getSliceSegmentArgument() const                        { return m_sliceSegmentArgument;                                }
2863  Void                        setSliceSegmentCurStartCtuTsAddr( UInt ctuTsAddr )     { m_sliceSegmentCurStartCtuTsAddr = ctuTsAddr;                  } // CTU Tile-scan address (as opposed to raster-scan)
2864  UInt                        getSliceSegmentCurStartCtuTsAddr() const               { return m_sliceSegmentCurStartCtuTsAddr;                       } // CTU Tile-scan address (as opposed to raster-scan)
2865  Void                        setSliceSegmentCurEndCtuTsAddr( UInt ctuTsAddr )       { m_sliceSegmentCurEndCtuTsAddr = ctuTsAddr;                    } // CTU Tile-scan address (as opposed to raster-scan)
2866  UInt                        getSliceSegmentCurEndCtuTsAddr() const                 { return m_sliceSegmentCurEndCtuTsAddr;                         } // CTU Tile-scan address (as opposed to raster-scan)
2867  Void                        setSliceBits( UInt uiVal )                             { m_sliceBits = uiVal;                                          }
2868  UInt                        getSliceBits() const                                   { return m_sliceBits;                                           }
2869  Void                        setSliceSegmentBits( UInt uiVal )                      { m_sliceSegmentBits = uiVal;                                   }
2870  UInt                        getSliceSegmentBits() const                            { return m_sliceSegmentBits;                                    }
2871  Void                        setFinalized( Bool uiVal )                             { m_bFinalized = uiVal;                                         }
2872  Bool                        getFinalized() const                                   { return m_bFinalized;                                          }
2873  Bool                        testWeightPred( ) const                                { return m_bTestWeightPred;                                     }
2874  Void                        setTestWeightPred( Bool bValue )                       { m_bTestWeightPred = bValue;                                   }
2875  Bool                        testWeightBiPred( ) const                              { return m_bTestWeightBiPred;                                   }
2876  Void                        setTestWeightBiPred( Bool bValue )                     { m_bTestWeightBiPred = bValue;                                 }
2877  Void                        setWpScaling( WPScalingParam  wp[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT] )
2878  {
2879    memcpy(m_weightPredTable, wp, sizeof(WPScalingParam)*NUM_REF_PIC_LIST_01*MAX_NUM_REF*MAX_NUM_COMPONENT);
2880  }
2881
2882  Void                        getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp);
2883
2884  Void                        resetWpScaling();
2885  Void                        initWpScaling(const TComSPS *sps);
2886
2887  Void                        setWpAcDcParam( WPACDCParam wp[MAX_NUM_COMPONENT] )
2888  {
2889    memcpy(m_weightACDCParam, wp, sizeof(WPACDCParam)*MAX_NUM_COMPONENT);
2890  }
2891
2892  Void                        getWpAcDcParam( WPACDCParam *&wp );
2893  Void                        initWpAcDcParam();
2894
2895  Void                        clearSubstreamSizes( )                                 { return m_substreamSizes.clear();                              }
2896  UInt                        getNumberOfSubstreamSizes( )                           { return (UInt) m_substreamSizes.size();                        }
2897  Void                        addSubstreamSize( UInt size )                          { m_substreamSizes.push_back(size);                             }
2898  UInt                        getSubstreamSize( Int idx )                            { assert(idx<getNumberOfSubstreamSizes()); return m_substreamSizes[idx]; }
2899
2900  Void                        setCabacInitFlag( Bool val )                           { m_cabacInitFlag = val;                                        } //!< set CABAC initial flag
2901  Bool                        getCabacInitFlag()                                     { return m_cabacInitFlag;                                       } //!< get CABAC initial flag
2902  Bool                        getTemporalLayerNonReferenceFlag()                     { return m_temporalLayerNonReferenceFlag;                       }
2903  Void                        setTemporalLayerNonReferenceFlag(Bool x)               { m_temporalLayerNonReferenceFlag = x;                          }
2904  Void                        setLFCrossSliceBoundaryFlag( Bool   val )              { m_LFCrossSliceBoundaryFlag = val;                             }
2905  Bool                        getLFCrossSliceBoundaryFlag()                          { return m_LFCrossSliceBoundaryFlag;                            }
2906
2907  Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
2908  Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
2909
2910  Void                        setEncCABACTableIdx( SliceType idx )                   { m_encCABACTableIdx = idx;                                     }
2911  SliceType                   getEncCABACTableIdx() const                            { return m_encCABACTableIdx;                                    }
2912
2913#if NH_MV
2914  Void                        setAvailableForTMVPRefFlag( Bool   b )                 { m_availableForTMVPRefFlag = b;                                }
2915  Bool                        getAvailableForTMVPRefFlag()                           { return m_availableForTMVPRefFlag;                             }
2916
2917  Void                        setLayerId     ( Int layerId )                         { m_layerId      = layerId;                                     }
2918  Int                         getLayerId     ()                 const                { return m_layerId;                                             }
2919  Int                         getLayerIdInVps()                 const                { return getVPS()->getLayerIdInVps( m_layerId );                }
2920  Void                        setViewId      ( Int viewId )                          { m_viewId = viewId;                                            }
2921  Int                         getViewId      ()                 const                { return m_viewId;                                              }
2922  Void                        setViewIndex   ( Int viewIndex )                       { m_viewIndex = viewIndex;                                      }
2923  Int                         getViewIndex   ()                 const                { return m_viewIndex;                                           }
2924#if NH_3D
2925#if H_3D_TMVP
2926  Void                        generateAlterRefforTMVP ();   
2927  Void                        setAlterRefIdx          ( RefPicList e, Int i )        { m_aiAlterRefIdx[e]    = i;                                    }
2928  Int                         getAlterRefIdx          ( RefPicList e )               { return  m_aiAlterRefIdx[e];                                   }
2929#endif                                                                                                                                               
2930#if NH_3D_ARP                                                                                                                                         
2931  Int                         getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];                                  }
2932  Void                        setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;                                   }
2933  Bool                        getArpRefPicAvailable  ( RefPicList e, Int viewIdx)    { return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, 0)]; }
2934  IntAry1d                    getPocsInCurrRPSs()                                    { return m_pocsInCurrRPSs;                                      } 
2935#endif                                                                                                                                               
2936  Void                        setIsDepth            ( Bool isDepth )                 { m_isDepth = isDepth;                                          }
2937  Bool                        getIsDepth            () const                         { return m_isDepth;                                             }
2938  Void                        setCamparaSlice       ( Int** aaiScale = 0, Int** aaiOffset = 0 );     
2939
2940  IntAry1d                    getCodedScale         ()                               { return m_aaiCodedScale [0];                                   }
2941  IntAry1d                    getCodedOffset        ()                               { return m_aaiCodedOffset[0];                                   }
2942  IntAry1d                    getInvCodedScale      ()                               { return m_aaiCodedScale [1];                                   }
2943  IntAry1d                    getInvCodedOffset     ()                               { return m_aaiCodedOffset[1];                                   }
2944                                                                                                                                                     
2945  Void                        setCpScale( Int j, Int  val )                          { m_aaiCodedScale[0][j] = val;                                  }
2946  Int                         getCpScale( Int j )                                    { return m_aaiCodedScale[0][j];                                 }
2947                                                                                                                                                     
2948  Void                        setCpOff( Int j, Int  val )                            { m_aaiCodedOffset[0][j] = val;                                 }
2949  Int                         getCpOff( Int j )                                      { return m_aaiCodedOffset[0][j];                                }
2950                                                                                                                                                     
2951  Void                        setCpInvScale( Int j, Int  val )                       { m_aaiCodedScale[1][j] = val;                                  }
2952  Int                         getCpInvScale( Int j )                                 { return m_aaiCodedScale[1][j];                                 }
2953                                                                                                                                                     
2954  Void                        setCpInvOff( Int j, Int  val )                         { m_aaiCodedOffset[1][j] = val;                                 }
2955  Int                         getCpInvOff( Int j )                                   { return m_aaiCodedOffset[1][j];                                }
2956                                                                                                                                                       
2957  Void                        setIvPicLists( TComPicLists* m_ivPicLists );                                                                             
2958  Void                        setDepthToDisparityLUTs();                                                                                               
2959                                                                                                                                                       
2960  Int*                        getDepthToDisparityB( Int refViewIdx )                 { return m_depthToDisparityB[ getVPS()->getVoiInVps( refViewIdx) ];}
2961  Int*                        getDepthToDisparityF( Int refViewIdx )                 { return m_depthToDisparityF[ getVPS()->getVoiInVps( refViewIdx) ];}
2962#if H_3D_IC                                                                                                                                             
2963  Void                        setICEnableCandidate( Int* icEnableCandidate)          { m_aICEnableCandidate = icEnableCandidate;                     }
2964  Void                        setICEnableNum( Int* icEnableNum)                      { m_aICEnableNum = icEnableNum;                                 }
2965  Void                        setICEnableCandidate( UInt layer, Int value)           { m_aICEnableCandidate[ layer ] = value;                        }
2966  Void                        setICEnableNum( UInt layer, Int value)                 { m_aICEnableNum[ layer ] = value; ;                            }
2967                                                                                                                                                     
2968  Int                         getICEnableCandidate( Int layer)                       { return  m_aICEnableCandidate[ layer ];                        }
2969  Int                         getICEnableNum( Int layer)                             { return m_aICEnableNum[ layer ];                               }
2970#endif
2971#endif
2972// Additional slice header syntax elements
2973
2974  Void                        setCrossLayerBlaFlag( Bool flag )                      { m_crossLayerBlaFlag = flag;                                   }
2975  Bool                        getCrossLayerBlaFlag(  ) const                         { return m_crossLayerBlaFlag;                                   }
2976  Void                        checkCrossLayerBlaFlag ( ) const ;
2977
2978#if !H_MV_HLS7_GEN
2979  Void                        setPocResetFlag( Bool flag )                           { m_pocResetFlag = flag;                                        }
2980  Bool                        getPocResetFlag(  ) const                              { return m_pocResetFlag;                                        }
2981#endif
2982
2983  Void                        setDiscardableFlag( Bool flag )                        { m_discardableFlag = flag;                                     }
2984  Bool                        getDiscardableFlag(  ) const                           { return m_discardableFlag;                                     }
2985
2986  Void                        setInterLayerPredEnabledFlag( Bool flag )              { m_interLayerPredEnabledFlag = flag;                           }
2987  Bool                        getInterLayerPredEnabledFlag(  ) const                 { return m_interLayerPredEnabledFlag;                           }
2988
2989  Void                        setNumInterLayerRefPicsMinus1( Int  val )              { m_numInterLayerRefPicsMinus1 = val;                           }
2990  Int                         getNumInterLayerRefPicsMinus1(  ) const                { return m_numInterLayerRefPicsMinus1;                          }
2991
2992  Void                        setInterLayerPredLayerIdc( Int i, Int  val )           { m_interLayerPredLayerIdc[i] = val;                            }
2993  Int                         getInterLayerPredLayerIdc( Int i ) const               { return m_interLayerPredLayerIdc[i];                           }
2994
2995  Void                        setSliceSegmentHeaderExtensionLength( Int  val )       { m_sliceSegmentHeaderExtensionLength = val;                    }
2996  Int                         getSliceSegmentHeaderExtensionLength(  ) const         { return m_sliceSegmentHeaderExtensionLength;                   }
2997
2998  Void                        setPocResetIdc( Int  val )                             { m_pocResetIdc = val;                                          }
2999  Int                         getPocResetIdc(  ) const                               { return m_pocResetIdc;                                         }
3000  Void                        checkPocResetIdc( ) const                              { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !(getSlicePicOrderCntLsb() > 0 ) || !( getPocResetIdc() == 2) ); }
3001
3002  Void                        setPocResetPeriodId( Int  val )                        { m_pocResetPeriodId = val;                                     }
3003  Int                         getPocResetPeriodId(  ) const                          { return m_pocResetPeriodId;                                    }
3004
3005  Void                        setFullPocResetFlag( Bool flag )                       { m_fullPocResetFlag = flag;                                    }
3006  Bool                        getFullPocResetFlag(  ) const                          { return m_fullPocResetFlag;                                    }
3007
3008  Void                        setPocLsbVal( Int  val )                               { m_pocLsbVal = val;                                            }
3009  Int                         getPocLsbVal(  )  const                                { return m_pocLsbVal;                                           }
3010  Void                        checkPocLsbVal( ) const                                { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !getFullPocResetFlag() || ( getPocLsbVal() == 0 ) ); }
3011
3012  Void                        setPocMsbValPresentFlag( Bool flag )                   { m_pocMsbValPresentFlag = flag;                                }
3013  Bool                        getPocMsbValPresentFlag(  )          const             { return m_pocMsbValPresentFlag;                                }
3014
3015  Void                        setPocMsbVal( Int  val )                               { m_pocMsbVal = val;                                            }
3016  Int                         getPocMsbVal(  )         const                         { return m_pocMsbVal;                                           }
3017
3018  Bool                        getCraOrBlaPicFlag()       const                       { return ( getCraPicFlag() || getBlaPicFlag() );                }
3019  Bool                        getPocMsbValRequiredFlag() const                       { return ( getCraOrBlaPicFlag() && ( getVPS()->getVpsPocLsbAlignedFlag() || getVPS()->getNumDirectRefLayers( getLayerIdInVps() ) == 0 ) );  }
3020
3021  UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4
3022
3023  Bool getBlaPicFlag() const
3024  {
3025    return  getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
3026    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
3027    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP;
3028  }
3029  Bool getCraPicFlag () const 
3030  {
3031    return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
3032  }
3033
3034  // Additional variables derived in slice header semantics
3035#if NH_3D
3036  Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
3037  Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
3038#else
3039  Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
3040  Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
3041#endif
3042
3043  Int                         getRefLayerPicFlag( Int i ) const;
3044  Int                         getRefLayerPicIdc ( Int j ) const;
3045  Int                         getNumRefLayerPics( ) const;
3046
3047  Int                         getNumActiveRefLayerPics( ) const;
3048
3049  Int                         getNumActiveRefLayerPics0( ) const                     { return (Int) m_refPicSetInterLayer0->size();                  };
3050  Int                         getNumActiveRefLayerPics1( ) const                     { return (Int) m_refPicSetInterLayer1->size();                  };
3051
3052  Int                         getRefPicLayerId             ( Int i ) const;
3053
3054  Void                        setRefPicSetInterLayer       ( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1);
3055  TComPic*                    getPicFromRefPicSetInterLayer ( Int setIdc, Int layerId ) const ;
3056
3057#if NH_3D
3058  // 3D-HEVC tool parameters
3059  Void                        deriveInCmpPredAndCpAvailFlag( );
3060  Void                        init3dToolParameters();
3061  Void                        checkInCompPredRefLayers();;
3062
3063  Bool                        getIvMvPredFlag           ( )                          { return m_ivMvPredFlag           ;                             };
3064  Bool                        getIvMvScalingFlag        ( )                          { return m_ivMvScalingFlag        ;                             };
3065  Bool                        getIvResPredFlag          ( )                          { return m_ivResPredFlag          ;                             };
3066  Bool                        getDepthRefinementFlag    ( )                          { return m_depthRefinementFlag    ;                             };
3067  Bool                        getViewSynthesisPredFlag  ( )                          { return m_viewSynthesisPredFlag  ;                             };
3068  Bool                        getDepthBasedBlkPartFlag  ( )                          { return m_depthBasedBlkPartFlag  ;                             };
3069  Bool                        getMpiFlag                ( )                          { return m_mpiFlag                ;                             };
3070  Bool                        getIntraContourFlag       ( )                          { return m_intraContourFlag       ;                             };
3071  Bool                        getIntraSdcWedgeFlag      ( )                          { return m_intraSdcWedgeFlag      ;                             };
3072  Bool                        getQtPredFlag             ( )                          { return m_qtPredFlag             ;                             };
3073  Bool                        getInterSdcFlag           ( )                          { return m_interSdcFlag           ;                             };
3074  Bool                        getDepthIntraSkipFlag     ( )                          { return m_depthIntraSkipFlag     ;                             };
3075
3076  Int                         getMpiSubPbSize           ( )                          { return m_mpiSubPbSize           ;                             };
3077  Int                         getSubPbSize              ( )                          { return m_subPbSize              ;                             };
3078#if NH_3D_NBDV
3079  Int                         getDefaultRefViewIdx()                                 { return m_iDefaultRefViewIdx;                                  }
3080  Void                        setDefaultRefViewIdx(Int iViewIdx)                     { m_iDefaultRefViewIdx = iViewIdx;                              }
3081
3082  Bool                        getDefaultRefViewIdxAvailableFlag()                    { return m_bDefaultRefViewIdxAvailableFlag;                     }
3083  Void                        setDefaultRefViewIdxAvailableFlag(Bool bViewIdx)       { m_bDefaultRefViewIdxAvailableFlag = bViewIdx;                 }
3084  Void                        setDefaultRefView( );
3085#endif
3086#endif
3087  // Inference
3088  Bool                        inferPocMsbValPresentFlag();
3089#endif
3090#if H_3D
3091  Int                         getDefaultRefViewIdx()                                 { return m_iDefaultRefViewIdx;                                  }
3092  Void                        setDefaultRefViewIdx(Int iViewIdx)                     { m_iDefaultRefViewIdx = iViewIdx;                              }
3093
3094  Bool                        getDefaultRefViewIdxAvailableFlag()                    { return m_bDefaultRefViewIdxAvailableFlag;                     }
3095  Void                        setDefaultRefViewIdxAvailableFlag(Bool bViewIdx)       { m_bDefaultRefViewIdxAvailableFlag = bViewIdx;                 }
3096  Void                        setDefaultRefView( );
3097#endif
3098protected:
3099  TComPic*                    xGetRefPic        (TComList<TComPic*>& rcListPic, Int poc);
3100  TComPic*                    xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
3101#if NH_MV
3102  TComPic*                    xGetInterLayerRefPic( std::vector<TComPic*>& rcListIlPic, Int layerId ); 
3103#endif
3104};// END CLASS DEFINITION TComSlice
3105
3106
3107Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData);
3108
3109template <class T> class ParameterSetMap
3110{
3111public:
3112  template <class Tm>
3113  struct MapData
3114  {
3115    Bool                  bChanged;
3116    std::vector<UChar>   *pNaluData; // Can be null
3117    Tm*                   parameterSet;
3118  };
3119
3120  ParameterSetMap(Int maxId)
3121  :m_maxId (maxId)
3122  {}
3123
3124  ~ParameterSetMap()
3125  {
3126    for (typename std::map<Int,MapData<T> >::iterator i = m_paramsetMap.begin(); i!= m_paramsetMap.end(); i++)
3127    {
3128      delete (*i).second.pNaluData;
3129      delete (*i).second.parameterSet;
3130    }
3131  }
3132
3133  Void storePS(Int psId, T *ps, const std::vector<UChar> &naluData)
3134  {
3135    assert ( psId < m_maxId );
3136    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
3137    {
3138      MapData<T> &mapData=m_paramsetMap[psId];
3139
3140      // work out changed flag
3141      calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, naluData);
3142      delete m_paramsetMap[psId].pNaluData;
3143      delete m_paramsetMap[psId].parameterSet;
3144
3145      m_paramsetMap[psId].parameterSet = ps;
3146    }
3147    else
3148    {
3149      m_paramsetMap[psId].parameterSet = ps;
3150      m_paramsetMap[psId].bChanged = false;
3151    }
3152      m_paramsetMap[psId].pNaluData=new std::vector<UChar>;
3153    *(m_paramsetMap[psId].pNaluData) = naluData;
3154  }
3155
3156  Void clearChangedFlag(Int psId)
3157  {
3158    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
3159    {
3160      m_paramsetMap[psId].bChanged=false;
3161    }
3162  }
3163
3164  Bool getChangedFlag(Int psId) const
3165  {
3166    const typename std::map<Int,MapData<T> >::const_iterator constit=m_paramsetMap.find(psId);
3167    if ( constit != m_paramsetMap.end() )
3168    {
3169      return constit->second.bChanged;
3170    }
3171    return false;
3172  }
3173
3174  T* getPS(Int psId)
3175  {
3176    typename std::map<Int,MapData<T> >::iterator it=m_paramsetMap.find(psId);
3177    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
3178  }
3179
3180  const T* getPS(Int psId) const
3181  {
3182    typename std::map<Int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId);
3183    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
3184  }
3185
3186  T* getFirstPS()
3187  {
3188    return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet;
3189  }
3190
3191private:
3192  std::map<Int,MapData<T> > m_paramsetMap;
3193  Int                       m_maxId;
3194};
3195
3196class ParameterSetManager
3197{
3198public:
3199                 ParameterSetManager();
3200  virtual        ~ParameterSetManager();
3201
3202  //! store sequence parameter set and take ownership of it
3203  Void           storeVPS(TComVPS *vps, const std::vector<UChar> &naluData) { m_vpsMap.storePS( vps->getVPSId(), vps, naluData); };
3204  //! get pointer to existing video parameter set
3205  TComVPS*       getVPS(Int vpsId)                                           { return m_vpsMap.getPS(vpsId); };
3206  Bool           getVPSChangedFlag(Int vpsId) const                          { return m_vpsMap.getChangedFlag(vpsId); }
3207  Void           clearVPSChangedFlag(Int vpsId)                              { m_vpsMap.clearChangedFlag(vpsId); }
3208  TComVPS*       getFirstVPS()                                               { return m_vpsMap.getFirstPS(); };
3209
3210  //! store sequence parameter set and take ownership of it
3211  Void           storeSPS(TComSPS *sps, const std::vector<UChar> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, naluData); };
3212  //! get pointer to existing sequence parameter set
3213  TComSPS*       getSPS(Int spsId)                                           { return m_spsMap.getPS(spsId); };
3214  Bool           getSPSChangedFlag(Int spsId) const                          { return m_spsMap.getChangedFlag(spsId); }
3215  Void           clearSPSChangedFlag(Int spsId)                              { m_spsMap.clearChangedFlag(spsId); }
3216  TComSPS*       getFirstSPS()                                               { return m_spsMap.getFirstPS(); };
3217
3218  //! store picture parameter set and take ownership of it
3219  Void           storePPS(TComPPS *pps, const std::vector<UChar> &naluData) { m_ppsMap.storePS( pps->getPPSId(), pps, naluData); };
3220  //! get pointer to existing picture parameter set
3221  TComPPS*       getPPS(Int ppsId)                                           { return m_ppsMap.getPS(ppsId); };
3222  Bool           getPPSChangedFlag(Int ppsId) const                          { return m_ppsMap.getChangedFlag(ppsId); }
3223  Void           clearPPSChangedFlag(Int ppsId)                              { m_ppsMap.clearChangedFlag(ppsId); }
3224  TComPPS*       getFirstPPS()                                               { return m_ppsMap.getFirstPS(); };
3225
3226  //! activate a SPS from a active parameter sets SEI message
3227  //! \returns true, if activation is successful
3228#if NH_MV
3229  // Bool           activateSPSWithSEI(Int SPSId, Int layerId );
3230#else
3231  // Bool           activateSPSWithSEI(Int SPSId);
3232#endif
3233
3234  //! activate a PPS and depending on isIDR parameter also SPS and VPS
3235  //! \returns true, if activation is successful
3236#if NH_MV
3237  Bool           activatePPS(Int ppsId, Bool isIRAP, Int layerId );
3238#else
3239  Bool           activatePPS(Int ppsId, Bool isIRAP);
3240#endif
3241
3242  const TComVPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); };
3243
3244#if NH_MV 
3245  const TComSPS* getActiveSPS( Int layer )const { return m_spsMap.getPS(m_activeSPSId[layer]); };
3246#else 
3247  const TComSPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); };
3248#endif
3249
3250protected:
3251  ParameterSetMap<TComVPS> m_vpsMap;
3252  ParameterSetMap<TComSPS> m_spsMap;
3253  ParameterSetMap<TComPPS> m_ppsMap;
3254
3255  Int m_activeVPSId; // -1 for nothing active
3256#if NH_MV 
3257  Int m_activeSPSId[ MAX_NUM_LAYERS ]; // -1 for nothing active
3258#else 
3259  Int m_activeSPSId; // -1 for nothing active
3260#endif
3261};
3262
3263//! \}
3264
3265#endif // __TCOMSLICE__
Note: See TracBrowser for help on using the repository browser.