source: SHVCSoftware/branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.h @ 108

Last change on this file since 108 was 108, checked in by qualcomm, 12 years ago

Rename VPS syntax elements (MACRO: VPS_RENAME)

Rename variables vps_max_nuh_reserved_zero_layer_id and vps_max_op_sets_minus1 to vps_max_layer_id and vps_num_layer_sets_minus1.

From: Adarsh K. Ramasubramonian <aramasub@…>

File size: 81.4 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-2013, 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
48//! \ingroup TLibCommon
49//! \{
50
51class TComPic;
52class TComTrQuant;
53
54#if SVC_EXTENSION
55class TComPicYuv;
56#endif
57// ====================================================================================================================
58// Constants
59// ====================================================================================================================
60
61// ====================================================================================================================
62// Class definition
63// ====================================================================================================================
64
65/// Reference Picture Set class
66class TComReferencePictureSet
67{
68private:
69  Int  m_numberOfPictures;
70  Int  m_numberOfNegativePictures;
71  Int  m_numberOfPositivePictures;
72  Int  m_numberOfLongtermPictures;
73  Int  m_deltaPOC[MAX_NUM_REF_PICS];
74  Int  m_POC[MAX_NUM_REF_PICS];
75  Bool m_used[MAX_NUM_REF_PICS];
76  Bool m_interRPSPrediction;
77  Int  m_deltaRIdxMinus1;   
78  Int  m_deltaRPS; 
79  Int  m_numRefIdc; 
80  Int  m_refIdc[MAX_NUM_REF_PICS+1];
81  Bool m_bCheckLTMSB[MAX_NUM_REF_PICS];
82  Int  m_pocLSBLT[MAX_NUM_REF_PICS];
83  Int  m_deltaPOCMSBCycleLT[MAX_NUM_REF_PICS];
84  Bool m_deltaPocMSBPresentFlag[MAX_NUM_REF_PICS];
85
86public:
87  TComReferencePictureSet();
88  virtual ~TComReferencePictureSet();
89  Int   getPocLSBLT(Int i)                       { return m_pocLSBLT[i]; }
90  Void  setPocLSBLT(Int i, Int x)                { m_pocLSBLT[i] = x; }
91  Int   getDeltaPocMSBCycleLT(Int i)             { return m_deltaPOCMSBCycleLT[i]; }
92  Void  setDeltaPocMSBCycleLT(Int i, Int x)      { m_deltaPOCMSBCycleLT[i] = x; }
93  Bool  getDeltaPocMSBPresentFlag(Int i)         { return m_deltaPocMSBPresentFlag[i]; }
94  Void  setDeltaPocMSBPresentFlag(Int i, Bool x) { m_deltaPocMSBPresentFlag[i] = x;    }
95  Void setUsed(Int bufferNum, Bool used);
96  Void setDeltaPOC(Int bufferNum, Int deltaPOC);
97  Void setPOC(Int bufferNum, Int deltaPOC);
98  Void setNumberOfPictures(Int numberOfPictures);
99  Void setCheckLTMSBPresent(Int bufferNum, Bool b );
100  Bool getCheckLTMSBPresent(Int bufferNum);
101
102  Int  getUsed(Int bufferNum);
103  Int  getDeltaPOC(Int bufferNum);
104  Int  getPOC(Int bufferNum);
105  Int  getNumberOfPictures();
106
107  Void setNumberOfNegativePictures(Int number)  { m_numberOfNegativePictures = number; }
108  Int  getNumberOfNegativePictures()            { return m_numberOfNegativePictures; }
109  Void setNumberOfPositivePictures(Int number)  { m_numberOfPositivePictures = number; }
110  Int  getNumberOfPositivePictures()            { return m_numberOfPositivePictures; }
111  Void setNumberOfLongtermPictures(Int number)  { m_numberOfLongtermPictures = number; }
112  Int  getNumberOfLongtermPictures()            { return m_numberOfLongtermPictures; }
113
114  Void setInterRPSPrediction(Bool flag)         { m_interRPSPrediction = flag; }
115  Bool getInterRPSPrediction()                  { return m_interRPSPrediction; }
116  Void setDeltaRIdxMinus1(Int x)                { m_deltaRIdxMinus1 = x; }
117  Int  getDeltaRIdxMinus1()                     { return m_deltaRIdxMinus1; }
118  Void setDeltaRPS(Int x)                       { m_deltaRPS = x; }
119  Int  getDeltaRPS()                            { return m_deltaRPS; }
120  Void setNumRefIdc(Int x)                      { m_numRefIdc = x; }
121  Int  getNumRefIdc()                           { return m_numRefIdc; }
122
123  Void setRefIdc(Int bufferNum, Int refIdc);
124  Int  getRefIdc(Int bufferNum);
125
126  Void sortDeltaPOC();
127  Void printDeltaPOC();
128};
129
130/// Reference Picture Set set class
131class TComRPSList
132{
133private:
134  Int  m_numberOfReferencePictureSets;
135  TComReferencePictureSet* m_referencePictureSets;
136 
137public:
138  TComRPSList();
139  virtual ~TComRPSList();
140 
141  Void  create  (Int numberOfEntries);
142  Void  destroy ();
143
144
145  TComReferencePictureSet* getReferencePictureSet(Int referencePictureSetNum);
146  Int getNumberOfReferencePictureSets();
147  Void setNumberOfReferencePictureSets(Int numberOfReferencePictureSets);
148};
149
150/// SCALING_LIST class
151class TComScalingList
152{
153public:
154  TComScalingList();
155  virtual ~TComScalingList();
156  Void     setScalingListPresentFlag    (Bool b)                               { m_scalingListPresentFlag = b;    }
157  Bool     getScalingListPresentFlag    ()                                     { return m_scalingListPresentFlag; }
158  Bool     getUseTransformSkip    ()                                     { return m_useTransformSkip; }     
159  Void     setUseTransformSkip    (Bool b)                               { m_useTransformSkip = b;    }
160  Int*     getScalingListAddress          (UInt sizeId, UInt listId)           { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient
161  Bool     checkPredMode                  (UInt sizeId, UInt listId);
162  Void     setRefMatrixId                 (UInt sizeId, UInt listId, UInt u)   { m_refMatrixId[sizeId][listId] = u;    }     //!< set reference matrix ID
163  UInt     getRefMatrixId                 (UInt sizeId, UInt listId)           { return m_refMatrixId[sizeId][listId]; }     //!< get reference matrix ID
164  Int*     getScalingListDefaultAddress   (UInt sizeId, UInt listId);                                                        //!< get default matrix coefficient
165  Void     processDefaultMarix            (UInt sizeId, UInt listId);
166  Void     setScalingListDC               (UInt sizeId, UInt listId, UInt u)   { m_scalingListDC[sizeId][listId] = u; }      //!< set DC value
167
168  Int      getScalingListDC               (UInt sizeId, UInt listId)           { return m_scalingListDC[sizeId][listId]; }   //!< get DC value
169  Void     checkDcOfMatrix                ();
170  Void     processRefMatrix               (UInt sizeId, UInt listId , UInt refListId );
171  Bool     xParseScalingList              (Char* pchFile);
172
173private:
174  Void     init                    ();
175  Void     destroy                 ();
176  Int      m_scalingListDC               [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< the DC value of the matrix coefficient for 16x16
177  Bool     m_useDefaultScalingMatrixFlag [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< UseDefaultScalingMatrixFlag
178  UInt     m_refMatrixId                 [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< RefMatrixID
179  Bool     m_scalingListPresentFlag;                                                //!< flag for using default matrix
180  UInt     m_predMatrixId                [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index
181  Int      *m_scalingListCoef            [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix
182  Bool     m_useTransformSkip;                                                      //!< transform skipping flag for setting default scaling matrix for 4x4
183};
184
185class ProfileTierLevel
186{
187  Int     m_profileSpace;
188  Bool    m_tierFlag;
189  Int     m_profileIdc;
190  Bool    m_profileCompatibilityFlag[32];
191  Int     m_levelIdc;
192
193#if L0046_CONSTRAINT_FLAGS
194  Bool m_progressiveSourceFlag;
195  Bool m_interlacedSourceFlag;
196  Bool m_nonPackedConstraintFlag;
197  Bool m_frameOnlyConstraintFlag;
198#endif
199 
200public:
201  ProfileTierLevel();
202
203  Int   getProfileSpace() const   { return m_profileSpace; }
204  Void  setProfileSpace(Int x)    { m_profileSpace = x; }
205
206  Bool  getTierFlag()     const   { return m_tierFlag; }
207  Void  setTierFlag(Bool x)       { m_tierFlag = x; }
208
209  Int   getProfileIdc()   const   { return m_profileIdc; }
210  Void  setProfileIdc(Int x)      { m_profileIdc = x; }
211
212  Bool  getProfileCompatibilityFlag(Int i) const    { return m_profileCompatibilityFlag[i]; }
213  Void  setProfileCompatibilityFlag(Int i, Bool x)  { m_profileCompatibilityFlag[i] = x; }
214
215  Int   getLevelIdc()   const   { return m_levelIdc; }
216  Void  setLevelIdc(Int x)      { m_levelIdc = x; }
217 
218#if L0046_CONSTRAINT_FLAGS
219  Bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; }
220  Void setProgressiveSourceFlag(Bool b) { m_progressiveSourceFlag = b; }
221 
222  Bool getInterlacedSourceFlag() const { return m_interlacedSourceFlag; }
223  Void setInterlacedSourceFlag(Bool b) { m_interlacedSourceFlag = b; }
224 
225  Bool getNonPackedConstraintFlag() const { return m_nonPackedConstraintFlag; }
226  Void setNonPackedConstraintFlag(Bool b) { m_nonPackedConstraintFlag = b; }
227 
228  Bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
229  Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
230#endif
231};
232
233
234class TComPTL
235{
236  ProfileTierLevel m_generalPTL;
237  ProfileTierLevel m_subLayerPTL[6];      // max. value of max_sub_layers_minus1 is 6
238  Bool m_subLayerProfilePresentFlag[6];
239  Bool m_subLayerLevelPresentFlag[6];
240
241public:
242  TComPTL();
243  Bool getSubLayerProfilePresentFlag(Int i) const { return m_subLayerProfilePresentFlag[i]; }
244  Void setSubLayerProfilePresentFlag(Int i, Bool x) { m_subLayerProfilePresentFlag[i] = x; }
245 
246  Bool getSubLayerLevelPresentFlag(Int i) const { return m_subLayerLevelPresentFlag[i]; }
247  Void setSubLayerLevelPresentFlag(Int i, Bool x) { m_subLayerLevelPresentFlag[i] = x; }
248
249  ProfileTierLevel* getGeneralPTL()  { return &m_generalPTL; }
250  ProfileTierLevel* getSubLayerPTL(Int i)  { return &m_subLayerPTL[i]; }
251};
252/// VPS class
253
254#if SIGNAL_BITRATE_PICRATE_IN_VPS
255class TComBitRatePicRateInfo
256{
257  Bool        m_bitRateInfoPresentFlag[MAX_TLAYER];
258  Bool        m_picRateInfoPresentFlag[MAX_TLAYER];
259  Int         m_avgBitRate[MAX_TLAYER];
260  Int         m_maxBitRate[MAX_TLAYER];
261  Int         m_constantPicRateIdc[MAX_TLAYER];
262  Int         m_avgPicRate[MAX_TLAYER];
263public:
264  TComBitRatePicRateInfo();
265  Bool        getBitRateInfoPresentFlag(Int i) {return m_bitRateInfoPresentFlag[i];}
266  Void        setBitRateInfoPresentFlag(Int i, Bool x) {m_bitRateInfoPresentFlag[i] = x;}
267
268  Bool        getPicRateInfoPresentFlag(Int i) {return m_picRateInfoPresentFlag[i];}
269  Void        setPicRateInfoPresentFlag(Int i, Bool x) {m_picRateInfoPresentFlag[i] = x;}
270
271  Int         getAvgBitRate(Int i) {return m_avgBitRate[i];}
272  Void        setAvgBitRate(Int i, Int x) {m_avgBitRate[i] = x;}
273
274  Int         getMaxBitRate(Int i) {return m_maxBitRate[i];}
275  Void        setMaxBitRate(Int i, Int x) {m_maxBitRate[i] = x;}
276
277  Int         getConstantPicRateIdc(Int i) {return m_constantPicRateIdc[i];}
278  Void        setConstantPicRateIdc(Int i, Int x) {m_constantPicRateIdc[i] = x;}
279
280  Int         getAvgPicRate(Int i) {return m_avgPicRate[i];}
281  Void        setAvgPicRate(Int i, Int x) {m_avgPicRate[i] = x;}
282};
283#endif
284
285struct HrdSubLayerInfo
286{
287  Bool fixedPicRateFlag;
288  Bool fixedPicRateWithinCvsFlag;
289  UInt picDurationInTcMinus1;
290  Bool lowDelayHrdFlag;
291  UInt cpbCntMinus1;
292  UInt bitRateValueMinus1[MAX_CPB_CNT][2];
293  UInt cpbSizeValue      [MAX_CPB_CNT][2];
294  UInt ducpbSizeValue    [MAX_CPB_CNT][2];
295  UInt cbrFlag           [MAX_CPB_CNT][2];
296#if L0363_DU_BIT_RATE
297  UInt duBitRateValue    [MAX_CPB_CNT][2];
298#endif
299};
300
301class TComHRD
302{
303private:
304#if !L0043_TIMING_INFO
305  Bool m_timingInfoPresentFlag;
306  UInt m_numUnitsInTick;
307  UInt m_timeScale;
308#endif
309  Bool m_nalHrdParametersPresentFlag;
310  Bool m_vclHrdParametersPresentFlag;
311  Bool m_subPicCpbParamsPresentFlag;
312  UInt m_tickDivisorMinus2;
313  UInt m_duCpbRemovalDelayLengthMinus1;
314  Bool m_subPicCpbParamsInPicTimingSEIFlag;
315#if L0044_DU_DPB_OUTPUT_DELAY_HRD
316  UInt m_dpbOutputDelayDuLengthMinus1;
317#endif
318  UInt m_bitRateScale;
319  UInt m_cpbSizeScale;
320  UInt m_ducpbSizeScale;
321  UInt m_initialCpbRemovalDelayLengthMinus1;
322  UInt m_cpbRemovalDelayLengthMinus1;
323  UInt m_dpbOutputDelayLengthMinus1;
324  UInt m_numDU;
325  HrdSubLayerInfo m_HRD[MAX_TLAYER];
326
327public:
328  TComHRD()
329#if !L0043_TIMING_INFO
330  :m_timingInfoPresentFlag(false)
331  ,m_numUnitsInTick(1001)
332  ,m_timeScale(60000)
333  ,m_nalHrdParametersPresentFlag(0)
334#else
335  :m_nalHrdParametersPresentFlag(0)
336#endif
337  ,m_vclHrdParametersPresentFlag(0)
338  ,m_subPicCpbParamsPresentFlag(false)
339  ,m_tickDivisorMinus2(0)
340  ,m_duCpbRemovalDelayLengthMinus1(0)
341  ,m_subPicCpbParamsInPicTimingSEIFlag(false)
342#if L0044_DU_DPB_OUTPUT_DELAY_HRD
343  ,m_dpbOutputDelayDuLengthMinus1(0)
344#endif
345  ,m_bitRateScale(0)
346  ,m_cpbSizeScale(0)
347  ,m_initialCpbRemovalDelayLengthMinus1(0)
348  ,m_cpbRemovalDelayLengthMinus1(0)
349  ,m_dpbOutputDelayLengthMinus1(0)
350  {}
351
352  virtual ~TComHRD() {}
353#if !L0043_TIMING_INFO
354  Void setTimingInfoPresentFlag             ( Bool flag )  { m_timingInfoPresentFlag = flag;               }
355  Bool getTimingInfoPresentFlag             ( )            { return m_timingInfoPresentFlag;               }
356
357  Void setNumUnitsInTick                    ( UInt value ) { m_numUnitsInTick = value;                     }
358  UInt getNumUnitsInTick                    ( )            { return m_numUnitsInTick;                      }
359
360  Void setTimeScale                         ( UInt value ) { m_timeScale = value;                          }
361  UInt getTimeScale                         ( )            { return m_timeScale;                           }
362#endif
363
364  Void setNalHrdParametersPresentFlag       ( Bool flag )  { m_nalHrdParametersPresentFlag = flag;         }
365  Bool getNalHrdParametersPresentFlag       ( )            { return m_nalHrdParametersPresentFlag;         }
366
367  Void setVclHrdParametersPresentFlag       ( Bool flag )  { m_vclHrdParametersPresentFlag = flag;         }
368  Bool getVclHrdParametersPresentFlag       ( )            { return m_vclHrdParametersPresentFlag;         }
369
370  Void setSubPicCpbParamsPresentFlag        ( Bool flag )  { m_subPicCpbParamsPresentFlag = flag;          }
371  Bool getSubPicCpbParamsPresentFlag        ( )            { return m_subPicCpbParamsPresentFlag;          }
372 
373  Void setTickDivisorMinus2                 ( UInt value ) { m_tickDivisorMinus2 = value;                  }
374  UInt getTickDivisorMinus2                 ( )            { return m_tickDivisorMinus2;                   }
375
376  Void setDuCpbRemovalDelayLengthMinus1     ( UInt value ) { m_duCpbRemovalDelayLengthMinus1 = value;      }
377  UInt getDuCpbRemovalDelayLengthMinus1     ( )            { return m_duCpbRemovalDelayLengthMinus1;       }
378
379  Void setSubPicCpbParamsInPicTimingSEIFlag ( Bool flag)   { m_subPicCpbParamsInPicTimingSEIFlag = flag;   }
380  Bool getSubPicCpbParamsInPicTimingSEIFlag ()             { return m_subPicCpbParamsInPicTimingSEIFlag;   }
381
382#if L0044_DU_DPB_OUTPUT_DELAY_HRD
383  Void setDpbOutputDelayDuLengthMinus1      (UInt value )  { m_dpbOutputDelayDuLengthMinus1 = value;       }
384  UInt getDpbOutputDelayDuLengthMinus1      ()             { return m_dpbOutputDelayDuLengthMinus1;        }
385#endif
386
387  Void setBitRateScale                      ( UInt value ) { m_bitRateScale = value;                       }
388  UInt getBitRateScale                      ( )            { return m_bitRateScale;                        }
389
390  Void setCpbSizeScale                      ( UInt value ) { m_cpbSizeScale = value;                       }
391  UInt getCpbSizeScale                      ( )            { return m_cpbSizeScale;                        }
392  Void setDuCpbSizeScale                    ( UInt value ) { m_ducpbSizeScale = value;                     }
393  UInt getDuCpbSizeScale                    ( )            { return m_ducpbSizeScale;                      }
394
395  Void setInitialCpbRemovalDelayLengthMinus1( UInt value ) { m_initialCpbRemovalDelayLengthMinus1 = value; }
396  UInt getInitialCpbRemovalDelayLengthMinus1( )            { return m_initialCpbRemovalDelayLengthMinus1;  }
397
398  Void setCpbRemovalDelayLengthMinus1       ( UInt value ) { m_cpbRemovalDelayLengthMinus1 = value;        }
399  UInt getCpbRemovalDelayLengthMinus1       ( )            { return m_cpbRemovalDelayLengthMinus1;         }
400
401  Void setDpbOutputDelayLengthMinus1        ( UInt value ) { m_dpbOutputDelayLengthMinus1 = value;         }
402  UInt getDpbOutputDelayLengthMinus1        ( )            { return m_dpbOutputDelayLengthMinus1;          }
403
404  Void setFixedPicRateFlag       ( Int layer, Bool flag )  { m_HRD[layer].fixedPicRateFlag = flag;         }
405  Bool getFixedPicRateFlag       ( Int layer            )  { return m_HRD[layer].fixedPicRateFlag;         }
406
407  Void setFixedPicRateWithinCvsFlag       ( Int layer, Bool flag )  { m_HRD[layer].fixedPicRateWithinCvsFlag = flag;         }
408  Bool getFixedPicRateWithinCvsFlag       ( Int layer            )  { return m_HRD[layer].fixedPicRateWithinCvsFlag;         }
409
410  Void setPicDurationInTcMinus1  ( Int layer, UInt value ) { m_HRD[layer].picDurationInTcMinus1 = value;   }
411  UInt getPicDurationInTcMinus1  ( Int layer             ) { return m_HRD[layer].picDurationInTcMinus1;    }
412
413  Void setLowDelayHrdFlag        ( Int layer, Bool flag )  { m_HRD[layer].lowDelayHrdFlag = flag;          }
414  Bool getLowDelayHrdFlag        ( Int layer            )  { return m_HRD[layer].lowDelayHrdFlag;          }
415
416  Void setCpbCntMinus1           ( Int layer, UInt value ) { m_HRD[layer].cpbCntMinus1 = value; }
417  UInt getCpbCntMinus1           ( Int layer            )  { return m_HRD[layer].cpbCntMinus1; }
418
419  Void setBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl] = value; }
420  UInt getBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl             ) { return m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl];  }
421
422  Void setCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl] = value;       }
423  UInt getCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl            )  { return m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl];        }
424  Void setDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl] = value;       }
425  UInt getDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl            )  { return m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl];        }
426#if L0363_DU_BIT_RATE
427  Void setDuBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl] = value;       }
428  UInt getDuBitRateValueMinus1     (Int layer, Int cpbcnt, Int nalOrVcl )              { return m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl];        }
429#endif
430  Void setCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl] = value;            }
431  Bool getCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl             ) { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl];             }
432
433  Void setNumDU                              ( UInt value ) { m_numDU = value;                            }
434  UInt getNumDU                              ( )            { return m_numDU;          }
435#if L0045_CONDITION_SIGNALLING
436  Bool getCpbDpbDelaysPresentFlag() { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
437#endif
438};
439
440#if L0043_TIMING_INFO
441class TimingInfo
442{
443  Bool m_timingInfoPresentFlag;
444  UInt m_numUnitsInTick;
445  UInt m_timeScale;
446  Bool m_pocProportionalToTimingFlag;
447  Int  m_numTicksPocDiffOneMinus1;
448public:
449  TimingInfo()
450  : m_timingInfoPresentFlag(false)
451  , m_numUnitsInTick(1001)
452  , m_timeScale(60000)
453  , m_pocProportionalToTimingFlag(false)
454  , m_numTicksPocDiffOneMinus1(0) {}
455
456  Void setTimingInfoPresentFlag             ( Bool flag )  { m_timingInfoPresentFlag = flag;               }
457  Bool getTimingInfoPresentFlag             ( )            { return m_timingInfoPresentFlag;               }
458
459  Void setNumUnitsInTick                    ( UInt value ) { m_numUnitsInTick = value;                     }
460  UInt getNumUnitsInTick                    ( )            { return m_numUnitsInTick;                      }
461
462  Void setTimeScale                         ( UInt value ) { m_timeScale = value;                          }
463  UInt getTimeScale                         ( )            { return m_timeScale;                           }
464 
465  Bool getPocProportionalToTimingFlag       ( )            { return m_pocProportionalToTimingFlag;         }
466  Void setPocProportionalToTimingFlag       (Bool x      ) { m_pocProportionalToTimingFlag = x;            }
467 
468  Int  getNumTicksPocDiffOneMinus1          ( )            { return m_numTicksPocDiffOneMinus1;            }
469  Void setNumTicksPocDiffOneMinus1          (Int x       ) { m_numTicksPocDiffOneMinus1 = x;               }
470};
471#endif
472
473class TComVPS
474{
475private:
476  Int         m_VPSId;
477  UInt        m_uiMaxTLayers;
478  UInt        m_uiMaxLayers;
479  Bool        m_bTemporalIdNestingFlag;
480 
481  UInt        m_numReorderPics[MAX_TLAYER];
482  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER]; 
483  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];
484
485  UInt        m_numHrdParameters;
486#if !VPS_RENAME
487  UInt        m_maxNuhReservedZeroLayerId;
488#endif
489  TComHRD*    m_hrdParameters;
490  UInt*       m_hrdOpSetIdx;
491  Bool*       m_cprmsPresentFlag;
492#if VPS_RENAME
493  UInt        m_maxLayerId;
494  UInt        m_numLayerSets;
495  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
496#else
497  UInt        m_numOpSets;
498  Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
499#endif
500
501  TComPTL     m_pcPTL;
502#if SIGNAL_BITRATE_PICRATE_IN_VPS
503  TComBitRatePicRateInfo    m_bitRatePicRateInfo;
504#endif
505#if L0043_TIMING_INFO
506  TimingInfo  m_timingInfo;
507#endif
508
509public:
510  TComVPS();
511  virtual ~TComVPS();
512
513  Void    createHrdParamBuffer()
514  {
515    m_hrdParameters    = new TComHRD[ getNumHrdParameters() ];
516    m_hrdOpSetIdx      = new UInt   [ getNumHrdParameters() ];
517    m_cprmsPresentFlag = new Bool   [ getNumHrdParameters() ];
518  }
519
520  TComHRD* getHrdParameters   ( UInt i )             { return &m_hrdParameters[ i ]; }
521  UInt    getHrdOpSetIdx      ( UInt i )             { return m_hrdOpSetIdx[ i ]; }
522  Void    setHrdOpSetIdx      ( UInt val, UInt i )   { m_hrdOpSetIdx[ i ] = val;  }
523  Bool    getCprmsPresentFlag ( UInt i )             { return m_cprmsPresentFlag[ i ]; }
524  Void    setCprmsPresentFlag ( Bool val, UInt i )   { m_cprmsPresentFlag[ i ] = val;  }
525
526  Int     getVPSId       ()                   { return m_VPSId;          }
527  Void    setVPSId       (Int i)              { m_VPSId = i;             }
528
529  UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
530  Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
531 
532  UInt    getMaxLayers   ()                   { return m_uiMaxLayers;   }
533  Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
534
535  Bool    getTemporalNestingFlag   ()         { return m_bTemporalIdNestingFlag;   }
536  Void    setTemporalNestingFlag   (Bool t)   { m_bTemporalIdNestingFlag = t; }
537 
538  Void    setNumReorderPics(UInt v, UInt tLayer)                { m_numReorderPics[tLayer] = v;    }
539  UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
540 
541  Void    setMaxDecPicBuffering(UInt v, UInt tLayer)            { m_uiMaxDecPicBuffering[tLayer] = v;    }
542  UInt    getMaxDecPicBuffering(UInt tLayer)                    { return m_uiMaxDecPicBuffering[tLayer]; }
543 
544  Void    setMaxLatencyIncrease(UInt v, UInt tLayer)            { m_uiMaxLatencyIncrease[tLayer] = v;    }
545  UInt    getMaxLatencyIncrease(UInt tLayer)                    { return m_uiMaxLatencyIncrease[tLayer]; }
546
547  UInt    getNumHrdParameters()                                 { return m_numHrdParameters; }
548  Void    setNumHrdParameters(UInt v)                           { m_numHrdParameters = v;    }
549
550#if VPS_RENAME
551  UInt    getMaxLayerId()                                       { return m_maxLayerId; }
552  Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;    }
553
554  UInt    getNumLayerSets()                                     { return m_numLayerSets; }
555  Void    setNumLayerSets(UInt v)                               { m_numLayerSets = v;    }
556#else
557  UInt    getMaxNuhReservedZeroLayerId()                        { return m_maxNuhReservedZeroLayerId; }
558  Void    setMaxNuhReservedZeroLayerId(UInt v)                  { m_maxNuhReservedZeroLayerId = v;    }
559
560  UInt    getMaxOpSets()                                        { return m_numOpSets; }
561  Void    setMaxOpSets(UInt v)                                  { m_numOpSets = v;    }
562#endif
563  Bool    getLayerIdIncludedFlag(UInt opsIdx, UInt id)          { return m_layerIdIncludedFlag[opsIdx][id]; }
564  Void    setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)  { m_layerIdIncludedFlag[opsIdx][id] = v;    }
565
566  TComPTL* getPTL() { return &m_pcPTL; }
567#if SIGNAL_BITRATE_PICRATE_IN_VPS
568  TComBitRatePicRateInfo *getBitratePicrateInfo() { return &m_bitRatePicRateInfo; }
569#endif
570#if L0043_TIMING_INFO
571  TimingInfo* getTimingInfo() { return &m_timingInfo; }
572#endif
573};
574
575class Window
576{
577private:
578  Bool          m_enabledFlag;
579  Int           m_winLeftOffset;
580  Int           m_winRightOffset;
581  Int           m_winTopOffset;
582  Int           m_winBottomOffset;
583public:
584  Window()
585  : m_enabledFlag (false)
586  , m_winLeftOffset     (0)
587  , m_winRightOffset    (0)
588  , m_winTopOffset      (0)
589  , m_winBottomOffset   (0)
590  { }
591
592  Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
593  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; }
594  Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
595  Void          setWindowLeftOffset(Int val)      { m_winLeftOffset = val; m_enabledFlag = true; }
596  Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
597  Void          setWindowRightOffset(Int val)     { m_winRightOffset = val; m_enabledFlag = true; }
598  Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
599  Void          setWindowTopOffset(Int val)       { m_winTopOffset = val; m_enabledFlag = true; }
600  Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
601  Void          setWindowBottomOffset(Int val)    { m_winBottomOffset = val; m_enabledFlag = true; }
602
603  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
604  {
605    m_enabledFlag       = true;
606    m_winLeftOffset     = offsetLeft;
607    m_winRightOffset    = offsetLRight;
608    m_winTopOffset      = offsetLTop;
609    m_winBottomOffset   = offsetLBottom;
610  }
611};
612
613
614class TComVUI
615{
616private:
617  Bool m_aspectRatioInfoPresentFlag;
618  Int  m_aspectRatioIdc;
619  Int  m_sarWidth;
620  Int  m_sarHeight;
621  Bool m_overscanInfoPresentFlag;
622  Bool m_overscanAppropriateFlag;
623  Bool m_videoSignalTypePresentFlag;
624  Int  m_videoFormat;
625  Bool m_videoFullRangeFlag;
626  Bool m_colourDescriptionPresentFlag;
627  Int  m_colourPrimaries;
628  Int  m_transferCharacteristics;
629  Int  m_matrixCoefficients;
630  Bool m_chromaLocInfoPresentFlag;
631  Int  m_chromaSampleLocTypeTopField;
632  Int  m_chromaSampleLocTypeBottomField;
633  Bool m_neutralChromaIndicationFlag;
634  Bool m_fieldSeqFlag;
635
636  Window m_defaultDisplayWindow;
637  Bool m_frameFieldInfoPresentFlag;
638  Bool m_hrdParametersPresentFlag;
639  Bool m_bitstreamRestrictionFlag;
640  Bool m_tilesFixedStructureFlag;
641  Bool m_motionVectorsOverPicBoundariesFlag;
642  Bool m_restrictedRefPicListsFlag;
643  Int  m_minSpatialSegmentationIdc;
644  Int  m_maxBytesPerPicDenom;
645  Int  m_maxBitsPerMinCuDenom;
646  Int  m_log2MaxMvLengthHorizontal;
647  Int  m_log2MaxMvLengthVertical;
648  TComHRD m_hrdParameters;
649#if L0043_TIMING_INFO
650  TimingInfo m_timingInfo;
651#else
652  Bool m_pocProportionalToTimingFlag;
653  Int  m_numTicksPocDiffOneMinus1;
654#endif
655
656public:
657  TComVUI()
658    :m_aspectRatioInfoPresentFlag(false)
659    ,m_aspectRatioIdc(0)
660    ,m_sarWidth(0)
661    ,m_sarHeight(0)
662    ,m_overscanInfoPresentFlag(false)
663    ,m_overscanAppropriateFlag(false)
664    ,m_videoSignalTypePresentFlag(false)
665    ,m_videoFormat(5)
666    ,m_videoFullRangeFlag(false)
667    ,m_colourDescriptionPresentFlag(false)
668    ,m_colourPrimaries(2)
669    ,m_transferCharacteristics(2)
670    ,m_matrixCoefficients(2)
671    ,m_chromaLocInfoPresentFlag(false)
672    ,m_chromaSampleLocTypeTopField(0)
673    ,m_chromaSampleLocTypeBottomField(0)
674    ,m_neutralChromaIndicationFlag(false)
675    ,m_fieldSeqFlag(false)
676    ,m_frameFieldInfoPresentFlag(false)
677    ,m_hrdParametersPresentFlag(false)
678    ,m_bitstreamRestrictionFlag(false)
679    ,m_tilesFixedStructureFlag(false)
680    ,m_motionVectorsOverPicBoundariesFlag(true)
681    ,m_restrictedRefPicListsFlag(1)
682    ,m_minSpatialSegmentationIdc(0)
683    ,m_maxBytesPerPicDenom(2)
684    ,m_maxBitsPerMinCuDenom(1)
685    ,m_log2MaxMvLengthHorizontal(15)
686    ,m_log2MaxMvLengthVertical(15)
687#if !L0043_TIMING_INFO 
688    ,m_pocProportionalToTimingFlag(false)
689    ,m_numTicksPocDiffOneMinus1(0)
690#endif
691  {}
692
693  virtual ~TComVUI() {}
694
695  Bool getAspectRatioInfoPresentFlag() { return m_aspectRatioInfoPresentFlag; }
696  Void setAspectRatioInfoPresentFlag(Bool i) { m_aspectRatioInfoPresentFlag = i; }
697
698  Int getAspectRatioIdc() { return m_aspectRatioIdc; }
699  Void setAspectRatioIdc(Int i) { m_aspectRatioIdc = i; }
700
701  Int getSarWidth() { return m_sarWidth; }
702  Void setSarWidth(Int i) { m_sarWidth = i; }
703
704  Int getSarHeight() { return m_sarHeight; }
705  Void setSarHeight(Int i) { m_sarHeight = i; }
706
707  Bool getOverscanInfoPresentFlag() { return m_overscanInfoPresentFlag; }
708  Void setOverscanInfoPresentFlag(Bool i) { m_overscanInfoPresentFlag = i; }
709
710  Bool getOverscanAppropriateFlag() { return m_overscanAppropriateFlag; }
711  Void setOverscanAppropriateFlag(Bool i) { m_overscanAppropriateFlag = i; }
712
713  Bool getVideoSignalTypePresentFlag() { return m_videoSignalTypePresentFlag; }
714  Void setVideoSignalTypePresentFlag(Bool i) { m_videoSignalTypePresentFlag = i; }
715
716  Int getVideoFormat() { return m_videoFormat; }
717  Void setVideoFormat(Int i) { m_videoFormat = i; }
718
719  Bool getVideoFullRangeFlag() { return m_videoFullRangeFlag; }
720  Void setVideoFullRangeFlag(Bool i) { m_videoFullRangeFlag = i; }
721
722  Bool getColourDescriptionPresentFlag() { return m_colourDescriptionPresentFlag; }
723  Void setColourDescriptionPresentFlag(Bool i) { m_colourDescriptionPresentFlag = i; }
724
725  Int getColourPrimaries() { return m_colourPrimaries; }
726  Void setColourPrimaries(Int i) { m_colourPrimaries = i; }
727
728  Int getTransferCharacteristics() { return m_transferCharacteristics; }
729  Void setTransferCharacteristics(Int i) { m_transferCharacteristics = i; }
730
731  Int getMatrixCoefficients() { return m_matrixCoefficients; }
732  Void setMatrixCoefficients(Int i) { m_matrixCoefficients = i; }
733
734  Bool getChromaLocInfoPresentFlag() { return m_chromaLocInfoPresentFlag; }
735  Void setChromaLocInfoPresentFlag(Bool i) { m_chromaLocInfoPresentFlag = i; }
736
737  Int getChromaSampleLocTypeTopField() { return m_chromaSampleLocTypeTopField; }
738  Void setChromaSampleLocTypeTopField(Int i) { m_chromaSampleLocTypeTopField = i; }
739
740  Int getChromaSampleLocTypeBottomField() { return m_chromaSampleLocTypeBottomField; }
741  Void setChromaSampleLocTypeBottomField(Int i) { m_chromaSampleLocTypeBottomField = i; }
742
743  Bool getNeutralChromaIndicationFlag() { return m_neutralChromaIndicationFlag; }
744  Void setNeutralChromaIndicationFlag(Bool i) { m_neutralChromaIndicationFlag = i; }
745
746  Bool getFieldSeqFlag() { return m_fieldSeqFlag; }
747  Void setFieldSeqFlag(Bool i) { m_fieldSeqFlag = i; }
748
749  Bool getFrameFieldInfoPresentFlag() { return m_frameFieldInfoPresentFlag; }
750  Void setFrameFieldInfoPresentFlag(Bool i) { m_frameFieldInfoPresentFlag = i; }
751
752  Window& getDefaultDisplayWindow()                              { return m_defaultDisplayWindow;                }
753  Void    setDefaultDisplayWindow(Window& defaultDisplayWindow ) { m_defaultDisplayWindow = defaultDisplayWindow; }
754
755  Bool getHrdParametersPresentFlag() { return m_hrdParametersPresentFlag; }
756  Void setHrdParametersPresentFlag(Bool i) { m_hrdParametersPresentFlag = i; }
757
758  Bool getBitstreamRestrictionFlag() { return m_bitstreamRestrictionFlag; }
759  Void setBitstreamRestrictionFlag(Bool i) { m_bitstreamRestrictionFlag = i; }
760
761  Bool getTilesFixedStructureFlag() { return m_tilesFixedStructureFlag; }
762  Void setTilesFixedStructureFlag(Bool i) { m_tilesFixedStructureFlag = i; }
763
764  Bool getMotionVectorsOverPicBoundariesFlag() { return m_motionVectorsOverPicBoundariesFlag; }
765  Void setMotionVectorsOverPicBoundariesFlag(Bool i) { m_motionVectorsOverPicBoundariesFlag = i; }
766
767  Bool getRestrictedRefPicListsFlag() { return m_restrictedRefPicListsFlag; }
768  Void setRestrictedRefPicListsFlag(Bool b) { m_restrictedRefPicListsFlag = b; }
769
770  Int getMinSpatialSegmentationIdc() { return m_minSpatialSegmentationIdc; }
771  Void setMinSpatialSegmentationIdc(Int i) { m_minSpatialSegmentationIdc = i; }
772  Int getMaxBytesPerPicDenom() { return m_maxBytesPerPicDenom; }
773  Void setMaxBytesPerPicDenom(Int i) { m_maxBytesPerPicDenom = i; }
774
775  Int getMaxBitsPerMinCuDenom() { return m_maxBitsPerMinCuDenom; }
776  Void setMaxBitsPerMinCuDenom(Int i) { m_maxBitsPerMinCuDenom = i; }
777
778  Int getLog2MaxMvLengthHorizontal() { return m_log2MaxMvLengthHorizontal; }
779  Void setLog2MaxMvLengthHorizontal(Int i) { m_log2MaxMvLengthHorizontal = i; }
780
781  Int getLog2MaxMvLengthVertical() { return m_log2MaxMvLengthVertical; }
782  Void setLog2MaxMvLengthVertical(Int i) { m_log2MaxMvLengthVertical = i; }
783
784  TComHRD* getHrdParameters                 ()             { return &m_hrdParameters; }
785#if L0043_TIMING_INFO
786  TimingInfo* getTimingInfo() { return &m_timingInfo; }
787#else
788  Bool getPocProportionalToTimingFlag() {return m_pocProportionalToTimingFlag; }
789  Void setPocProportionalToTimingFlag(Bool x) {m_pocProportionalToTimingFlag = x;}
790  Int  getNumTicksPocDiffOneMinus1() {return m_numTicksPocDiffOneMinus1;}
791  Void setNumTicksPocDiffOneMinus1(Int x) { m_numTicksPocDiffOneMinus1 = x;}
792#endif
793};
794
795/// SPS class
796class TComSPS
797{
798private:
799  Int         m_SPSId;
800  Int         m_VPSId;
801  Int         m_chromaFormatIdc;
802
803  UInt        m_uiMaxTLayers;           // maximum number of temporal layers
804
805  // Structure
806  UInt        m_picWidthInLumaSamples;
807  UInt        m_picHeightInLumaSamples;
808 
809  Window      m_conformanceWindow;
810
811  UInt        m_uiMaxCUWidth;
812  UInt        m_uiMaxCUHeight;
813  UInt        m_uiMaxCUDepth;
814  UInt        m_uiMinTrDepth;
815  UInt        m_uiMaxTrDepth;
816  TComRPSList m_RPSList;
817  Bool        m_bLongTermRefsPresent;
818  Bool        m_TMVPFlagsPresent;
819  Int         m_numReorderPics[MAX_TLAYER];
820 
821  // Tool list
822  UInt        m_uiQuadtreeTULog2MaxSize;
823  UInt        m_uiQuadtreeTULog2MinSize;
824  UInt        m_uiQuadtreeTUMaxDepthInter;
825  UInt        m_uiQuadtreeTUMaxDepthIntra;
826  Bool        m_usePCM;
827  UInt        m_pcmLog2MaxSize;
828  UInt        m_uiPCMLog2MinSize;
829  Bool        m_useAMP;
830
831  Bool        m_bUseLComb;
832 
833  // Parameter
834  Int         m_bitDepthY;
835  Int         m_bitDepthC;
836  Int         m_qpBDOffsetY;
837  Int         m_qpBDOffsetC;
838
839  Bool        m_useLossless;
840
841  UInt        m_uiPCMBitDepthLuma;
842  UInt        m_uiPCMBitDepthChroma;
843  Bool        m_bPCMFilterDisableFlag;
844
845  UInt        m_uiBitsForPOC;
846  UInt        m_numLongTermRefPicSPS;
847  UInt        m_ltRefPicPocLsbSps[33];
848  Bool        m_usedByCurrPicLtSPSFlag[33];
849  // Max physical transform size
850  UInt        m_uiMaxTrSize;
851 
852  Int m_iAMPAcc[MAX_CU_DEPTH];
853  Bool        m_bUseSAO; 
854
855  Bool        m_bTemporalIdNestingFlag; // temporal_id_nesting_flag
856
857  Bool        m_scalingListEnabledFlag;
858  Bool        m_scalingListPresentFlag;
859  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
860  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER]; 
861  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];
862
863  Bool        m_useDF;
864  Bool        m_useStrongIntraSmoothing;
865
866  Bool        m_vuiParametersPresentFlag;
867  TComVUI     m_vuiParameters;
868
869  static const Int   m_winUnitX[MAX_CHROMA_FORMAT_IDC+1];
870  static const Int   m_winUnitY[MAX_CHROMA_FORMAT_IDC+1];
871  TComPTL     m_pcPTL;
872
873#if SVC_EXTENSION
874  UInt m_layerId;
875#endif
876#if REF_IDX_MFM
877  Bool m_bMFMEnabledFlag;
878#endif
879public:
880  TComSPS();
881  virtual ~TComSPS();
882
883  Int  getVPSId       ()         { return m_VPSId;          }
884  Void setVPSId       (Int i)    { m_VPSId = i;             }
885  Int  getSPSId       ()         { return m_SPSId;          }
886  Void setSPSId       (Int i)    { m_SPSId = i;             }
887  Int  getChromaFormatIdc ()         { return m_chromaFormatIdc;       }
888  Void setChromaFormatIdc (Int i)    { m_chromaFormatIdc = i;          }
889
890  static Int getWinUnitX (Int chromaFormatIdc) { assert (chromaFormatIdc > 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitX[chromaFormatIdc];      }
891  static Int getWinUnitY (Int chromaFormatIdc) { assert (chromaFormatIdc > 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc];      }
892 
893  // structure
894  Void setPicWidthInLumaSamples       ( UInt u ) { m_picWidthInLumaSamples = u;        }
895  UInt getPicWidthInLumaSamples       ()         { return  m_picWidthInLumaSamples;    }
896  Void setPicHeightInLumaSamples      ( UInt u ) { m_picHeightInLumaSamples = u;       }
897  UInt getPicHeightInLumaSamples      ()         { return  m_picHeightInLumaSamples;   }
898
899  Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
900  Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
901
902  UInt  getNumLongTermRefPicSPS()             { return m_numLongTermRefPicSPS; }
903  Void  setNumLongTermRefPicSPS(UInt val)     { m_numLongTermRefPicSPS = val; }
904
905  UInt  getLtRefPicPocLsbSps(UInt index)             { return m_ltRefPicPocLsbSps[index]; }
906  Void  setLtRefPicPocLsbSps(UInt index, UInt val)     { m_ltRefPicPocLsbSps[index] = val; }
907
908  Bool getUsedByCurrPicLtSPSFlag(Int i)        {return m_usedByCurrPicLtSPSFlag[i];}
909  Void setUsedByCurrPicLtSPSFlag(Int i, Bool x)      { m_usedByCurrPicLtSPSFlag[i] = x;}
910  Void setMaxCUWidth  ( UInt u ) { m_uiMaxCUWidth = u;      }
911  UInt getMaxCUWidth  ()         { return  m_uiMaxCUWidth;  }
912  Void setMaxCUHeight ( UInt u ) { m_uiMaxCUHeight = u;     }
913  UInt getMaxCUHeight ()         { return  m_uiMaxCUHeight; }
914  Void setMaxCUDepth  ( UInt u ) { m_uiMaxCUDepth = u;      }
915  UInt getMaxCUDepth  ()         { return  m_uiMaxCUDepth;  }
916  Void setUsePCM      ( Bool b ) { m_usePCM = b;           }
917  Bool getUsePCM      ()         { return m_usePCM;        }
918  Void setPCMLog2MaxSize  ( UInt u ) { m_pcmLog2MaxSize = u;      }
919  UInt getPCMLog2MaxSize  ()         { return  m_pcmLog2MaxSize;  }
920  Void setPCMLog2MinSize  ( UInt u ) { m_uiPCMLog2MinSize = u;      }
921  UInt getPCMLog2MinSize  ()         { return  m_uiPCMLog2MinSize;  }
922  Void setBitsForPOC  ( UInt u ) { m_uiBitsForPOC = u;      }
923  UInt getBitsForPOC  ()         { return m_uiBitsForPOC;   }
924  Bool getUseAMP() { return m_useAMP; }
925  Void setUseAMP( Bool b ) { m_useAMP = b; }
926  Void setMinTrDepth  ( UInt u ) { m_uiMinTrDepth = u;      }
927  UInt getMinTrDepth  ()         { return  m_uiMinTrDepth;  }
928  Void setMaxTrDepth  ( UInt u ) { m_uiMaxTrDepth = u;      }
929  UInt getMaxTrDepth  ()         { return  m_uiMaxTrDepth;  }
930  Void setQuadtreeTULog2MaxSize( UInt u ) { m_uiQuadtreeTULog2MaxSize = u;    }
931  UInt getQuadtreeTULog2MaxSize()         { return m_uiQuadtreeTULog2MaxSize; }
932  Void setQuadtreeTULog2MinSize( UInt u ) { m_uiQuadtreeTULog2MinSize = u;    }
933  UInt getQuadtreeTULog2MinSize()         { return m_uiQuadtreeTULog2MinSize; }
934  Void setQuadtreeTUMaxDepthInter( UInt u ) { m_uiQuadtreeTUMaxDepthInter = u;    }
935  Void setQuadtreeTUMaxDepthIntra( UInt u ) { m_uiQuadtreeTUMaxDepthIntra = u;    }
936  UInt getQuadtreeTUMaxDepthInter()         { return m_uiQuadtreeTUMaxDepthInter; }
937  UInt getQuadtreeTUMaxDepthIntra()         { return m_uiQuadtreeTUMaxDepthIntra; }
938  Void setNumReorderPics(Int i, UInt tlayer)              { m_numReorderPics[tlayer] = i;    }
939  Int  getNumReorderPics(UInt tlayer)                     { return m_numReorderPics[tlayer]; }
940  Void         createRPSList( Int numRPS );
941  TComRPSList* getRPSList()                      { return &m_RPSList;          }
942  Bool      getLongTermRefsPresent()         { return m_bLongTermRefsPresent; }
943  Void      setLongTermRefsPresent(Bool b)   { m_bLongTermRefsPresent=b;      }
944  Bool      getTMVPFlagsPresent()         { return m_TMVPFlagsPresent; }
945  Void      setTMVPFlagsPresent(Bool b)   { m_TMVPFlagsPresent=b;      } 
946  // physical transform
947  Void setMaxTrSize   ( UInt u ) { m_uiMaxTrSize = u;       }
948  UInt getMaxTrSize   ()         { return  m_uiMaxTrSize;   }
949 
950  // Tool list
951  Void setUseLComb    (Bool b)   { m_bUseLComb = b;         }
952  Bool getUseLComb    ()         { return m_bUseLComb;      }
953
954  Bool getUseLossless ()         { return m_useLossless; }
955  Void setUseLossless ( Bool b ) { m_useLossless  = b; }
956 
957  // AMP accuracy
958  Int       getAMPAcc   ( UInt uiDepth ) { return m_iAMPAcc[uiDepth]; }
959  Void      setAMPAcc   ( UInt uiDepth, Int iAccu ) { assert( uiDepth < g_uiMaxCUDepth);  m_iAMPAcc[uiDepth] = iAccu; }
960
961  // Bit-depth
962  Int      getBitDepthY() { return m_bitDepthY; }
963  Void     setBitDepthY(Int u) { m_bitDepthY = u; }
964  Int      getBitDepthC() { return m_bitDepthC; }
965  Void     setBitDepthC(Int u) { m_bitDepthC = u; }
966  Int       getQpBDOffsetY  ()             { return m_qpBDOffsetY;   }
967  Void      setQpBDOffsetY  ( Int value  ) { m_qpBDOffsetY = value;  }
968  Int       getQpBDOffsetC  ()             { return m_qpBDOffsetC;   }
969  Void      setQpBDOffsetC  ( Int value  ) { m_qpBDOffsetC = value;  }
970  Void setUseSAO                  (Bool bVal)  {m_bUseSAO = bVal;}
971  Bool getUseSAO                  ()           {return m_bUseSAO;}
972
973  UInt      getMaxTLayers()                           { return m_uiMaxTLayers; }
974  Void      setMaxTLayers( UInt uiMaxTLayers )        { assert( uiMaxTLayers <= MAX_TLAYER ); m_uiMaxTLayers = uiMaxTLayers; }
975
976  Bool      getTemporalIdNestingFlag()                { return m_bTemporalIdNestingFlag; }
977  Void      setTemporalIdNestingFlag( Bool bValue )   { m_bTemporalIdNestingFlag = bValue; }
978  UInt      getPCMBitDepthLuma     ()         { return m_uiPCMBitDepthLuma;     }
979  Void      setPCMBitDepthLuma     ( UInt u ) { m_uiPCMBitDepthLuma = u;        }
980  UInt      getPCMBitDepthChroma   ()         { return m_uiPCMBitDepthChroma;   }
981  Void      setPCMBitDepthChroma   ( UInt u ) { m_uiPCMBitDepthChroma = u;      }
982  Void      setPCMFilterDisableFlag     ( Bool   bValue  )    { m_bPCMFilterDisableFlag = bValue; }
983  Bool      getPCMFilterDisableFlag     ()                    { return m_bPCMFilterDisableFlag;   } 
984
985  Bool getScalingListFlag       ()         { return m_scalingListEnabledFlag;     }
986  Void setScalingListFlag       ( Bool b ) { m_scalingListEnabledFlag  = b;       }
987  Bool getScalingListPresentFlag()         { return m_scalingListPresentFlag;     }
988  Void setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag  = b;       }
989  Void setScalingList      ( TComScalingList *scalingList);
990  TComScalingList* getScalingList ()       { return m_scalingList; }               //!< get ScalingList class pointer in SPS
991  UInt getMaxDecPicBuffering  (UInt tlayer)            { return m_uiMaxDecPicBuffering[tlayer]; }
992  Void setMaxDecPicBuffering  ( UInt ui, UInt tlayer ) { m_uiMaxDecPicBuffering[tlayer] = ui;   }
993  UInt getMaxLatencyIncrease  (UInt tlayer)            { return m_uiMaxLatencyIncrease[tlayer];   }
994  Void setMaxLatencyIncrease  ( UInt ui , UInt tlayer) { m_uiMaxLatencyIncrease[tlayer] = ui;      }
995
996  Void setUseStrongIntraSmoothing (Bool bVal)  {m_useStrongIntraSmoothing = bVal;}
997  Bool getUseStrongIntraSmoothing ()           {return m_useStrongIntraSmoothing;}
998
999  Bool getVuiParametersPresentFlag() { return m_vuiParametersPresentFlag; }
1000  Void setVuiParametersPresentFlag(Bool b) { m_vuiParametersPresentFlag = b; }
1001  TComVUI* getVuiParameters() { return &m_vuiParameters; }
1002  Void setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess );
1003
1004  TComPTL* getPTL()     { return &m_pcPTL; }
1005
1006#if SVC_EXTENSION
1007  Void     setLayerId(UInt layerId) { m_layerId = layerId; }
1008  UInt     getLayerId() { return m_layerId; }
1009#endif
1010#if REF_IDX_MFM
1011  Void     setMFMEnabledFlag(Bool flag) {m_bMFMEnabledFlag = flag;}
1012  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
1013#endif
1014};
1015
1016/// Reference Picture Lists class
1017class TComRefPicListModification
1018{
1019private:
1020  UInt      m_bRefPicListModificationFlagL0; 
1021  UInt      m_bRefPicListModificationFlagL1; 
1022  UInt      m_RefPicSetIdxL0[32];
1023  UInt      m_RefPicSetIdxL1[32];
1024   
1025public:
1026  TComRefPicListModification();
1027  virtual ~TComRefPicListModification();
1028 
1029  Void  create                    ();
1030  Void  destroy                   ();
1031
1032  Bool       getRefPicListModificationFlagL0() { return m_bRefPicListModificationFlagL0; }
1033  Void       setRefPicListModificationFlagL0(Bool flag) { m_bRefPicListModificationFlagL0 = flag; }
1034  Bool       getRefPicListModificationFlagL1() { return m_bRefPicListModificationFlagL1; }
1035  Void       setRefPicListModificationFlagL1(Bool flag) { m_bRefPicListModificationFlagL1 = flag; }
1036  Void       setRefPicSetIdxL0(UInt idx, UInt refPicSetIdx) { m_RefPicSetIdxL0[idx] = refPicSetIdx; }
1037  UInt       getRefPicSetIdxL0(UInt idx) { return m_RefPicSetIdxL0[idx]; }
1038  Void       setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { m_RefPicSetIdxL1[idx] = refPicSetIdx; }
1039  UInt       getRefPicSetIdxL1(UInt idx) { return m_RefPicSetIdxL1[idx]; }
1040};
1041
1042/// PPS class
1043class TComPPS
1044{
1045private:
1046  Int         m_PPSId;                    // pic_parameter_set_id
1047  Int         m_SPSId;                    // seq_parameter_set_id
1048  Int         m_picInitQPMinus26;
1049  Bool        m_useDQP;
1050  Bool        m_bConstrainedIntraPred;    // constrained_intra_pred_flag
1051  Bool        m_bSliceChromaQpFlag;       // slicelevel_chroma_qp_flag
1052
1053  // access channel
1054  TComSPS*    m_pcSPS;
1055  UInt        m_uiMaxCuDQPDepth;
1056  UInt        m_uiMinCuDQPSize;
1057
1058  Int         m_chromaCbQpOffset;
1059  Int         m_chromaCrQpOffset;
1060
1061  UInt        m_numRefIdxL0DefaultActive;
1062  UInt        m_numRefIdxL1DefaultActive;
1063
1064  Bool        m_bUseWeightPred;           // Use of Weighting Prediction (P_SLICE)
1065  Bool        m_useWeightedBiPred;        // Use of Weighting Bi-Prediction (B_SLICE)
1066  Bool        m_OutputFlagPresentFlag;   // Indicates the presence of output_flag in slice header
1067
1068  Bool        m_TransquantBypassEnableFlag; // Indicates presence of cu_transquant_bypass_flag in CUs.
1069  Bool        m_useTransformSkip;
1070  Bool        m_dependentSliceSegmentsEnabledFlag;     //!< Indicates the presence of dependent slices
1071  Bool        m_tilesEnabledFlag;              //!< Indicates the presence of tiles
1072  Bool        m_entropyCodingSyncEnabledFlag;  //!< Indicates the presence of wavefronts
1073 
1074  Bool     m_loopFilterAcrossTilesEnabledFlag;
1075  Int      m_uniformSpacingFlag;
1076  Int      m_iNumColumnsMinus1;
1077  UInt*    m_puiColumnWidth;
1078  Int      m_iNumRowsMinus1;
1079  UInt*    m_puiRowHeight;
1080
1081  Int      m_iNumSubstreams;
1082
1083  Int      m_signHideFlag;
1084
1085  Bool     m_cabacInitPresentFlag;
1086  UInt     m_encCABACTableIdx;           // Used to transmit table selection across slices
1087
1088  Bool     m_sliceHeaderExtensionPresentFlag;
1089  Bool     m_loopFilterAcrossSlicesEnabledFlag;
1090  Bool     m_deblockingFilterControlPresentFlag;
1091  Bool     m_deblockingFilterOverrideEnabledFlag;
1092  Bool     m_picDisableDeblockingFilterFlag;
1093  Int      m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
1094  Int      m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
1095  Bool     m_scalingListPresentFlag;
1096  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
1097  Bool m_listsModificationPresentFlag;
1098  UInt m_log2ParallelMergeLevelMinus2;
1099  Int m_numExtraSliceHeaderBits;
1100
1101public:
1102  TComPPS();
1103  virtual ~TComPPS();
1104 
1105  Int       getPPSId ()      { return m_PPSId; }
1106  Void      setPPSId (Int i) { m_PPSId = i; }
1107  Int       getSPSId ()      { return m_SPSId; }
1108  Void      setSPSId (Int i) { m_SPSId = i; }
1109 
1110  Int       getPicInitQPMinus26 ()         { return  m_picInitQPMinus26; }
1111  Void      setPicInitQPMinus26 ( Int i )  { m_picInitQPMinus26 = i;     }
1112  Bool      getUseDQP ()                   { return m_useDQP;        }
1113  Void      setUseDQP ( Bool b )           { m_useDQP   = b;         }
1114  Bool      getConstrainedIntraPred ()         { return  m_bConstrainedIntraPred; }
1115  Void      setConstrainedIntraPred ( Bool b ) { m_bConstrainedIntraPred = b;     }
1116  Bool      getSliceChromaQpFlag ()         { return  m_bSliceChromaQpFlag; }
1117  Void      setSliceChromaQpFlag ( Bool b ) { m_bSliceChromaQpFlag = b;     }
1118
1119  Void      setSPS              ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
1120  TComSPS*  getSPS              ()         { return m_pcSPS;          }
1121  Void      setMaxCuDQPDepth    ( UInt u ) { m_uiMaxCuDQPDepth = u;   }
1122  UInt      getMaxCuDQPDepth    ()         { return m_uiMaxCuDQPDepth;}
1123  Void      setMinCuDQPSize     ( UInt u ) { m_uiMinCuDQPSize = u;    }
1124  UInt      getMinCuDQPSize     ()         { return m_uiMinCuDQPSize; }
1125
1126  Void      setChromaCbQpOffset( Int i ) { m_chromaCbQpOffset = i;    }
1127  Int       getChromaCbQpOffset()        { return m_chromaCbQpOffset; }
1128  Void      setChromaCrQpOffset( Int i ) { m_chromaCrQpOffset = i;    }
1129  Int       getChromaCrQpOffset()        { return m_chromaCrQpOffset; }
1130
1131  Void      setNumRefIdxL0DefaultActive(UInt ui)    { m_numRefIdxL0DefaultActive=ui;     }
1132  UInt      getNumRefIdxL0DefaultActive()           { return m_numRefIdxL0DefaultActive; }
1133  Void      setNumRefIdxL1DefaultActive(UInt ui)    { m_numRefIdxL1DefaultActive=ui;     }
1134  UInt      getNumRefIdxL1DefaultActive()           { return m_numRefIdxL1DefaultActive; }
1135
1136  Bool getUseWP                     ()          { return m_bUseWeightPred;  }
1137  Bool getWPBiPred                  ()          { return m_useWeightedBiPred;     }
1138  Void setUseWP                     ( Bool b )  { m_bUseWeightPred = b;     }
1139  Void setWPBiPred                  ( Bool b )  { m_useWeightedBiPred = b;  }
1140  Void      setOutputFlagPresentFlag( Bool b )  { m_OutputFlagPresentFlag = b;    }
1141  Bool      getOutputFlagPresentFlag()          { return m_OutputFlagPresentFlag; }
1142  Void      setTransquantBypassEnableFlag( Bool b ) { m_TransquantBypassEnableFlag = b; }
1143  Bool      getTransquantBypassEnableFlag()         { return m_TransquantBypassEnableFlag; }
1144
1145  Bool      getUseTransformSkip       ()         { return m_useTransformSkip;     }
1146  Void      setUseTransformSkip       ( Bool b ) { m_useTransformSkip  = b;       }
1147
1148  Void    setLoopFilterAcrossTilesEnabledFlag  (Bool b)    { m_loopFilterAcrossTilesEnabledFlag = b; }
1149  Bool    getLoopFilterAcrossTilesEnabledFlag  ()          { return m_loopFilterAcrossTilesEnabledFlag;   }
1150  Bool    getDependentSliceSegmentsEnabledFlag() const     { return m_dependentSliceSegmentsEnabledFlag; }
1151  Void    setDependentSliceSegmentsEnabledFlag(Bool val)   { m_dependentSliceSegmentsEnabledFlag = val; }
1152  Bool    getTilesEnabledFlag() const                      { return m_tilesEnabledFlag; }
1153  Void    setTilesEnabledFlag(Bool val)                    { m_tilesEnabledFlag = val; }
1154  Bool    getEntropyCodingSyncEnabledFlag() const          { return m_entropyCodingSyncEnabledFlag; }
1155  Void    setEntropyCodingSyncEnabledFlag(Bool val)        { m_entropyCodingSyncEnabledFlag = val; }
1156  Void     setUniformSpacingFlag            ( Bool b )          { m_uniformSpacingFlag = b; }
1157  Bool     getUniformSpacingFlag            ()                  { return m_uniformSpacingFlag; }
1158  Void     setNumColumnsMinus1              ( Int i )           { m_iNumColumnsMinus1 = i; }
1159  Int      getNumColumnsMinus1              ()                  { return m_iNumColumnsMinus1; }
1160  Void     setColumnWidth ( UInt* columnWidth )
1161  {
1162    if( m_uniformSpacingFlag == 0 && m_iNumColumnsMinus1 > 0 )
1163    {
1164      m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ];
1165
1166      for(Int i=0; i<m_iNumColumnsMinus1; i++)
1167      {
1168        m_puiColumnWidth[i] = columnWidth[i];
1169      }
1170    }
1171  }
1172  UInt     getColumnWidth  (UInt columnIdx) { return *( m_puiColumnWidth + columnIdx ); }
1173  Void     setNumRowsMinus1( Int i )        { m_iNumRowsMinus1 = i; }
1174  Int      getNumRowsMinus1()               { return m_iNumRowsMinus1; }
1175  Void     setRowHeight    ( UInt* rowHeight )
1176  {
1177    if( m_uniformSpacingFlag == 0 && m_iNumRowsMinus1 > 0 )
1178    {
1179      m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ];
1180
1181      for(Int i=0; i<m_iNumRowsMinus1; i++)
1182      {
1183        m_puiRowHeight[i] = rowHeight[i];
1184      }
1185    }
1186  }
1187  UInt     getRowHeight           (UInt rowIdx)    { return *( m_puiRowHeight + rowIdx ); }
1188  Void     setNumSubstreams(Int iNumSubstreams)               { m_iNumSubstreams = iNumSubstreams; }
1189  Int      getNumSubstreams()                                 { return m_iNumSubstreams; }
1190
1191  Void      setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; }
1192  Int       getSignHideFlag()                    { return m_signHideFlag; }
1193
1194  Void     setCabacInitPresentFlag( Bool flag )     { m_cabacInitPresentFlag = flag;    }
1195  Void     setEncCABACTableIdx( Int idx )           { m_encCABACTableIdx = idx;         }
1196  Bool     getCabacInitPresentFlag()                { return m_cabacInitPresentFlag;    }
1197  UInt     getEncCABACTableIdx()                    { return m_encCABACTableIdx;        }
1198  Void     setDeblockingFilterControlPresentFlag( Bool val )  { m_deblockingFilterControlPresentFlag = val; }
1199  Bool     getDeblockingFilterControlPresentFlag()            { return m_deblockingFilterControlPresentFlag; }
1200  Void     setDeblockingFilterOverrideEnabledFlag( Bool val ) { m_deblockingFilterOverrideEnabledFlag = val; }
1201  Bool     getDeblockingFilterOverrideEnabledFlag()           { return m_deblockingFilterOverrideEnabledFlag; }
1202  Void     setPicDisableDeblockingFilterFlag(Bool val)        { m_picDisableDeblockingFilterFlag = val; }       //!< set offset for deblocking filter disabled
1203  Bool     getPicDisableDeblockingFilterFlag()                { return m_picDisableDeblockingFilterFlag; }      //!< get offset for deblocking filter disabled
1204  Void     setDeblockingFilterBetaOffsetDiv2(Int val)         { m_deblockingFilterBetaOffsetDiv2 = val; }       //!< set beta offset for deblocking filter
1205  Int      getDeblockingFilterBetaOffsetDiv2()                { return m_deblockingFilterBetaOffsetDiv2; }      //!< get beta offset for deblocking filter
1206  Void     setDeblockingFilterTcOffsetDiv2(Int val)           { m_deblockingFilterTcOffsetDiv2 = val; }               //!< set tc offset for deblocking filter
1207  Int      getDeblockingFilterTcOffsetDiv2()                  { return m_deblockingFilterTcOffsetDiv2; }              //!< get tc offset for deblocking filter
1208  Bool     getScalingListPresentFlag()         { return m_scalingListPresentFlag;     }
1209  Void     setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag  = b;       }
1210  Void     setScalingList      ( TComScalingList *scalingList);
1211  TComScalingList* getScalingList ()          { return m_scalingList; }         //!< get ScalingList class pointer in PPS
1212  Bool getListsModificationPresentFlag ()          { return m_listsModificationPresentFlag; }
1213  Void setListsModificationPresentFlag ( Bool b )  { m_listsModificationPresentFlag = b;    }
1214  UInt getLog2ParallelMergeLevelMinus2      ()                    { return m_log2ParallelMergeLevelMinus2; }
1215  Void setLog2ParallelMergeLevelMinus2      (UInt mrgLevel)       { m_log2ParallelMergeLevelMinus2 = mrgLevel; }
1216  Int getNumExtraSliceHeaderBits() { return m_numExtraSliceHeaderBits; }
1217  Void setNumExtraSliceHeaderBits(Int i) { m_numExtraSliceHeaderBits = i; }
1218  Void      setLoopFilterAcrossSlicesEnabledFlag ( Bool   bValue  )    { m_loopFilterAcrossSlicesEnabledFlag = bValue; }
1219  Bool      getLoopFilterAcrossSlicesEnabledFlag ()                    { return m_loopFilterAcrossSlicesEnabledFlag;   } 
1220  Bool getSliceHeaderExtensionPresentFlag   ()                    { return m_sliceHeaderExtensionPresentFlag; }
1221  Void setSliceHeaderExtensionPresentFlag   (Bool val)            { m_sliceHeaderExtensionPresentFlag = val; }
1222};
1223
1224typedef struct
1225{
1226  // Explicit weighted prediction parameters parsed in slice header,
1227  // or Implicit weighted prediction parameters (8 bits depth values).
1228  Bool        bPresentFlag;
1229  UInt        uiLog2WeightDenom;
1230  Int         iWeight;
1231  Int         iOffset;
1232
1233  // Weighted prediction scaling values built from above parameters (bitdepth scaled):
1234  Int         w, o, offset, shift, round;
1235} wpScalingParam;
1236
1237typedef struct
1238{
1239  Int64 iAC;
1240  Int64 iDC;
1241} wpACDCParam;
1242
1243/// slice header class
1244class TComSlice
1245{
1246 
1247private:
1248  //  Bitstream writing
1249  Bool       m_saoEnabledFlag;
1250  Bool       m_saoEnabledFlagChroma;      ///< SAO Cb&Cr enabled flag
1251  Int         m_iPPSId;               ///< picture parameter set ID
1252  Bool        m_PicOutputFlag;        ///< pic_output_flag
1253  Int         m_iPOC;
1254  Int         m_iLastIDR;
1255  static Int  m_prevPOC;
1256  TComReferencePictureSet *m_pcRPS;
1257  TComReferencePictureSet m_LocalRPS;
1258  Int         m_iBDidx; 
1259  TComRefPicListModification m_RefPicListModification;
1260  NalUnitType m_eNalUnitType;         ///< Nal unit type for the slice
1261  SliceType   m_eSliceType;
1262  Int         m_iSliceQp;
1263  Bool        m_dependentSliceSegmentFlag;
1264#if ADAPTIVE_QP_SELECTION
1265  Int         m_iSliceQpBase;
1266#endif
1267  Bool        m_deblockingFilterDisable;
1268  Bool        m_deblockingFilterOverrideFlag;      //< offsets for deblocking filter inherit from PPS
1269  Int         m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
1270  Int         m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
1271 
1272  Int         m_aiNumRefIdx   [3];    //  for multiple reference of current slice
1273
1274#if REF_LIST_BUGFIX
1275  Int         m_aiNumILRRefIdx;       //< for inter-layer reference picture ser
1276#endif
1277
1278  Int         m_iRefIdxOfLC[2][MAX_NUM_REF_LC];
1279  Int         m_eListIdFromIdxOfLC[MAX_NUM_REF_LC];
1280  Int         m_iRefIdxFromIdxOfLC[MAX_NUM_REF_LC];
1281  Int         m_iRefIdxOfL1FromRefIdxOfL0[MAX_NUM_REF_LC];
1282  Int         m_iRefIdxOfL0FromRefIdxOfL1[MAX_NUM_REF_LC];
1283  Bool        m_bRefPicListModificationFlagLC;
1284  Bool        m_bRefPicListCombinationFlag;
1285
1286  Bool        m_bCheckLDC;
1287
1288  //  Data
1289  Int         m_iSliceQpDelta;
1290  Int         m_iSliceQpDeltaCb;
1291  Int         m_iSliceQpDeltaCr;
1292  TComPic*    m_apcRefPicList [2][MAX_NUM_REF+1];
1293  Int         m_aiRefPOCList  [2][MAX_NUM_REF+1];
1294  Bool        m_bIsUsedAsLongTerm[2][MAX_NUM_REF+1];
1295  Int         m_iDepth;
1296 
1297  // referenced slice?
1298  Bool        m_bRefenced;
1299 
1300  // access channel
1301  TComVPS*    m_pcVPS;
1302  TComSPS*    m_pcSPS;
1303  TComPPS*    m_pcPPS;
1304  TComPic*    m_pcPic;
1305#if ADAPTIVE_QP_SELECTION
1306  TComTrQuant* m_pcTrQuant;
1307#endif 
1308  UInt        m_colFromL0Flag;  // collocated picture from List0 flag
1309 
1310  UInt        m_colRefIdx;
1311  UInt        m_maxNumMergeCand;
1312
1313
1314#if SAO_CHROMA_LAMBDA
1315  Double      m_dLambdaLuma;
1316  Double      m_dLambdaChroma;
1317#else
1318  Double      m_dLambda;
1319#endif
1320
1321  Bool        m_abEqualRef  [2][MAX_NUM_REF][MAX_NUM_REF];
1322 
1323  Bool        m_bNoBackPredFlag;
1324  UInt        m_uiTLayer;
1325#if SVC_EXTENSION
1326  UInt        m_layerId;
1327  TComPic*    m_pcBaseColPic;
1328  TComPicYuv* m_pcFullPelBaseRec;
1329#endif
1330  Bool        m_bTLayerSwitchingFlag;
1331
1332  UInt        m_sliceMode;
1333  UInt        m_sliceArgument;
1334  UInt        m_sliceCurStartCUAddr;
1335  UInt        m_sliceCurEndCUAddr;
1336  UInt        m_sliceIdx;
1337  UInt        m_sliceSegmentMode;
1338  UInt        m_sliceSegmentArgument;
1339  UInt        m_sliceSegmentCurStartCUAddr;
1340  UInt        m_sliceSegmentCurEndCUAddr;
1341  Bool        m_nextSlice;
1342  Bool        m_nextSliceSegment;
1343  UInt        m_sliceBits;
1344  UInt        m_sliceSegmentBits;
1345  Bool        m_bFinalized;
1346
1347  wpScalingParam  m_weightPredTable[2][MAX_NUM_REF][3]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
1348  wpACDCParam    m_weightACDCParam[3];                 // [0:Y, 1:U, 2:V]
1349
1350  std::vector<UInt> m_tileByteLocation;
1351  UInt        m_uiTileOffstForMultES;
1352
1353  UInt*       m_puiSubstreamSizes;
1354  TComScalingList*     m_scalingList;                 //!< pointer of quantization matrix
1355  Bool        m_cabacInitFlag; 
1356
1357  Bool       m_bLMvdL1Zero;
1358  Int         m_numEntryPointOffsets;
1359  Bool       m_temporalLayerNonReferenceFlag;
1360  Bool       m_LFCrossSliceBoundaryFlag;
1361
1362  Bool       m_enableTMVPFlag;
1363public:
1364  TComSlice();
1365  virtual ~TComSlice(); 
1366#if SVC_EXTENSION
1367  Void      initSlice       ( UInt layerId );
1368#else
1369  Void      initSlice       ();
1370#endif
1371
1372  Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
1373  TComVPS*  getVPS          () { return m_pcVPS; }
1374  Void      setSPS          ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
1375  TComSPS*  getSPS          () { return m_pcSPS; }
1376 
1377  Void      setPPS          ( TComPPS* pcPPS )         { assert(pcPPS!=NULL); m_pcPPS = pcPPS; m_iPPSId = pcPPS->getPPSId(); }
1378  TComPPS*  getPPS          () { return m_pcPPS; }
1379
1380#if ADAPTIVE_QP_SELECTION
1381  Void          setTrQuant          ( TComTrQuant* pcTrQuant ) { m_pcTrQuant = pcTrQuant; }
1382  TComTrQuant*  getTrQuant          () { return m_pcTrQuant; }
1383#endif
1384
1385  Void      setPPSId        ( Int PPSId )         { m_iPPSId = PPSId; }
1386  Int       getPPSId        () { return m_iPPSId; }
1387  Void      setPicOutputFlag( Bool b )         { m_PicOutputFlag = b;    }
1388  Bool      getPicOutputFlag()                 { return m_PicOutputFlag; }
1389  Void      setSaoEnabledFlag(Bool s) {m_saoEnabledFlag =s; }
1390  Bool      getSaoEnabledFlag() { return m_saoEnabledFlag; }
1391  Void      setSaoEnabledFlagChroma(Bool s) {m_saoEnabledFlagChroma =s; }       //!< set SAO Cb&Cr enabled flag
1392  Bool      getSaoEnabledFlagChroma() { return m_saoEnabledFlagChroma; }        //!< get SAO Cb&Cr enabled flag
1393  Void      setRPS          ( TComReferencePictureSet *pcRPS ) { m_pcRPS = pcRPS; }
1394  TComReferencePictureSet*  getRPS          () { return m_pcRPS; }
1395  TComReferencePictureSet*  getLocalRPS     () { return &m_LocalRPS; }
1396
1397  Void      setRPSidx          ( Int iBDidx ) { m_iBDidx = iBDidx; }
1398  Int       getRPSidx          () { return m_iBDidx; }
1399  Int       getPrevPOC      ()                          { return  m_prevPOC;       }
1400  TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; }
1401  Void      setLastIDR(Int iIDRPOC)                       { m_iLastIDR = iIDRPOC; }
1402  Int       getLastIDR()                                  { return m_iLastIDR; }
1403  SliceType getSliceType    ()                          { return  m_eSliceType;         }
1404  Int       getPOC          ()                          { return  m_iPOC;           }
1405  Int       getSliceQp      ()                          { return  m_iSliceQp;           }
1406  Bool      getDependentSliceSegmentFlag() const        { return m_dependentSliceSegmentFlag; }
1407  void      setDependentSliceSegmentFlag(Bool val)      { m_dependentSliceSegmentFlag = val; }
1408#if ADAPTIVE_QP_SELECTION
1409  Int       getSliceQpBase  ()                          { return  m_iSliceQpBase;       }
1410#endif
1411  Int       getSliceQpDelta ()                          { return  m_iSliceQpDelta;      }
1412  Int       getSliceQpDeltaCb ()                          { return  m_iSliceQpDeltaCb;      }
1413  Int       getSliceQpDeltaCr ()                          { return  m_iSliceQpDeltaCr;      }
1414  Bool      getDeblockingFilterDisable()                { return  m_deblockingFilterDisable; }
1415  Bool      getDeblockingFilterOverrideFlag()           { return  m_deblockingFilterOverrideFlag; }
1416  Int       getDeblockingFilterBetaOffsetDiv2()         { return  m_deblockingFilterBetaOffsetDiv2; }
1417  Int       getDeblockingFilterTcOffsetDiv2()           { return  m_deblockingFilterTcOffsetDiv2; }
1418#if REF_LIST_BUGFIX
1419  Int       getNumILRRefIdx     ( )                     { return  m_aiNumILRRefIdx; }
1420  Void      setNumILRRefIdx     ( Int i )                     { m_aiNumILRRefIdx = i; }
1421#endif
1422  Int       getNumRefIdx        ( RefPicList e )                { return  m_aiNumRefIdx[e];             }
1423  TComPic*  getPic              ()                              { return  m_pcPic;                      }
1424  TComPic*  getRefPic           ( RefPicList e, Int iRefIdx)    { return  m_apcRefPicList[e][iRefIdx];  }
1425  Int       getRefPOC           ( RefPicList e, Int iRefIdx)    { return  m_aiRefPOCList[e][iRefIdx];   }
1426  Int       getDepth            ()                              { return  m_iDepth;                     }
1427  UInt      getColFromL0Flag    ()                              { return  m_colFromL0Flag;              }
1428  UInt      getColRefIdx        ()                              { return  m_colRefIdx;                  }
1429  Void      checkColRefIdx      (UInt curSliceIdx, TComPic* pic);
1430  Bool      getIsUsedAsLongTerm (Int i, Int j)                  { return m_bIsUsedAsLongTerm[i][j]; }
1431  Bool      getCheckLDC     ()                                  { return m_bCheckLDC; }
1432  Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
1433  Int       getNumRpsCurrTempList();
1434  Int       getRefIdxOfLC       (RefPicList e, Int iRefIdx)     { return m_iRefIdxOfLC[e][iRefIdx];           }
1435  Int       getListIdFromIdxOfLC(Int iRefIdx)                   { return m_eListIdFromIdxOfLC[iRefIdx];       }
1436  Int       getRefIdxFromIdxOfLC(Int iRefIdx)                   { return m_iRefIdxFromIdxOfLC[iRefIdx];       }
1437  Int       getRefIdxOfL0FromRefIdxOfL1(Int iRefIdx)            { return m_iRefIdxOfL0FromRefIdxOfL1[iRefIdx];}
1438  Int       getRefIdxOfL1FromRefIdxOfL0(Int iRefIdx)            { return m_iRefIdxOfL1FromRefIdxOfL0[iRefIdx];}
1439  Bool      getRefPicListModificationFlagLC()                   {return m_bRefPicListModificationFlagLC;}
1440  Void      setRefPicListModificationFlagLC(Bool bflag)         {m_bRefPicListModificationFlagLC=bflag;}     
1441  Bool      getRefPicListCombinationFlag()                      {return m_bRefPicListCombinationFlag;}
1442  Void      setRefPicListCombinationFlag(Bool bflag)            {m_bRefPicListCombinationFlag=bflag;}   
1443  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
1444  Bool      isReferenced()                                      { return m_bRefenced; }
1445  Void      setPOC              ( Int i )                       { m_iPOC              = i; if(getTLayer()==0) m_prevPOC=i; }
1446  Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
1447  NalUnitType getNalUnitType    ()                              { return m_eNalUnitType;        }
1448  Bool      getRapPicFlag       (); 
1449  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
1450  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA);
1451  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic);
1452  Void      setSliceType        ( SliceType e )                 { m_eSliceType        = e;      }
1453  Void      setSliceQp          ( Int i )                       { m_iSliceQp          = i;      }
1454#if ADAPTIVE_QP_SELECTION
1455  Void      setSliceQpBase      ( Int i )                       { m_iSliceQpBase      = i;      }
1456#endif
1457  Void      setSliceQpDelta     ( Int i )                       { m_iSliceQpDelta     = i;      }
1458  Void      setSliceQpDeltaCb   ( Int i )                       { m_iSliceQpDeltaCb   = i;      }
1459  Void      setSliceQpDeltaCr   ( Int i )                       { m_iSliceQpDeltaCr   = i;      }
1460  Void      setDeblockingFilterDisable( Bool b )                { m_deblockingFilterDisable= b;      }
1461  Void      setDeblockingFilterOverrideFlag( Bool b )           { m_deblockingFilterOverrideFlag = b; }
1462  Void      setDeblockingFilterBetaOffsetDiv2( Int i )          { m_deblockingFilterBetaOffsetDiv2 = i; }
1463  Void      setDeblockingFilterTcOffsetDiv2( Int i )            { m_deblockingFilterTcOffsetDiv2 = i; }
1464 
1465  Void      setRefPic           ( TComPic* p, RefPicList e, Int iRefIdx ) { m_apcRefPicList[e][iRefIdx] = p; }
1466  Void      setRefPOC           ( Int i, RefPicList e, Int iRefIdx ) { m_aiRefPOCList[e][iRefIdx] = i; }
1467  Void      setNumRefIdx        ( RefPicList e, Int i )         { m_aiNumRefIdx[e]    = i;      }
1468  Void      setPic              ( TComPic* p )                  { m_pcPic             = p;      }
1469  Void      setDepth            ( Int iDepth )                  { m_iDepth            = iDepth; }
1470 
1471#if SVC_EXTENSION 
1472  Void      setBaseColPic       ( TComPic* p)                   { m_pcBaseColPic = p; }
1473  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
1474  TComPic*  getBaseColPic       ()  { return m_pcBaseColPic; }
1475
1476  Void      setLayerId (UInt layerId) { m_layerId = layerId; }
1477  UInt      getLayerId ()               { return m_layerId; }
1478
1479  Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
1480  TComPicYuv* getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
1481
1482#if AVC_SYNTAX
1483  Void      initBaseLayerRPL( TComSlice *pcSlice );
1484#endif
1485#endif
1486
1487#if REF_IDX_MFM
1488  Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
1489#endif
1490
1491  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
1492  Void      setRefPOCList       ();
1493  Void      setColFromL0Flag    ( UInt colFromL0 ) { m_colFromL0Flag = colFromL0; }
1494  Void      setColRefIdx        ( UInt refIdx) { m_colRefIdx = refIdx; }
1495  Void      setCheckLDC         ( Bool b )                      { m_bCheckLDC = b; }
1496  Void      setMvdL1ZeroFlag     ( Bool b)                       { m_bLMvdL1Zero = b; }
1497
1498#if REF_LIST_BUGFIX
1499  Void      setRefPicListModificationSvc();
1500  Void      setRefPicListSvc    ( TComList<TComPic*>& rcListPic, TComPic** ilpPic );
1501#endif
1502
1503  Bool      isIntra         ()                          { return  m_eSliceType == I_SLICE;  }
1504  Bool      isInterB        ()                          { return  m_eSliceType == B_SLICE;  }
1505  Bool      isInterP        ()                          { return  m_eSliceType == P_SLICE;  }
1506 
1507#if SAO_CHROMA_LAMBDA 
1508  Void      setLambda( Double d, Double e ) { m_dLambdaLuma = d; m_dLambdaChroma = e;}
1509  Double    getLambdaLuma() { return m_dLambdaLuma;        }
1510  Double    getLambdaChroma() { return m_dLambdaChroma;        }
1511#else
1512  Void      setLambda( Double d ) { m_dLambda = d; }
1513  Double    getLambda() { return m_dLambda;        }
1514#endif
1515 
1516  Void      initEqualRef();
1517  Bool      isEqualRef  ( RefPicList e, Int iRefIdx1, Int iRefIdx2 )
1518  {
1519    if (iRefIdx1 < 0 || iRefIdx2 < 0) return false;
1520    return m_abEqualRef[e][iRefIdx1][iRefIdx2];
1521  }
1522 
1523  Void setEqualRef( RefPicList e, Int iRefIdx1, Int iRefIdx2, Bool b)
1524  {
1525    m_abEqualRef[e][iRefIdx1][iRefIdx2] = m_abEqualRef[e][iRefIdx2][iRefIdx1] = b;
1526  }
1527 
1528  static Void      sortPicList         ( TComList<TComPic*>& rcListPic );
1529 
1530  Bool getNoBackPredFlag() { return m_bNoBackPredFlag; }
1531  Void setNoBackPredFlag( Bool b ) { m_bNoBackPredFlag = b; }
1532  Void generateCombinedList       ();
1533
1534  UInt getTLayer             ()                            { return m_uiTLayer;                      }
1535  Void setTLayer             ( UInt uiTLayer )             { m_uiTLayer = uiTLayer;                  }
1536
1537  Void setTLayerInfo( UInt uiTLayer );
1538  Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ); 
1539  Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
1540  Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
1541  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
1542  Int       checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
1543  Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet);
1544
1545  Void setMaxNumMergeCand               (UInt val )         { m_maxNumMergeCand = val;                    }
1546  UInt getMaxNumMergeCand               ()                  { return m_maxNumMergeCand;                   }
1547
1548  Void setSliceMode                     ( UInt uiMode )     { m_sliceMode = uiMode;                     }
1549  UInt getSliceMode                     ()                  { return m_sliceMode;                       }
1550  Void setSliceArgument                 ( UInt uiArgument ) { m_sliceArgument = uiArgument;             }
1551  UInt getSliceArgument                 ()                  { return m_sliceArgument;                   }
1552  Void setSliceCurStartCUAddr           ( UInt uiAddr )     { m_sliceCurStartCUAddr = uiAddr;           }
1553  UInt getSliceCurStartCUAddr           ()                  { return m_sliceCurStartCUAddr;             }
1554  Void setSliceCurEndCUAddr             ( UInt uiAddr )     { m_sliceCurEndCUAddr = uiAddr;             }
1555  UInt getSliceCurEndCUAddr             ()                  { return m_sliceCurEndCUAddr;               }
1556  Void setSliceIdx                      ( UInt i)           { m_sliceIdx = i;                           }
1557  UInt getSliceIdx                      ()                  { return  m_sliceIdx;                       }
1558  Void copySliceInfo                    (TComSlice *pcSliceSrc);
1559  Void setSliceSegmentMode              ( UInt uiMode )     { m_sliceSegmentMode = uiMode;              }
1560  UInt getSliceSegmentMode              ()                  { return m_sliceSegmentMode;                }
1561  Void setSliceSegmentArgument          ( UInt uiArgument ) { m_sliceSegmentArgument = uiArgument;      }
1562  UInt getSliceSegmentArgument          ()                  { return m_sliceSegmentArgument;            }
1563  Void setSliceSegmentCurStartCUAddr    ( UInt uiAddr )     { m_sliceSegmentCurStartCUAddr = uiAddr;    }
1564  UInt getSliceSegmentCurStartCUAddr    ()                  { return m_sliceSegmentCurStartCUAddr;      }
1565  Void setSliceSegmentCurEndCUAddr      ( UInt uiAddr )     { m_sliceSegmentCurEndCUAddr = uiAddr;      }
1566  UInt getSliceSegmentCurEndCUAddr      ()                  { return m_sliceSegmentCurEndCUAddr;        }
1567  Void setNextSlice                     ( Bool b )          { m_nextSlice = b;                           }
1568  Bool isNextSlice                      ()                  { return m_nextSlice;                        }
1569  Void setNextSliceSegment              ( Bool b )          { m_nextSliceSegment = b;                    }
1570  Bool isNextSliceSegment               ()                  { return m_nextSliceSegment;                 }
1571  Void setSliceBits                     ( UInt uiVal )      { m_sliceBits = uiVal;                      }
1572  UInt getSliceBits                     ()                  { return m_sliceBits;                       } 
1573  Void setSliceSegmentBits              ( UInt uiVal )      { m_sliceSegmentBits = uiVal;            }
1574  UInt getSliceSegmentBits              ()                  { return m_sliceSegmentBits;             }
1575  Void setFinalized                     ( Bool uiVal )      { m_bFinalized = uiVal;                       }
1576  Bool getFinalized                     ()                  { return m_bFinalized;                        }
1577  Void  setWpScaling    ( wpScalingParam  wp[2][MAX_NUM_REF][3] ) { memcpy(m_weightPredTable, wp, sizeof(wpScalingParam)*2*MAX_NUM_REF*3); }
1578  Void  getWpScaling    ( RefPicList e, Int iRefIdx, wpScalingParam *&wp);
1579
1580  Void  resetWpScaling  (wpScalingParam  wp[2][MAX_NUM_REF][3]);
1581  Void  initWpScaling    (wpScalingParam  wp[2][MAX_NUM_REF][3]);
1582  Void  initWpScaling   ();
1583  inline Bool applyWP   () { return( (m_eSliceType==P_SLICE && m_pcPPS->getUseWP()) || (m_eSliceType==B_SLICE && m_pcPPS->getWPBiPred()) ); }
1584
1585  Void  setWpAcDcParam  ( wpACDCParam wp[3] ) { memcpy(m_weightACDCParam, wp, sizeof(wpACDCParam)*3); }
1586  Void  getWpAcDcParam  ( wpACDCParam *&wp );
1587  Void  initWpAcDcParam ();
1588 
1589  Void setTileLocationCount             ( UInt cnt )               { return m_tileByteLocation.resize(cnt);    }
1590  UInt getTileLocationCount             ()                         { return (UInt) m_tileByteLocation.size();  }
1591  Void setTileLocation                  ( Int idx, UInt location ) { assert (idx<m_tileByteLocation.size());
1592                                                                     m_tileByteLocation[idx] = location;       }
1593  Void addTileLocation                  ( UInt location )          { m_tileByteLocation.push_back(location);   }
1594  UInt getTileLocation                  ( Int idx )                { return m_tileByteLocation[idx];           }
1595
1596  Void setTileOffstForMultES            (UInt uiOffset )      { m_uiTileOffstForMultES = uiOffset;        }
1597  UInt getTileOffstForMultES            ()                    { return m_uiTileOffstForMultES;            }
1598  Void allocSubstreamSizes              ( UInt uiNumSubstreams );
1599  UInt* getSubstreamSizes               ()                  { return m_puiSubstreamSizes; }
1600  Void  setScalingList              ( TComScalingList* scalingList ) { m_scalingList = scalingList; }
1601  TComScalingList*   getScalingList ()                               { return m_scalingList; }
1602  Void  setDefaultScalingList       ();
1603  Bool  checkDefaultScalingList     ();
1604  Void      setCabacInitFlag  ( Bool val ) { m_cabacInitFlag = val;      }  //!< set CABAC initial flag
1605  Bool      getCabacInitFlag  ()           { return m_cabacInitFlag;     }  //!< get CABAC initial flag
1606  Void      setNumEntryPointOffsets(Int val)  { m_numEntryPointOffsets = val;     }
1607  Int       getNumEntryPointOffsets()         { return m_numEntryPointOffsets;    }
1608  Bool      getTemporalLayerNonReferenceFlag()       { return m_temporalLayerNonReferenceFlag;}
1609  Void      setTemporalLayerNonReferenceFlag(Bool x) { m_temporalLayerNonReferenceFlag = x;}
1610  Void      setLFCrossSliceBoundaryFlag     ( Bool   val )    { m_LFCrossSliceBoundaryFlag = val; }
1611  Bool      getLFCrossSliceBoundaryFlag     ()                { return m_LFCrossSliceBoundaryFlag;} 
1612
1613  Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
1614  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
1615#if REF_IDX_FRAMEWORK
1616  Void      addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset=0 );
1617#endif
1618protected:
1619  TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
1620                         Int                 poc);
1621  TComPic*  xGetLongTermRefPic  (TComList<TComPic*>& rcListPic,
1622                         Int                 poc);
1623};// END CLASS DEFINITION TComSlice
1624
1625
1626template <class T> class ParameterSetMap
1627{
1628public:
1629  ParameterSetMap(Int maxId)
1630  :m_maxId (maxId)
1631  {}
1632
1633  ~ParameterSetMap()
1634  {
1635    for (typename std::map<Int,T *>::iterator i = m_paramsetMap.begin(); i!= m_paramsetMap.end(); i++)
1636    {
1637      delete (*i).second;
1638    }
1639  }
1640
1641  Void storePS(Int psId, T *ps)
1642  {
1643    assert ( psId < m_maxId );
1644    if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
1645    {
1646      delete m_paramsetMap[psId];
1647    }
1648    m_paramsetMap[psId] = ps; 
1649  }
1650
1651  Void mergePSList(ParameterSetMap<T> &rPsList)
1652  {
1653    for (typename std::map<Int,T *>::iterator i = rPsList.m_paramsetMap.begin(); i!= rPsList.m_paramsetMap.end(); i++)
1654    {
1655      storePS(i->first, i->second);
1656    }
1657    rPsList.m_paramsetMap.clear();
1658  }
1659
1660
1661  T* getPS(Int psId)
1662  {
1663    return ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) ? NULL : m_paramsetMap[psId];
1664  }
1665
1666  T* getFirstPS()
1667  {
1668    return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second;
1669  }
1670
1671private:
1672  std::map<Int,T *> m_paramsetMap;
1673  Int               m_maxId;
1674};
1675
1676class ParameterSetManager
1677{
1678public:
1679  ParameterSetManager();
1680  virtual ~ParameterSetManager();
1681
1682  //! store sequence parameter set and take ownership of it
1683  Void storeVPS(TComVPS *vps) { m_vpsMap.storePS( vps->getVPSId(), vps); };
1684  //! get pointer to existing video parameter set 
1685  TComVPS* getVPS(Int vpsId)  { return m_vpsMap.getPS(vpsId); };
1686  TComVPS* getFirstVPS()      { return m_vpsMap.getFirstPS(); };
1687 
1688  //! store sequence parameter set and take ownership of it
1689  Void storeSPS(TComSPS *sps) { m_spsMap.storePS( sps->getSPSId(), sps); };
1690  //! get pointer to existing sequence parameter set 
1691  TComSPS* getSPS(Int spsId)  { return m_spsMap.getPS(spsId); };
1692  TComSPS* getFirstSPS()      { return m_spsMap.getFirstPS(); };
1693
1694  //! store picture parameter set and take ownership of it
1695  Void storePPS(TComPPS *pps) { m_ppsMap.storePS( pps->getPPSId(), pps); };
1696  //! get pointer to existing picture parameter set 
1697  TComPPS* getPPS(Int ppsId)  { return m_ppsMap.getPS(ppsId); };
1698  TComPPS* getFirstPPS()      { return m_ppsMap.getFirstPS(); };
1699
1700  //! activate a SPS from a active parameter sets SEI message
1701  //! \returns true, if activation is successful
1702  Bool activateSPSWithSEI(Int SPSId);
1703
1704  //! activate a PPS and depending on isIDR parameter also SPS and VPS
1705  //! \returns true, if activation is successful
1706  Bool activatePPS(Int ppsId, Bool isIDR);
1707
1708  TComVPS* getActiveVPS(){ return m_vpsMap.getPS(m_activeVPSId); };
1709  TComSPS* getActiveSPS(){ return m_spsMap.getPS(m_activeSPSId); };
1710  TComPPS* getActivePPS(){ return m_ppsMap.getPS(m_activePPSId); };
1711
1712protected:
1713
1714#if SVC_EXTENSION
1715  static ParameterSetMap<TComVPS> m_vpsMap;
1716#else
1717  ParameterSetMap<TComVPS> m_vpsMap;
1718#endif
1719  ParameterSetMap<TComSPS> m_spsMap; 
1720  ParameterSetMap<TComPPS> m_ppsMap;
1721
1722#if SVC_EXTENSION
1723  static Int m_activeVPSId;
1724#else
1725  Int m_activeVPSId;
1726#endif
1727  Int m_activeSPSId;
1728  Int m_activePPSId;
1729};
1730
1731//! \}
1732
1733#endif // __TCOMSLICE__
Note: See TracBrowser for help on using the repository browser.