source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComSlice.h @ 1313

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

Merged 14.1-update-dev1@1312.

  • Property svn:eol-style set to native
File size: 223.3 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#if NH_MV_FIX_TICKET_105
1122  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() - 1 ); } 
1123#else
1124  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() ); } 
1125#endif
1126
1127  Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )            { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
1128  Bool    getOutputLayerFlag( Int outLayerSetIdx, Int i )            const      { return m_outputLayerFlag[ outLayerSetIdx ][ i ]; } 
1129
1130  Bool    inferOutputLayerFlag( Int i, Int j )                       const;
1131
1132  Void    setProfileTierLevelIdx( Int i, Int j, Int val )                       { m_profileTierLevelIdx[ i ][ j ] = val; }
1133  Int     getProfileTierLevelIdx( Int i, Int j )                     const      { return m_profileTierLevelIdx[ i ][ j ]; } 
1134  Int     inferProfileTierLevelIdx( Int i, Int j )                   const; 
1135                                                                     
1136  Void    setAltOutputLayerFlag( Int i, Bool flag )                             { m_altOutputLayerFlag[i] = flag; } 
1137  Bool    getAltOutputLayerFlag( Int i )                             const      { return m_altOutputLayerFlag[i]; } 
1138                                                                     
1139  Void    setRepFormatIdxPresentFlag( Bool flag )                               { m_repFormatIdxPresentFlag = flag; } 
1140  Bool    getRepFormatIdxPresentFlag(  )                             const      { return m_repFormatIdxPresentFlag; } 
1141                                                                     
1142  Void    setVpsNumRepFormatsMinus1( Int  val )                                 { m_vpsNumRepFormatsMinus1 = val; } 
1143  Int     getVpsNumRepFormatsMinus1(  )                              const      { return m_vpsNumRepFormatsMinus1; } 
1144                                                                     
1145  Void    setVpsRepFormatIdx( Int i, Int  val )                                 { m_vpsRepFormatIdx[i] = val; } 
1146  Int     getVpsRepFormatIdx( Int i )                                const      { return m_vpsRepFormatIdx[i]; } 
1147
1148  Int     inferVpsRepFormatIdx( Int i )                              const      { return std::min( i, getVpsNumRepFormatsMinus1()  );  }
1149
1150  Void    setRepFormat( Int i, TComRepFormat val )                              { m_repFormat[i] = val;  }
1151  Void    setRepFormat( std::vector<TComRepFormat> val )                        { m_repFormat = val;  }
1152  const TComRepFormat* getRepFormat( Int i )                         const      { return &m_repFormat[i]; }
1153                                                                     
1154  Void    setMaxOneActiveRefLayerFlag( Bool flag)                               { m_maxOneActiveRefLayerFlag = flag; } 
1155  Bool    getMaxOneActiveRefLayerFlag( )                             const      { return m_maxOneActiveRefLayerFlag; } 
1156                                                                     
1157  Void    setVpsPocLsbAlignedFlag( Bool flag )                                  { m_vpsPocLsbAlignedFlag = flag; } 
1158  Bool    getVpsPocLsbAlignedFlag(  )                                const      { return m_vpsPocLsbAlignedFlag; } 
1159                                                                     
1160  Void    setDpbSize( TComDpbSize val )                                         { m_dpbSize = val; } 
1161  const TComDpbSize * getDpbSize( )                                  const      { return &m_dpbSize; } 
1162                                                                     
1163                                                                     
1164  Void    setPocLsbNotPresentFlag( Int i, Bool flag )                           { m_pocLsbNotPresentFlag[i] = flag; } 
1165  Bool    getPocLsbNotPresentFlag( Int i )                           const      { return m_pocLsbNotPresentFlag[i]; } 
1166                                                                     
1167  Void    setDirectDepTypeLenMinus2( Int val)                                   { m_directDepTypeLenMinus2 = val; } 
1168  Int     getDirectDepTypeLenMinus2( )                               const      { return m_directDepTypeLenMinus2; } 
1169                                                                     
1170  Void    setDefaultDirectDependencyFlag( Bool flag )                           { m_defaultDirectDependencyFlag = flag; } 
1171  Bool    getDefaultDirectDependencyFlag(  )                         const      { return m_defaultDirectDependencyFlag; } 
1172                                                                     
1173  Void    setDefaultDirectDependencyType( Int  val )                            { m_defaultDirectDependencyType = val; } 
1174  Int     getDefaultDirectDependencyType(  )                         const      { return m_defaultDirectDependencyType; } 
1175 
1176  Void    setDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps, Int val) { m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ] = val; } 
1177  Int     getDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps) const { return m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ]; } 
1178
1179  Void    setVpsVuiPresentFlag( Bool flag )                                     { m_vpsVuiPresentFlag = flag; } 
1180  Bool    getVpsVuiPresentFlag(  )                                   const      { return m_vpsVuiPresentFlag; } 
1181                                                         
1182  const TComVPSVUI* getVPSVUI(  )                                    const      { return &m_vpsVUI;  }
1183  Void  setVPSVUI( TComVPSVUI val )                                             { m_vpsVUI = val;  }
1184 
1185 // VPS EXTENSION SEMANTICS VARIABLES
1186  Void    setLayerIdInVps( Int layerIdInNuh, Int val )                          { m_layerIdInVps[layerIdInNuh] = val;  }
1187  Int     getLayerIdInVps( Int layerIdInNuh )                        const      { assert( m_layerIdInVps[layerIdInNuh] >= 0 ); return m_layerIdInVps[layerIdInNuh]; }
1188
1189  Int     getScalabilityId ( Int layerIdInVps, ScalabilityType scalType ) const ;
1190  Int     getViewId        ( Int layerIdInNuh )                 const           { return m_viewIdVal[ getViewIndex( layerIdInNuh )]; }
1191  Void    setRefLayers(); 
1192
1193  // To be aligned with spec naming, getViewIndex will be removed in future versions
1194  Int     getViewOrderIdx ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), VIEW_ORDER_INDEX  ); }   
1195  Int     getViewIndex    ( Int layerIdInNuh ) const                            { return getViewOrderIdx( layerIdInNuh ); }   
1196  Int     getAuxId        ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), AUX_ID  ); }   
1197  Int     getDependencyId ( Int layerIdInNuh ) const                            { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPENDENCY_ID  ); }   
1198  Int     getNumViews()                        const                            { return m_numViews; }
1199  Void    initNumViews();
1200#if NH_3D
1201  Void    initViewCompLayer( );
1202  Int     getViewOIdxList( Int i )             const                            { return m_viewOIdxList[i]; }
1203  std::vector<Int> getViewOIdxList( )          const                            { return m_viewOIdxList; }
1204
1205  Int     getVoiInVps( Int viewOIdx )          const;
1206
1207  Bool    getViewCompLayerPresentFlag (Int i, Bool d ) const                    { return  m_viewCompLayerPresentFlag[ getVoiInVps(i) ][d]; }
1208  Bool    getViewCompLayerId          (Int i, Bool d ) const                    { return  m_viewCompLayerId         [ getVoiInVps(i) ][d]; }
1209#endif
1210  Bool    getDependencyFlag( Int i, Int j ) const                               { return m_dependencyFlag[i][j]; }
1211  Int     getNumDirectRefLayers( Int layerIdInNuh ) const                       { return m_numDirectRefLayers[ layerIdInNuh ];  };                               
1212#if NH_3D                                                                     
1213  Int     getNumRefListLayers( Int layerIdInNuh )   const                       { return m_numRefListLayers[ layerIdInNuh ];  };                               
1214#endif
1215
1216  Int     getNumRefLayers            ( Int i )      const                       { return m_numRefLayers[i]; } 
1217  Int     getNumPredictedLayers      ( Int i )      const                       { return m_numPredictedLayers[i]; } 
1218                                                                               
1219  Int     getIdRefLayer              ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumRefLayers      ( i )); return m_idRefLayer      [i][j]; } 
1220  Int     getIdPredictedLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumPredictedLayers( i )); return m_idPredictedLayer[i][j]; } 
1221  Int     getIdDirectRefLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumDirectRefLayers( i )); return m_idDirectRefLayer[i][j]; } 
1222#if NH_3D                                                                     
1223  Int     getIdRefListLayer          ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumRefListLayers   ( i )); return m_idRefListLayer[i][j]; } 
1224#endif                                                                         
1225  Int     getNumIndependentLayers    (  )             const                     { return m_numIndependentLayers; } 
1226  Int     getNumLayersInTreePartition( Int i )        const                     { return m_numLayersInTreePartition[i]; } 
1227  Int     getTreePartitionLayerIdList( Int i, Int j ) const                     { return m_treePartitionLayerIdList[i][j]; } 
1228  Bool    getRecursiveRefLayerFlag   ( Int i, Int j ) const                     { return m_recursiveRefLayerFlag[i][j]; } 
1229  Int     getNumLayerSets( )                          const                     { return getVpsNumLayerSetsMinus1() + 1 + getNumAddLayerSets();  }; 
1230                                                                               
1231  Int     getFirstAddLayerSetIdx()                    const                     { return getVpsNumLayerSetsMinus1() + 1; } 
1232  Int     getLastAddLayerSetIdx()                     const                     { return getFirstAddLayerSetIdx() + getNumAddLayerSets() - 1; }
1233  Bool    checkVPSExtensionSyntax(); 
1234  Int     scalTypeToScalIdx   ( ScalabilityType scalType ) const ;
1235
1236  Int     getProfileTierLevelIdxLen()                 const                     { return gCeilLog2( getVpsNumProfileTierLevelMinus1() + 1 ); };       
1237  Int     getVpsRepFormatIdxLen()                     const                     { return gCeilLog2( getVpsNumRepFormatsMinus1() + 1 ); };       
1238
1239  Int     getNumLayersInIdList ( Int lsIdx )          const; 
1240  Int     getLayerSetLayerIdList(Int lsIdx, Int j )   const                     { return m_layerSetLayerIdList[ lsIdx ][ j ]; }; 
1241
1242  Int     getNumOutputLayerSets()                     const; 
1243
1244  Bool    isOutputLayer( Int outLayerSetIdx, Int layerIdInNuh )  const;   
1245  Void    deriveLayerSetLayerIdList();
1246
1247  Int     olsIdxToLsIdx( Int i )                                       const    { return ( i < getNumLayerSets() ) ? i  : getLayerSetIdxForOlsMinus1( i ) + 1 ; };
1248  Void    initTargetLayerIdLists  ( );
1249  Void    deriveTargetLayerIdList ( Int i );
1250  std::vector<Int> getTargetDecLayerIdList( Int targetDecLayerSetIdx ) const     { return m_targetDecLayerIdLists[targetDecLayerSetIdx]; }; 
1251  std::vector<Int> getTargetOptLayerIdList( Int targetOptLayerSetIdx ) const     { return m_targetOptLayerIdLists[targetOptLayerSetIdx]; }; 
1252
1253  Int     getNumOutputLayersInOutputLayerSet( Int i )                  const     { return (Int) getTargetOptLayerIdList( i ).size(); }; 
1254  Int     getOlsHighestOutputLayerId( Int i )                          const     { return getTargetOptLayerIdList( i ).back(); }; 
1255
1256  Void    deriveAddLayerSetLayerIdList( Int i );
1257  Void    deriveNecessaryLayerFlags( Int olsIdx );
1258  Int     getNecessaryLayerFlag( Int i, Int j )                        const     { AOF( i >= 0 && i < getNumOutputLayerSets() ); AOF( j >= 0 && j < getNumLayersInIdList( olsIdxToLsIdx( i ) )  );  return m_necessaryLayerFlag[i][j]; }; 
1259
1260  Int     getMaxSubLayersInLayerSetMinus1( Int i )                     const;
1261  Int     getHighestLayerIdxPlus1Len( Int j )                          const     { return gCeilLog2( getNumLayersInTreePartition( j ) + 1 );   }; 
1262  Bool    getAltOutputLayerFlagVar( Int i )                            const;
1263
1264  // inference
1265  Int     inferDimensionId     ( Int i, Int j )                        const;
1266  Int     inferLastDimsionIdLenMinus1()                                const;
1267
1268  // helpers
1269  Void    printPTL()                                                   const;
1270  Void    printLayerDependencies()                                     const;
1271  Void    printScalabilityId()                                         const;
1272  Void    printLayerSets()                                             const;
1273
1274
1275  /// VPS EXTENSION 2 SYNTAX ELEMENTS
1276  Int     getDepthId                   ( Int layerIdInNuh)             const    { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPTH_ID ); }
1277#if NH_3D                                                             
1278  Bool    getVpsDepthFlag              ( Int layerIdInNuh)             const    { return (getDepthId( layerIdInNuh ) > 0);  }
1279  Int     getLayerIdInNuh              ( Int viewIndex, Bool depthFlag ) const;   
1280         
1281  Void    createCamPars                ( Int iNumViews ); 
1282  Void    initCamParaVPS               ( Int vOIdxInVps, Int numCp, Bool cpInSliceSegmentHeaderFlag, Int* cpRefVoi, Int** aaiScale, Int** aaiOffset );                                               
1283                                       
1284  Void    setCpPrecision               ( Int  val )                             { m_cpPrecision = val;                       }
1285  Int     getCpPrecision               (  )                            const    { return m_cpPrecision;                      }
1286                                                                                                               
1287  Void    setNumCp                     ( Int i, Int  val )                      { m_numCp[i] = val;                          }
1288  Int     getNumCp                     ( Int i )                       const    { return m_numCp[i];                         }
1289                                                                                                               
1290  Void    setCpRefVoi                  ( Int i, Int m, Int  val )               { m_cpRefVoi[i][m] = val;                    }
1291  Int     getCpRefVoi                  ( Int i, Int m )                const    { return m_cpRefVoi[i][m];                   }
1292                                                                                                               
1293  Void    setCpInSliceSegmentHeaderFlag( Int i, Bool flag )                     { m_cpInSliceSegmentHeaderFlag[i] = flag;    }
1294  Bool    getCpInSliceSegmentHeaderFlag( Int i )                       const    { return m_cpInSliceSegmentHeaderFlag[i];    }
1295                                                                                                               
1296  Void    setVpsCpScale                ( Int i, Int j, Int val )                { m_aaaiCodedScale [i][0][j] = val;          }
1297  Int     getVpsCpScale                ( Int i, Int j )                const    { return m_aaaiCodedScale[i][0][j];          }
1298                                                                                                               
1299  Void    setVpsCpOff                  ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][0][j] = val;          }
1300  Int     getVpsCpOff                  ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][0][j];         }
1301                                                                                                               
1302  Void    setVpsCpInvScale             ( Int i, Int j, Int val )                { m_aaaiCodedScale[i][1][j] = val;           }
1303  Int     getVpsCpInvScale             ( Int i, Int j )                const    { return m_aaaiCodedScale[i][1][j];          }
1304                                                                                                               
1305  Void    setVpsCpInvOff               ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][1][j] = val;          }
1306  Int     getVpsCpInvOff               ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][1][j];         }
1307
1308// Derived
1309  Void    deriveCpPresentFlag          ( );                 
1310  Void    setCpPresentFlag             ( Int i, Int m, Bool flag )              { m_cpPresentFlag[i][m] = flag;             } 
1311  Bool    getCpPresentFlag             ( Int i, Int m )                const    { return m_cpPresentFlag[i][m];             }   
1312                                                                       
1313  const IntAry1d& getCodedScale        ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][0];   }
1314  const IntAry1d& getCodedOffset       ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][0];   }
1315  const IntAry1d& getInvCodedScale     ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][1];   }
1316  const IntAry1d& getInvCodedOffset    ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][1];   }
1317#endif
1318
1319  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
1320  {
1321    std::cout << std::endl; 
1322    for (Int j = 0; j < numElemDim1; j++ )
1323    { 
1324      std::cout << std::right << std::setw(27) << name; 
1325      if (printIdx)
1326      {
1327        std::cout << "[" << std::right << std::setw(3) << idx[ j ] << "]" ; 
1328      }
1329      else
1330      {
1331        std::cout << std::right << std::setw(5) << " "; 
1332      }
1333
1334      if ( printNumber )
1335      {
1336        std::cout << " (" << std::right << std::setw(3) << numElemDim2[j] << ")";       
1337      }         
1338      else
1339      {
1340        std::cout << std::right << std::setw(6) << " ";             
1341      }
1342
1343      std::cout << ":";
1344      for (Int i = 0; i < numElemDim2[j]; i++)
1345      {
1346        std::cout << std::right << std::setw(3) << vec[j][i];
1347      }   
1348      std::cout << std::endl; 
1349    }
1350  }
1351
1352  template <typename T> Void xPrintArray( const char* name, Int numElem, T vec, Bool printNumber  )  const
1353  {
1354    std::vector<Int> numElemDim2(1, numElem);   
1355    std::vector<T>   vec2       (1,  vec    );
1356    std::vector<Int> idx2       (0); 
1357    xPrintArray( name, 1, idx2, numElemDim2, vec2, printNumber, false );
1358  }
1359
1360#endif
1361};
1362
1363#if NH_3D_DLT
1364class TComDLT
1365{
1366private:
1367  Bool              m_bDltPresentFlag;
1368  Bool              m_bUseDLTFlag                 [ MAX_NUM_LAYERS ];
1369  Bool              m_bInterViewDltPredEnableFlag [ MAX_NUM_LAYERS ];
1370  Bool              m_bDltBitMapRepFlag           [ MAX_NUM_LAYERS ];
1371
1372  Int               m_iNumDepthmapValues          [ MAX_NUM_LAYERS ];
1373  std::vector<Int>  m_iDepthValue2Idx             [ MAX_NUM_LAYERS ];
1374  std::vector<Int>  m_iIdx2DepthValue             [ MAX_NUM_LAYERS ];
1375
1376  Int               m_iNumDepthViews;
1377  UInt              m_uiDepthViewBitDepth;
1378 
1379  // mapping
1380  Int               m_iDepthIdxToLayerId          [ MAX_NUM_LAYERS ];
1381
1382public:
1383  TComDLT();
1384  ~TComDLT();
1385 
1386  Int     getDepthIdxToLayerId(Int depthIdx) const        { return m_iDepthIdxToLayerId[depthIdx]; }
1387  Void    setDepthIdxToLayerId(Int depthIdx, Int layerId) { m_iDepthIdxToLayerId[depthIdx] = layerId; }
1388
1389  Bool    getDltPresentFlag  ()                           const   { return m_bDltPresentFlag; }
1390  Void    setDltPresentFlag  ( Bool b )                   { m_bDltPresentFlag = b;    }
1391
1392  Bool    getUseDLTFlag      ( Int layerIdInVps )         const   { return m_bUseDLTFlag[ layerIdInVps ]; }
1393  Void    setUseDLTFlag      ( Int layerIdInVps, Bool b ) { m_bUseDLTFlag[ layerIdInVps ]  = b;   }
1394 
1395  Bool    getInterViewDltPredEnableFlag( Int layerIdInVps )         const   { return m_bInterViewDltPredEnableFlag[ layerIdInVps ]; }
1396  Void    setInterViewDltPredEnableFlag( Int layerIdInVps, Bool b ) { m_bInterViewDltPredEnableFlag[ layerIdInVps ] = b;    }
1397 
1398  Bool    getUseBitmapRep      ( Int layerIdInVps )         const   { return m_bDltBitMapRepFlag[ layerIdInVps ]; }
1399  Void    setUseBitmapRep      ( Int layerIdInVps, Bool b ) { m_bDltBitMapRepFlag[ layerIdInVps ]  = b;   }
1400
1401  Void    setNumDepthViews   ( Int n )                    { m_iNumDepthViews = n; }
1402  Int     getNumDepthViews   ()                           const   { return m_iNumDepthViews; }
1403
1404  Void    setDepthViewBitDepth( UInt n )                  { m_uiDepthViewBitDepth = n; }
1405  UInt    getDepthViewBitDepth()                          const   { return m_uiDepthViewBitDepth; }
1406
1407  Int     getNumDepthValues( Int layerIdInVps )           const   { return getUseDLTFlag(layerIdInVps)?m_iNumDepthmapValues[layerIdInVps]:(1 << m_uiDepthViewBitDepth); }
1408  Int     depthValue2idx( Int layerIdInVps, Pel value )   const   { return getUseDLTFlag(layerIdInVps)?m_iDepthValue2Idx[layerIdInVps][value]:value; }
1409  Pel     idx2DepthValue( Int layerIdInVps, UInt uiIdx )  const   { return getUseDLTFlag(layerIdInVps)?m_iIdx2DepthValue[layerIdInVps][ClipBD(uiIdx,m_uiDepthViewBitDepth)]:uiIdx; }
1410  Void    setDepthLUTs( Int layerIdInVps, std::vector<Int> idx2DepthValue, Int iNumDepthValues = 0 );
1411  std::vector<Int>    idx2DepthValue( Int layerIdInVps )  const   { return m_iIdx2DepthValue[layerIdInVps]; }
1412  Void    getDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int>& riDeltaDLTOut, UInt& ruiDeltaDLTOutNum ) const;
1413  Void    setDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int> piDeltaDLTIn, UInt uiDeltaDLTInNum );
1414};
1415#endif
1416
1417
1418class Window
1419{
1420private:
1421  Bool m_enabledFlag;
1422  Int  m_winLeftOffset;
1423  Int  m_winRightOffset;
1424  Int  m_winTopOffset;
1425  Int  m_winBottomOffset;
1426#if NH_MV
1427  Bool          m_scaledFlag; 
1428#endif
1429public:
1430  Window()
1431  : m_enabledFlag    (false)
1432  , m_winLeftOffset  (0)
1433  , m_winRightOffset (0)
1434  , m_winTopOffset   (0)
1435  , m_winBottomOffset(0)
1436#if NH_MV
1437  , m_scaledFlag(true)
1438#endif
1439  { }
1440
1441  Bool getWindowEnabledFlag() const   { return m_enabledFlag;                          }
1442  Int  getWindowLeftOffset() const    { return m_enabledFlag ? m_winLeftOffset : 0;    }
1443  Void setWindowLeftOffset(Int val)   { m_winLeftOffset = val; m_enabledFlag = true;   }
1444  Int  getWindowRightOffset() const   { return m_enabledFlag ? m_winRightOffset : 0;   }
1445  Void setWindowRightOffset(Int val)  { m_winRightOffset = val; m_enabledFlag = true;  }
1446  Int  getWindowTopOffset() const     { return m_enabledFlag ? m_winTopOffset : 0;     }
1447  Void setWindowTopOffset(Int val)    { m_winTopOffset = val; m_enabledFlag = true;    }
1448  Int  getWindowBottomOffset() const  { return m_enabledFlag ? m_winBottomOffset: 0;   }
1449  Void setWindowBottomOffset(Int val) { m_winBottomOffset = val; m_enabledFlag = true; }
1450
1451#if NH_MV
1452  Void          setScaledFlag(Bool flag)          { m_scaledFlag = flag;  } 
1453  Bool          getScaledFlag() const             { return m_scaledFlag;  } 
1454  Void          scaleOffsets( Int scal );
1455#endif
1456  Void setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
1457  {
1458    m_enabledFlag     = true;
1459    m_winLeftOffset   = offsetLeft;
1460    m_winRightOffset  = offsetLRight;
1461    m_winTopOffset    = offsetLTop;
1462    m_winBottomOffset = offsetLBottom;
1463  }
1464};
1465
1466
1467class TComVUI
1468{
1469private:
1470  Bool       m_aspectRatioInfoPresentFlag;
1471  Int        m_aspectRatioIdc;
1472  Int        m_sarWidth;
1473  Int        m_sarHeight;
1474  Bool       m_overscanInfoPresentFlag;
1475  Bool       m_overscanAppropriateFlag;
1476  Bool       m_videoSignalTypePresentFlag;
1477  Int        m_videoFormat;
1478  Bool       m_videoFullRangeFlag;
1479  Bool       m_colourDescriptionPresentFlag;
1480  Int        m_colourPrimaries;
1481  Int        m_transferCharacteristics;
1482  Int        m_matrixCoefficients;
1483  Bool       m_chromaLocInfoPresentFlag;
1484  Int        m_chromaSampleLocTypeTopField;
1485  Int        m_chromaSampleLocTypeBottomField;
1486  Bool       m_neutralChromaIndicationFlag;
1487  Bool       m_fieldSeqFlag;
1488  Window     m_defaultDisplayWindow;
1489  Bool       m_frameFieldInfoPresentFlag;
1490  Bool       m_hrdParametersPresentFlag;
1491  Bool       m_bitstreamRestrictionFlag;
1492  Bool       m_tilesFixedStructureFlag;
1493  Bool       m_motionVectorsOverPicBoundariesFlag;
1494  Bool       m_restrictedRefPicListsFlag;
1495  Int        m_minSpatialSegmentationIdc;
1496  Int        m_maxBytesPerPicDenom;
1497  Int        m_maxBitsPerMinCuDenom;
1498  Int        m_log2MaxMvLengthHorizontal;
1499  Int        m_log2MaxMvLengthVertical;
1500  TComHRD    m_hrdParameters;
1501  TimingInfo m_timingInfo;
1502
1503public:
1504  TComVUI()
1505    : m_aspectRatioInfoPresentFlag        (false) //TODO: This initialiser list contains magic numbers
1506    , m_aspectRatioIdc                    (0)
1507    , m_sarWidth                          (0)
1508    , m_sarHeight                         (0)
1509    , m_overscanInfoPresentFlag           (false)
1510    , m_overscanAppropriateFlag           (false)
1511    , m_videoSignalTypePresentFlag        (false)
1512    , m_videoFormat                       (5)
1513    , m_videoFullRangeFlag                (false)
1514    , m_colourDescriptionPresentFlag      (false)
1515    , m_colourPrimaries                   (2)
1516    , m_transferCharacteristics           (2)
1517    , m_matrixCoefficients                (2)
1518    , m_chromaLocInfoPresentFlag          (false)
1519    , m_chromaSampleLocTypeTopField       (0)
1520    , m_chromaSampleLocTypeBottomField    (0)
1521    , m_neutralChromaIndicationFlag       (false)
1522    , m_fieldSeqFlag                      (false)
1523    , m_frameFieldInfoPresentFlag         (false)
1524    , m_hrdParametersPresentFlag          (false)
1525    , m_bitstreamRestrictionFlag          (false)
1526    , m_tilesFixedStructureFlag           (false)
1527    , m_motionVectorsOverPicBoundariesFlag(true)
1528    , m_restrictedRefPicListsFlag         (1)
1529    , m_minSpatialSegmentationIdc         (0)
1530    , m_maxBytesPerPicDenom               (2)
1531    , m_maxBitsPerMinCuDenom              (1)
1532    , m_log2MaxMvLengthHorizontal         (15)
1533    , m_log2MaxMvLengthVertical           (15)
1534  {}
1535
1536  virtual           ~TComVUI() {}
1537
1538  Bool              getAspectRatioInfoPresentFlag() const                  { return m_aspectRatioInfoPresentFlag;           }
1539  Void              setAspectRatioInfoPresentFlag(Bool i)                  { m_aspectRatioInfoPresentFlag = i;              }
1540
1541  Int               getAspectRatioIdc() const                              { return m_aspectRatioIdc;                       }
1542  Void              setAspectRatioIdc(Int i)                               { m_aspectRatioIdc = i;                          }
1543
1544  Int               getSarWidth() const                                    { return m_sarWidth;                             }
1545  Void              setSarWidth(Int i)                                     { m_sarWidth = i;                                }
1546
1547  Int               getSarHeight() const                                   { return m_sarHeight;                            }
1548  Void              setSarHeight(Int i)                                    { m_sarHeight = i;                               }
1549
1550  Bool              getOverscanInfoPresentFlag() const                     { return m_overscanInfoPresentFlag;              }
1551  Void              setOverscanInfoPresentFlag(Bool i)                     { m_overscanInfoPresentFlag = i;                 }
1552
1553  Bool              getOverscanAppropriateFlag() const                     { return m_overscanAppropriateFlag;              }
1554  Void              setOverscanAppropriateFlag(Bool i)                     { m_overscanAppropriateFlag = i;                 }
1555
1556  Bool              getVideoSignalTypePresentFlag() const                  { return m_videoSignalTypePresentFlag;           }
1557  Void              setVideoSignalTypePresentFlag(Bool i)                  { m_videoSignalTypePresentFlag = i;              }
1558
1559  Int               getVideoFormat() const                                 { return m_videoFormat;                          }
1560  Void              setVideoFormat(Int i)                                  { m_videoFormat = i;                             }
1561
1562  Bool              getVideoFullRangeFlag() const                          { return m_videoFullRangeFlag;                   }
1563  Void              setVideoFullRangeFlag(Bool i)                          { m_videoFullRangeFlag = i;                      }
1564
1565  Bool              getColourDescriptionPresentFlag() const                { return m_colourDescriptionPresentFlag;         }
1566  Void              setColourDescriptionPresentFlag(Bool i)                { m_colourDescriptionPresentFlag = i;            }
1567
1568  Int               getColourPrimaries() const                             { return m_colourPrimaries;                      }
1569  Void              setColourPrimaries(Int i)                              { m_colourPrimaries = i;                         }
1570
1571  Int               getTransferCharacteristics() const                     { return m_transferCharacteristics;              }
1572  Void              setTransferCharacteristics(Int i)                      { m_transferCharacteristics = i;                 }
1573
1574  Int               getMatrixCoefficients() const                          { return m_matrixCoefficients;                   }
1575  Void              setMatrixCoefficients(Int i)                           { m_matrixCoefficients = i;                      }
1576
1577  Bool              getChromaLocInfoPresentFlag() const                    { return m_chromaLocInfoPresentFlag;             }
1578  Void              setChromaLocInfoPresentFlag(Bool i)                    { m_chromaLocInfoPresentFlag = i;                }
1579
1580  Int               getChromaSampleLocTypeTopField() const                 { return m_chromaSampleLocTypeTopField;          }
1581  Void              setChromaSampleLocTypeTopField(Int i)                  { m_chromaSampleLocTypeTopField = i;             }
1582
1583  Int               getChromaSampleLocTypeBottomField() const              { return m_chromaSampleLocTypeBottomField;       }
1584  Void              setChromaSampleLocTypeBottomField(Int i)               { m_chromaSampleLocTypeBottomField = i;          }
1585
1586  Bool              getNeutralChromaIndicationFlag() const                 { return m_neutralChromaIndicationFlag;          }
1587  Void              setNeutralChromaIndicationFlag(Bool i)                 { m_neutralChromaIndicationFlag = i;             }
1588
1589  Bool              getFieldSeqFlag() const                                { return m_fieldSeqFlag;                         }
1590  Void              setFieldSeqFlag(Bool i)                                { m_fieldSeqFlag = i;                            }
1591
1592  Bool              getFrameFieldInfoPresentFlag() const                   { return m_frameFieldInfoPresentFlag;            }
1593  Void              setFrameFieldInfoPresentFlag(Bool i)                   { m_frameFieldInfoPresentFlag = i;               }
1594
1595  Window&           getDefaultDisplayWindow()                              { return m_defaultDisplayWindow;                 }
1596  const Window&     getDefaultDisplayWindow() const                        { return m_defaultDisplayWindow;                 }
1597  Void              setDefaultDisplayWindow(Window& defaultDisplayWindow ) { m_defaultDisplayWindow = defaultDisplayWindow; }
1598
1599  Bool              getHrdParametersPresentFlag() const                    { return m_hrdParametersPresentFlag;             }
1600  Void              setHrdParametersPresentFlag(Bool i)                    { m_hrdParametersPresentFlag = i;                }
1601
1602  Bool              getBitstreamRestrictionFlag() const                    { return m_bitstreamRestrictionFlag;             }
1603  Void              setBitstreamRestrictionFlag(Bool i)                    { m_bitstreamRestrictionFlag = i;                }
1604
1605  Bool              getTilesFixedStructureFlag() const                     { return m_tilesFixedStructureFlag;              }
1606  Void              setTilesFixedStructureFlag(Bool i)                     { m_tilesFixedStructureFlag = i;                 }
1607
1608  Bool              getMotionVectorsOverPicBoundariesFlag() const          { return m_motionVectorsOverPicBoundariesFlag;   }
1609  Void              setMotionVectorsOverPicBoundariesFlag(Bool i)          { m_motionVectorsOverPicBoundariesFlag = i;      }
1610
1611  Bool              getRestrictedRefPicListsFlag() const                   { return m_restrictedRefPicListsFlag;            }
1612  Void              setRestrictedRefPicListsFlag(Bool b)                   { m_restrictedRefPicListsFlag = b;               }
1613
1614  Int               getMinSpatialSegmentationIdc() const                   { return m_minSpatialSegmentationIdc;            }
1615  Void              setMinSpatialSegmentationIdc(Int i)                    { m_minSpatialSegmentationIdc = i;               }
1616
1617  Int               getMaxBytesPerPicDenom() const                         { return m_maxBytesPerPicDenom;                  }
1618  Void              setMaxBytesPerPicDenom(Int i)                          { m_maxBytesPerPicDenom = i;                     }
1619
1620  Int               getMaxBitsPerMinCuDenom() const                        { return m_maxBitsPerMinCuDenom;                 }
1621  Void              setMaxBitsPerMinCuDenom(Int i)                         { m_maxBitsPerMinCuDenom = i;                    }
1622
1623  Int               getLog2MaxMvLengthHorizontal() const                   { return m_log2MaxMvLengthHorizontal;            }
1624  Void              setLog2MaxMvLengthHorizontal(Int i)                    { m_log2MaxMvLengthHorizontal = i;               }
1625
1626  Int               getLog2MaxMvLengthVertical() const                     { return m_log2MaxMvLengthVertical;              }
1627  Void              setLog2MaxMvLengthVertical(Int i)                      { m_log2MaxMvLengthVertical = i;                 }
1628
1629  TComHRD*          getHrdParameters()                                     { return &m_hrdParameters;                       }
1630  const TComHRD*    getHrdParameters()  const                              { return &m_hrdParameters;                       }
1631
1632  TimingInfo*       getTimingInfo()                                        { return &m_timingInfo;                          }
1633  const TimingInfo* getTimingInfo() const                                  { return &m_timingInfo;                          }
1634#if NH_MV
1635  Void              inferVideoSignalInfo( const TComVPS* vps, Int layerIdCurr );
1636#endif
1637};
1638
1639/// SPS RExt class
1640class TComSPSRExt // Names aligned to text specification
1641{
1642private:
1643  Bool             m_transformSkipRotationEnabledFlag;
1644  Bool             m_transformSkipContextEnabledFlag;
1645  Bool             m_rdpcmEnabledFlag[NUMBER_OF_RDPCM_SIGNALLING_MODES];
1646  Bool             m_extendedPrecisionProcessingFlag;
1647  Bool             m_intraSmoothingDisabledFlag;
1648  Bool             m_highPrecisionOffsetsEnabledFlag;
1649  Bool             m_persistentRiceAdaptationEnabledFlag;
1650  Bool             m_cabacBypassAlignmentEnabledFlag;
1651
1652public:
1653  TComSPSRExt();
1654
1655  Bool settingsDifferFromDefaults() const
1656  {
1657    return getTransformSkipRotationEnabledFlag()
1658        || getTransformSkipContextEnabledFlag()
1659        || getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT)
1660        || getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT)
1661        || getExtendedPrecisionProcessingFlag()
1662        || getIntraSmoothingDisabledFlag()
1663        || getHighPrecisionOffsetsEnabledFlag()
1664        || getPersistentRiceAdaptationEnabledFlag()
1665        || getCabacBypassAlignmentEnabledFlag();
1666  }
1667
1668
1669  Bool getTransformSkipRotationEnabledFlag() const                                     { return m_transformSkipRotationEnabledFlag;     }
1670  Void setTransformSkipRotationEnabledFlag(const Bool value)                           { m_transformSkipRotationEnabledFlag = value;    }
1671
1672  Bool getTransformSkipContextEnabledFlag() const                                      { return m_transformSkipContextEnabledFlag;      }
1673  Void setTransformSkipContextEnabledFlag(const Bool value)                            { m_transformSkipContextEnabledFlag = value;     }
1674
1675  Bool getRdpcmEnabledFlag(const RDPCMSignallingMode signallingMode) const             { return m_rdpcmEnabledFlag[signallingMode];     }
1676  Void setRdpcmEnabledFlag(const RDPCMSignallingMode signallingMode, const Bool value) { m_rdpcmEnabledFlag[signallingMode] = value;    }
1677
1678  Bool getExtendedPrecisionProcessingFlag() const                                      { return m_extendedPrecisionProcessingFlag;      }
1679  Void setExtendedPrecisionProcessingFlag(Bool value)                                  { m_extendedPrecisionProcessingFlag = value;     }
1680
1681  Bool getIntraSmoothingDisabledFlag() const                                           { return m_intraSmoothingDisabledFlag;           }
1682  Void setIntraSmoothingDisabledFlag(Bool bValue)                                      { m_intraSmoothingDisabledFlag=bValue;           }
1683
1684  Bool getHighPrecisionOffsetsEnabledFlag() const                                      { return m_highPrecisionOffsetsEnabledFlag;      }
1685  Void setHighPrecisionOffsetsEnabledFlag(Bool value)                                  { m_highPrecisionOffsetsEnabledFlag = value;     }
1686
1687  Bool getPersistentRiceAdaptationEnabledFlag() const                                  { return m_persistentRiceAdaptationEnabledFlag;  }
1688  Void setPersistentRiceAdaptationEnabledFlag(const Bool value)                        { m_persistentRiceAdaptationEnabledFlag = value; }
1689
1690  Bool getCabacBypassAlignmentEnabledFlag() const                                      { return m_cabacBypassAlignmentEnabledFlag;      }
1691  Void setCabacBypassAlignmentEnabledFlag(const Bool value)                            { m_cabacBypassAlignmentEnabledFlag = value;     }
1692};
1693
1694
1695#if NH_3D
1696class TComSps3dExtension
1697{
1698public:
1699  TComSps3dExtension()
1700  {
1701    for (Int d = 0; d < 2; d++)
1702    {
1703      m_ivMvPredFlag          [d] = false; 
1704      m_ivMvScalingFlag       [d] = false; 
1705      m_log2SubPbSizeMinus3   [d] = 3; 
1706      m_ivResPredFlag         [d] = false; 
1707      m_depthRefinementFlag   [d] = false; 
1708      m_viewSynthesisPredFlag [d] = false; 
1709      m_depthBasedBlkPartFlag [d] = false; 
1710      m_mpiFlag               [d] = false; 
1711      m_log2MpiSubPbSizeMinus3[d] = 3; 
1712      m_intraContourFlag      [d] = false; 
1713      m_intraSdcWedgeFlag     [d] = false; 
1714      m_qtPredFlag            [d] = false; 
1715      m_interSdcFlag          [d] = false; 
1716      m_depthIntraSkipFlag    [d] = false;   
1717    }
1718  }
1719
1720  Void          setIvMvPredFlag( Int d, Bool flag )         { m_ivMvPredFlag[d] = flag;             }
1721  Bool          getIvMvPredFlag( Int d ) const              { return m_ivMvPredFlag[d];             }
1722
1723  Void          setIvMvScalingFlag( Int d, Bool flag )      { m_ivMvScalingFlag[d] = flag;          }
1724  Bool          getIvMvScalingFlag( Int d ) const           { return m_ivMvScalingFlag[d];          }
1725
1726  Void          setLog2SubPbSizeMinus3( Int d, Int  val )   { m_log2SubPbSizeMinus3[d] = val;       }
1727  Int           getLog2SubPbSizeMinus3( Int d ) const       { return m_log2SubPbSizeMinus3[d];      }
1728
1729  Void          setIvResPredFlag( Int d, Bool flag )        { m_ivResPredFlag[d] = flag;            }
1730  Bool          getIvResPredFlag( Int d ) const             { return m_ivResPredFlag[d];            }
1731
1732  Void          setDepthRefinementFlag( Int d, Bool flag )  { m_depthRefinementFlag[d] = flag;      }
1733  Bool          getDepthRefinementFlag( Int d ) const       { return m_depthRefinementFlag[d];      }
1734
1735  Void          setViewSynthesisPredFlag( Int d, Bool flag ) { m_viewSynthesisPredFlag[d] = flag;   }
1736  Bool          getViewSynthesisPredFlag( Int d ) const     { return m_viewSynthesisPredFlag[d];    }
1737
1738  Void          setDepthBasedBlkPartFlag( Int d, Bool flag ) { m_depthBasedBlkPartFlag[d] = flag;   }
1739  Bool          getDepthBasedBlkPartFlag( Int d ) const     { return m_depthBasedBlkPartFlag[d];    }
1740
1741  Void          setMpiFlag( Int d, Bool flag )              { m_mpiFlag[d] = flag;                  }
1742  Bool          getMpiFlag( Int d ) const                   { return m_mpiFlag[d];                  }
1743
1744  Void          setLog2MpiSubPbSizeMinus3( Int d, Int  val ) { m_log2MpiSubPbSizeMinus3[d] = val;   }
1745  Int           getLog2MpiSubPbSizeMinus3( Int d ) const    { return m_log2MpiSubPbSizeMinus3[d];   }
1746
1747  Void          setIntraContourFlag( Int d, Bool flag )     { m_intraContourFlag[d] = flag;         }
1748  Bool          getIntraContourFlag( Int d ) const          { return m_intraContourFlag[d];         }
1749
1750  Void          setIntraSdcWedgeFlag( Int d, Bool flag )    { m_intraSdcWedgeFlag[d] = flag;        }
1751  Bool          getIntraSdcWedgeFlag( Int d ) const         { return m_intraSdcWedgeFlag[d];        }
1752
1753  Void          setQtPredFlag( Int d, Bool flag )           { m_qtPredFlag[d] = flag;               }
1754  Bool          getQtPredFlag( Int d ) const                { return m_qtPredFlag[d];               }
1755
1756  Void          setInterSdcFlag( Int d, Bool flag )         { m_interSdcFlag[d] = flag;             }
1757  Bool          getInterSdcFlag( Int d ) const              { return m_interSdcFlag[d];             }
1758
1759  Void          setDepthIntraSkipFlag( Int d, Bool flag )   { m_depthIntraSkipFlag[d] = flag;       }
1760  Bool          getDepthIntraSkipFlag( Int d ) const        { return m_depthIntraSkipFlag[d];       }
1761private:
1762
1763  Bool        m_ivMvPredFlag          [2];
1764  Bool        m_ivMvScalingFlag       [2];
1765  Int         m_log2SubPbSizeMinus3   [2];
1766  Bool        m_ivResPredFlag         [2];
1767  Bool        m_depthRefinementFlag   [2];
1768  Bool        m_viewSynthesisPredFlag [2];
1769  Bool        m_depthBasedBlkPartFlag [2];
1770  Bool        m_mpiFlag               [2];
1771  Int         m_log2MpiSubPbSizeMinus3[2];
1772  Bool        m_intraContourFlag      [2];
1773  Bool        m_intraSdcWedgeFlag     [2];
1774  Bool        m_qtPredFlag            [2];
1775  Bool        m_interSdcFlag          [2];
1776  Bool        m_depthIntraSkipFlag    [2]; 
1777};
1778
1779#endif
1780
1781
1782/// SPS class
1783class TComSPS
1784{
1785private:
1786  Int              m_SPSId;
1787  Int              m_VPSId;
1788  ChromaFormat     m_chromaFormatIdc;
1789
1790  UInt             m_uiMaxTLayers;           // maximum number of temporal layers
1791
1792  // Structure
1793  UInt             m_picWidthInLumaSamples;
1794  UInt             m_picHeightInLumaSamples;
1795
1796  Int              m_log2MinCodingBlockSize;
1797  Int              m_log2DiffMaxMinCodingBlockSize;
1798  UInt             m_uiMaxCUWidth;
1799  UInt             m_uiMaxCUHeight;
1800  UInt             m_uiMaxTotalCUDepth; ///< Total CU depth, relative to the smallest possible transform block size.
1801
1802  Window           m_conformanceWindow;
1803
1804  TComRPSList      m_RPSList;
1805  Bool             m_bLongTermRefsPresent;
1806  Bool             m_TMVPFlagsPresent;
1807  Int              m_numReorderPics[MAX_TLAYER];
1808
1809  // Tool list
1810  UInt             m_uiQuadtreeTULog2MaxSize;
1811  UInt             m_uiQuadtreeTULog2MinSize;
1812  UInt             m_uiQuadtreeTUMaxDepthInter;
1813  UInt             m_uiQuadtreeTUMaxDepthIntra;
1814  Bool             m_usePCM;
1815  UInt             m_pcmLog2MaxSize;
1816  UInt             m_uiPCMLog2MinSize;
1817  Bool             m_useAMP;
1818
1819  // Parameter
1820  BitDepths        m_bitDepths;
1821  Int              m_qpBDOffset[MAX_NUM_CHANNEL_TYPE];
1822  Int              m_pcmBitDepths[MAX_NUM_CHANNEL_TYPE];
1823  Bool             m_bPCMFilterDisableFlag;
1824
1825  UInt             m_uiBitsForPOC;
1826  UInt             m_numLongTermRefPicSPS;
1827  UInt             m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
1828  Bool             m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS];
1829  // Max physical transform size
1830  UInt             m_uiMaxTrSize;
1831
1832  Bool             m_bUseSAO;
1833
1834  Bool             m_bTemporalIdNestingFlag; // temporal_id_nesting_flag
1835
1836  Bool             m_scalingListEnabledFlag;
1837  Bool             m_scalingListPresentFlag;
1838  TComScalingList  m_scalingList;
1839  UInt             m_uiMaxDecPicBuffering[MAX_TLAYER];
1840  UInt             m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
1841
1842  Bool             m_useStrongIntraSmoothing;
1843
1844  Bool             m_vuiParametersPresentFlag;
1845  TComVUI          m_vuiParameters;
1846
1847  TComSPSRExt      m_spsRangeExtension;
1848
1849  static const Int m_winUnitX[NUM_CHROMA_FORMAT];
1850  static const Int m_winUnitY[NUM_CHROMA_FORMAT];
1851  TComPTL          m_pcPTL;
1852
1853#if O0043_BEST_EFFORT_DECODING
1854  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)
1855#endif
1856#if NH_MV
1857  TComVPS*         m_pcVPS; 
1858  // SPS           
1859  Int              m_spsMaxSubLayersMinus1;
1860  Int              m_spsExtOrMaxSubLayersMinus1;
1861  Bool             m_spsExtensionPresentFlag; 
1862                   
1863  Bool             m_spsRangeExtensionsFlag;
1864  Bool             m_spsMultilayerExtensionFlag;
1865
1866  Bool             m_sps3dExtensionFlag;
1867  Int              m_spsExtension5bits;
1868
1869  Bool             m_spsInferScalingListFlag;
1870  Int              m_spsScalingListRefLayerId;
1871  Bool             m_updateRepFormatFlag;
1872  Int              m_spsRepFormatIdx;
1873  // SPS Extension
1874  Bool             m_interViewMvVertConstraintFlag;
1875#endif
1876#if NH_3D
1877  TComSps3dExtension m_sps3dExtension; 
1878  Int              m_aaiCodedScale [2][MAX_NUM_LAYERS];
1879  Int              m_aaiCodedOffset[2][MAX_NUM_LAYERS];
1880#endif             
1881#if NH_MV           
1882  Int              m_layerId; 
1883#endif
1884
1885public:
1886                         TComSPS();
1887  virtual                ~TComSPS();
1888#if O0043_BEST_EFFORT_DECODING
1889  Void                   setForceDecodeBitDepth(UInt bitDepth)                                           { m_forceDecodeBitDepth = bitDepth;                                    }
1890  UInt                   getForceDecodeBitDepth()        const                                           { return m_forceDecodeBitDepth;                                        }
1891#endif
1892
1893  Int                    getVPSId() const                                                                { return m_VPSId;                                                      }
1894  Void                   setVPSId(Int i)                                                                 { m_VPSId = i;                                                         }
1895  Int                    getSPSId() const                                                                { return m_SPSId;                                                      }
1896  Void                   setSPSId(Int i)                                                                 { m_SPSId = i;                                                         }
1897  ChromaFormat           getChromaFormatIdc () const                                                     { return m_chromaFormatIdc;                                            }
1898  Void                   setChromaFormatIdc (ChromaFormat i)                                             { m_chromaFormatIdc = i;                                               }
1899
1900  static Int             getWinUnitX (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitX[chromaFormatIdc]; }
1901  static Int             getWinUnitY (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitY[chromaFormatIdc]; }
1902
1903  // structure
1904  Void                   setPicWidthInLumaSamples( UInt u )                                              { m_picWidthInLumaSamples = u;                                         }
1905  UInt                   getPicWidthInLumaSamples() const                                                { return  m_picWidthInLumaSamples;                                     }
1906  Void                   setPicHeightInLumaSamples( UInt u )                                             { m_picHeightInLumaSamples = u;                                        }
1907  UInt                   getPicHeightInLumaSamples() const                                               { return  m_picHeightInLumaSamples;                                    }
1908
1909  Window&                getConformanceWindow()                                                          { return  m_conformanceWindow;                                         }
1910  const Window&          getConformanceWindow() const                                                    { return  m_conformanceWindow;                                         }
1911  Void                   setConformanceWindow(Window& conformanceWindow )                                { m_conformanceWindow = conformanceWindow;                             }
1912
1913  UInt                   getNumLongTermRefPicSPS() const                                                 { return m_numLongTermRefPicSPS;                                       }
1914  Void                   setNumLongTermRefPicSPS(UInt val)                                               { m_numLongTermRefPicSPS = val;                                        }
1915
1916  UInt                   getLtRefPicPocLsbSps(UInt index) const                                          { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); return m_ltRefPicPocLsbSps[index]; }
1917  Void                   setLtRefPicPocLsbSps(UInt index, UInt val)                                      { assert( index < MAX_NUM_LONG_TERM_REF_PICS ); m_ltRefPicPocLsbSps[index] = val;  }
1918
1919  Bool                   getUsedByCurrPicLtSPSFlag(Int i) const                                          { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); return m_usedByCurrPicLtSPSFlag[i];    }
1920  Void                   setUsedByCurrPicLtSPSFlag(Int i, Bool x)                                        { assert( i < MAX_NUM_LONG_TERM_REF_PICS ); m_usedByCurrPicLtSPSFlag[i] = x;       }
1921
1922  Int                    getLog2MinCodingBlockSize() const                                               { return m_log2MinCodingBlockSize;                                     }
1923  Void                   setLog2MinCodingBlockSize(Int val)                                              { m_log2MinCodingBlockSize = val;                                      }
1924  Int                    getLog2DiffMaxMinCodingBlockSize() const                                        { return m_log2DiffMaxMinCodingBlockSize;                              }
1925  Void                   setLog2DiffMaxMinCodingBlockSize(Int val)                                       { m_log2DiffMaxMinCodingBlockSize = val;                               }
1926
1927  Void                   setMaxCUWidth( UInt u )                                                         { m_uiMaxCUWidth = u;                                                  }
1928  UInt                   getMaxCUWidth() const                                                           { return  m_uiMaxCUWidth;                                              }
1929  Void                   setMaxCUHeight( UInt u )                                                        { m_uiMaxCUHeight = u;                                                 }
1930  UInt                   getMaxCUHeight() const                                                          { return  m_uiMaxCUHeight;                                             }
1931  Void                   setMaxTotalCUDepth( UInt u )                                                    { m_uiMaxTotalCUDepth = u;                                             }
1932  UInt                   getMaxTotalCUDepth() const                                                      { return  m_uiMaxTotalCUDepth;                                         }
1933  Void                   setUsePCM( Bool b )                                                             { m_usePCM = b;                                                        }
1934  Bool                   getUsePCM() const                                                               { return m_usePCM;                                                     }
1935  Void                   setPCMLog2MaxSize( UInt u )                                                     { m_pcmLog2MaxSize = u;                                                }
1936  UInt                   getPCMLog2MaxSize() const                                                       { return  m_pcmLog2MaxSize;                                            }
1937  Void                   setPCMLog2MinSize( UInt u )                                                     { m_uiPCMLog2MinSize = u;                                              }
1938  UInt                   getPCMLog2MinSize() const                                                       { return  m_uiPCMLog2MinSize;                                          }
1939  Void                   setBitsForPOC( UInt u )                                                         { m_uiBitsForPOC = u;                                                  }
1940  UInt                   getBitsForPOC() const                                                           { return m_uiBitsForPOC;                                               }
1941  Bool                   getUseAMP() const                                                               { return m_useAMP;                                                     }
1942  Void                   setUseAMP( Bool b )                                                             { m_useAMP = b;                                                        }
1943  Void                   setQuadtreeTULog2MaxSize( UInt u )                                              { m_uiQuadtreeTULog2MaxSize = u;                                       }
1944  UInt                   getQuadtreeTULog2MaxSize() const                                                { return m_uiQuadtreeTULog2MaxSize;                                    }
1945  Void                   setQuadtreeTULog2MinSize( UInt u )                                              { m_uiQuadtreeTULog2MinSize = u;                                       }
1946  UInt                   getQuadtreeTULog2MinSize() const                                                { return m_uiQuadtreeTULog2MinSize;                                    }
1947  Void                   setQuadtreeTUMaxDepthInter( UInt u )                                            { m_uiQuadtreeTUMaxDepthInter = u;                                     }
1948  Void                   setQuadtreeTUMaxDepthIntra( UInt u )                                            { m_uiQuadtreeTUMaxDepthIntra = u;                                     }
1949  UInt                   getQuadtreeTUMaxDepthInter() const                                              { return m_uiQuadtreeTUMaxDepthInter;                                  }
1950  UInt                   getQuadtreeTUMaxDepthIntra() const                                              { return m_uiQuadtreeTUMaxDepthIntra;                                  }
1951  Void                   setNumReorderPics(Int i, UInt tlayer)                                           { m_numReorderPics[tlayer] = i;                                        }
1952  Int                    getNumReorderPics(UInt tlayer) const                                            { return m_numReorderPics[tlayer];                                     }
1953  Void                   createRPSList( Int numRPS );
1954  const TComRPSList*     getRPSList() const                                                              { return &m_RPSList;                                                   }
1955  TComRPSList*           getRPSList()                                                                    { return &m_RPSList;                                                   }
1956  Bool                   getLongTermRefsPresent() const                                                  { return m_bLongTermRefsPresent;                                       }
1957  Void                   setLongTermRefsPresent(Bool b)                                                  { m_bLongTermRefsPresent=b;                                            }
1958  Bool                   getTMVPFlagsPresent() const                                                     { return m_TMVPFlagsPresent;                                           }
1959  Void                   setTMVPFlagsPresent(Bool b)                                                     { m_TMVPFlagsPresent=b;                                                }
1960  // physical transform
1961  Void                   setMaxTrSize( UInt u )                                                          { m_uiMaxTrSize = u;                                                   }
1962  UInt                   getMaxTrSize() const                                                            { return  m_uiMaxTrSize;                                               }
1963
1964  // Bit-depth
1965  Int                    getBitDepth(ChannelType type) const                                             { return m_bitDepths.recon[type];                                      }
1966  Void                   setBitDepth(ChannelType type, Int u )                                           { m_bitDepths.recon[type] = u;                                         }
1967#if O0043_BEST_EFFORT_DECODING
1968  Int                    getStreamBitDepth(ChannelType type) const                                       { return m_bitDepths.stream[type];                                     }
1969  Void                   setStreamBitDepth(ChannelType type, Int u )                                     { m_bitDepths.stream[type] = u;                                        }
1970#endif
1971  const BitDepths&       getBitDepths() const                                                            { return m_bitDepths;                                                  }
1972  Int                    getMaxLog2TrDynamicRange(ChannelType channelType) const                         { return getSpsRangeExtension().getExtendedPrecisionProcessingFlag() ? std::max<Int>(15, Int(m_bitDepths.recon[channelType] + 6)) : 15; }
1973
1974  Int                    getDifferentialLumaChromaBitDepth() const                                       { return Int(m_bitDepths.recon[CHANNEL_TYPE_LUMA]) - Int(m_bitDepths.recon[CHANNEL_TYPE_CHROMA]); }
1975  Int                    getQpBDOffset(ChannelType type) const                                           { return m_qpBDOffset[type];                                           }
1976  Void                   setQpBDOffset(ChannelType type, Int i)                                          { m_qpBDOffset[type] = i;                                              }
1977
1978  Void                   setUseSAO(Bool bVal)                                                            { m_bUseSAO = bVal;                                                    }
1979  Bool                   getUseSAO() const                                                               { return m_bUseSAO;                                                    }
1980
1981  UInt                   getMaxTLayers() const                                                           { return m_uiMaxTLayers; }
1982  Void                   setMaxTLayers( UInt uiMaxTLayers )                                              { assert( uiMaxTLayers <= MAX_TLAYER ); m_uiMaxTLayers = uiMaxTLayers; }
1983
1984  Bool                   getTemporalIdNestingFlag() const                                                { return m_bTemporalIdNestingFlag;                                     }
1985  Void                   setTemporalIdNestingFlag( Bool bValue )                                         { m_bTemporalIdNestingFlag = bValue;                                   }
1986  UInt                   getPCMBitDepth(ChannelType type) const                                          { return m_pcmBitDepths[type];                                         }
1987  Void                   setPCMBitDepth(ChannelType type, UInt u)                                        { m_pcmBitDepths[type] = u;                                            }
1988  Void                   setPCMFilterDisableFlag( Bool bValue )                                          { m_bPCMFilterDisableFlag = bValue;                                    }
1989  Bool                   getPCMFilterDisableFlag() const                                                 { return m_bPCMFilterDisableFlag;                                      }
1990
1991  Bool                   getScalingListFlag() const                                                      { return m_scalingListEnabledFlag;                                     }
1992  Void                   setScalingListFlag( Bool b )                                                    { m_scalingListEnabledFlag  = b;                                       }
1993  Bool                   getScalingListPresentFlag() const                                               { return m_scalingListPresentFlag;                                     }
1994  Void                   setScalingListPresentFlag( Bool b )                                             { m_scalingListPresentFlag  = b;                                       }
1995  Void                   setScalingList( TComScalingList *scalingList);
1996  TComScalingList&       getScalingList()                                                                { return m_scalingList;                                                }
1997  const TComScalingList& getScalingList() const                                                          { return m_scalingList;                                                }
1998  UInt                   getMaxDecPicBuffering(UInt tlayer) const                                        { return m_uiMaxDecPicBuffering[tlayer];                               }
1999  Void                   setMaxDecPicBuffering( UInt ui, UInt tlayer )                                   { assert(tlayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tlayer] = ui;    }
2000  UInt                   getMaxLatencyIncrease(UInt tlayer) const                                        { return m_uiMaxLatencyIncrease[tlayer];                               }
2001  Void                   setMaxLatencyIncrease( UInt ui , UInt tlayer)                                   { m_uiMaxLatencyIncrease[tlayer] = ui;                                 }
2002
2003  Void                   setUseStrongIntraSmoothing(Bool bVal)                                           { m_useStrongIntraSmoothing = bVal;                                    }
2004  Bool                   getUseStrongIntraSmoothing() const                                              { return m_useStrongIntraSmoothing;                                    }
2005
2006  Bool                   getVuiParametersPresentFlag() const                                             { return m_vuiParametersPresentFlag;                                   }
2007  Void                   setVuiParametersPresentFlag(Bool b)                                             { m_vuiParametersPresentFlag = b;                                      }
2008  TComVUI*               getVuiParameters()                                                              { return &m_vuiParameters;                                             }
2009  const TComVUI*         getVuiParameters() const                                                        { return &m_vuiParameters;                                             }
2010  const TComPTL*         getPTL() const                                                                  { return &m_pcPTL;                                                     }
2011  TComPTL*               getPTL()                                                                        { return &m_pcPTL;                                                     }
2012
2013  const TComSPSRExt&     getSpsRangeExtension() const                                                    { return m_spsRangeExtension;                                          }
2014  TComSPSRExt&           getSpsRangeExtension()                                                          { return m_spsRangeExtension;                                          }
2015
2016  // Sequence parameter set range extension syntax
2017  // WAS: getUseResidualRotation and setUseResidualRotation
2018  // Now getSpsRangeExtension().getTransformSkipRotationEnabledFlag and getSpsRangeExtension().setTransformSkipRotationEnabledFlag
2019
2020  // WAS: getUseSingleSignificanceMapContext and setUseSingleSignificanceMapContext
2021  // Now: getSpsRangeExtension().getTransformSkipContextEnabledFlag and getSpsRangeExtension().setTransformSkipContextEnabledFlag
2022
2023  // WAS: getUseResidualDPCM and setUseResidualDPCM
2024  // Now: getSpsRangeExtension().getRdpcmEnabledFlag and getSpsRangeExtension().setRdpcmEnabledFlag and
2025
2026  // WAS: getUseExtendedPrecision and setUseExtendedPrecision
2027  // Now: getSpsRangeExtension().getExtendedPrecisionProcessingFlag and getSpsRangeExtension().setExtendedPrecisionProcessingFlag
2028
2029  // WAS: getDisableIntraReferenceSmoothing and setDisableIntraReferenceSmoothing
2030  // Now: getSpsRangeExtension().getIntraSmoothingDisabledFlag and getSpsRangeExtension().setIntraSmoothingDisabledFlag
2031
2032  // WAS: getUseHighPrecisionPredictionWeighting and setUseHighPrecisionPredictionWeighting
2033  // Now: getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag and getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag
2034
2035  // WAS: getUseGolombRiceParameterAdaptation and setUseGolombRiceParameterAdaptation
2036  // Now: getSpsRangeExtension().getPersistentRiceAdaptationEnabledFlag and getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag
2037
2038  // WAS: getAlignCABACBeforeBypass and setAlignCABACBeforeBypass
2039  // Now: getSpsRangeExtension().getCabacBypassAlignmentEnabledFlag and getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag
2040
2041
2042#if NH_MV
2043
2044  UInt                   getSpsMaxSubLayersMinus1() const                                                { return ( m_uiMaxTLayers - 1);                                        }
2045  Void                   setSpsMaxSubLayersMinus1( UInt val )                                            { setMaxTLayers( val + 1 );                                            }
2046
2047  Void                   setSpsExtOrMaxSubLayersMinus1( Int  val )                                       { m_spsExtOrMaxSubLayersMinus1 = val;                                  }
2048  Int                    getSpsExtOrMaxSubLayersMinus1(  )         const                                 { return m_spsExtOrMaxSubLayersMinus1;                                 }
2049  Void                   inferSpsMaxSubLayersMinus1( Bool atPsActivation, TComVPS* vps  );                                                                                     
2050                                                                                                                                                                               
2051  Bool                   getMultiLayerExtSpsFlag()            const { return ( getLayerId() != 0  &&  getSpsExtOrMaxSubLayersMinus1() == 7 );                                   }
2052  Void                   inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder );                                             
2053                                                                                                                                                                               
2054  Void                   setSpsExtensionPresentFlag( Bool flag )                                         { m_spsExtensionPresentFlag = flag;                                    }
2055  Bool                   getSpsExtensionPresentFlag( )           const                                   { return m_spsExtensionPresentFlag;                                    }
2056                                                                                                                                                                               
2057  Void                   setSpsRangeExtensionsFlag( Bool flag )                                          { m_spsRangeExtensionsFlag = flag;                                     }
2058  Bool                   getSpsRangeExtensionsFlag(  )                     const                         { return m_spsRangeExtensionsFlag;                                     }
2059                                                                                                                                                                               
2060  Void                   setSpsMultilayerExtensionFlag( Bool flag )                                      { m_spsMultilayerExtensionFlag = flag;                                 }
2061  Bool                   getSpsMultilayerExtensionFlag( )                  const                         { return m_spsMultilayerExtensionFlag;                                 }
2062
2063  Void                   setSps3dExtensionFlag( Bool flag )                                              { m_sps3dExtensionFlag = flag;                                         }
2064  Bool                   getSps3dExtensionFlag(  )                         const                         { return m_sps3dExtensionFlag;                                         }
2065                                                                                                                                                                               
2066  Void                   setSpsExtension5bits( Int  val )                                                { m_spsExtension5bits = val;                                           }
2067  Int                    getSpsExtension5bits(  )                          const                         { return m_spsExtension5bits;                                          }
2068                                                                                                                                                                               
2069  Void                   setVPS          ( TComVPS* pcVPS )                                              { m_pcVPS = pcVPS;                                                     }
2070  TComVPS*               getVPS          ()                 const                                        { return m_pcVPS;                                                      }
2071                                                                                                                                                                               
2072  Void                   setSpsInferScalingListFlag( Bool flag )                                         { m_spsInferScalingListFlag = flag;                                    }
2073  Bool                   getSpsInferScalingListFlag(  )          const                                   { return m_spsInferScalingListFlag;                                    }
2074                                                                                                                                                                               
2075  Void                   setSpsScalingListRefLayerId( Int  val )                                         { m_spsScalingListRefLayerId = val;                                    }
2076  Int                    getSpsScalingListRefLayerId(  )         const                                   { return m_spsScalingListRefLayerId;                                   }
2077                                                                                                                                                                               
2078  Void                   setUpdateRepFormatFlag( Bool flag )                                             { m_updateRepFormatFlag = flag;                                        }
2079  Bool                   getUpdateRepFormatFlag(  )              const                                   { return m_updateRepFormatFlag;                                        }
2080 
2081  Void                   setSpsRepFormatIdx( Int  val )                                                  { m_spsRepFormatIdx = val;                                             }
2082  Int                    getSpsRepFormatIdx(  )                  const                                   { return m_spsRepFormatIdx;                                            }
2083                                                                                                                                                                               
2084// SPS Extension                                                                                                                                                               
2085  Void                   setInterViewMvVertConstraintFlag(Bool val)                                      { m_interViewMvVertConstraintFlag = val;                               }
2086  Bool                   getInterViewMvVertConstraintFlag()         const                                { return m_interViewMvVertConstraintFlag;                              }
2087                                                                                                                                                                               
2088#if NH_3D
2089  Void                   setSps3dExtension ( TComSps3dExtension& sps3dExtension )                        { m_sps3dExtension = sps3dExtension;                                   }
2090  const TComSps3dExtension* getSps3dExtension ( )  const                                                 { return &m_sps3dExtension;                                            } 
2091#endif                 
2092                       
2093  // Inference         
2094                       
2095  Void                   inferRepFormat( TComVPS* vps, Int layerIdCurr, Bool encoder );
2096  Void                   inferScalingList( const TComSPS* spsSrc );
2097                       
2098  // others             
2099  Void                   checkRpsMaxNumPics( const TComVPS* vps, Int currLayerId ) const;
2100                       
2101  Int                    getLayerId            ()           const                                        { return m_layerId;                                                    }
2102  Void                   setLayerId            ( Int val )                                               { m_layerId = val;                                                     }
2103
2104#endif
2105
2106};
2107
2108
2109/// Reference Picture Lists class
2110
2111class TComRefPicListModification
2112{
2113private:
2114  Bool m_refPicListModificationFlagL0;
2115  Bool m_refPicListModificationFlagL1;
2116  UInt m_RefPicSetIdxL0[REF_PIC_LIST_NUM_IDX];
2117  UInt m_RefPicSetIdxL1[REF_PIC_LIST_NUM_IDX];
2118
2119public:
2120          TComRefPicListModification();
2121  virtual ~TComRefPicListModification();
2122
2123  Void    create();
2124  Void    destroy();
2125
2126  Bool    getRefPicListModificationFlagL0() const        { return m_refPicListModificationFlagL0;                                  }
2127  Void    setRefPicListModificationFlagL0(Bool flag)     { m_refPicListModificationFlagL0 = flag;                                  }
2128  Bool    getRefPicListModificationFlagL1() const        { return m_refPicListModificationFlagL1;                                  }
2129  Void    setRefPicListModificationFlagL1(Bool flag)     { m_refPicListModificationFlagL1 = flag;                                  }
2130  UInt    getRefPicSetIdxL0(UInt idx) const              { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL0[idx];         }
2131  Void    setRefPicSetIdxL0(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL0[idx] = refPicSetIdx; }
2132  UInt    getRefPicSetIdxL1(UInt idx) const              { assert(idx<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL1[idx];         }
2133  Void    setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
2134#if NH_MV
2135  // Why not a listIdx for all members, would avoid code duplication??
2136  Void    setRefPicSetIdxL(UInt li, UInt idx, UInt refPicSetIdx) {( li==0 ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ) = refPicSetIdx;              }
2137  UInt    getRefPicSetIdxL(UInt li, UInt idx )                   { return ( li == 0 ) ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ;                  }
2138  Void    setRefPicListModificationFlagL(UInt li, Bool flag)     { ( li==0  ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1 ) = flag;  }
2139  Bool    getRefPicListModificationFlagL(UInt li )               { return ( li== 0) ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1;   }
2140#endif
2141};
2142
2143/// PPS RExt class
2144class TComPPSRExt // Names aligned to text specification
2145{
2146private:
2147  Int              m_log2MaxTransformSkipBlockSize;
2148  Bool             m_crossComponentPredictionEnabledFlag;
2149
2150  // Chroma QP Adjustments
2151  Int              m_diffCuChromaQpOffsetDepth;
2152  Int              m_chromaQpOffsetListLen; // size (excludes the null entry used in the following array).
2153  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
2154
2155  UInt             m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE];
2156
2157public:
2158  TComPPSRExt();
2159
2160  Bool settingsDifferFromDefaults(const bool bTransformSkipEnabledFlag) const
2161  {
2162    return (bTransformSkipEnabledFlag && (getLog2MaxTransformSkipBlockSize() !=2))
2163        || (getCrossComponentPredictionEnabledFlag() )
2164        || (getChromaQpOffsetListEnabledFlag() )
2165        || (getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA) !=0 )
2166        || (getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) !=0 );
2167  }
2168
2169  UInt                   getLog2MaxTransformSkipBlockSize() const                         { return m_log2MaxTransformSkipBlockSize;         }
2170  Void                   setLog2MaxTransformSkipBlockSize( UInt u )                       { m_log2MaxTransformSkipBlockSize  = u;           }
2171
2172  Bool                   getCrossComponentPredictionEnabledFlag() const                   { return m_crossComponentPredictionEnabledFlag;   }
2173  Void                   setCrossComponentPredictionEnabledFlag(Bool value)               { m_crossComponentPredictionEnabledFlag = value;  }
2174
2175  Void                   clearChromaQpOffsetList()                                        { m_chromaQpOffsetListLen = 0;                    }
2176
2177  UInt                   getDiffCuChromaQpOffsetDepth () const                            { return m_diffCuChromaQpOffsetDepth;             }
2178  Void                   setDiffCuChromaQpOffsetDepth ( UInt u )                          { m_diffCuChromaQpOffsetDepth = u;                }
2179
2180  Bool                   getChromaQpOffsetListEnabledFlag() const                         { return getChromaQpOffsetListLen()>0;            }
2181  Int                    getChromaQpOffsetListLen() const                                 { return m_chromaQpOffsetListLen;                 }
2182
2183  const ChromaQpAdj&     getChromaQpOffsetListEntry( Int cuChromaQpOffsetIdxPlus1 ) const
2184  {
2185    assert(cuChromaQpOffsetIdxPlus1 < m_chromaQpOffsetListLen+1);
2186    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
2187  }
2188
2189  Void                   setChromaQpOffsetListEntry( Int cuChromaQpOffsetIdxPlus1, Int cbOffset, Int crOffset )
2190  {
2191    assert (cuChromaQpOffsetIdxPlus1 != 0 && cuChromaQpOffsetIdxPlus1 <= MAX_QP_OFFSET_LIST_SIZE);
2192    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
2193    m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset;
2194    m_chromaQpOffsetListLen = max(m_chromaQpOffsetListLen, cuChromaQpOffsetIdxPlus1);
2195  }
2196
2197  // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale
2198  UInt                   getLog2SaoOffsetScale(ChannelType type) const                    { return m_log2SaoOffsetScale[type];             }
2199  Void                   setLog2SaoOffsetScale(ChannelType type, UInt uiBitShift)         { m_log2SaoOffsetScale[type] = uiBitShift;       }
2200
2201};
2202
2203
2204/// PPS class
2205class TComPPS
2206{
2207private:
2208  Int              m_PPSId;                    // pic_parameter_set_id
2209  Int              m_SPSId;                    // seq_parameter_set_id
2210  Int              m_picInitQPMinus26;
2211  Bool             m_useDQP;
2212  Bool             m_bConstrainedIntraPred;    // constrained_intra_pred_flag
2213  Bool             m_bSliceChromaQpFlag;       // slicelevel_chroma_qp_flag
2214
2215  // access channel
2216  UInt             m_uiMaxCuDQPDepth;
2217
2218  Int              m_chromaCbQpOffset;
2219  Int              m_chromaCrQpOffset;
2220
2221  UInt             m_numRefIdxL0DefaultActive;
2222  UInt             m_numRefIdxL1DefaultActive;
2223
2224  Bool             m_bUseWeightPred;                    //!< Use of Weighting Prediction (P_SLICE)
2225  Bool             m_useWeightedBiPred;                 //!< Use of Weighting Bi-Prediction (B_SLICE)
2226  Bool             m_OutputFlagPresentFlag;             //!< Indicates the presence of output_flag in slice header
2227  Bool             m_TransquantBypassEnableFlag;        //!< Indicates presence of cu_transquant_bypass_flag in CUs.
2228  Bool             m_useTransformSkip;
2229  Bool             m_dependentSliceSegmentsEnabledFlag; //!< Indicates the presence of dependent slices
2230  Bool             m_tilesEnabledFlag;                  //!< Indicates the presence of tiles
2231  Bool             m_entropyCodingSyncEnabledFlag;      //!< Indicates the presence of wavefronts
2232
2233  Bool             m_loopFilterAcrossTilesEnabledFlag;
2234  Bool             m_uniformSpacingFlag;
2235  Int              m_numTileColumnsMinus1;
2236  Int              m_numTileRowsMinus1;
2237  std::vector<Int> m_tileColumnWidth;
2238  std::vector<Int> m_tileRowHeight;
2239
2240  Bool             m_signHideFlag;
2241
2242  Bool             m_cabacInitPresentFlag;
2243
2244  Bool             m_sliceHeaderExtensionPresentFlag;
2245  Bool             m_loopFilterAcrossSlicesEnabledFlag;
2246  Bool             m_deblockingFilterControlPresentFlag;
2247  Bool             m_deblockingFilterOverrideEnabledFlag;
2248  Bool             m_picDisableDeblockingFilterFlag;
2249  Int              m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
2250  Int              m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
2251  Bool             m_scalingListPresentFlag;
2252  TComScalingList  m_scalingList;                       //!< ScalingList class
2253  Bool             m_listsModificationPresentFlag;
2254  UInt             m_log2ParallelMergeLevelMinus2;
2255  Int              m_numExtraSliceHeaderBits;
2256
2257  TComPPSRExt      m_ppsRangeExtension;
2258
2259#if NH_MV
2260  Int              m_layerId; 
2261  Bool             m_ppsInferScalingListFlag;
2262  Int              m_ppsScalingListRefLayerId;
2263                   
2264  Bool             m_ppsRangeExtensionsFlag;
2265  Bool             m_ppsMultilayerExtensionFlag;
2266  Bool             m_pps3dExtensionFlag;
2267  Int              m_ppsExtension5bits;
2268
2269  Bool             m_pocResetInfoPresentFlag;
2270#endif
2271
2272#if NH_3D_DLT
2273  TComDLT                m_cDLT;
2274#endif
2275
2276public:
2277                         TComPPS();
2278  virtual                ~TComPPS();
2279
2280  Int                    getPPSId() const                                                 { return m_PPSId;                               }
2281  Void                   setPPSId(Int i)                                                  { m_PPSId = i;                                  }
2282  Int                    getSPSId() const                                                 { return m_SPSId;                               }
2283  Void                   setSPSId(Int i)                                                  { m_SPSId = i;                                  }
2284
2285  Int                    getPicInitQPMinus26() const                                      { return  m_picInitQPMinus26;                   }
2286  Void                   setPicInitQPMinus26( Int i )                                     { m_picInitQPMinus26 = i;                       }
2287  Bool                   getUseDQP() const                                                { return m_useDQP;                              }
2288  Void                   setUseDQP( Bool b )                                              { m_useDQP   = b;                               }
2289  Bool                   getConstrainedIntraPred() const                                  { return  m_bConstrainedIntraPred;              }
2290  Void                   setConstrainedIntraPred( Bool b )                                { m_bConstrainedIntraPred = b;                  }
2291  Bool                   getSliceChromaQpFlag() const                                     { return  m_bSliceChromaQpFlag;                 }
2292  Void                   setSliceChromaQpFlag( Bool b )                                   { m_bSliceChromaQpFlag = b;                     }
2293
2294  Void                   setMaxCuDQPDepth( UInt u )                                       { m_uiMaxCuDQPDepth = u;                        }
2295  UInt                   getMaxCuDQPDepth() const                                         { return m_uiMaxCuDQPDepth;                     }
2296
2297#if NH_3D_DLT
2298  Void                   setDLT( TComDLT cDLT )                                           { m_cDLT = cDLT;                                }
2299  const TComDLT*         getDLT() const                                                   { return &m_cDLT;                               }
2300  TComDLT*               getDLT()                                                         { return &m_cDLT;                               }
2301#endif
2302
2303
2304  Void                   setQpOffset(ComponentID compID, Int i )
2305  {
2306    if      (compID==COMPONENT_Cb)
2307    {
2308      m_chromaCbQpOffset = i;
2309    }
2310    else if (compID==COMPONENT_Cr)
2311    {
2312      m_chromaCrQpOffset = i;
2313    }
2314    else
2315    {
2316      assert(0);
2317    }
2318  }
2319  Int                    getQpOffset(ComponentID compID) const
2320  {
2321    return (compID==COMPONENT_Y) ? 0 : (compID==COMPONENT_Cb ? m_chromaCbQpOffset : m_chromaCrQpOffset );
2322  }
2323
2324  Void                   setNumRefIdxL0DefaultActive(UInt ui)                             { m_numRefIdxL0DefaultActive=ui;                }
2325  UInt                   getNumRefIdxL0DefaultActive() const                              { return m_numRefIdxL0DefaultActive;            }
2326  Void                   setNumRefIdxL1DefaultActive(UInt ui)                             { m_numRefIdxL1DefaultActive=ui;                }
2327  UInt                   getNumRefIdxL1DefaultActive() const                              { return m_numRefIdxL1DefaultActive;            }
2328
2329  Bool                   getUseWP() const                                                 { return m_bUseWeightPred;                      }
2330  Bool                   getWPBiPred() const                                              { return m_useWeightedBiPred;                   }
2331  Void                   setUseWP( Bool b )                                               { m_bUseWeightPred = b;                         }
2332  Void                   setWPBiPred( Bool b )                                            { m_useWeightedBiPred = b;                      }
2333
2334  Void                   setOutputFlagPresentFlag( Bool b )                               { m_OutputFlagPresentFlag = b;                  }
2335  Bool                   getOutputFlagPresentFlag() const                                 { return m_OutputFlagPresentFlag;               }
2336  Void                   setTransquantBypassEnableFlag( Bool b )                          { m_TransquantBypassEnableFlag = b;             }
2337  Bool                   getTransquantBypassEnableFlag() const                            { return m_TransquantBypassEnableFlag;          }
2338
2339  Bool                   getUseTransformSkip() const                                      { return m_useTransformSkip;                    }
2340  Void                   setUseTransformSkip( Bool b )                                    { m_useTransformSkip  = b;                      }
2341
2342  Void                   setLoopFilterAcrossTilesEnabledFlag(Bool b)                      { m_loopFilterAcrossTilesEnabledFlag = b;       }
2343  Bool                   getLoopFilterAcrossTilesEnabledFlag() const                      { return m_loopFilterAcrossTilesEnabledFlag;    }
2344  Bool                   getDependentSliceSegmentsEnabledFlag() const                     { return m_dependentSliceSegmentsEnabledFlag;   }
2345  Void                   setDependentSliceSegmentsEnabledFlag(Bool val)                   { m_dependentSliceSegmentsEnabledFlag = val;    }
2346  Bool                   getEntropyCodingSyncEnabledFlag() const                          { return m_entropyCodingSyncEnabledFlag;        }
2347  Void                   setEntropyCodingSyncEnabledFlag(Bool val)                        { m_entropyCodingSyncEnabledFlag = val;         }
2348
2349  Void                   setTilesEnabledFlag(Bool val)                                    { m_tilesEnabledFlag = val;                     }
2350  Bool                   getTilesEnabledFlag() const                                      { return m_tilesEnabledFlag;                    }
2351  Void                   setTileUniformSpacingFlag(Bool b)                                { m_uniformSpacingFlag = b;                     }
2352  Bool                   getTileUniformSpacingFlag() const                                { return m_uniformSpacingFlag;                  }
2353  Void                   setNumTileColumnsMinus1(Int i)                                   { m_numTileColumnsMinus1 = i;                   }
2354  Int                    getNumTileColumnsMinus1() const                                  { return m_numTileColumnsMinus1;                }
2355  Void                   setTileColumnWidth(const std::vector<Int>& columnWidth )         { m_tileColumnWidth = columnWidth;              }
2356  UInt                   getTileColumnWidth(UInt columnIdx) const                         { return  m_tileColumnWidth[columnIdx];         }
2357  Void                   setNumTileRowsMinus1(Int i)                                      { m_numTileRowsMinus1 = i;                      }
2358  Int                    getNumTileRowsMinus1() const                                     { return m_numTileRowsMinus1;                   }
2359  Void                   setTileRowHeight(const std::vector<Int>& rowHeight)              { m_tileRowHeight = rowHeight;                  }
2360  UInt                   getTileRowHeight(UInt rowIdx) const                              { return m_tileRowHeight[rowIdx];               }
2361
2362  Void                   setSignHideFlag( Bool signHideFlag )                             { m_signHideFlag = signHideFlag;                }
2363  Bool                   getSignHideFlag() const                                          { return m_signHideFlag;                        }
2364
2365  Void                   setCabacInitPresentFlag( Bool flag )                             { m_cabacInitPresentFlag = flag;                }
2366  Bool                   getCabacInitPresentFlag() const                                  { return m_cabacInitPresentFlag;                }
2367  Void                   setDeblockingFilterControlPresentFlag( Bool val )                { m_deblockingFilterControlPresentFlag = val;   }
2368  Bool                   getDeblockingFilterControlPresentFlag() const                    { return m_deblockingFilterControlPresentFlag;  }
2369  Void                   setDeblockingFilterOverrideEnabledFlag( Bool val )               { m_deblockingFilterOverrideEnabledFlag = val;  }
2370  Bool                   getDeblockingFilterOverrideEnabledFlag() const                   { return m_deblockingFilterOverrideEnabledFlag; }
2371  Void                   setPicDisableDeblockingFilterFlag(Bool val)                      { m_picDisableDeblockingFilterFlag = val;       } //!< set offset for deblocking filter disabled
2372  Bool                   getPicDisableDeblockingFilterFlag() const                        { return m_picDisableDeblockingFilterFlag;      } //!< get offset for deblocking filter disabled
2373  Void                   setDeblockingFilterBetaOffsetDiv2(Int val)                       { m_deblockingFilterBetaOffsetDiv2 = val;       } //!< set beta offset for deblocking filter
2374  Int                    getDeblockingFilterBetaOffsetDiv2() const                        { return m_deblockingFilterBetaOffsetDiv2;      } //!< get beta offset for deblocking filter
2375  Void                   setDeblockingFilterTcOffsetDiv2(Int val)                         { m_deblockingFilterTcOffsetDiv2 = val;         } //!< set tc offset for deblocking filter
2376  Int                    getDeblockingFilterTcOffsetDiv2() const                          { return m_deblockingFilterTcOffsetDiv2;        } //!< get tc offset for deblocking filter
2377  Bool                   getScalingListPresentFlag() const                                { return m_scalingListPresentFlag;              }
2378  Void                   setScalingListPresentFlag( Bool b )                              { m_scalingListPresentFlag  = b;                }
2379  TComScalingList&       getScalingList()                                                 { return m_scalingList;                         }
2380  const TComScalingList& getScalingList() const                                           { return m_scalingList;                         }
2381  Bool                   getListsModificationPresentFlag() const                          { return m_listsModificationPresentFlag;        }
2382  Void                   setListsModificationPresentFlag( Bool b )                        { m_listsModificationPresentFlag = b;           }
2383  UInt                   getLog2ParallelMergeLevelMinus2() const                          { return m_log2ParallelMergeLevelMinus2;        }
2384  Void                   setLog2ParallelMergeLevelMinus2(UInt mrgLevel)                   { m_log2ParallelMergeLevelMinus2 = mrgLevel;    }
2385  Int                    getNumExtraSliceHeaderBits() const                               { return m_numExtraSliceHeaderBits;             }
2386  Void                   setNumExtraSliceHeaderBits(Int i)                                { m_numExtraSliceHeaderBits = i;                }
2387  Void                   setLoopFilterAcrossSlicesEnabledFlag( Bool bValue )              { m_loopFilterAcrossSlicesEnabledFlag = bValue; }
2388  Bool                   getLoopFilterAcrossSlicesEnabledFlag() const                     { return m_loopFilterAcrossSlicesEnabledFlag;   }
2389  Bool                   getSliceHeaderExtensionPresentFlag() const                       { return m_sliceHeaderExtensionPresentFlag;     }
2390  Void                   setSliceHeaderExtensionPresentFlag(Bool val)                     { m_sliceHeaderExtensionPresentFlag = val;      }
2391
2392
2393  const TComPPSRExt&     getPpsRangeExtension() const                                     { return m_ppsRangeExtension;                   }
2394  TComPPSRExt&           getPpsRangeExtension()                                           { return m_ppsRangeExtension;                   }
2395
2396  // WAS: getTransformSkipLog2MaxSize and setTransformSkipLog2MaxSize
2397  // Now: getPpsRangeExtension().getLog2MaxTransformSkipBlockSize and getPpsRangeExtension().setLog2MaxTransformSkipBlockSize
2398
2399  // WAS: getUseCrossComponentPrediction and setUseCrossComponentPrediction
2400  // Now: getPpsRangeExtension().getCrossComponentPredictionEnabledFlag and getPpsRangeExtension().setCrossComponentPredictionEnabledFlag
2401
2402  // WAS: clearChromaQpAdjTable
2403  // Now: getPpsRangeExtension().clearChromaQpOffsetList
2404
2405  // WAS: getMaxCuChromaQpAdjDepth and setMaxCuChromaQpAdjDepth
2406  // Now: getPpsRangeExtension().getDiffCuChromaQpOffsetDepth and getPpsRangeExtension().setDiffCuChromaQpOffsetDepth
2407
2408  // WAS: getChromaQpAdjTableSize
2409  // Now: getPpsRangeExtension().getChromaQpOffsetListLen
2410
2411  // WAS: getChromaQpAdjTableAt and setChromaQpAdjTableAt
2412  // Now: getPpsRangeExtension().getChromaQpOffsetListEntry and getPpsRangeExtension().setChromaQpOffsetListEntry
2413
2414  // WAS: getSaoOffsetBitShift and setSaoOffsetBitShift
2415  // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale
2416
2417#if NH_MV
2418  Void    setLayerId( Int  val )                                                     { m_layerId = val;                                           }
2419  Int     getLayerId(  ) const                                                       { return m_layerId;                                          }
2420
2421  Void    setPpsInferScalingListFlag( Bool flag )                                    { m_ppsInferScalingListFlag = flag;                          }
2422  Bool    getPpsInferScalingListFlag(  ) const                                       { return m_ppsInferScalingListFlag;                          }
2423
2424  Void    setPpsScalingListRefLayerId( Int  val )                                    { m_ppsScalingListRefLayerId = val;                          }
2425  Int     getPpsScalingListRefLayerId(  ) const                                      { return m_ppsScalingListRefLayerId;                         }
2426
2427  Void    setPpsRangeExtensionsFlag( Bool flag )                                     { m_ppsRangeExtensionsFlag = flag;                           }
2428  Bool    getPpsRangeExtensionsFlag(  ) const                                        { return m_ppsRangeExtensionsFlag;                           }
2429
2430  Void    setPpsMultilayerExtensionFlag( Bool flag )                                 { m_ppsMultilayerExtensionFlag = flag;                       }
2431  Bool    getPpsMultilayerExtensionFlag(  ) const                                    { return m_ppsMultilayerExtensionFlag;                       }
2432
2433  Void    setPps3dExtensionFlag( Bool flag )                                         { m_pps3dExtensionFlag = flag;                               }
2434  Bool    getPps3dExtensionFlag(  ) const                                            { return m_pps3dExtensionFlag;                               }
2435
2436  Void    setPpsExtension5bits( Int  val )                                           { m_ppsExtension5bits = val;                                 }
2437  Int     getPpsExtension5bits(  ) const                                             { return m_ppsExtension5bits;                                }
2438
2439  Void    setPocResetInfoPresentFlag( Bool flag )                                    { m_pocResetInfoPresentFlag = flag;                          }
2440  Bool    getPocResetInfoPresentFlag(  ) const                                       { return m_pocResetInfoPresentFlag;                          }
2441#endif
2442};
2443struct WPScalingParam
2444{
2445  // Explicit weighted prediction parameters parsed in slice header,
2446  // or Implicit weighted prediction parameters (8 bits depth values).
2447  Bool bPresentFlag;
2448  UInt uiLog2WeightDenom;
2449  Int  iWeight;
2450  Int  iOffset;
2451
2452  // Weighted prediction scaling values built from above parameters (bitdepth scaled):
2453  Int  w;
2454  Int  o;
2455  Int  offset;
2456  Int  shift;
2457  Int  round;
2458};
2459
2460struct WPACDCParam
2461{
2462  Int64 iAC;
2463  Int64 iDC;
2464};
2465
2466/// slice header class
2467class TComSlice
2468{
2469
2470private:
2471  //  Bitstream writing
2472  Bool                       m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
2473  Int                        m_iPPSId;               ///< picture parameter set ID
2474  Bool                       m_PicOutputFlag;        ///< pic_output_flag
2475#if NH_MV
2476  Int                        m_slicePicOrderCntLsb;   
2477#endif 
2478  Int                        m_iPOC;
2479#if NH_MV
2480  Int                        m_iPOCBeforeReset; 
2481#endif
2482  Int                        m_iLastIDR;
2483  Int                        m_iAssociatedIRAP;
2484  NalUnitType                m_iAssociatedIRAPType;
2485  const TComReferencePictureSet* m_pRPS;             //< pointer to RPS, either in the SPS or the local RPS in the same slice header
2486  TComReferencePictureSet    m_localRPS;             //< RPS when present in slice header
2487  Int                        m_rpsIdx;               //< index of used RPS in the SPS or -1 for local RPS in the slice header
2488  TComRefPicListModification m_RefPicListModification;
2489  NalUnitType                m_eNalUnitType;         ///< Nal unit type for the slice
2490  SliceType                  m_eSliceType;
2491  Int                        m_iSliceQp;
2492  Bool                       m_dependentSliceSegmentFlag;
2493#if ADAPTIVE_QP_SELECTION
2494  Int                        m_iSliceQpBase;
2495#endif
2496  Bool                       m_ChromaQpAdjEnabled;
2497  Bool                       m_deblockingFilterDisable;
2498  Bool                       m_deblockingFilterOverrideFlag;      //< offsets for deblocking filter inherit from PPS
2499  Int                        m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
2500  Int                        m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
2501  Int                        m_list1IdxToList0Idx[MAX_NUM_REF];
2502  Int                        m_aiNumRefIdx   [NUM_REF_PIC_LIST_01];    //  for multiple reference of current slice
2503
2504  Bool                       m_bCheckLDC;
2505
2506  //  Data
2507  Int                        m_iSliceQpDelta;
2508  Int                        m_iSliceChromaQpDelta[MAX_NUM_COMPONENT];
2509  TComPic*                   m_apcRefPicList [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2510  Int                        m_aiRefPOCList  [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2511#if NH_MV
2512  Int         m_aiRefLayerIdList[2][MAX_NUM_REF+1];
2513#endif
2514  Bool                       m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
2515  Int                        m_iDepth;
2516
2517  // referenced slice?
2518  Bool                       m_bRefenced;
2519
2520  // access channel
2521  const TComVPS*             m_pcVPS;
2522  const TComSPS*             m_pcSPS;
2523  const TComPPS*             m_pcPPS;
2524  TComPic*                   m_pcPic;
2525  Bool                       m_colFromL0Flag;  // collocated picture from List0 flag
2526
2527  Bool                       m_noOutputPriorPicsFlag;
2528  Bool                       m_noRaslOutputFlag;
2529  Bool                       m_handleCraAsBlaFlag;
2530
2531  UInt                       m_colRefIdx;
2532  UInt                       m_maxNumMergeCand;
2533
2534  Double                     m_lambdas[MAX_NUM_COMPONENT];
2535
2536  Bool                       m_abEqualRef  [NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_REF];
2537  UInt                       m_uiTLayer;
2538  Bool                       m_bTLayerSwitchingFlag;
2539
2540  SliceConstraint            m_sliceMode;
2541  UInt                       m_sliceArgument;
2542  UInt                       m_sliceCurStartCtuTsAddr;
2543  UInt                       m_sliceCurEndCtuTsAddr;
2544  UInt                       m_sliceIdx;
2545  SliceConstraint            m_sliceSegmentMode;
2546  UInt                       m_sliceSegmentArgument;
2547  UInt                       m_sliceSegmentCurStartCtuTsAddr;
2548  UInt                       m_sliceSegmentCurEndCtuTsAddr;
2549  Bool                       m_nextSlice;
2550  Bool                       m_nextSliceSegment;
2551  UInt                       m_sliceBits;
2552  UInt                       m_sliceSegmentBits;
2553  Bool                       m_bFinalized;
2554
2555  Bool                       m_bTestWeightPred;
2556  Bool                       m_bTestWeightBiPred;
2557  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]
2558  WPACDCParam                m_weightACDCParam[MAX_NUM_COMPONENT];
2559
2560  std::vector<UInt>          m_substreamSizes;
2561
2562  Bool                       m_cabacInitFlag;
2563
2564  Bool                       m_bLMvdL1Zero;
2565  Bool                       m_temporalLayerNonReferenceFlag;
2566  Bool                       m_LFCrossSliceBoundaryFlag;
2567
2568  Bool                       m_enableTMVPFlag;
2569
2570  SliceType                  m_encCABACTableIdx;           // Used to transmit table selection across slices.
2571#if NH_MV
2572  Bool       m_availableForTMVPRefFlag;
2573#endif
2574
2575#if NH_MV
2576  std::vector<TComPic*>* m_refPicSetInterLayer0; 
2577  std::vector<TComPic*>* m_refPicSetInterLayer1; 
2578  Int        m_layerId; 
2579  Int        m_viewId;
2580  Int        m_viewIndex; 
2581#if NH_3D
2582  Bool       m_isDepth;
2583#endif
2584
2585// Additional slice header syntax elements
2586#if !H_MV_HLS7_GEN
2587  Bool       m_pocResetFlag; 
2588#endif
2589  Bool       m_crossLayerBlaFlag;
2590  Bool       m_discardableFlag;
2591  Bool       m_interLayerPredEnabledFlag;
2592  Int        m_numInterLayerRefPicsMinus1;
2593  Int        m_interLayerPredLayerIdc       [MAX_NUM_LAYERS];
2594
2595  Int        m_sliceSegmentHeaderExtensionLength;
2596  Int        m_pocResetIdc;
2597  Int        m_pocResetPeriodId;
2598  Bool       m_fullPocResetFlag;
2599  Int        m_pocLsbVal;
2600  Bool       m_pocMsbValPresentFlag;
2601  Int        m_pocMsbVal;
2602  Bool       m_pocMsbValRequiredFlag;
2603
2604#if NH_3D
2605  IntAry2d   m_aaiCodedScale ;
2606  IntAry2d   m_aaiCodedOffset;
2607#endif
2608#if NH_3D_TMVP
2609  Int        m_aiAlterRefIdx   [2]; 
2610#endif
2611#if NH_3D_ARP
2612  Bool       m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
2613  TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
2614  UInt        m_nARPStepNum; 
2615  Int         m_aiFirstTRefIdx    [2];   
2616#endif
2617#if NH_3D
2618  std::vector<Int> m_pocsInCurrRPSs; 
2619#endif
2620#if NH_3D_IC
2621  Bool       m_bApplyIC;
2622  Bool       m_icSkipParseFlag;
2623#endif
2624#if NH_3D
2625  std::vector<Int> m_inCmpRefViewIdcs;
2626  Bool       m_inCmpPredAvailFlag; 
2627  Bool       m_inCmpPredFlag; 
2628  Bool       m_cpAvailableFlag; 
2629  Int        m_numViews; 
2630  TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS]; 
2631  Int**      m_depthToDisparityB; 
2632  Int**      m_depthToDisparityF; 
2633  Bool       m_bApplyDIS;
2634#endif
2635#endif
2636#if NH_3D_IC
2637  Int*       m_aICEnableCandidate;
2638  Int*       m_aICEnableNum;
2639#endif       
2640#if NH_3D   
2641  Int        m_iDefaultRefViewIdx;
2642  Bool       m_bDefaultRefViewIdxAvailableFlag;
2643             
2644  Bool       m_ivMvPredFlag         ;
2645  Bool       m_ivMvScalingFlag      ;
2646  Bool       m_ivResPredFlag        ;
2647  Bool       m_depthRefinementFlag  ;
2648  Bool       m_viewSynthesisPredFlag;
2649  Bool       m_depthBasedBlkPartFlag;
2650  Bool       m_mpiFlag              ;
2651  Bool       m_intraContourFlag     ;
2652  Bool       m_intraSdcWedgeFlag    ;
2653  Bool       m_qtPredFlag           ;
2654  Bool       m_interSdcFlag         ;
2655  Bool       m_depthIntraSkipFlag   ;
2656  Int        m_mpiSubPbSize         ; 
2657  Int        m_subPbSize            ; 
2658#endif
2659public:
2660                              TComSlice();
2661  virtual                     ~TComSlice();
2662  Void                        initSlice();
2663
2664  Void                        setVPS( TComVPS* pcVPS )                               { m_pcVPS = pcVPS;                                              }
2665  const TComVPS*              getVPS() const                                         { return m_pcVPS;                                               }
2666  Void                        setSPS( const TComSPS* pcSPS )                         { m_pcSPS = pcSPS;                                              }
2667  const TComSPS*              getSPS() const                                         { return m_pcSPS;                                               }
2668
2669  Void                        setPPS( const TComPPS* pcPPS )                         { m_pcPPS = pcPPS; m_iPPSId = (pcPPS) ? pcPPS->getPPSId() : -1; }
2670  const TComPPS*              getPPS() const                                         { return m_pcPPS;                                               }
2671
2672  Void                        setPPSId( Int PPSId )                                  { m_iPPSId = PPSId;                                             }
2673  Int                         getPPSId() const                                       { return m_iPPSId;                                              }
2674  Void                        setPicOutputFlag( Bool b   )                           { m_PicOutputFlag = b;                                          }
2675#if NH_MV
2676  Void                        setSlicePicOrderCntLsb( Int i )                        { m_slicePicOrderCntLsb = i;                                    }
2677  Int                         getSlicePicOrderCntLsb(  )  const                      { return m_slicePicOrderCntLsb;                                 }
2678#endif
2679  Bool                        getPicOutputFlag() const                               { return m_PicOutputFlag;                                       }
2680  Void                        setSaoEnabledFlag(ChannelType chType, Bool s)          {m_saoEnabledFlag[chType] =s;                                   }
2681  Bool                        getSaoEnabledFlag(ChannelType chType) const            { return m_saoEnabledFlag[chType];                              }
2682  Void                        setRPS( const TComReferencePictureSet *pcRPS )         { m_pRPS = pcRPS;                                               }
2683  const TComReferencePictureSet* getRPS()                                            { return m_pRPS;                                                }
2684  TComReferencePictureSet*    getLocalRPS()                                          { return &m_localRPS;                                           }
2685
2686  Void                        setRPSidx( Int rpsIdx )                                { m_rpsIdx = rpsIdx;                                            }
2687  Int                         getRPSidx() const                                      { return m_rpsIdx;                                              }
2688  TComRefPicListModification* getRefPicListModification()                            { return &m_RefPicListModification;                             }
2689  Void                        setLastIDR(Int iIDRPOC)                                { m_iLastIDR = iIDRPOC;                                         }
2690  Int                         getLastIDR() const                                     { return m_iLastIDR;                                            }
2691  Void                        setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)           { m_iAssociatedIRAP = iAssociatedIRAPPOC;                       }
2692  Int                         getAssociatedIRAPPOC() const                           { return m_iAssociatedIRAP;                                     }
2693  Void                        setAssociatedIRAPType(NalUnitType associatedIRAPType)  { m_iAssociatedIRAPType = associatedIRAPType;                   }
2694  NalUnitType                 getAssociatedIRAPType() const                          { return m_iAssociatedIRAPType;                                 }
2695  SliceType                   getSliceType() const                                   { return m_eSliceType;                                          }
2696  Int                         getPOC() const                                         { return m_iPOC;                                                }
2697  Int                         getSliceQp() const                                     { return m_iSliceQp;                                            }
2698  Bool                        getDependentSliceSegmentFlag() const                   { return m_dependentSliceSegmentFlag;                           }
2699  Void                        setDependentSliceSegmentFlag(Bool val)                 { m_dependentSliceSegmentFlag = val;                            }
2700#if ADAPTIVE_QP_SELECTION
2701  Int                         getSliceQpBase() const                                 { return m_iSliceQpBase;                                        }
2702#endif
2703  Int                         getSliceQpDelta() const                                { return m_iSliceQpDelta;                                       }
2704  Int                         getSliceChromaQpDelta(ComponentID compID) const        { return isLuma(compID) ? 0 : m_iSliceChromaQpDelta[compID];    }
2705  Bool                        getUseChromaQpAdj() const                              { return m_ChromaQpAdjEnabled;                                  }
2706  Bool                        getDeblockingFilterDisable() const                     { return m_deblockingFilterDisable;                             }
2707  Bool                        getDeblockingFilterOverrideFlag() const                { return m_deblockingFilterOverrideFlag;                        }
2708  Int                         getDeblockingFilterBetaOffsetDiv2()const               { return m_deblockingFilterBetaOffsetDiv2;                      }
2709  Int                         getDeblockingFilterTcOffsetDiv2() const                { return m_deblockingFilterTcOffsetDiv2;                        }
2710
2711  Int                         getNumRefIdx( RefPicList e ) const                     { return m_aiNumRefIdx[e];                                      }
2712  TComPic*                    getPic()                                               { return m_pcPic;                                               }
2713  TComPic*                    getRefPic( RefPicList e, Int iRefIdx)                  { return m_apcRefPicList[e][iRefIdx];                           }
2714  Int                         getRefPOC( RefPicList e, Int iRefIdx)                  { return m_aiRefPOCList[e][iRefIdx];                            }
2715#if NH_3D
2716  Bool                        getInCmpPredAvailFlag( )                 const         { return m_inCmpPredAvailFlag;                                  }
2717  Bool                        getCpAvailableFlag( )                    const         { return m_cpAvailableFlag;                                     }
2718  Bool                        getInCompPredFlag( )                     const         { return m_inCmpPredFlag;                                       }
2719  Void                        setInCompPredFlag( Bool b )                            { m_inCmpPredFlag = b;                                          }
2720  Int                         getInCmpRefViewIdcs( Int i )             const         { return m_inCmpRefViewIdcs  [i];                               }
2721  Int                         getNumCurCmpLIds( )                      const         { return (Int) m_inCmpRefViewIdcs.size();                       }
2722  TComPic*                    getIvPic( Bool depthFlag, Int viewIndex) const         { return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ];    }
2723  TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
2724#endif                           
2725#if NH_3D_IC                                                                                                                                         
2726  Void                        setApplyIC( Bool b )                                   { m_bApplyIC = b;                                               }
2727  Bool                        getApplyIC()                                           { return m_bApplyIC;                                            }
2728  Void                        xSetApplyIC();                                                                                                         
2729  Void                        xSetApplyIC(Bool bUseLowLatencyICEnc);                                                                                 
2730  Void                        setIcSkipParseFlag( Bool b )                           { m_icSkipParseFlag = b;                                        }
2731  Bool                        getIcSkipParseFlag()                                   { return m_icSkipParseFlag;                                     }
2732#endif                                                                                                                                               
2733#if NH_3D_ARP                                                                                                                                         
2734  Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                 
2735  Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                             
2736  TComPic*                    getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )     { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
2737  UInt                        getARPStepNum( )                                       { return m_nARPStepNum;                                         } 
2738#endif
2739  Int                         getDepth() const                                       { return m_iDepth;                                              }
2740  Bool                        getColFromL0Flag() const                               { return m_colFromL0Flag;                                       }
2741  UInt                        getColRefIdx() const                                   { return m_colRefIdx;                                           }
2742  Void                        checkColRefIdx(UInt curSliceIdx, TComPic* pic);
2743  Bool                        getIsUsedAsLongTerm(Int i, Int j) const                { return m_bIsUsedAsLongTerm[i][j];                             }
2744  Void                        setIsUsedAsLongTerm(Int i, Int j, Bool value)          { m_bIsUsedAsLongTerm[i][j] = value;                            }
2745  Bool                        getCheckLDC() const                                    { return m_bCheckLDC;                                           }
2746  Bool                        getMvdL1ZeroFlag() const                               { return m_bLMvdL1Zero;                                         }
2747  Int                         getNumRpsCurrTempList() const;
2748  Int                         getList1IdxToList0Idx( Int list1Idx ) const            { return m_list1IdxToList0Idx[list1Idx];                        }
2749  Void                        setReferenced(Bool b)                                  { m_bRefenced = b;                                              }
2750  Bool                        isReferenced() const                                   { return m_bRefenced;                                           }
2751  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) ); }
2752  Void                        setPOC( Int i )                                        { m_iPOC              = i; }
2753  Void                        setNalUnitType( NalUnitType e )                        { m_eNalUnitType      = e;                                      }
2754  NalUnitType                 getNalUnitType() const                                 { return m_eNalUnitType;                                        }
2755  Bool                        getRapPicFlag() const;
2756  Bool                        getIdrPicFlag() const                                  { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
2757  Bool                        isIRAP() const                                         { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23);  }
2758  Void                        checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
2759  Void                        decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled);
2760  Void                        setSliceType( SliceType e )                            { m_eSliceType        = e;                                      }
2761  Void                        setSliceQp( Int i )                                    { m_iSliceQp          = i;                                      }
2762#if ADAPTIVE_QP_SELECTION
2763  Void                        setSliceQpBase( Int i )                                { m_iSliceQpBase      = i;                                      }
2764#endif
2765  Void                        setSliceQpDelta( Int i )                               { m_iSliceQpDelta     = i;                                      }
2766  Void                        setSliceChromaQpDelta( ComponentID compID, Int i )     { m_iSliceChromaQpDelta[compID] = isLuma(compID) ? 0 : i;       }
2767  Void                        setUseChromaQpAdj( Bool b )                            { m_ChromaQpAdjEnabled = b;                                     }
2768  Void                        setDeblockingFilterDisable( Bool b )                   { m_deblockingFilterDisable= b;                                 }
2769  Void                        setDeblockingFilterOverrideFlag( Bool b )              { m_deblockingFilterOverrideFlag = b;                           }
2770  Void                        setDeblockingFilterBetaOffsetDiv2( Int i )             { m_deblockingFilterBetaOffsetDiv2 = i;                         }
2771  Void                        setDeblockingFilterTcOffsetDiv2( Int i )               { m_deblockingFilterTcOffsetDiv2 = i;                           }
2772
2773  Void                        setRefPic( TComPic* p, RefPicList e, Int iRefIdx )     { m_apcRefPicList[e][iRefIdx] = p;                              }
2774  Void                        setRefPOC( Int i, RefPicList e, Int iRefIdx )          { m_aiRefPOCList[e][iRefIdx] = i;                               }
2775  Void                        setNumRefIdx( RefPicList e, Int i )                    { m_aiNumRefIdx[e]    = i;                                      }
2776  Void                        setPic( TComPic* p )                                   { m_pcPic             = p;                                      }
2777  Void                        setDepth( Int iDepth )                                 { m_iDepth            = iDepth;                                 }
2778#if NH_MV
2779  Void                        setPocBeforeReset( Int i )                             { m_iPOCBeforeReset = i;                                        }
2780  Int                         getPocBeforeReset( )                                   { return m_iPOCBeforeReset;                                     }
2781  Int                         getRefLayerId( RefPicList e, Int iRefIdx)              { return  m_aiRefLayerIdList[e][iRefIdx];                       }
2782  Void                        setRefLayerId( Int i, RefPicList e, Int iRefIdx )      { m_aiRefLayerIdList[e][iRefIdx] = i;                        }
2783  Void                        getTempRefPicLists   ( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1,                                     
2784                                                     std::vector<TComPic*> rpsCurrList[2], BoolAry1d usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr = false );
2785                             
2786  Void                        setRefPicList        ( std::vector<TComPic*> rpsCurrList[2], BoolAry1d usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr = false ); 
2787#else
2788  Void                        setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
2789#endif
2790  Void                        setRefPOCList();
2791  Void                        setColFromL0Flag( Bool colFromL0 )                     { m_colFromL0Flag = colFromL0;                                  }
2792  Void                        setColRefIdx( UInt refIdx)                             { m_colRefIdx = refIdx;                                         }
2793  Void                        setCheckLDC( Bool b )                                  { m_bCheckLDC = b;                                              }
2794  Void                        setMvdL1ZeroFlag( Bool b)                              { m_bLMvdL1Zero = b;                                            }
2795
2796  Bool                        isIntra() const                                        { return m_eSliceType == I_SLICE;                               }
2797  Bool                        isInterB() const                                       { return m_eSliceType == B_SLICE;                               }
2798  Bool                        isInterP() const                                       { return m_eSliceType == P_SLICE;                               }
2799
2800  Void                        setLambdas( const Double lambdas[MAX_NUM_COMPONENT] )  { for (Int component = 0; component < MAX_NUM_COMPONENT; component++) m_lambdas[component] = lambdas[component]; }
2801  const Double*               getLambdas() const                                     { return m_lambdas;                                             }
2802
2803  Void                        initEqualRef();
2804  Bool                        isEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2 )
2805  {
2806    assert(e<NUM_REF_PIC_LIST_01);
2807    if (iRefIdx1 < 0 || iRefIdx2 < 0)
2808    {
2809      return false;
2810    }
2811    else
2812    {
2813      return m_abEqualRef[e][iRefIdx1][iRefIdx2];
2814    }
2815  }
2816
2817  Void                        setEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2, Bool b)
2818  {
2819    assert(e<NUM_REF_PIC_LIST_01);
2820    m_abEqualRef[e][iRefIdx1][iRefIdx2] = m_abEqualRef[e][iRefIdx2][iRefIdx1] = b;
2821  }
2822
2823  static Void                 sortPicList( TComList<TComPic*>& rcListPic );
2824  Void                        setList1IdxToList0Idx();
2825
2826  UInt                        getTLayer() const                                      { return m_uiTLayer;                                            }
2827  Void                        setTLayer( UInt uiTLayer )                             { m_uiTLayer = uiTLayer;                                        }
2828#if NH_MV
2829  Int                         getTemporalId          ( )                             { return (Int) m_uiTLayer;                                      }
2830#endif
2831
2832  Void                        setTLayerInfo( UInt uiTLayer );
2833  Void                        decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
2834  Void                        checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
2835  Void                        applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *RPSList);
2836#if NH_MV
2837  Void                        createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 );
2838  static Void                 markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 );
2839  static Void                 markCurrPic                 ( TComPic* currPic );
2840  Void                        printRefPicList();
2841#endif
2842  Bool                        isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
2843  Bool                        isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
2844  Int                         checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
2845  Void                        createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled);
2846  Void                        setMaxNumMergeCand(UInt val )                          { m_maxNumMergeCand = val;                                      }
2847  UInt                        getMaxNumMergeCand() const                             { return m_maxNumMergeCand;                                     }
2848
2849  Void                        setNoOutputPriorPicsFlag( Bool val )                   { m_noOutputPriorPicsFlag = val;                                }
2850  Bool                        getNoOutputPriorPicsFlag() const                       { return m_noOutputPriorPicsFlag;                               }
2851
2852  Void                        setNoRaslOutputFlag( Bool val )                        { m_noRaslOutputFlag = val;                                     }
2853  Bool                        getNoRaslOutputFlag() const                            { return m_noRaslOutputFlag;                                    }
2854
2855  Void                        setHandleCraAsBlaFlag( Bool val )                      { m_handleCraAsBlaFlag = val;                                   }
2856  Bool                        getHandleCraAsBlaFlag() const                          { return m_handleCraAsBlaFlag;                                  }
2857
2858  Void                        setSliceMode( SliceConstraint mode )                   { m_sliceMode = mode;                                           }
2859  SliceConstraint             getSliceMode() const                                   { return m_sliceMode;                                           }
2860  Void                        setSliceArgument( UInt uiArgument )                    { m_sliceArgument = uiArgument;                                 }
2861  UInt                        getSliceArgument() const                               { return m_sliceArgument;                                       }
2862  Void                        setSliceCurStartCtuTsAddr( UInt ctuTsAddr )            { m_sliceCurStartCtuTsAddr = ctuTsAddr;                         } // CTU Tile-scan address (as opposed to raster-scan)
2863  UInt                        getSliceCurStartCtuTsAddr() const                      { return m_sliceCurStartCtuTsAddr;                              } // CTU Tile-scan address (as opposed to raster-scan)
2864  Void                        setSliceCurEndCtuTsAddr( UInt ctuTsAddr )              { m_sliceCurEndCtuTsAddr = ctuTsAddr;                           } // CTU Tile-scan address (as opposed to raster-scan)
2865  UInt                        getSliceCurEndCtuTsAddr() const                        { return m_sliceCurEndCtuTsAddr;                                } // CTU Tile-scan address (as opposed to raster-scan)
2866  Void                        setSliceIdx( UInt i)                                   { m_sliceIdx = i;                                               }
2867  UInt                        getSliceIdx() const                                    { return  m_sliceIdx;                                           }
2868  Void                        copySliceInfo(TComSlice *pcSliceSrc);
2869  Void                        setSliceSegmentMode( SliceConstraint mode )            { m_sliceSegmentMode = mode;                                    }
2870  SliceConstraint             getSliceSegmentMode() const                            { return m_sliceSegmentMode;                                    }
2871  Void                        setSliceSegmentArgument( UInt uiArgument )             { m_sliceSegmentArgument = uiArgument;                          }
2872  UInt                        getSliceSegmentArgument() const                        { return m_sliceSegmentArgument;                                }
2873  Void                        setSliceSegmentCurStartCtuTsAddr( UInt ctuTsAddr )     { m_sliceSegmentCurStartCtuTsAddr = ctuTsAddr;                  } // CTU Tile-scan address (as opposed to raster-scan)
2874  UInt                        getSliceSegmentCurStartCtuTsAddr() const               { return m_sliceSegmentCurStartCtuTsAddr;                       } // CTU Tile-scan address (as opposed to raster-scan)
2875  Void                        setSliceSegmentCurEndCtuTsAddr( UInt ctuTsAddr )       { m_sliceSegmentCurEndCtuTsAddr = ctuTsAddr;                    } // CTU Tile-scan address (as opposed to raster-scan)
2876  UInt                        getSliceSegmentCurEndCtuTsAddr() const                 { return m_sliceSegmentCurEndCtuTsAddr;                         } // CTU Tile-scan address (as opposed to raster-scan)
2877  Void                        setSliceBits( UInt uiVal )                             { m_sliceBits = uiVal;                                          }
2878  UInt                        getSliceBits() const                                   { return m_sliceBits;                                           }
2879  Void                        setSliceSegmentBits( UInt uiVal )                      { m_sliceSegmentBits = uiVal;                                   }
2880  UInt                        getSliceSegmentBits() const                            { return m_sliceSegmentBits;                                    }
2881  Void                        setFinalized( Bool uiVal )                             { m_bFinalized = uiVal;                                         }
2882  Bool                        getFinalized() const                                   { return m_bFinalized;                                          }
2883  Bool                        testWeightPred( ) const                                { return m_bTestWeightPred;                                     }
2884  Void                        setTestWeightPred( Bool bValue )                       { m_bTestWeightPred = bValue;                                   }
2885  Bool                        testWeightBiPred( ) const                              { return m_bTestWeightBiPred;                                   }
2886  Void                        setTestWeightBiPred( Bool bValue )                     { m_bTestWeightBiPred = bValue;                                 }
2887  Void                        setWpScaling( WPScalingParam  wp[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT] )
2888  {
2889    memcpy(m_weightPredTable, wp, sizeof(WPScalingParam)*NUM_REF_PIC_LIST_01*MAX_NUM_REF*MAX_NUM_COMPONENT);
2890  }
2891
2892  Void                        getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp);
2893
2894  Void                        resetWpScaling();
2895  Void                        initWpScaling(const TComSPS *sps);
2896
2897  Void                        setWpAcDcParam( WPACDCParam wp[MAX_NUM_COMPONENT] )
2898  {
2899    memcpy(m_weightACDCParam, wp, sizeof(WPACDCParam)*MAX_NUM_COMPONENT);
2900  }
2901
2902  Void                        getWpAcDcParam( WPACDCParam *&wp );
2903  Void                        initWpAcDcParam();
2904
2905  Void                        clearSubstreamSizes( )                                 { return m_substreamSizes.clear();                              }
2906  UInt                        getNumberOfSubstreamSizes( )                           { return (UInt) m_substreamSizes.size();                        }
2907  Void                        addSubstreamSize( UInt size )                          { m_substreamSizes.push_back(size);                             }
2908  UInt                        getSubstreamSize( Int idx )                            { assert(idx<getNumberOfSubstreamSizes()); return m_substreamSizes[idx]; }
2909
2910  Void                        setCabacInitFlag( Bool val )                           { m_cabacInitFlag = val;                                        } //!< set CABAC initial flag
2911  Bool                        getCabacInitFlag()                                     { return m_cabacInitFlag;                                       } //!< get CABAC initial flag
2912  Bool                        getTemporalLayerNonReferenceFlag()                     { return m_temporalLayerNonReferenceFlag;                       }
2913  Void                        setTemporalLayerNonReferenceFlag(Bool x)               { m_temporalLayerNonReferenceFlag = x;                          }
2914  Void                        setLFCrossSliceBoundaryFlag( Bool   val )              { m_LFCrossSliceBoundaryFlag = val;                             }
2915  Bool                        getLFCrossSliceBoundaryFlag()                          { return m_LFCrossSliceBoundaryFlag;                            }
2916
2917  Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
2918  Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
2919
2920  Void                        setEncCABACTableIdx( SliceType idx )                   { m_encCABACTableIdx = idx;                                     }
2921  SliceType                   getEncCABACTableIdx() const                            { return m_encCABACTableIdx;                                    }
2922
2923#if NH_MV
2924  Void                        setAvailableForTMVPRefFlag( Bool   b )                 { m_availableForTMVPRefFlag = b;                                }
2925  Bool                        getAvailableForTMVPRefFlag()                           { return m_availableForTMVPRefFlag;                             }
2926
2927  Void                        setLayerId     ( Int layerId )                         { m_layerId      = layerId;                                     }
2928  Int                         getLayerId     ()                 const                { return m_layerId;                                             }
2929  Int                         getLayerIdInVps()                 const                { return getVPS()->getLayerIdInVps( m_layerId );                }
2930  Void                        setViewId      ( Int viewId )                          { m_viewId = viewId;                                            }
2931  Int                         getViewId      ()                 const                { return m_viewId;                                              }
2932  Void                        setViewIndex   ( Int viewIndex )                       { m_viewIndex = viewIndex;                                      }
2933  Int                         getViewIndex   ()                 const                { return m_viewIndex;                                           }
2934#if NH_3D
2935#if NH_3D_TMVP
2936  Void                        generateAlterRefforTMVP ();   
2937  Void                        setAlterRefIdx          ( RefPicList e, Int i )        { m_aiAlterRefIdx[e]    = i;                                    }
2938  Int                         getAlterRefIdx          ( RefPicList e )               { return  m_aiAlterRefIdx[e];                                   }
2939#endif                                                                                                                                               
2940#if NH_3D_ARP                                                                                                                                         
2941  Int                         getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];                                  }
2942  Void                        setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;                                   }
2943  Bool                        getArpRefPicAvailable  ( RefPicList e, Int viewIdx)    { return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, 0)]; }
2944  IntAry1d                    getPocsInCurrRPSs()                                    { return m_pocsInCurrRPSs;                                      } 
2945#endif                                                                                                                                               
2946  Void                        setIsDepth            ( Bool isDepth )                 { m_isDepth = isDepth;                                          }
2947  Bool                        getIsDepth            () const                         { return m_isDepth;                                             }
2948  Void                        setCamparaSlice       ( Int** aaiScale = 0, Int** aaiOffset = 0 );     
2949
2950  IntAry1d                    getCodedScale         () const                         { return m_aaiCodedScale [0];                                   }
2951  IntAry1d                    getCodedOffset        () const                         { return m_aaiCodedOffset[0];                                   }
2952  IntAry1d                    getInvCodedScale      () const                         { return m_aaiCodedScale [1];                                   }
2953  IntAry1d                    getInvCodedOffset     () const                         { return m_aaiCodedOffset[1];                                   }
2954                                                                                                                                                     
2955  Void                        setCpScale( Int j, Int  val )                          { m_aaiCodedScale[0][j] = val;                                  }
2956  Int                         getCpScale( Int j )                                    { return m_aaiCodedScale[0][j];                                 }
2957                                                                                                                                                     
2958  Void                        setCpOff( Int j, Int  val )                            { m_aaiCodedOffset[0][j] = val;                                 }
2959  Int                         getCpOff( Int j )                                      { return m_aaiCodedOffset[0][j];                                }
2960                                                                                                                                                     
2961  Void                        setCpInvScale( Int j, Int  val )                       { m_aaiCodedScale[1][j] = val;                                  }
2962  Int                         getCpInvScale( Int j )                                 { return m_aaiCodedScale[1][j];                                 }
2963                                                                                                                                                     
2964  Void                        setCpInvOff( Int j, Int  val )                         { m_aaiCodedOffset[1][j] = val;                                 }
2965  Int                         getCpInvOff( Int j )                                   { return m_aaiCodedOffset[1][j];                                }
2966                                                                                                                                                       
2967  Void                        setIvPicLists( TComPicLists* m_ivPicLists );                                                                             
2968  Void                        setDepthToDisparityLUTs();                                                                                               
2969                                                                                                                                                       
2970  Int*                        getDepthToDisparityB( Int refViewIdx )                 { return m_depthToDisparityB[ getVPS()->getVoiInVps( refViewIdx) ];}
2971  Int*                        getDepthToDisparityF( Int refViewIdx )                 { return m_depthToDisparityF[ getVPS()->getVoiInVps( refViewIdx) ];}
2972#if NH_3D_IC                                                                                                                                             
2973  Void                        setICEnableCandidate( Int* icEnableCandidate)          { m_aICEnableCandidate = icEnableCandidate;                     }
2974  Void                        setICEnableNum( Int* icEnableNum)                      { m_aICEnableNum = icEnableNum;                                 }
2975  Void                        setICEnableCandidate( UInt layer, Int value)           { m_aICEnableCandidate[ layer ] = value;                        }
2976  Void                        setICEnableNum( UInt layer, Int value)                 { m_aICEnableNum[ layer ] = value; ;                            }
2977                                                                                                                                                     
2978  Int                         getICEnableCandidate( Int layer)                       { return  m_aICEnableCandidate[ layer ];                        }
2979  Int                         getICEnableNum( Int layer)                             { return m_aICEnableNum[ layer ];                               }
2980#endif
2981#endif
2982// Additional slice header syntax elements
2983
2984  Void                        setCrossLayerBlaFlag( Bool flag )                      { m_crossLayerBlaFlag = flag;                                   }
2985  Bool                        getCrossLayerBlaFlag(  ) const                         { return m_crossLayerBlaFlag;                                   }
2986  Void                        checkCrossLayerBlaFlag ( ) const ;
2987
2988#if !H_MV_HLS7_GEN
2989  Void                        setPocResetFlag( Bool flag )                           { m_pocResetFlag = flag;                                        }
2990  Bool                        getPocResetFlag(  ) const                              { return m_pocResetFlag;                                        }
2991#endif
2992
2993  Void                        setDiscardableFlag( Bool flag )                        { m_discardableFlag = flag;                                     }
2994  Bool                        getDiscardableFlag(  ) const                           { return m_discardableFlag;                                     }
2995
2996  Void                        setInterLayerPredEnabledFlag( Bool flag )              { m_interLayerPredEnabledFlag = flag;                           }
2997  Bool                        getInterLayerPredEnabledFlag(  ) const                 { return m_interLayerPredEnabledFlag;                           }
2998
2999  Void                        setNumInterLayerRefPicsMinus1( Int  val )              { m_numInterLayerRefPicsMinus1 = val;                           }
3000  Int                         getNumInterLayerRefPicsMinus1(  ) const                { return m_numInterLayerRefPicsMinus1;                          }
3001
3002  Void                        setInterLayerPredLayerIdc( Int i, Int  val )           { m_interLayerPredLayerIdc[i] = val;                            }
3003  Int                         getInterLayerPredLayerIdc( Int i ) const               { return m_interLayerPredLayerIdc[i];                           }
3004
3005  Void                        setSliceSegmentHeaderExtensionLength( Int  val )       { m_sliceSegmentHeaderExtensionLength = val;                    }
3006  Int                         getSliceSegmentHeaderExtensionLength(  ) const         { return m_sliceSegmentHeaderExtensionLength;                   }
3007
3008  Void                        setPocResetIdc( Int  val )                             { m_pocResetIdc = val;                                          }
3009  Int                         getPocResetIdc(  ) const                               { return m_pocResetIdc;                                         }
3010  Void                        checkPocResetIdc( ) const                              { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !(getSlicePicOrderCntLsb() > 0 ) || !( getPocResetIdc() == 2) ); }
3011
3012  Void                        setPocResetPeriodId( Int  val )                        { m_pocResetPeriodId = val;                                     }
3013  Int                         getPocResetPeriodId(  ) const                          { return m_pocResetPeriodId;                                    }
3014
3015  Void                        setFullPocResetFlag( Bool flag )                       { m_fullPocResetFlag = flag;                                    }
3016  Bool                        getFullPocResetFlag(  ) const                          { return m_fullPocResetFlag;                                    }
3017
3018  Void                        setPocLsbVal( Int  val )                               { m_pocLsbVal = val;                                            }
3019  Int                         getPocLsbVal(  )  const                                { return m_pocLsbVal;                                           }
3020  Void                        checkPocLsbVal( ) const                                { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !getFullPocResetFlag() || ( getPocLsbVal() == 0 ) ); }
3021
3022  Void                        setPocMsbValPresentFlag( Bool flag )                   { m_pocMsbValPresentFlag = flag;                                }
3023  Bool                        getPocMsbValPresentFlag(  )          const             { return m_pocMsbValPresentFlag;                                }
3024
3025  Void                        setPocMsbVal( Int  val )                               { m_pocMsbVal = val;                                            }
3026  Int                         getPocMsbVal(  )         const                         { return m_pocMsbVal;                                           }
3027
3028  Bool                        getCraOrBlaPicFlag()       const                       { return ( getCraPicFlag() || getBlaPicFlag() );                }
3029  Bool                        getPocMsbValRequiredFlag() const                       { return ( getCraOrBlaPicFlag() && ( getVPS()->getVpsPocLsbAlignedFlag() || getVPS()->getNumDirectRefLayers( getLayerIdInVps() ) == 0 ) );  }
3030
3031  UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4
3032
3033  Bool getBlaPicFlag() const
3034  {
3035    return  getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
3036    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
3037    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP;
3038  }
3039  Bool getCraPicFlag () const 
3040  {
3041    return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
3042  }
3043
3044  // Additional variables derived in slice header semantics
3045#if NH_3D
3046  Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
3047  Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
3048#else
3049  Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
3050  Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
3051#endif
3052
3053  Int                         getRefLayerPicFlag( Int i ) const;
3054  Int                         getRefLayerPicIdc ( Int j ) const;
3055  Int                         getNumRefLayerPics( ) const;
3056
3057  Int                         getNumActiveRefLayerPics( ) const;
3058
3059  Int                         getNumActiveRefLayerPics0( ) const                     { return (Int) m_refPicSetInterLayer0->size();                  };
3060  Int                         getNumActiveRefLayerPics1( ) const                     { return (Int) m_refPicSetInterLayer1->size();                  };
3061
3062  Int                         getRefPicLayerId             ( Int i ) const;
3063
3064  Void                        setRefPicSetInterLayer       ( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1);
3065  TComPic*                    getPicFromRefPicSetInterLayer ( Int setIdc, Int layerId ) const ;
3066
3067#if NH_3D
3068  // 3D-HEVC tool parameters
3069  Void                        deriveInCmpPredAndCpAvailFlag( );
3070  Void                        init3dToolParameters();
3071  Void                        checkInCompPredRefLayers();;
3072
3073  Bool                        getIvMvPredFlag           ( )                          { return m_ivMvPredFlag           ;                             };
3074  Bool                        getIvMvScalingFlag        ( )                          { return m_ivMvScalingFlag        ;                             };
3075  Bool                        getIvResPredFlag          ( )                          { return m_ivResPredFlag          ;                             };
3076  Bool                        getDepthRefinementFlag    ( )                          { return m_depthRefinementFlag    ;                             };
3077  Bool                        getViewSynthesisPredFlag  ( )                          { return m_viewSynthesisPredFlag  ;                             };
3078  Bool                        getDepthBasedBlkPartFlag  ( )                          { return m_depthBasedBlkPartFlag  ;                             };
3079  Bool                        getMpiFlag                ( )                          { return m_mpiFlag                ;                             };
3080  Bool                        getIntraContourFlag       ( )                          { return m_intraContourFlag       ;                             };
3081  Bool                        getIntraSdcWedgeFlag      ( )                          { return m_intraSdcWedgeFlag      ;                             };
3082  Bool                        getQtPredFlag             ( )                          { return m_qtPredFlag             ;                             };
3083  Bool                        getInterSdcFlag           ( )                          { return m_interSdcFlag           ;                             };
3084  Bool                        getDepthIntraSkipFlag     ( )                          { return m_depthIntraSkipFlag     ;                             };
3085
3086  Int                         getMpiSubPbSize           ( )                          { return m_mpiSubPbSize           ;                             };
3087  Int                         getSubPbSize              ( )                          { return m_subPbSize              ;                             };
3088#if NH_3D_NBDV
3089  Int                         getDefaultRefViewIdx()                                 { return m_iDefaultRefViewIdx;                                  }
3090  Void                        setDefaultRefViewIdx(Int iViewIdx)                     { m_iDefaultRefViewIdx = iViewIdx;                              }
3091
3092  Bool                        getDefaultRefViewIdxAvailableFlag()                    { return m_bDefaultRefViewIdxAvailableFlag;                     }
3093  Void                        setDefaultRefViewIdxAvailableFlag(Bool bViewIdx)       { m_bDefaultRefViewIdxAvailableFlag = bViewIdx;                 }
3094  Void                        setDefaultRefView( );
3095#endif
3096#endif
3097  // Inference
3098  Bool                        inferPocMsbValPresentFlag();
3099#endif
3100protected:
3101  TComPic*                    xGetRefPic        (TComList<TComPic*>& rcListPic, Int poc);
3102  TComPic*                    xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
3103#if NH_MV
3104  TComPic*                    xGetInterLayerRefPic( std::vector<TComPic*>& rcListIlPic, Int layerId ); 
3105#endif
3106};// END CLASS DEFINITION TComSlice
3107
3108
3109Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData);
3110
3111template <class T> class ParameterSetMap
3112{
3113public:
3114  template <class Tm>
3115  struct MapData
3116  {
3117    Bool                  bChanged;
3118    std::vector<UChar>   *pNaluData; // Can be null
3119    Tm*                   parameterSet;
3120  };
3121
3122  ParameterSetMap(Int maxId)
3123  :m_maxId (maxId)
3124  {}
3125
3126  ~ParameterSetMap()
3127  {
3128    for (typename std::map<Int,MapData<T> >::iterator i = m_paramsetMap.begin(); i!= m_paramsetMap.end(); i++)
3129    {
3130      delete (*i).second.pNaluData;
3131      delete (*i).second.parameterSet;
3132    }
3133  }
3134
3135  Void storePS(Int psId, T *ps, const std::vector<UChar> &naluData)
3136  {
3137    assert ( psId < m_maxId );
3138    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
3139    {
3140      MapData<T> &mapData=m_paramsetMap[psId];
3141
3142      // work out changed flag
3143      calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, naluData);
3144      delete m_paramsetMap[psId].pNaluData;
3145      delete m_paramsetMap[psId].parameterSet;
3146
3147      m_paramsetMap[psId].parameterSet = ps;
3148    }
3149    else
3150    {
3151      m_paramsetMap[psId].parameterSet = ps;
3152      m_paramsetMap[psId].bChanged = false;
3153    }
3154      m_paramsetMap[psId].pNaluData=new std::vector<UChar>;
3155    *(m_paramsetMap[psId].pNaluData) = naluData;
3156  }
3157
3158  Void clearChangedFlag(Int psId)
3159  {
3160    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
3161    {
3162      m_paramsetMap[psId].bChanged=false;
3163    }
3164  }
3165
3166  Bool getChangedFlag(Int psId) const
3167  {
3168    const typename std::map<Int,MapData<T> >::const_iterator constit=m_paramsetMap.find(psId);
3169    if ( constit != m_paramsetMap.end() )
3170    {
3171      return constit->second.bChanged;
3172    }
3173    return false;
3174  }
3175
3176  T* getPS(Int psId)
3177  {
3178    typename std::map<Int,MapData<T> >::iterator it=m_paramsetMap.find(psId);
3179    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
3180  }
3181
3182  const T* getPS(Int psId) const
3183  {
3184    typename std::map<Int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId);
3185    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
3186  }
3187
3188  T* getFirstPS()
3189  {
3190    return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet;
3191  }
3192
3193private:
3194  std::map<Int,MapData<T> > m_paramsetMap;
3195  Int                       m_maxId;
3196};
3197
3198class ParameterSetManager
3199{
3200public:
3201                 ParameterSetManager();
3202  virtual        ~ParameterSetManager();
3203
3204  //! store sequence parameter set and take ownership of it
3205  Void           storeVPS(TComVPS *vps, const std::vector<UChar> &naluData) { m_vpsMap.storePS( vps->getVPSId(), vps, naluData); };
3206  //! get pointer to existing video parameter set
3207  TComVPS*       getVPS(Int vpsId)                                           { return m_vpsMap.getPS(vpsId); };
3208  Bool           getVPSChangedFlag(Int vpsId) const                          { return m_vpsMap.getChangedFlag(vpsId); }
3209  Void           clearVPSChangedFlag(Int vpsId)                              { m_vpsMap.clearChangedFlag(vpsId); }
3210  TComVPS*       getFirstVPS()                                               { return m_vpsMap.getFirstPS(); };
3211
3212  //! store sequence parameter set and take ownership of it
3213  Void           storeSPS(TComSPS *sps, const std::vector<UChar> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, naluData); };
3214  //! get pointer to existing sequence parameter set
3215  TComSPS*       getSPS(Int spsId)                                           { return m_spsMap.getPS(spsId); };
3216  Bool           getSPSChangedFlag(Int spsId) const                          { return m_spsMap.getChangedFlag(spsId); }
3217  Void           clearSPSChangedFlag(Int spsId)                              { m_spsMap.clearChangedFlag(spsId); }
3218  TComSPS*       getFirstSPS()                                               { return m_spsMap.getFirstPS(); };
3219
3220  //! store picture parameter set and take ownership of it
3221  Void           storePPS(TComPPS *pps, const std::vector<UChar> &naluData) { m_ppsMap.storePS( pps->getPPSId(), pps, naluData); };
3222  //! get pointer to existing picture parameter set
3223  TComPPS*       getPPS(Int ppsId)                                           { return m_ppsMap.getPS(ppsId); };
3224  Bool           getPPSChangedFlag(Int ppsId) const                          { return m_ppsMap.getChangedFlag(ppsId); }
3225  Void           clearPPSChangedFlag(Int ppsId)                              { m_ppsMap.clearChangedFlag(ppsId); }
3226  TComPPS*       getFirstPPS()                                               { return m_ppsMap.getFirstPS(); };
3227
3228  //! activate a SPS from a active parameter sets SEI message
3229  //! \returns true, if activation is successful
3230#if NH_MV
3231  // Bool           activateSPSWithSEI(Int SPSId, Int layerId );
3232#else
3233  // Bool           activateSPSWithSEI(Int SPSId);
3234#endif
3235
3236  //! activate a PPS and depending on isIDR parameter also SPS and VPS
3237  //! \returns true, if activation is successful
3238#if NH_MV
3239  Bool           activatePPS(Int ppsId, Bool isIRAP, Int layerId );
3240#else
3241  Bool           activatePPS(Int ppsId, Bool isIRAP);
3242#endif
3243
3244  const TComVPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); };
3245
3246#if NH_MV 
3247  const TComSPS* getActiveSPS( Int layer )const { return m_spsMap.getPS(m_activeSPSId[layer]); };
3248#else 
3249  const TComSPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); };
3250#endif
3251
3252protected:
3253  ParameterSetMap<TComVPS> m_vpsMap;
3254  ParameterSetMap<TComSPS> m_spsMap;
3255  ParameterSetMap<TComPPS> m_ppsMap;
3256
3257  Int m_activeVPSId; // -1 for nothing active
3258#if NH_MV 
3259  Int m_activeSPSId[ MAX_NUM_LAYERS ]; // -1 for nothing active
3260#else 
3261  Int m_activeSPSId; // -1 for nothing active
3262#endif
3263};
3264
3265//! \}
3266
3267#endif // __TCOMSLICE__
Note: See TracBrowser for help on using the repository browser.