source: 3DVCSoftware/branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComSlice.h

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

Removed 3D.

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