source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h @ 478

Last change on this file since 478 was 478, checked in by tech, 11 years ago

Minor clean ups.

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