source: SHVCSoftware/branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h @ 157

Last change on this file since 157 was 134, checked in by seregin, 12 years ago

add reference layer dependency

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