source: SHVCSoftware/branches/SHM-3.1-dev/source/Lib/TLibCommon/TComSlice.cpp @ 394

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

Signaling representation format in VPS (MACRO: REPN_FORMAT_IN_VPS)

Includes signaling of representation format - including picture resolution, bit depth, chroma format - in the VPS, with the option of updating them in the SPS. The configuration file has "RepFormatIdx%d" added to indicate for each layer which representation format is used. The rep_format() structures are automatically created by the encoder. If the bit depth and the chroma format are also changed across layers, some more configuration support would be needed.

From: Adarsh K. Ramasubramonian <aramasub@…>

  • Property svn:eol-style set to native
File size: 84.6 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-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.cpp
35    \brief    slice header and SPS class
36*/
37
38#include "CommonDef.h"
39#include "TComSlice.h"
40#include "TComPic.h"
41#include "TLibEncoder/TEncSbac.h"
42#include "TLibDecoder/TDecSbac.h"
43
44//! \ingroup TLibCommon
45//! \{
46
47#if SVC_EXTENSION
48  ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS);
49  Int ParameterSetManager::m_activeVPSId = -1;
50#endif
51
52TComSlice::TComSlice()
53: m_iPPSId                        ( -1 )
54, m_iPOC                          ( 0 )
55, m_iLastIDR                      ( 0 )
56, m_eNalUnitType                  ( NAL_UNIT_CODED_SLICE_IDR_W_RADL )
57, m_eSliceType                    ( I_SLICE )
58, m_iSliceQp                      ( 0 )
59, m_dependentSliceSegmentFlag            ( false )
60#if ADAPTIVE_QP_SELECTION
61, m_iSliceQpBase                  ( 0 )
62#endif
63, m_deblockingFilterDisable        ( false )
64, m_deblockingFilterOverrideFlag   ( false )
65, m_deblockingFilterBetaOffsetDiv2 ( 0 )
66, m_deblockingFilterTcOffsetDiv2   ( 0 )
67, m_bCheckLDC                     ( false )
68, m_iSliceQpDelta                 ( 0 )
69, m_iSliceQpDeltaCb               ( 0 )
70, m_iSliceQpDeltaCr               ( 0 )
71, m_iDepth                        ( 0 )
72, m_bRefenced                     ( false )
73#if SH_DISCARDABLE_FLAG
74, m_bDiscardableFlag              ( false )
75#endif
76, m_pcSPS                         ( NULL )
77, m_pcPPS                         ( NULL )
78, m_pcPic                         ( NULL )
79, m_colFromL0Flag                 ( 1 )
80, m_colRefIdx                     ( 0 )
81#if SAO_CHROMA_LAMBDA
82, m_dLambdaLuma( 0.0 )
83, m_dLambdaChroma( 0.0 )
84#else
85, m_dLambda                       ( 0.0 )
86#endif
87, m_uiTLayer                      ( 0 )
88#if SVC_EXTENSION
89, m_layerId                     ( 0 )
90#endif
91, m_bTLayerSwitchingFlag          ( false )
92, m_sliceMode                   ( 0 )
93, m_sliceArgument               ( 0 )
94, m_sliceCurStartCUAddr         ( 0 )
95, m_sliceCurEndCUAddr           ( 0 )
96, m_sliceIdx                    ( 0 )
97, m_sliceSegmentMode            ( 0 )
98, m_sliceSegmentArgument        ( 0 )
99, m_sliceSegmentCurStartCUAddr  ( 0 )
100, m_sliceSegmentCurEndCUAddr    ( 0 )
101, m_nextSlice                    ( false )
102, m_nextSliceSegment             ( false )
103, m_sliceBits                   ( 0 )
104, m_sliceSegmentBits         ( 0 )
105, m_bFinalized                    ( false )
106, m_uiTileOffstForMultES          ( 0 )
107, m_puiSubstreamSizes             ( NULL )
108, m_cabacInitFlag                 ( false )
109, m_bLMvdL1Zero                   ( false )
110, m_numEntryPointOffsets          ( 0 )
111, m_temporalLayerNonReferenceFlag ( false )
112, m_enableTMVPFlag                ( true )
113{
114  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0;
115
116#if SVC_EXTENSION
117  memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
118#if JCTVC_M0458_INTERLAYER_RPS_SIG
119  m_activeNumILRRefIdx        = 0; 
120  m_interLayerPredEnabledFlag = 0;
121  ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) );
122#else
123  m_numILRRefIdx = 0;
124#endif
125#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
126  m_altColIndicationFlag = false;
127  m_colRefLayerIdx       = 0;
128#endif
129#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
130  m_numSamplePredRefLayers       = 0;
131  m_interLayerSamplePredOnlyFlag = false;
132#endif
133#endif
134
135  initEqualRef();
136 
137  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
138  {
139    m_list1IdxToList0Idx[idx] = -1;
140  }
141  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++)
142  {
143    m_apcRefPicList [0][iNumCount] = NULL;
144    m_apcRefPicList [1][iNumCount] = NULL;
145    m_aiRefPOCList  [0][iNumCount] = 0;
146    m_aiRefPOCList  [1][iNumCount] = 0;
147  }
148  resetWpScaling();
149  initWpAcDcParam();
150  m_saoEnabledFlag = false;
151}
152
153TComSlice::~TComSlice()
154{
155  delete[] m_puiSubstreamSizes;
156  m_puiSubstreamSizes = NULL;
157}
158
159
160#if SVC_EXTENSION
161Void TComSlice::initSlice( UInt layerId )
162#else
163Void TComSlice::initSlice()
164#endif
165{
166#if SVC_EXTENSION
167  m_layerId = layerId;
168#if JCTVC_M0458_INTERLAYER_RPS_SIG
169  m_activeNumILRRefIdx        = 0;
170  m_interLayerPredEnabledFlag = 0;
171#else
172  m_numILRRefIdx              = 0;
173#endif
174#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
175  m_numSamplePredRefLayers       = 0;
176  m_interLayerSamplePredOnlyFlag = false;
177#endif
178#endif
179  m_aiNumRefIdx[0]      = 0;
180  m_aiNumRefIdx[1]      = 0;
181  m_colFromL0Flag = 1;
182 
183  m_colRefIdx = 0;
184  initEqualRef();
185  m_bCheckLDC = false;
186  m_iSliceQpDeltaCb = 0;
187  m_iSliceQpDeltaCr = 0;
188
189  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
190
191  m_bFinalized=false;
192
193  m_tileByteLocation.clear();
194  m_cabacInitFlag        = false;
195  m_numEntryPointOffsets = 0;
196  m_enableTMVPFlag = true;
197}
198
199Bool TComSlice::getRapPicFlag()
200{
201  return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
202      || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
203      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
204      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
205      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
206      || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
207}
208
209/**
210 - allocate table to contain substream sizes to be written to the slice header.
211 .
212 \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1.
213 */
214Void  TComSlice::allocSubstreamSizes(UInt uiNumSubstreams)
215{
216  delete[] m_puiSubstreamSizes;
217  m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0];
218}
219
220Void  TComSlice::sortPicList(TComList<TComPic*>& rcListPic)
221{
222  TComPic*    pcPicExtract;
223  TComPic*    pcPicInsert;
224 
225  TComList<TComPic*>::iterator    iterPicExtract;
226  TComList<TComPic*>::iterator    iterPicExtract_1;
227  TComList<TComPic*>::iterator    iterPicInsert;
228 
229  for (Int i = 1; i < (Int)(rcListPic.size()); i++)
230  {
231    iterPicExtract = rcListPic.begin();
232    for (Int j = 0; j < i; j++) iterPicExtract++;
233    pcPicExtract = *(iterPicExtract);
234    pcPicExtract->setCurrSliceIdx(0);
235   
236    iterPicInsert = rcListPic.begin();
237    while (iterPicInsert != iterPicExtract)
238    {
239      pcPicInsert = *(iterPicInsert);
240      pcPicInsert->setCurrSliceIdx(0);
241      if (pcPicInsert->getPOC() >= pcPicExtract->getPOC())
242      {
243        break;
244      }
245     
246      iterPicInsert++;
247    }
248   
249    iterPicExtract_1 = iterPicExtract;    iterPicExtract_1++;
250   
251    //  swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position
252    rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1);
253    rcListPic.erase  (iterPicExtract);
254  }
255}
256
257TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic,
258                                Int                 poc)
259{
260  TComList<TComPic*>::iterator  iterPic = rcListPic.begin(); 
261  TComPic*                      pcPic = *(iterPic);
262  while ( iterPic != rcListPic.end() )
263  {
264    if(pcPic->getPOC() == poc)
265    {
266      break;
267    }
268    iterPic++;
269    pcPic = *(iterPic);
270  }
271  return  pcPic;
272}
273
274
275TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb)
276{
277  TComList<TComPic*>::iterator  iterPic = rcListPic.begin(); 
278  TComPic*                      pcPic = *(iterPic);
279  TComPic*                      pcStPic = pcPic;
280 
281  Int pocCycle = 1 << getSPS()->getBitsForPOC();
282  if (!pocHasMsb)
283  {
284    poc = poc % pocCycle;
285  }
286 
287  while ( iterPic != rcListPic.end() )
288  {
289    pcPic = *(iterPic);
290    if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced())
291    {
292      Int picPoc = pcPic->getPOC();
293      if (!pocHasMsb)
294      {
295        picPoc = picPoc % pocCycle;
296      }
297     
298      if (poc == picPoc)
299      {
300       if (pcPic->getIsLongTerm())
301      {
302        return pcPic;
303      }
304      else
305      {
306        pcStPic = pcPic;
307      }
308      break;
309    }
310    }
311
312    iterPic++;
313  }
314 
315  return  pcStPic;
316}
317
318Void TComSlice::setRefPOCList()
319{
320  for (Int iDir = 0; iDir < 2; iDir++)
321  {
322    for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++)
323    {
324      m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC();
325    }
326  }
327
328}
329
330Void TComSlice::setList1IdxToList0Idx()
331{
332  Int idxL0, idxL1;
333  for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ )
334  {
335    m_list1IdxToList0Idx[idxL1] = -1;
336    for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ )
337    {
338      if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() )
339      {
340        m_list1IdxToList0Idx[idxL1] = idxL0;
341        break;
342      }
343    }
344  }
345}
346
347#if FIX1071
348#if SVC_EXTENSION
349Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic)
350#else
351Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
352#endif
353#else
354Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
355#endif
356{
357#if FIX1071
358  if (!checkNumPocTotalCurr)
359#endif
360  {
361    if (m_eSliceType == I_SLICE)
362    {
363      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
364      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
365     
366      return;
367    }
368 
369    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
370    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
371  }
372
373  TComPic*  pcRefPic= NULL;
374  TComPic*  RefPicSetStCurr0[16];
375  TComPic*  RefPicSetStCurr1[16];
376  TComPic*  RefPicSetLtCurr[16];
377  UInt NumPocStCurr0 = 0;
378  UInt NumPocStCurr1 = 0;
379  UInt NumPocLtCurr = 0;
380  Int i;
381
382#if SVC_EXTENSION
383  if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) )
384  {
385#endif
386  for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
387  {
388    if(m_pcRPS->getUsed(i))
389    {
390      pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
391      pcRefPic->setIsLongTerm(0);
392      pcRefPic->getPicYuvRec()->extendPicBorder();
393      RefPicSetStCurr0[NumPocStCurr0] = pcRefPic;
394#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
395      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
396#endif
397      NumPocStCurr0++;
398      pcRefPic->setCheckLTMSBPresent(false); 
399    }
400  }
401 
402  for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++)
403  {
404    if(m_pcRPS->getUsed(i))
405    {
406      pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
407      pcRefPic->setIsLongTerm(0);
408      pcRefPic->getPicYuvRec()->extendPicBorder();
409      RefPicSetStCurr1[NumPocStCurr1] = pcRefPic;
410#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
411      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
412#endif
413      NumPocStCurr1++;
414      pcRefPic->setCheckLTMSBPresent(false); 
415    }
416  }
417 
418  for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--)
419  {
420    if(m_pcRPS->getUsed(i))
421    {
422      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
423      pcRefPic->setIsLongTerm(1);
424      pcRefPic->getPicYuvRec()->extendPicBorder();
425      RefPicSetLtCurr[NumPocLtCurr] = pcRefPic;
426#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
427      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
428#endif
429      NumPocLtCurr++;
430    }
431    if(pcRefPic==NULL) 
432    {
433      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
434    }
435    pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
436  }
437#if SVC_EXTENSION
438  }
439#endif
440
441#if SVC_EXTENSION
442  for( i = 0; i < m_activeNumILRRefIdx; i++ )
443  {
444    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
445    //inter-layer reference picture
446
447#if ILR_RESTR
448    Int maxSubLayerForILPPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
449    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  ) 
450#else //#if ILR_RESTR
451    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
452#endif //#if ILR_RESTR
453    {
454#if REF_IDX_MFM
455#if M0457_COL_PICTURE_SIGNALING
456      if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && getMFMEnabledFlag())
457#else
458      if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag())
459#endif
460      { 
461        ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
462      }
463      else
464      {
465        ilpPic[refLayerIdc]->initUpsampledMvField();
466      }
467#endif
468      ilpPic[refLayerIdc]->setIsLongTerm(1);
469    }
470  }
471#endif
472  // ref_pic_list_init
473  TComPic*  rpsCurrList0[MAX_NUM_REF+1];
474  TComPic*  rpsCurrList1[MAX_NUM_REF+1];
475#if SVC_EXTENSION
476#if ILR_RESTR
477  Int numInterLayerRPSPics = 0;
478#if M0040_ADAPTIVE_RESOLUTION_CHANGE
479  if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
480#else
481  if( m_layerId > 0 )
482#endif
483  {
484    for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ )
485    {
486      Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
487      if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
488      {
489        numInterLayerRPSPics++;
490      }
491    }
492#if JCTVC_M0458_INTERLAYER_RPS_SIG
493    if (numInterLayerRPSPics < m_activeNumILRRefIdx)
494    {
495      m_activeNumILRRefIdx = numInterLayerRPSPics;
496    }
497#if MAX_ONE_RESAMPLING_DIRECT_LAYERS
498    if( m_pcVPS->getScalabilityMask(1) )
499    {
500      Int numResampler = 0;
501      const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]);
502      Int scalingOffset = ((scalEL.getWindowLeftOffset()   == 0 ) && 
503                           (scalEL.getWindowRightOffset()  == 0 ) && 
504                           (scalEL.getWindowTopOffset()    == 0 ) && 
505                           (scalEL.getWindowBottomOffset() == 0 ) 
506                          );
507
508      for( i=0; i < m_activeNumILRRefIdx; i++ )
509      {
510        UInt refLayerIdc = m_interLayerPredLayerIdc[i];
511        if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x
512        {
513          numResampler++;
514        }
515      }
516
517      //Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture.
518      assert(numResampler <= 1);
519    }
520#endif
521#else
522    if (numInterLayerRPSPics < m_numILRRefIdx)
523    {
524      m_numILRRefIdx = numInterLayerRPSPics;
525    }
526#endif
527  }
528#endif
529#if JCTVC_M0458_INTERLAYER_RPS_SIG
530  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx;
531#else
532  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_numILRRefIdx;
533#endif
534#else
535  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
536#endif
537#if FIX1071
538  if (checkNumPocTotalCurr)
539  {
540    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
541#if ILP_RAP    // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0
542    // – If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0.
543    // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
544    if (getRapPicFlag() && getLayerId()==0)
545#else
546    // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
547    // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
548    if (getRapPicFlag())
549#endif
550    {
551      assert(numPocTotalCurr == 0);
552    }
553
554    if (m_eSliceType == I_SLICE)
555  {
556      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
557      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
558     
559      return;
560    }
561   
562    assert(numPocTotalCurr > 0);
563   
564    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
565    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
566  }
567#endif
568
569#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
570    if( m_interLayerSamplePredOnlyFlag && getLayerId() ) 
571    {
572      m_aiNumRefIdx[0] = m_aiNumRefIdx[0] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[0];
573      m_aiNumRefIdx[1] = m_aiNumRefIdx[1] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[1];
574    }
575#endif
576 
577    Int cIdx = 0;
578    for ( i=0; i<NumPocStCurr0; i++, cIdx++)
579    {
580      rpsCurrList0[cIdx] = RefPicSetStCurr0[i];
581    }
582#if SVC_EXTENSION
583#if RPL_INIT_N0316_N0082
584    if( m_layerId > 0 )
585    {
586#if JCTVC_M0458_INTERLAYER_RPS_SIG
587      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)     
588#else
589      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
590#endif
591      {
592        Int refLayerIdc = m_interLayerPredLayerIdc[i];
593#if ILR_RESTR
594        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
595        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
596#endif
597          rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
598      }
599    }
600#endif
601#endif
602    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
603    {
604      rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
605    }
606    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
607    {
608      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
609    }   
610#if !RPL_INIT_N0316_N0082
611#if SVC_EXTENSION
612    if( m_layerId > 0 )
613    {
614#if JCTVC_M0458_INTERLAYER_RPS_SIG
615      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)     
616#else
617      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
618#endif
619      {
620        Int refLayerIdc = m_interLayerPredLayerIdc[i];
621#if ILR_RESTR
622         Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
623        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
624#endif
625        rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
626      }
627    }
628#endif
629#endif
630  assert(cIdx == numPocTotalCurr);
631
632  if (m_eSliceType==B_SLICE)
633  {
634    cIdx = 0;
635    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
636    {
637      rpsCurrList1[cIdx] = RefPicSetStCurr1[i];
638    }
639    for ( i=0; i<NumPocStCurr0; i++, cIdx++)
640    {
641      rpsCurrList1[cIdx] = RefPicSetStCurr0[i];
642    }
643    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
644    {
645      rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
646    }   
647
648#if SVC_EXTENSION
649    if( m_layerId > 0 )
650    {
651#if JCTVC_M0458_INTERLAYER_RPS_SIG
652      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
653#else
654      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
655#endif
656      {
657        Int refLayerIdc = m_interLayerPredLayerIdc[i];
658#if ILR_RESTR
659        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
660        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
661#endif
662        rpsCurrList1[cIdx] = ilpPic[refLayerIdc];
663      }
664    }
665#endif
666
667    assert(cIdx == numPocTotalCurr);
668  }
669
670  ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
671
672  for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++)
673  {
674    cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr;
675    assert(cIdx >= 0 && cIdx < numPocTotalCurr);
676    m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ];
677#if RPL_INIT_N0316_N0082
678    m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 && cIdx < NumPocStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPocStCurr0 + NumPocStCurr1 + m_activeNumILRRefIdx );
679#else
680    m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
681#endif
682  }
683  if ( m_eSliceType != B_SLICE )
684  {
685    m_aiNumRefIdx[1] = 0;
686    ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]));
687  }
688  else
689  {
690    for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++)
691    {
692      cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr;
693      assert(cIdx >= 0 && cIdx < numPocTotalCurr);
694      m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ];
695      m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
696    }
697  }
698}
699
700#if SVC_EXTENSION
701Void TComSlice::setRefPicListModificationSvc()
702{
703  if( !m_pcPPS->getListsModificationPresentFlag()) 
704  {
705    return;
706  }
707
708  if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA)
709  {
710    return;
711  }
712
713  TComRefPicListModification* refPicListModification = &m_RefPicListModification;
714  Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
715#if RPL_INIT_N0316_N0082
716  Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList();  // number of negative temporal ref pics
717#endif
718
719  assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1);
720  assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 1);
721
722  //set L0 inter-layer reference picture modification
723#if RPL_INIT_N0316_N0082
724  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
725#else
726  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
727#endif
728#if FINAL_RPL_CHANGE_N0082
729  hasModification = false; //modification is not necessary
730#endif
731  refPicListModification->setRefPicListModificationFlagL0(hasModification);
732  if(hasModification)
733  { 
734    for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++)
735    {
736      refPicListModification->setRefPicSetIdxL0(i, i);
737    }
738    if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList)
739    {
740        // repeat last ref pic when the number of active ref idx are more than RPS entries
741      for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++)
742      {
743        refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1);
744      }
745    }
746    else
747    {
748#if JCTVC_M0458_INTERLAYER_RPS_SIG
749      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
750#else
751      for(Int i = m_numILRRefIdx; i > 0; i-- )
752#endif
753      {
754#if RPL_INIT_N0316_N0082
755        if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0])
756        {
757          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
758        }
759        else
760        {
761          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
762          for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++)
763          {
764            refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx);
765          }
766        }
767#else
768        refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
769#endif
770      }
771    }
772  }
773
774  //set L1 inter-layer reference picture modification
775  hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] == numberOfRpsCurrTempList) ? false : true;
776  refPicListModification->setRefPicListModificationFlagL1(hasModification);
777  if(hasModification)
778  { 
779    for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++)
780    {
781      refPicListModification->setRefPicSetIdxL1(i, i);
782    }
783    if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList)
784    {
785      for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++)
786      {
787        // repeat last ref pic when the number of active ref idx are more than RPS entries
788        refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); 
789      }
790    }
791    else
792    {
793#if JCTVC_M0458_INTERLAYER_RPS_SIG
794      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
795#else
796      for(Int i = m_numILRRefIdx; i > 0; i-- )
797#endif
798      {
799        refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
800      }
801    }
802  }
803  return;
804}
805#endif
806#if RPL_INIT_N0316_N0082
807Int TComSlice::getNumNegativeRpsCurrTempList()
808{
809  if( m_eSliceType == I_SLICE ) 
810  {
811    return 0;
812  }
813
814  Int numPocBeforeCurr = 0;
815  for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ )
816  {
817    if(m_pcRPS->getUsed(i))
818    {
819      numPocBeforeCurr++;
820    }
821  }
822
823  return numPocBeforeCurr;
824}
825#endif
826Int TComSlice::getNumRpsCurrTempList()
827{
828  Int numRpsCurrTempList = 0;
829
830#if SVC_EXTENSION
831  if( m_eSliceType == I_SLICE || ( m_pcSPS->getLayerId() && 
832    (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
833    (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) )
834#else
835  if (m_eSliceType == I_SLICE) 
836#endif
837  {
838#if SVC_EXTENSION
839#if JCTVC_M0458_INTERLAYER_RPS_SIG
840    return m_activeNumILRRefIdx;
841#else
842    return getNumILRRefIdx();
843#endif
844#else
845    return 0;
846#endif
847  }
848  for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++)
849  {
850    if(m_pcRPS->getUsed(i))
851    {
852      numRpsCurrTempList++;
853    }
854  }
855#if SVC_EXTENSION
856  if( m_layerId > 0 )
857  {
858#if JCTVC_M0458_INTERLAYER_RPS_SIG
859    numRpsCurrTempList += m_activeNumILRRefIdx;
860#else
861    numRpsCurrTempList += getNumILRRefIdx();
862#endif
863  }
864#endif
865
866  return numRpsCurrTempList;
867}
868
869Void TComSlice::initEqualRef()
870{
871  for (Int iDir = 0; iDir < 2; iDir++)
872  {
873    for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++)
874    {
875      for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++)
876      {
877        m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false);
878      }
879    }
880  }
881}
882
883Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic)
884{
885  Int i;
886  TComSlice* curSlice = pic->getSlice(curSliceIdx);
887  Int currColRefPOC =  curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx());
888  TComSlice* preSlice;
889  Int preColRefPOC;
890  for(i=curSliceIdx-1; i>=0; i--)
891  {
892    preSlice = pic->getSlice(i);
893    if(preSlice->getSliceType() != I_SLICE)
894    {
895      preColRefPOC  = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx());
896      if(currColRefPOC != preColRefPOC)
897      {
898        printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n");
899        exit(EXIT_FAILURE);
900      }
901      else
902      {
903        break;
904      }
905    }
906  }
907}
908
909Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)
910{
911  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
912  {
913    if(pocCRA < MAX_UINT && getPOC() > pocCRA)
914    {
915      assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA);
916    }
917  }
918  for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++)
919  {
920    if(pocCRA < MAX_UINT && getPOC() > pocCRA)
921    {
922      if (!pReferencePictureSet->getCheckLTMSBPresent(i))
923      {
924        assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA);
925      }
926      else
927      {
928      assert(pReferencePictureSet->getPOC(i) >= pocCRA);
929    }
930  }
931  }
932  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found
933  {
934    pocCRA = getPOC();
935    prevRAPisBLA = false;
936  }
937  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
938  {
939    pocCRA = getPOC();
940    prevRAPisBLA = false;
941  }
942  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
943         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
944         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found
945  {
946    pocCRA = getPOC();
947    prevRAPisBLA = true;
948  }
949}
950
951/** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered.
952 * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture
953 * \param bRefreshPending flag indicating if a deferred decoding refresh is pending
954 * \param rcListPic reference to the reference picture list
955 * This function marks the reference pictures as "unused for reference" in the following conditions.
956 * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list 
957 * are marked as "unused for reference"
958 *    If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture.
959 * Otherwise
960 *    If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current
961 *    temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA),
962 *    mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set
963 *    the bRefreshPending flag to false.
964 *    If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal
965 *    reference of the current picture.
966 * Note that the current picture is already placed in the reference list and its marking is not changed.
967 * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference".
968 */
969Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic)
970{
971  TComPic*                 rpcPic;
972  Int pocCurr = getPOC(); 
973
974  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
975    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
976    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
977    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
978    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )  // IDR or BLA picture
979  {
980    // mark all pictures as not used for reference
981    TComList<TComPic*>::iterator        iterPic       = rcListPic.begin();
982    while (iterPic != rcListPic.end())
983    {
984      rpcPic = *(iterPic);
985      rpcPic->setCurrSliceIdx(0);
986      if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false);
987      iterPic++;
988    }
989    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
990      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
991      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
992    {
993      pocCRA = pocCurr;
994    }
995  }
996  else // CRA or No DR
997  {
998    if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending
999    {
1000      TComList<TComPic*>::iterator        iterPic       = rcListPic.begin();
1001      while (iterPic != rcListPic.end())
1002      {
1003        rpcPic = *(iterPic);
1004        if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA)
1005        {
1006          rpcPic->getSlice(0)->setReferenced(false);
1007        }
1008        iterPic++;
1009      }
1010      bRefreshPending = false; 
1011    }
1012    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
1013    {
1014      bRefreshPending = true; 
1015      pocCRA = pocCurr;
1016    }
1017  }
1018}
1019
1020Void TComSlice::copySliceInfo(TComSlice *pSrc)
1021{
1022  assert( pSrc != NULL );
1023
1024  Int i, j, k;
1025
1026  m_iPOC                 = pSrc->m_iPOC;
1027  m_eNalUnitType         = pSrc->m_eNalUnitType;
1028  m_eSliceType           = pSrc->m_eSliceType;
1029  m_iSliceQp             = pSrc->m_iSliceQp;
1030#if ADAPTIVE_QP_SELECTION
1031  m_iSliceQpBase         = pSrc->m_iSliceQpBase;
1032#endif
1033  m_deblockingFilterDisable   = pSrc->m_deblockingFilterDisable;
1034  m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag;
1035  m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2;
1036  m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2;
1037 
1038  for (i = 0; i < 2; i++)
1039  {
1040    m_aiNumRefIdx[i]     = pSrc->m_aiNumRefIdx[i];
1041  }
1042
1043  for (i = 0; i < MAX_NUM_REF; i++)
1044  {
1045    m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i];
1046  } 
1047  m_bCheckLDC             = pSrc->m_bCheckLDC;
1048  m_iSliceQpDelta        = pSrc->m_iSliceQpDelta;
1049  m_iSliceQpDeltaCb      = pSrc->m_iSliceQpDeltaCb;
1050  m_iSliceQpDeltaCr      = pSrc->m_iSliceQpDeltaCr;
1051  for (i = 0; i < 2; i++)
1052  {
1053    for (j = 0; j < MAX_NUM_REF; j++)
1054    {
1055      m_apcRefPicList[i][j]  = pSrc->m_apcRefPicList[i][j];
1056      m_aiRefPOCList[i][j]   = pSrc->m_aiRefPOCList[i][j];
1057    }
1058  }
1059  for (i = 0; i < 2; i++)
1060  {
1061    for (j = 0; j < MAX_NUM_REF + 1; j++)
1062    {
1063      m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j];
1064    }
1065  }
1066  m_iDepth               = pSrc->m_iDepth;
1067
1068  // referenced slice
1069  m_bRefenced            = pSrc->m_bRefenced;
1070
1071  // access channel
1072#if SVC_EXTENSION
1073  m_pcVPS                = pSrc->m_pcVPS;
1074#if JCTVC_M0458_INTERLAYER_RPS_SIG
1075  m_activeNumILRRefIdx         = pSrc->m_activeNumILRRefIdx;
1076  m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
1077  memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) );
1078#endif
1079#endif
1080  m_pcSPS                = pSrc->m_pcSPS;
1081  m_pcPPS                = pSrc->m_pcPPS;
1082  m_pcRPS                = pSrc->m_pcRPS;
1083  m_iLastIDR             = pSrc->m_iLastIDR;
1084
1085  m_pcPic                = pSrc->m_pcPic;
1086
1087  m_colFromL0Flag        = pSrc->m_colFromL0Flag;
1088  m_colRefIdx            = pSrc->m_colRefIdx;
1089#if SAO_CHROMA_LAMBDA
1090  m_dLambdaLuma          = pSrc->m_dLambdaLuma;
1091  m_dLambdaChroma        = pSrc->m_dLambdaChroma;
1092#else
1093  m_dLambda              = pSrc->m_dLambda;
1094#endif
1095  for (i = 0; i < 2; i++)
1096  {
1097    for (j = 0; j < MAX_NUM_REF; j++)
1098    {
1099      for (k =0; k < MAX_NUM_REF; k++)
1100      {
1101        m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k];
1102      }
1103    }
1104  }
1105
1106  m_uiTLayer                      = pSrc->m_uiTLayer;
1107  m_bTLayerSwitchingFlag          = pSrc->m_bTLayerSwitchingFlag;
1108
1109  m_sliceMode                   = pSrc->m_sliceMode;
1110  m_sliceArgument               = pSrc->m_sliceArgument;
1111  m_sliceCurStartCUAddr         = pSrc->m_sliceCurStartCUAddr;
1112  m_sliceCurEndCUAddr           = pSrc->m_sliceCurEndCUAddr;
1113  m_sliceIdx                    = pSrc->m_sliceIdx;
1114  m_sliceSegmentMode            = pSrc->m_sliceSegmentMode;
1115  m_sliceSegmentArgument        = pSrc->m_sliceSegmentArgument; 
1116  m_sliceSegmentCurStartCUAddr  = pSrc->m_sliceSegmentCurStartCUAddr;
1117  m_sliceSegmentCurEndCUAddr    = pSrc->m_sliceSegmentCurEndCUAddr;
1118  m_nextSlice                    = pSrc->m_nextSlice;
1119  m_nextSliceSegment             = pSrc->m_nextSliceSegment;
1120  for ( Int e=0 ; e<2 ; e++ )
1121  {
1122    for ( Int n=0 ; n<MAX_NUM_REF ; n++ )
1123    {
1124      memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 );
1125    }
1126  }
1127  m_saoEnabledFlag = pSrc->m_saoEnabledFlag; 
1128  m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma;
1129  m_cabacInitFlag                = pSrc->m_cabacInitFlag;
1130  m_numEntryPointOffsets  = pSrc->m_numEntryPointOffsets;
1131
1132  m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero;
1133  m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag;
1134  m_enableTMVPFlag                = pSrc->m_enableTMVPFlag;
1135  m_maxNumMergeCand               = pSrc->m_maxNumMergeCand;
1136}
1137
1138Int TComSlice::m_prevPOC = 0;
1139
1140/** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag.
1141 * \param uiTLayer Temporal layer ID of the current slice
1142 * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on
1143 * the SPS's temporal_id_nesting_flag and the parsed PPS.  Then, current slice's temporal layer ID and
1144 * temporal_layer_switching_point_flag is set accordingly.
1145 */
1146Void TComSlice::setTLayerInfo( UInt uiTLayer )
1147{
1148  m_uiTLayer = uiTLayer;
1149}
1150
1151/** Function for checking if this is a switching-point
1152*/
1153Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic )
1154{
1155  TComPic* rpcPic;
1156  // loop through all pictures in the reference picture buffer
1157  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1158  while ( iterPic != rcListPic.end())
1159  {
1160    rpcPic = *(iterPic++);
1161    if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC())
1162    {
1163      if(rpcPic->getTLayer() >= getTLayer())
1164      {
1165        return false;
1166      }
1167    }
1168  }
1169  return true;
1170}
1171
1172/** Function for checking if this is a STSA candidate
1173 */
1174Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic )
1175{
1176    TComPic* rpcPic;
1177   
1178    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1179    while ( iterPic != rcListPic.end())
1180    {
1181        rpcPic = *(iterPic++);
1182        if(rpcPic->getSlice(0)->isReferenced() &&  (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC())
1183        {
1184            if(rpcPic->getTLayer() >= getTLayer())
1185            {
1186                return false;
1187            }
1188        }
1189    }
1190    return true;
1191}
1192
1193/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
1194*/
1195Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet)
1196{
1197  TComPic* rpcPic;
1198  Int i, isReference;
1199
1200  // loop through all pictures in the reference picture buffer
1201  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1202  while ( iterPic != rcListPic.end())
1203  {
1204    rpcPic = *(iterPic++);
1205
1206    if(!rpcPic->getSlice( 0 )->isReferenced())
1207    {
1208      continue;
1209    }
1210
1211    isReference = 0;
1212    // loop through all pictures in the Reference Picture Set
1213    // to see if the picture should be kept as reference picture
1214    for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++)
1215    {
1216      if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i))
1217      {
1218        isReference = 1;
1219        rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1220        rpcPic->setIsLongTerm(0);
1221      }
1222    }
1223    for(;i<pReferencePictureSet->getNumberOfPictures();i++)
1224    {
1225      if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
1226      {
1227        if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i))
1228        {
1229          isReference = 1;
1230          rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1231        }
1232      }
1233      else 
1234      {
1235        if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()))
1236        {
1237          isReference = 1;
1238          rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1239        }
1240      }
1241
1242    }
1243    // mark the picture as "unused for reference" if it is not in
1244    // the Reference Picture Set
1245    if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0)   
1246    {           
1247      rpcPic->getSlice( 0 )->setReferenced( false );   
1248      rpcPic->setUsedByCurr(0);
1249      rpcPic->setIsLongTerm(0);
1250    }
1251    //check that pictures of higher temporal layers are not used
1252    assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer());
1253    //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
1254    if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
1255    {
1256      assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer());
1257    }
1258    //check that pictures marked as temporal layer non-reference pictures are not used for reference
1259    if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer())
1260    {
1261      assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false);
1262    }
1263  }
1264}
1265
1266/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
1267*/
1268Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess)
1269{
1270  TComPic* rpcPic;
1271  Int i, isAvailable;
1272  Int atLeastOneLost = 0;
1273  Int atLeastOneRemoved = 0;
1274  Int iPocLost = 0;
1275
1276  // loop through all long-term pictures in the Reference Picture Set
1277  // to see if the picture should be kept as reference picture
1278  for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++)
1279  {
1280    isAvailable = 0;
1281    // loop through all pictures in the reference picture buffer
1282    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1283    while ( iterPic != rcListPic.end())
1284    {
1285      rpcPic = *(iterPic++);
1286      if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
1287      {
1288        if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced())
1289        {
1290          isAvailable = 1;
1291        }
1292      }
1293      else 
1294      {
1295        if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced())
1296        {
1297          isAvailable = 1;
1298        }
1299      }
1300    }
1301    // if there was no such long-term check the short terms
1302    if(!isAvailable)
1303    {
1304      iterPic = rcListPic.begin();
1305      while ( iterPic != rcListPic.end())
1306      {
1307        rpcPic = *(iterPic++);
1308
1309        Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
1310        Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC();
1311        Int refPoc = pReferencePictureSet->getPOC(i);
1312        if (!pReferencePictureSet->getCheckLTMSBPresent(i))
1313        {
1314          curPoc = curPoc % pocCycle;
1315          refPoc = refPoc % pocCycle;
1316        }
1317       
1318        if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc)
1319        {
1320          isAvailable = 1;
1321          rpcPic->setIsLongTerm(1);
1322          break;
1323        }
1324      }
1325    }
1326    // report that a picture is lost if it is in the Reference Picture Set
1327    // but not available as reference picture
1328    if(isAvailable == 0)   
1329    {           
1330      if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
1331      {
1332        if(!pReferencePictureSet->getUsed(i) )
1333        {
1334          if(printErrors)
1335          {
1336            printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1337          }
1338          atLeastOneRemoved = 1;
1339        }
1340        else
1341        {
1342          if(printErrors)
1343          {
1344            printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1345          }
1346          atLeastOneLost = 1;
1347          iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
1348        }
1349      }
1350    }
1351  } 
1352  // loop through all short-term pictures in the Reference Picture Set
1353  // to see if the picture should be kept as reference picture
1354  for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++)
1355  {
1356    isAvailable = 0;
1357    // loop through all pictures in the reference picture buffer
1358    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1359    while ( iterPic != rcListPic.end())
1360    {
1361      rpcPic = *(iterPic++);
1362
1363      if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
1364      {
1365        isAvailable = 1;
1366      }
1367    }
1368    // report that a picture is lost if it is in the Reference Picture Set
1369    // but not available as reference picture
1370    if(isAvailable == 0)   
1371    {           
1372      if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
1373      {
1374        if(!pReferencePictureSet->getUsed(i) )
1375        {
1376          if(printErrors)
1377          {
1378            printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1379          }
1380          atLeastOneRemoved = 1;
1381        }
1382        else
1383        {
1384          if(printErrors)
1385          {
1386            printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1387          }
1388          atLeastOneLost = 1;
1389          iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
1390        }
1391      }
1392    }
1393  }   
1394  if(atLeastOneLost)
1395  {
1396    return iPocLost+1;
1397  }
1398  if(atLeastOneRemoved)
1399  {
1400    return -2;
1401  }
1402  else
1403  {
1404    return 0;
1405  }
1406}
1407
1408/** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set
1409*/
1410#if FIX1071
1411Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP)
1412#else
1413Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet)
1414#endif
1415{
1416  TComPic* rpcPic;
1417  Int i, j;
1418  Int k = 0;
1419  Int nrOfNegativePictures = 0;
1420  Int nrOfPositivePictures = 0;
1421  TComReferencePictureSet* pcRPS = this->getLocalRPS();
1422
1423  // loop through all pictures in the Reference Picture Set
1424  for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++)
1425  {
1426    j = 0;
1427    // loop through all pictures in the reference picture buffer
1428    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1429    while ( iterPic != rcListPic.end())
1430    {
1431      j++;
1432      rpcPic = *(iterPic++);
1433
1434      if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
1435      {
1436        // This picture exists as a reference picture
1437        // and should be added to the explicit Reference Picture Set
1438        pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
1439#if FIX1071
1440        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
1441#else
1442        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i));
1443#endif
1444        if(pcRPS->getDeltaPOC(k) < 0)
1445        {
1446          nrOfNegativePictures++;
1447        }
1448        else
1449        {
1450          nrOfPositivePictures++;
1451        }
1452        k++;
1453      }
1454    }
1455  }
1456  pcRPS->setNumberOfNegativePictures(nrOfNegativePictures);
1457  pcRPS->setNumberOfPositivePictures(nrOfPositivePictures);
1458  pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures);
1459  // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the
1460  // inter RPS prediction with.  Here we just use the reference used by pReferencePictureSet.
1461  // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled.
1462  if (!pReferencePictureSet->getInterRPSPrediction())
1463  {
1464    pcRPS->setInterRPSPrediction(false);
1465    pcRPS->setNumRefIdc(0);
1466  }
1467  else
1468  {
1469    Int rIdx =  this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1;
1470    Int deltaRPS = pReferencePictureSet->getDeltaRPS();
1471    TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx);
1472    Int iRefPics = pcRefRPS->getNumberOfPictures();
1473    Int iNewIdc=0;
1474    for(i=0; i<= iRefPics; i++) 
1475    {
1476      Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0);  // check if the reference abs POC is >= 0
1477      Int iRefIdc = 0;
1478      for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the  pictures in the new RPS
1479      {
1480        if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j))
1481        {
1482          if (pcRPS->getUsed(j))
1483          {
1484            iRefIdc = 1;
1485          }
1486          else
1487          {
1488            iRefIdc = 2;
1489          }
1490        }
1491      }
1492      pcRPS->setRefIdc(i, iRefIdc);
1493      iNewIdc++;
1494    }
1495    pcRPS->setInterRPSPrediction(true);
1496    pcRPS->setNumRefIdc(iNewIdc);
1497    pcRPS->setDeltaRPS(deltaRPS); 
1498    pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx());
1499  }
1500
1501  this->setRPS(pcRPS);
1502  this->setRPSidx(-1);
1503}
1504
1505/** get AC and DC values for weighted pred
1506 * \param *wp
1507 * \returns Void
1508 */
1509Void  TComSlice::getWpAcDcParam(wpACDCParam *&wp)
1510{
1511  wp = m_weightACDCParam;
1512}
1513
1514/** init AC and DC values for weighted pred
1515 * \returns Void
1516 */
1517Void  TComSlice::initWpAcDcParam()
1518{
1519  for(Int iComp = 0; iComp < 3; iComp++ )
1520  {
1521    m_weightACDCParam[iComp].iAC = 0;
1522    m_weightACDCParam[iComp].iDC = 0;
1523  }
1524}
1525
1526/** get WP tables for weighted pred
1527 * \param RefPicList
1528 * \param iRefIdx
1529 * \param *&wpScalingParam
1530 * \returns Void
1531 */
1532Void  TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp )
1533{
1534  wp = m_weightPredTable[e][iRefIdx];
1535}
1536
1537/** reset Default WP tables settings : no weight.
1538 * \param wpScalingParam
1539 * \returns Void
1540 */
1541Void  TComSlice::resetWpScaling()
1542{
1543  for ( Int e=0 ; e<2 ; e++ )
1544  {
1545    for ( Int i=0 ; i<MAX_NUM_REF ; i++ )
1546    {
1547      for ( Int yuv=0 ; yuv<3 ; yuv++ )
1548      {
1549        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
1550        pwp->bPresentFlag      = false;
1551        pwp->uiLog2WeightDenom = 0;
1552        pwp->uiLog2WeightDenom = 0;
1553        pwp->iWeight           = 1;
1554        pwp->iOffset           = 0;
1555      }
1556    }
1557  }
1558}
1559
1560/** init WP table
1561 * \returns Void
1562 */
1563Void  TComSlice::initWpScaling()
1564{
1565  for ( Int e=0 ; e<2 ; e++ )
1566  {
1567    for ( Int i=0 ; i<MAX_NUM_REF ; i++ )
1568    {
1569      for ( Int yuv=0 ; yuv<3 ; yuv++ )
1570      {
1571        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
1572        if ( !pwp->bPresentFlag ) 
1573        {
1574          // Inferring values not present :
1575          pwp->iWeight = (1 << pwp->uiLog2WeightDenom);
1576          pwp->iOffset = 0;
1577        }
1578
1579        pwp->w      = pwp->iWeight;
1580        Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY;
1581        pwp->o      = pwp->iOffset << (bitDepth-8);
1582        pwp->shift  = pwp->uiLog2WeightDenom;
1583        pwp->round  = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0);
1584      }
1585    }
1586  }
1587}
1588
1589#if REPN_FORMAT_IN_VPS
1590UInt TComSlice::getPicWidthInLumaSamples()
1591{
1592  TComSPS *sps = getSPS();
1593  TComVPS *vps = getVPS();
1594  UInt retVal, layerId = getLayerId();
1595  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
1596  {
1597    retVal = sps->getPicWidthInLumaSamples();
1598  }
1599  else
1600  {
1601    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples();
1602  }
1603  return retVal;
1604}
1605UInt TComSlice::getPicHeightInLumaSamples()
1606{
1607  TComSPS *sps = getSPS();
1608  TComVPS *vps = getVPS();
1609  UInt retVal, layerId = getLayerId();
1610  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
1611  {
1612    retVal = sps->getPicHeightInLumaSamples();
1613  }
1614  else
1615  {
1616    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples();
1617  }
1618  return retVal;
1619}
1620UInt TComSlice::getChromaFormatIdc()
1621{
1622  TComSPS *sps = getSPS();
1623  TComVPS *vps = getVPS();
1624  UInt retVal, layerId = getLayerId();
1625  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
1626  {
1627    retVal = sps->getChromaFormatIdc();
1628  }
1629  else
1630  {
1631    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc();
1632  }
1633  return retVal;
1634}
1635UInt TComSlice::getBitDepthY()
1636{
1637  TComSPS *sps = getSPS();
1638  TComVPS *vps = getVPS();
1639  UInt retVal, layerId = getLayerId();
1640  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
1641  {
1642    retVal = sps->getBitDepthY();
1643  }
1644  else
1645  {
1646    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma();
1647  }
1648  return retVal;
1649}
1650UInt TComSlice::getBitDepthC()
1651{
1652  TComSPS *sps = getSPS();
1653  TComVPS *vps = getVPS();
1654  UInt retVal, layerId = getLayerId();
1655  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
1656  {
1657    retVal = sps->getBitDepthC();
1658  }
1659  else
1660  {
1661    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma();
1662  }
1663  return retVal;
1664}
1665Int TComSlice::getQpBDOffsetY()
1666{
1667  return (getBitDepthY() - 8) * 6;
1668}
1669Int TComSlice::getQpBDOffsetC()
1670{
1671  return (getBitDepthC() - 8) * 6;
1672}
1673
1674RepFormat::RepFormat()
1675: m_chromaFormatVpsIdc          (0)
1676, m_separateColourPlaneVpsFlag  (false)
1677, m_picWidthVpsInLumaSamples    (0)
1678, m_picHeightVpsInLumaSamples   (0)
1679, m_bitDepthVpsLuma             (0)
1680, m_bitDepthVpsChroma           (0)
1681{}
1682#endif
1683
1684// ------------------------------------------------------------------------------------------------
1685// Video parameter set (VPS)
1686// ------------------------------------------------------------------------------------------------
1687TComVPS::TComVPS()
1688: m_VPSId                     (  0)
1689, m_uiMaxTLayers              (  1)
1690, m_uiMaxLayers               (  1)
1691, m_bTemporalIdNestingFlag    (false)
1692, m_numHrdParameters          (  0)
1693#if !VPS_RENAME
1694, m_maxNuhReservedZeroLayerId (  0)
1695#endif
1696, m_hrdParameters             (NULL)
1697, m_hrdOpSetIdx               (NULL)
1698, m_cprmsPresentFlag          (NULL)
1699#if VPS_RENAME
1700, m_maxLayerId                (0)
1701, m_numLayerSets              (0)
1702#endif
1703#if VPS_EXTN_OP_LAYER_SETS
1704, m_numOutputLayerSets        (0) 
1705#endif
1706#if VPS_PROFILE_OUTPUT_LAYERS
1707, m_numProfileTierLevel       (0)
1708, m_moreOutputLayerSetsThanDefaultFlag (false)
1709, m_numAddOutputLayerSets     (0)
1710, m_defaultOneTargetOutputLayerFlag    (false)
1711#endif
1712#if VPS_VUI_BITRATE_PICRATE
1713, m_bitRatePresentVpsFlag     (false)
1714, m_picRatePresentVpsFlag     (false)
1715#endif
1716#if REPN_FORMAT_IN_VPS
1717, m_repFormatIdxPresentFlag   (true)
1718, m_vpsNumRepFormats          (1)
1719#endif
1720{
1721  for( Int i = 0; i < MAX_TLAYER; i++)
1722  {
1723    m_numReorderPics[i] = 0;
1724    m_uiMaxDecPicBuffering[i] = 1; 
1725    m_uiMaxLatencyIncrease[i] = 0;
1726  }
1727#if VPS_EXTN_MASK_AND_DIM_INFO
1728  m_avcBaseLayerFlag = false;
1729  m_splittingFlag = false;
1730  ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask));
1731  ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen));
1732  m_nuhLayerIdPresentFlag = false;
1733  ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh));
1734  ::memset(m_dimensionId, 0, sizeof(m_dimensionId));
1735
1736  m_numScalabilityTypes = 0;
1737  ::memset(m_layerIdInVps, 0, sizeof(m_layerIdInVps));
1738#endif
1739#if VPS_EXTN_PROFILE_INFO
1740  ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag));
1741  ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef));
1742#endif
1743#if VPS_EXTN_OP_LAYER_SETS
1744  ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag));
1745  // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag
1746  ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx));
1747  ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag));
1748#endif
1749#if VPS_EXTN_DIRECT_REF_LAYERS
1750  ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag));
1751  ::memset(m_numDirectRefLayers,   0, sizeof(m_numDirectRefLayers  ));
1752  ::memset(m_refLayerId,           0, sizeof(m_refLayerId          ));
1753#if M0457_PREDICTION_INDICATIONS
1754  m_directDepTypeLen = 2;
1755  ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType));
1756#endif
1757#endif
1758#if DERIVE_LAYER_ID_LIST_VARIABLES
1759  ::memset(m_layerSetLayerIdList,  0, sizeof(m_layerSetLayerIdList));
1760  ::memset(m_numLayerInIdList,     0, sizeof(m_numLayerInIdList   )); 
1761#endif
1762#if VPS_PROFILE_OUTPUT_LAYERS
1763  ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
1764#endif
1765#if JCTVC_M0458_INTERLAYER_RPS_SIG
1766  m_maxOneActiveRefLayerFlag = true;
1767#endif
1768#if JCTVC_M0203_INTERLAYER_PRED_IDC
1769#if N0120_MAX_TID_REF_PRESENT_FLAG
1770  m_maxTidIlRefPicsPlus1PresentFlag = true;
1771#endif
1772  for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
1773  {
1774    m_maxSublayerForIlpPlus1[i] = m_uiMaxTLayers + 1;
1775  }
1776#endif
1777#if TILE_BOUNDARY_ALIGNED_FLAG
1778   ::memset(m_tileBoundariesAlignedFlag,  0, sizeof(m_tileBoundariesAlignedFlag));
1779#endif
1780#if N0160_VUI_EXT_ILP_REF
1781   m_numIlpRestrictedRefLayers = false;
1782   ::memset(m_minSpatialSegmentOffsetPlus1,  0, sizeof(m_minSpatialSegmentOffsetPlus1));
1783   ::memset(m_ctuBasedOffsetEnabledFlag,     0, sizeof(m_ctuBasedOffsetEnabledFlag));
1784   ::memset(m_minHorizontalCtuOffsetPlus1,   0, sizeof(m_minHorizontalCtuOffsetPlus1));
1785#endif
1786#if VPS_VUI_BITRATE_PICRATE 
1787  ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag));
1788  ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag));
1789  ::memset(m_avgBitRate        , 0, sizeof(m_avgBitRate)        );
1790  ::memset(m_maxBitRate        , 0, sizeof(m_maxBitRate)        );
1791  ::memset(m_constPicRateIdc   , 0, sizeof(m_constPicRateIdc)   );
1792  ::memset(m_avgPicRate        , 0, sizeof(m_avgPicRate)        );
1793#endif
1794#if REPN_FORMAT_IN_VPS
1795  ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) );
1796#endif
1797}
1798
1799TComVPS::~TComVPS()
1800{
1801  if( m_hrdParameters    != NULL )     delete[] m_hrdParameters;
1802  if( m_hrdOpSetIdx      != NULL )     delete[] m_hrdOpSetIdx;
1803  if( m_cprmsPresentFlag != NULL )     delete[] m_cprmsPresentFlag;
1804}
1805#if DERIVE_LAYER_ID_LIST_VARIABLES
1806Void TComVPS::deriveLayerIdListVariables()
1807{
1808  // For layer 0
1809  setNumLayersInIdList(0, 1);
1810  setLayerSetLayerIdList(0, 0, 0);
1811
1812  // For other layers
1813  Int i, m, n;
1814  for( i = 1; i <= getNumLayerSets() - 1; i++ )
1815  {
1816    n = 0;
1817    for( m = 0; m <= this->getMaxLayerId(); m++)
1818    {
1819      if(this->getLayerIdIncludedFlag(i, m))
1820      {
1821        setLayerSetLayerIdList(i, n, m);
1822        n++;
1823      }
1824    }
1825    setNumLayersInIdList(i, n);
1826  }
1827}
1828#endif
1829// ------------------------------------------------------------------------------------------------
1830// Sequence parameter set (SPS)
1831// ------------------------------------------------------------------------------------------------
1832
1833TComSPS::TComSPS()
1834: m_SPSId                     (  0)
1835, m_VPSId                     (  0)
1836, m_chromaFormatIdc           (CHROMA_420)
1837, m_uiMaxTLayers              (  1)
1838// Structure
1839, m_picWidthInLumaSamples     (352)
1840, m_picHeightInLumaSamples    (288)
1841, m_log2MinCodingBlockSize    (  0)
1842, m_log2DiffMaxMinCodingBlockSize (0)
1843, m_uiMaxCUWidth              ( 32)
1844, m_uiMaxCUHeight             ( 32)
1845, m_uiMaxCUDepth              (  3)
1846, m_bLongTermRefsPresent      (false)
1847, m_uiQuadtreeTULog2MaxSize   (  0)
1848, m_uiQuadtreeTULog2MinSize   (  0)
1849, m_uiQuadtreeTUMaxDepthInter (  0)
1850, m_uiQuadtreeTUMaxDepthIntra (  0)
1851// Tool list
1852, m_usePCM                   (false)
1853, m_pcmLog2MaxSize            (  5)
1854, m_uiPCMLog2MinSize          (  7)
1855, m_bitDepthY                 (  8)
1856, m_bitDepthC                 (  8)
1857, m_qpBDOffsetY               (  0)
1858, m_qpBDOffsetC               (  0)
1859, m_useLossless               (false)
1860, m_uiPCMBitDepthLuma         (  8)
1861, m_uiPCMBitDepthChroma       (  8)
1862, m_bPCMFilterDisableFlag     (false)
1863, m_uiBitsForPOC              (  8)
1864, m_numLongTermRefPicSPS    (  0) 
1865, m_uiMaxTrSize               ( 32)
1866, m_bUseSAO                   (false) 
1867, m_bTemporalIdNestingFlag    (false)
1868, m_scalingListEnabledFlag    (false)
1869, m_useStrongIntraSmoothing   (false)
1870, m_vuiParametersPresentFlag  (false)
1871, m_vuiParameters             ()
1872#if M0463_VUI_EXT_ILP_REF
1873, m_interViewMvVertConstraintFlag (false)
1874, m_numIlpRestrictedRefLayers ( 0 )
1875#endif
1876#if SVC_EXTENSION
1877, m_layerId(0)
1878#endif
1879#if SCALED_REF_LAYER_OFFSETS
1880, m_numScaledRefLayerOffsets  (0)
1881#endif
1882#if REPN_FORMAT_IN_VPS
1883, m_updateRepFormatFlag       (false)
1884#endif
1885{
1886  for ( Int i = 0; i < MAX_TLAYER; i++ )
1887  {
1888    m_uiMaxLatencyIncrease[i] = 0;
1889    m_uiMaxDecPicBuffering[i] = 1;
1890    m_numReorderPics[i]       = 0;
1891  }
1892  m_scalingList = new TComScalingList;
1893  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
1894  ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
1895#if M0463_VUI_EXT_ILP_REF
1896  for (Int i = 0; i < MAX_LAYERS; i++ )
1897  {
1898    m_minSpatialSegmentOffsetPlus1[ i ] = 0;
1899    m_ctuBasedOffsetEnabledFlag   [ i ] = false;
1900    m_minHorizontalCtuOffsetPlus1 [ i ] = 0;
1901  }
1902#endif
1903}
1904
1905TComSPS::~TComSPS()
1906{
1907  delete m_scalingList;
1908  m_RPSList.destroy();
1909}
1910
1911Void  TComSPS::createRPSList( Int numRPS )
1912{ 
1913  m_RPSList.destroy();
1914  m_RPSList.create(numRPS);
1915}
1916
1917Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
1918{
1919  if( !getVuiParametersPresentFlag() )
1920  {
1921    return;
1922  }
1923
1924  TComVUI *vui = getVuiParameters();
1925  TComHRD *hrd = vui->getHrdParameters();
1926
1927  TimingInfo *timingInfo = vui->getTimingInfo();
1928#if TIMING_INFO_NONZERO_LAYERID_SPS
1929  if( getLayerId() > 0 )
1930  {
1931    timingInfo->setTimingInfoPresentFlag( false );
1932  }
1933  else
1934  {
1935#endif
1936    timingInfo->setTimingInfoPresentFlag( true );
1937    switch( frameRate )
1938    {
1939    case 24:
1940      timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
1941      break;
1942    case 25:
1943      timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
1944      break;
1945    case 30:
1946      timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
1947      break;
1948    case 50:
1949      timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
1950      break;
1951    case 60:
1952      timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
1953      break;
1954    default:
1955      timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
1956      break;
1957    }
1958
1959    Bool rateCnt = ( bitRate > 0 );
1960    hrd->setNalHrdParametersPresentFlag( rateCnt );
1961    hrd->setVclHrdParametersPresentFlag( rateCnt );
1962
1963    hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
1964
1965    if( hrd->getSubPicCpbParamsPresentFlag() )
1966    {
1967      hrd->setTickDivisorMinus2( 100 - 2 );                          //
1968      hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
1969      hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
1970      hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
1971    }
1972    else
1973    {
1974      hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); 
1975    }
1976
1977    hrd->setBitRateScale( 4 );                                       // in units of 2~( 6 + 4 ) = 1,024 bps
1978    hrd->setCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
1979    hrd->setDuCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
1980 
1981    hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
1982    if( randomAccess )
1983    {
1984      hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
1985      hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
1986    }
1987    else
1988    {
1989      hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
1990      hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
1991    }
1992
1993  /*
1994     Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
1995  */
1996    Int i, j;
1997    UInt birateValue, cpbSizeValue;
1998    UInt ducpbSizeValue;
1999    UInt duBitRateValue = 0;
2000
2001    for( i = 0; i < MAX_TLAYER; i ++ )
2002    {
2003      hrd->setFixedPicRateFlag( i, 1 );
2004      hrd->setPicDurationInTcMinus1( i, 0 );
2005      hrd->setLowDelayHrdFlag( i, 0 );
2006      hrd->setCpbCntMinus1( i, 0 );
2007
2008      birateValue  = bitRate;
2009      cpbSizeValue = bitRate;                                     // 1 second
2010      ducpbSizeValue = bitRate/numDU;
2011      duBitRateValue = bitRate;
2012      for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
2013      {
2014        hrd->setBitRateValueMinus1( i, j, 0, ( birateValue  - 1 ) );
2015        hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
2016        hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) );
2017        hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
2018
2019        hrd->setBitRateValueMinus1( i, j, 1, ( birateValue  - 1) );
2020        hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
2021        hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
2022        hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
2023        hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
2024      }
2025    }
2026#if TIMING_INFO_NONZERO_LAYERID_SPS
2027  }
2028#endif
2029}
2030const Int TComSPS::m_winUnitX[]={1,2,2,1};
2031const Int TComSPS::m_winUnitY[]={1,2,1,1};
2032
2033TComPPS::TComPPS()
2034: m_PPSId                       (0)
2035, m_SPSId                       (0)
2036, m_picInitQPMinus26            (0)
2037, m_useDQP                      (false)
2038, m_bConstrainedIntraPred       (false)
2039, m_bSliceChromaQpFlag          (false)
2040, m_pcSPS                       (NULL)
2041, m_uiMaxCuDQPDepth             (0)
2042, m_uiMinCuDQPSize              (0)
2043, m_chromaCbQpOffset            (0)
2044, m_chromaCrQpOffset            (0)
2045, m_numRefIdxL0DefaultActive    (1)
2046, m_numRefIdxL1DefaultActive    (1)
2047, m_TransquantBypassEnableFlag  (false)
2048, m_useTransformSkip             (false)
2049, m_dependentSliceSegmentsEnabledFlag    (false)
2050, m_tilesEnabledFlag               (false)
2051, m_entropyCodingSyncEnabledFlag   (false)
2052, m_loopFilterAcrossTilesEnabledFlag  (true)
2053, m_uniformSpacingFlag           (0)
2054, m_iNumColumnsMinus1            (0)
2055, m_puiColumnWidth               (NULL)
2056, m_iNumRowsMinus1               (0)
2057, m_puiRowHeight                 (NULL)
2058, m_iNumSubstreams             (1)
2059, m_signHideFlag(0)
2060, m_cabacInitPresentFlag        (false)
2061, m_encCABACTableIdx            (I_SLICE)
2062, m_sliceHeaderExtensionPresentFlag    (false)
2063, m_loopFilterAcrossSlicesEnabledFlag (false)
2064, m_listsModificationPresentFlag(  0)
2065, m_numExtraSliceHeaderBits(0)
2066{
2067  m_scalingList = new TComScalingList;
2068}
2069
2070TComPPS::~TComPPS()
2071{
2072  if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 )
2073  {
2074    if (m_puiColumnWidth) delete [] m_puiColumnWidth; 
2075    m_puiColumnWidth = NULL;
2076  }
2077  if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 )
2078  {
2079    if (m_puiRowHeight) delete [] m_puiRowHeight;
2080    m_puiRowHeight = NULL;
2081  }
2082  delete m_scalingList;
2083}
2084
2085TComReferencePictureSet::TComReferencePictureSet()
2086: m_numberOfPictures (0)
2087, m_numberOfNegativePictures (0)
2088, m_numberOfPositivePictures (0)
2089, m_numberOfLongtermPictures (0)
2090, m_interRPSPrediction (0) 
2091, m_deltaRIdxMinus1 (0)   
2092, m_deltaRPS (0) 
2093, m_numRefIdc (0) 
2094{
2095  ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) );
2096  ::memset( m_POC, 0, sizeof(m_POC) );
2097  ::memset( m_used, 0, sizeof(m_used) );
2098  ::memset( m_refIdc, 0, sizeof(m_refIdc) );
2099}
2100
2101TComReferencePictureSet::~TComReferencePictureSet()
2102{
2103}
2104
2105Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used)
2106{
2107  m_used[bufferNum] = used;
2108}
2109
2110Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC)
2111{
2112  m_deltaPOC[bufferNum] = deltaPOC;
2113}
2114
2115Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures)
2116{
2117  m_numberOfPictures = numberOfPictures;
2118}
2119
2120Int TComReferencePictureSet::getUsed(Int bufferNum)
2121{
2122  return m_used[bufferNum];
2123}
2124
2125Int TComReferencePictureSet::getDeltaPOC(Int bufferNum)
2126{
2127  return m_deltaPOC[bufferNum];
2128}
2129
2130Int TComReferencePictureSet::getNumberOfPictures()
2131{
2132  return m_numberOfPictures;
2133}
2134
2135Int TComReferencePictureSet::getPOC(Int bufferNum)
2136{
2137  return m_POC[bufferNum];
2138}
2139
2140Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC)
2141{
2142  m_POC[bufferNum] = POC;
2143}
2144
2145Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum)
2146{
2147  return m_bCheckLTMSB[bufferNum];
2148}
2149
2150Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b)
2151{
2152  m_bCheckLTMSB[bufferNum] = b;
2153}
2154
2155/** set the reference idc value at uiBufferNum entry to the value of iRefIdc
2156 * \param uiBufferNum
2157 * \param iRefIdc
2158 * \returns Void
2159 */
2160Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc)
2161{
2162  m_refIdc[bufferNum] = refIdc;
2163}
2164
2165/** get the reference idc value at uiBufferNum
2166 * \param uiBufferNum
2167 * \returns Int
2168 */
2169Int  TComReferencePictureSet::getRefIdc(Int bufferNum)
2170{
2171  return m_refIdc[bufferNum];
2172}
2173
2174/** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values.
2175 *  deltaPOC values are sorted with -ve values before the +ve values.  -ve values are in decreasing order.
2176 *  +ve values are in increasing order.
2177 * \returns Void
2178 */
2179Void TComReferencePictureSet::sortDeltaPOC()
2180{
2181  // sort in increasing order (smallest first)
2182  for(Int j=1; j < getNumberOfPictures(); j++)
2183  { 
2184    Int deltaPOC = getDeltaPOC(j);
2185    Bool used = getUsed(j);
2186    for (Int k=j-1; k >= 0; k--)
2187    {
2188      Int temp = getDeltaPOC(k);
2189      if (deltaPOC < temp)
2190      {
2191        setDeltaPOC(k+1, temp);
2192        setUsed(k+1, getUsed(k));
2193        setDeltaPOC(k, deltaPOC);
2194        setUsed(k, used);
2195      }
2196    }
2197  }
2198  // flip the negative values to largest first
2199  Int numNegPics = getNumberOfNegativePictures();
2200  for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--)
2201  { 
2202    Int deltaPOC = getDeltaPOC(j);
2203    Bool used = getUsed(j);
2204    setDeltaPOC(j, getDeltaPOC(k));
2205    setUsed(j, getUsed(k));
2206    setDeltaPOC(k, deltaPOC);
2207    setUsed(k, used);
2208  }
2209}
2210
2211/** Prints the deltaPOC and RefIdc (if available) values in the RPS.
2212 *  A "*" is added to the deltaPOC value if it is Used bu current.
2213 * \returns Void
2214 */
2215Void TComReferencePictureSet::printDeltaPOC()
2216{
2217  printf("DeltaPOC = { ");
2218  for(Int j=0; j < getNumberOfPictures(); j++)
2219  {
2220    printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":"");
2221  } 
2222  if (getInterRPSPrediction()) 
2223  {
2224    printf("}, RefIdc = { ");
2225    for(Int j=0; j < getNumRefIdc(); j++)
2226    {
2227      printf("%d ", getRefIdc(j));
2228    } 
2229  }
2230  printf("}\n");
2231}
2232
2233TComRPSList::TComRPSList()
2234:m_referencePictureSets (NULL)
2235{
2236}
2237
2238TComRPSList::~TComRPSList()
2239{
2240}
2241
2242Void TComRPSList::create( Int numberOfReferencePictureSets)
2243{
2244  m_numberOfReferencePictureSets = numberOfReferencePictureSets;
2245  m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets];
2246}
2247
2248Void TComRPSList::destroy()
2249{
2250  if (m_referencePictureSets)
2251  {
2252    delete [] m_referencePictureSets;
2253  }
2254  m_numberOfReferencePictureSets = 0;
2255  m_referencePictureSets = NULL;
2256}
2257
2258
2259
2260TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum)
2261{
2262  return &m_referencePictureSets[referencePictureSetNum];
2263}
2264
2265Int TComRPSList::getNumberOfReferencePictureSets()
2266{
2267  return m_numberOfReferencePictureSets;
2268}
2269
2270Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets)
2271{
2272  m_numberOfReferencePictureSets = numberOfReferencePictureSets;
2273}
2274
2275TComRefPicListModification::TComRefPicListModification()
2276: m_bRefPicListModificationFlagL0 (false)
2277, m_bRefPicListModificationFlagL1 (false)
2278{
2279  ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) );
2280  ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) );
2281}
2282
2283TComRefPicListModification::~TComRefPicListModification()
2284{
2285}
2286
2287TComScalingList::TComScalingList()
2288{
2289  m_useTransformSkip = false;
2290  init();
2291}
2292TComScalingList::~TComScalingList()
2293{
2294  destroy();
2295}
2296
2297/** set default quantization matrix to array
2298*/
2299Void TComSlice::setDefaultScalingList()
2300{
2301  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2302  {
2303    for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++)
2304    {
2305      getScalingList()->processDefaultMarix(sizeId, listId);
2306    }
2307  }
2308}
2309/** check if use default quantization matrix
2310 * \returns true if use default quantization matrix in all size
2311*/
2312Bool TComSlice::checkDefaultScalingList()
2313{
2314  UInt defaultCounter=0;
2315
2316  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2317  {
2318    for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++)
2319    {
2320      if( !memcmp(getScalingList()->getScalingListAddress(sizeId,listId), getScalingList()->getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix
2321     && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value
2322      {
2323        defaultCounter++;
2324      }
2325    }
2326  }
2327  return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32
2328}
2329
2330/** get scaling matrix from RefMatrixID
2331 * \param sizeId size index
2332 * \param Index of input matrix
2333 * \param Index of reference matrix
2334 */
2335Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId )
2336{
2337  ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
2338}
2339
2340/** parse syntax infomation
2341 *  \param pchFile syntax infomation
2342 *  \returns false if successful
2343 */
2344Bool TComScalingList::xParseScalingList(Char* pchFile)
2345{
2346  FILE *fp;
2347  Char line[1024];
2348  UInt sizeIdc,listIdc;
2349  UInt i,size = 0;
2350  Int *src=0,data;
2351  Char *ret;
2352  UInt  retval;
2353
2354  if((fp = fopen(pchFile,"r")) == (FILE*)NULL)
2355  {
2356    printf("can't open file %s :: set Default Matrix\n",pchFile);
2357    return true;
2358  }
2359
2360  for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++)
2361  {
2362    size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]);
2363    for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++)
2364    {
2365      src = getScalingListAddress(sizeIdc, listIdc);
2366
2367      fseek(fp,0,0);
2368      do 
2369      {
2370        ret = fgets(line, 1024, fp);
2371        if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp)))
2372        {
2373          printf("Error: can't read Matrix :: set Default Matrix\n");
2374          return true;
2375        }
2376      }
2377      while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL);
2378      for (i=0; i<size; i++)
2379      {
2380        retval = fscanf(fp, "%d,", &data);
2381        if (retval!=1)
2382        {
2383          printf("Error: can't read Matrix :: set Default Matrix\n");
2384          return true;
2385        }
2386        src[i] = data;
2387      }
2388      //set DC value for default matrix check
2389      setScalingListDC(sizeIdc,listIdc,src[0]);
2390
2391      if(sizeIdc > SCALING_LIST_8x8)
2392      {
2393        fseek(fp,0,0);
2394        do 
2395        {
2396          ret = fgets(line, 1024, fp);
2397          if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp)))
2398          {
2399            printf("Error: can't read DC :: set Default Matrix\n");
2400            return true;
2401          }
2402        }
2403        while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL);
2404        retval = fscanf(fp, "%d,", &data);
2405        if (retval!=1)
2406        {
2407          printf("Error: can't read Matrix :: set Default Matrix\n");
2408          return true;
2409        }
2410        //overwrite DC value when size of matrix is larger than 16x16
2411        setScalingListDC(sizeIdc,listIdc,data);
2412      }
2413    }
2414  }
2415  fclose(fp);
2416  return false;
2417}
2418
2419/** initialization process of quantization matrix array
2420 */
2421Void TComScalingList::init()
2422{
2423  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2424  {
2425    for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++)
2426    {
2427      m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])];
2428    }
2429  }
2430  m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32
2431}
2432
2433/** destroy quantization matrix array
2434 */
2435Void TComScalingList::destroy()
2436{
2437  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2438  {
2439    for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++)
2440    {
2441      if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId];
2442    }
2443  }
2444}
2445
2446/** get default address of quantization matrix
2447 * \param sizeId size index
2448 * \param listId list index
2449 * \returns pointer of quantization matrix
2450 */
2451Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId)
2452{
2453  Int *src = 0;
2454  switch(sizeId)
2455  {
2456    case SCALING_LIST_4x4:
2457      src = g_quantTSDefault4x4;
2458      break;
2459    case SCALING_LIST_8x8:
2460      src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8;
2461      break;
2462    case SCALING_LIST_16x16:
2463      src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8;
2464      break;
2465    case SCALING_LIST_32x32:
2466      src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8;
2467      break;
2468    default:
2469      assert(0);
2470      src = NULL;
2471      break;
2472  }
2473  return src;
2474}
2475
2476/** process of default matrix
2477 * \param sizeId size index
2478 * \param Index of input matrix
2479 */
2480Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId)
2481{
2482  ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
2483  setScalingListDC(sizeId,listId,SCALING_LIST_DC);
2484}
2485
2486/** check DC value of matrix for default matrix signaling
2487 */
2488Void TComScalingList::checkDcOfMatrix()
2489{
2490  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2491  {
2492    for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++)
2493    {
2494      //check default matrix?
2495      if(getScalingListDC(sizeId,listId) == 0)
2496      {
2497        processDefaultMarix(sizeId, listId);
2498      }
2499    }
2500  }
2501}
2502
2503ParameterSetManager::ParameterSetManager()
2504#if SVC_EXTENSION
2505: m_spsMap(MAX_NUM_SPS)
2506, m_ppsMap(MAX_NUM_PPS)
2507, m_activeSPSId(-1)
2508, m_activePPSId(-1)
2509#else
2510: m_vpsMap(MAX_NUM_VPS)
2511, m_spsMap(MAX_NUM_SPS)
2512, m_ppsMap(MAX_NUM_PPS)
2513, m_activeVPSId(-1)
2514, m_activeSPSId(-1)
2515, m_activePPSId(-1)
2516#endif
2517{
2518}
2519
2520
2521ParameterSetManager::~ParameterSetManager()
2522{
2523}
2524
2525//! activate a SPS from a active parameter sets SEI message
2526//! \returns true, if activation is successful
2527Bool ParameterSetManager::activateSPSWithSEI(Int spsId)
2528{
2529  TComSPS *sps = m_spsMap.getPS(spsId);
2530  if (sps)
2531  {
2532    Int vpsId = sps->getVPSId();
2533    if (m_vpsMap.getPS(vpsId))
2534    {
2535      m_activeVPSId = vpsId;
2536      m_activeSPSId = spsId;
2537      return true;
2538    }
2539    else
2540    {
2541      printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist.");
2542    }
2543  }
2544  else
2545  {
2546    printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message.");
2547  }
2548  return false;
2549}
2550
2551//! activate a PPS and depending on isIDR parameter also SPS and VPS
2552//! \returns true, if activation is successful
2553Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP)
2554{
2555  TComPPS *pps = m_ppsMap.getPS(ppsId);
2556  if (pps)
2557  {
2558    Int spsId = pps->getSPSId();
2559    if (!isIRAP && (spsId != m_activeSPSId))
2560    {
2561      printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP.");
2562      return false;
2563    }
2564    TComSPS *sps = m_spsMap.getPS(spsId);
2565    if (sps)
2566    {
2567      Int vpsId = sps->getVPSId();
2568      if (!isIRAP && (vpsId != m_activeVPSId))
2569      {
2570        printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP.");
2571        return false;
2572      }
2573      if (m_vpsMap.getPS(vpsId))
2574      {
2575        m_activePPSId = ppsId;
2576        m_activeVPSId = vpsId;
2577        m_activeSPSId = spsId;
2578        return true;
2579      }
2580      else
2581      {
2582        printf("Warning: tried to activate PPS that refers to a non-existing VPS.");
2583      }
2584    }
2585    else
2586    {
2587      printf("Warning: tried to activate a PPS that refers to a non-existing SPS.");
2588    }
2589  }
2590  else
2591  {
2592    printf("Warning: tried to activate non-existing PPS.");
2593  }
2594  return false;
2595}
2596
2597ProfileTierLevel::ProfileTierLevel()
2598  : m_profileSpace    (0)
2599  , m_tierFlag        (false)
2600  , m_profileIdc      (0)
2601  , m_levelIdc        (0)
2602, m_progressiveSourceFlag  (false)
2603, m_interlacedSourceFlag   (false)
2604, m_nonPackedConstraintFlag(false)
2605, m_frameOnlyConstraintFlag(false)
2606{
2607  ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag));
2608}
2609#if VPS_EXTN_PROFILE_INFO
2610Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl)
2611{
2612  this->setProfileSpace          ( ptl->getProfileSpace()      );
2613  this->setTierFlag              ( ptl->getTierFlag()          );
2614  this->setProfileIdc            ( ptl->getProfileIdc()        );
2615  for(Int j = 0; j < 32; j++)
2616  {
2617    this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j));
2618  }
2619  this->setProgressiveSourceFlag  ( ptl->getProgressiveSourceFlag()  );
2620  this->setInterlacedSourceFlag   ( ptl->getInterlacedSourceFlag()   );
2621  this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag());
2622  this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); 
2623}
2624#endif
2625
2626TComPTL::TComPTL()
2627{
2628  ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag));
2629  ::memset(m_subLayerLevelPresentFlag,   0, sizeof(m_subLayerLevelPresentFlag  ));
2630}
2631#if VPS_EXTN_PROFILE_INFO
2632Void TComPTL::copyProfileInfo(TComPTL *ptl)
2633{
2634  // Copy all information related to general profile
2635  this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL());
2636}
2637#endif
2638
2639#if SVC_EXTENSION
2640#if AVC_SYNTAX
2641Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice )
2642{
2643// Assumed that RPL of the base layer is same to the EL, otherwise this information should be also dumped and read from the metadata file
2644  setPOC( pcSlice->getPOC() );
2645  if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
2646  {
2647    setSliceType( I_SLICE );
2648  }
2649  else
2650  {
2651    setSliceType( pcSlice->getSliceType() );
2652  }
2653
2654  if( this->isIntra() )
2655  {
2656    return;
2657  }
2658
2659  //initialize reference POC of BL
2660  for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ )
2661  {
2662    RefPicList eRefPicList = RefPicList( iRefPicList );
2663
2664    assert( pcSlice->getNumRefIdx( eRefPicList) >= 0 );
2665    setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 );
2666    assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF);
2667
2668    for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++) 
2669    {
2670      setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx );
2671      setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx );
2672      /*
2673      // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused.
2674      getRefPic( eRefPicList, refIdx )->setLayerId( 0 );
2675      getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() );     
2676      */
2677
2678    }
2679  } 
2680  return;
2681}
2682#endif
2683
2684Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt refLayerIdc )
2685{ 
2686  if(m_layerId == 0)
2687  {
2688    memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
2689    return;
2690  }       
2691  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); 
2692}
2693#endif
2694
2695#if REF_IDX_MFM
2696Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL )
2697{
2698  for( UInt i = 0; i < m_activeNumILRRefIdx; i++ )
2699  {
2700    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
2701
2702    TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc];
2703    //set reference picture POC of each ILP reference
2704    Int thePoc = ilpPic[refLayerIdc]->getPOC(); 
2705    assert(thePoc >= 0); 
2706    assert(thePoc == pcRefPicBL->getPOC());
2707
2708    ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
2709
2710    //copy reference pictures marking from the reference layer
2711    ilpPic[refLayerIdc]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
2712
2713    for( Int refList = 0; refList < 2; refList++ )
2714    {
2715      RefPicList refPicList = RefPicList( refList );
2716
2717      //set reference POC of ILP
2718      ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
2719      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
2720      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
2721
2722      //initialize reference POC of ILP
2723      for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
2724      {
2725        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
2726        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
2727      }
2728
2729      for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) 
2730      { 
2731        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); 
2732        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); 
2733      }
2734    }
2735  }
2736  return;
2737}
2738#endif
2739
2740//! \}
Note: See TracBrowser for help on using the repository browser.