HEVC Test Model (HM)  HM-16.3
TComSlice.cpp
Go to the documentation of this file.
1 /* The copyright in this software is being made available under the BSD
2  * License, included below. This software may be subject to other third party
3  * and contributor rights, including patent rights, and no such rights are
4  * granted under this license.
5  *
6  * Copyright (c) 2010-2015, ITU/ISO/IEC
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18  * be used to endorse or promote products derived from this software without
19  * specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31  * THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
38 #include "CommonDef.h"
39 #include "TComSlice.h"
40 #include "TComPic.h"
41 #include "TLibEncoder/TEncSbac.h"
42 #include "TLibDecoder/TDecSbac.h"
43 
44 
47 
49 : m_iPPSId ( -1 )
50 , m_PicOutputFlag ( true )
51 , m_iPOC ( 0 )
52 , m_iLastIDR ( 0 )
53 , m_iAssociatedIRAP ( 0 )
54 , m_iAssociatedIRAPType ( NAL_UNIT_INVALID )
55 , m_pcRPS ( 0 )
56 , m_LocalRPS ( )
57 , m_iBDidx ( 0 )
58 , m_RefPicListModification ( )
59 , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL )
60 , m_eSliceType ( I_SLICE )
61 , m_iSliceQp ( 0 )
62 , m_dependentSliceSegmentFlag ( false )
64 , m_iSliceQpBase ( 0 )
65 #endif
66 , m_ChromaQpAdjEnabled ( false )
67 , m_deblockingFilterDisable ( false )
68 , m_deblockingFilterOverrideFlag ( false )
69 , m_deblockingFilterBetaOffsetDiv2( 0 )
70 , m_deblockingFilterTcOffsetDiv2 ( 0 )
71 , m_bCheckLDC ( false )
72 , m_iSliceQpDelta ( 0 )
73 , m_iDepth ( 0 )
74 , m_bRefenced ( false )
75 , m_pcVPS ( NULL )
76 , m_pcSPS ( NULL )
77 , m_pcPPS ( NULL )
78 , m_pcPic ( NULL )
80 , m_pcTrQuant ( NULL )
81 #endif
82 , m_colFromL0Flag ( true )
83 , m_noOutputPriorPicsFlag ( false )
84 , m_noRaslOutputFlag ( false )
85 , m_handleCraAsBlaFlag ( false )
86 , m_colRefIdx ( 0 )
87 , m_maxNumMergeCand ( 0 )
88 , m_uiTLayer ( 0 )
89 , m_bTLayerSwitchingFlag ( false )
90 , m_sliceMode ( NO_SLICES )
91 , m_sliceArgument ( 0 )
92 , m_sliceCurStartCtuTsAddr ( 0 )
93 , m_sliceCurEndCtuTsAddr ( 0 )
94 , m_sliceIdx ( 0 )
95 , m_sliceSegmentMode ( NO_SLICES )
96 , m_sliceSegmentArgument ( 0 )
97 , m_sliceSegmentCurStartCtuTsAddr ( 0 )
98 , m_sliceSegmentCurEndCtuTsAddr ( 0 )
99 , m_nextSlice ( false )
100 , m_nextSliceSegment ( false )
101 , m_sliceBits ( 0 )
102 , m_sliceSegmentBits ( 0 )
103 , m_bFinalized ( false )
104 , m_bTestWeightPred ( false )
105 , m_bTestWeightBiPred ( false )
106 , m_substreamSizes ( )
107 , m_cabacInitFlag ( false )
108 , m_bLMvdL1Zero ( false )
109 , m_temporalLayerNonReferenceFlag ( false )
110 , m_LFCrossSliceBoundaryFlag ( false )
111 , m_enableTMVPFlag ( true )
112 , m_encCABACTableIdx (I_SLICE)
113 {
114  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
115  {
116  m_aiNumRefIdx[i] = 0;
117  }
118 
119  for (UInt component = 0; component < MAX_NUM_COMPONENT; component++)
120  {
121  m_lambdas [component] = 0.0;
122  m_iSliceChromaQpDelta[component] = 0;
123  }
124 
125  initEqualRef();
126 
127  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
128  {
129  m_list1IdxToList0Idx[idx] = -1;
130  }
131 
132  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++)
133  {
134  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
135  {
136  m_apcRefPicList [i][iNumCount] = NULL;
137  m_aiRefPOCList [i][iNumCount] = 0;
138  }
139  }
140 
141  resetWpScaling();
142  initWpAcDcParam();
143 
144  for(Int ch=0; ch < MAX_NUM_CHANNEL_TYPE; ch++)
145  {
146  m_saoEnabledFlag[ch] = false;
147  }
148 }
149 
151 {
152 }
153 
154 
156 {
157  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
158  {
159  m_aiNumRefIdx[i] = 0;
160  }
161  m_colFromL0Flag = true;
162 
163  m_colRefIdx = 0;
164  initEqualRef();
165 
166  m_bCheckLDC = false;
167 
168  for (UInt component = 0; component < MAX_NUM_COMPONENT; component++)
169  {
170  m_iSliceChromaQpDelta[component] = 0;
171  }
172 
174 
175  m_bFinalized=false;
176 
177  m_substreamSizes.clear();
178  m_cabacInitFlag = false;
179  m_enableTMVPFlag = true;
180 }
181 
183 {
190 }
191 
192 
194 {
195  TComPic* pcPicExtract;
196  TComPic* pcPicInsert;
197 
198  TComList<TComPic*>::iterator iterPicExtract;
199  TComList<TComPic*>::iterator iterPicExtract_1;
200  TComList<TComPic*>::iterator iterPicInsert;
201 
202  for (Int i = 1; i < (Int)(rcListPic.size()); i++)
203  {
204  iterPicExtract = rcListPic.begin();
205  for (Int j = 0; j < i; j++)
206  {
207  iterPicExtract++;
208  }
209  pcPicExtract = *(iterPicExtract);
210  pcPicExtract->setCurrSliceIdx(0);
211 
212  iterPicInsert = rcListPic.begin();
213  while (iterPicInsert != iterPicExtract)
214  {
215  pcPicInsert = *(iterPicInsert);
216  pcPicInsert->setCurrSliceIdx(0);
217  if (pcPicInsert->getPOC() >= pcPicExtract->getPOC())
218  {
219  break;
220  }
221 
222  iterPicInsert++;
223  }
224 
225  iterPicExtract_1 = iterPicExtract; iterPicExtract_1++;
226 
227  // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position
228  rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1);
229  rcListPic.erase (iterPicExtract);
230  }
231 }
232 
234 {
235  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
236  TComPic* pcPic = *(iterPic);
237  while ( iterPic != rcListPic.end() )
238  {
239  if(pcPic->getPOC() == poc)
240  {
241  break;
242  }
243  iterPic++;
244  pcPic = *(iterPic);
245  }
246  return pcPic;
247 }
248 
249 
251 {
252  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
253  TComPic* pcPic = *(iterPic);
254  TComPic* pcStPic = pcPic;
255 
256  Int pocCycle = 1 << getSPS()->getBitsForPOC();
257  if (!pocHasMsb)
258  {
259  poc = poc & (pocCycle - 1);
260  }
261 
262  while ( iterPic != rcListPic.end() )
263  {
264  pcPic = *(iterPic);
265  if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced())
266  {
267  Int picPoc = pcPic->getPOC();
268  if (!pocHasMsb)
269  {
270  picPoc = picPoc & (pocCycle - 1);
271  }
272 
273  if (poc == picPoc)
274  {
275  if(pcPic->getIsLongTerm())
276  {
277  return pcPic;
278  }
279  else
280  {
281  pcStPic = pcPic;
282  }
283  break;
284  }
285  }
286 
287  iterPic++;
288  }
289 
290  return pcStPic;
291 }
292 
294 {
295  for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++)
296  {
297  for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++)
298  {
299  m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC();
300  }
301  }
302 
303 }
304 
306 {
307  Int idxL0, idxL1;
308  for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ )
309  {
310  m_list1IdxToList0Idx[idxL1] = -1;
311  for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ )
312  {
314  {
315  m_list1IdxToList0Idx[idxL1] = idxL0;
316  break;
317  }
318  }
319  }
320 }
321 
322 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
323 {
324  if (!checkNumPocTotalCurr)
325  {
326  if (m_eSliceType == I_SLICE)
327  {
328  ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
329  ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx ));
330 
331  return;
332  }
333 
336  }
337 
338  TComPic* pcRefPic= NULL;
339  static const UInt MAX_NUM_NEGATIVE_PICTURES=16;
340  TComPic* RefPicSetStCurr0[MAX_NUM_NEGATIVE_PICTURES];
341  TComPic* RefPicSetStCurr1[MAX_NUM_NEGATIVE_PICTURES];
342  TComPic* RefPicSetLtCurr[MAX_NUM_NEGATIVE_PICTURES];
343  UInt NumPicStCurr0 = 0;
344  UInt NumPicStCurr1 = 0;
345  UInt NumPicLtCurr = 0;
346  Int i;
347 
348  for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
349  {
350  if(m_pcRPS->getUsed(i))
351  {
352  pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
353  pcRefPic->setIsLongTerm(0);
354  pcRefPic->getPicYuvRec()->extendPicBorder();
355  RefPicSetStCurr0[NumPicStCurr0] = pcRefPic;
356  NumPicStCurr0++;
357  pcRefPic->setCheckLTMSBPresent(false);
358  }
359  }
360 
362  {
363  if(m_pcRPS->getUsed(i))
364  {
365  pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
366  pcRefPic->setIsLongTerm(0);
367  pcRefPic->getPicYuvRec()->extendPicBorder();
368  RefPicSetStCurr1[NumPicStCurr1] = pcRefPic;
369  NumPicStCurr1++;
370  pcRefPic->setCheckLTMSBPresent(false);
371  }
372  }
373 
375  {
376  if(m_pcRPS->getUsed(i))
377  {
378  pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
379  pcRefPic->setIsLongTerm(1);
380  pcRefPic->getPicYuvRec()->extendPicBorder();
381  RefPicSetLtCurr[NumPicLtCurr] = pcRefPic;
382  NumPicLtCurr++;
383  }
384  if(pcRefPic==NULL)
385  {
386  pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
387  }
389  }
390 
391  // ref_pic_list_init
392  TComPic* rpsCurrList0[MAX_NUM_REF+1];
393  TComPic* rpsCurrList1[MAX_NUM_REF+1];
394  Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr;
395 
396  if (checkNumPocTotalCurr)
397  {
398  // 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:
399  // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
400  // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
401  if (getRapPicFlag())
402  {
403  assert(numPicTotalCurr == 0);
404  }
405 
406  if (m_eSliceType == I_SLICE)
407  {
408  ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
409  ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx ));
410 
411  return;
412  }
413 
414  assert(numPicTotalCurr > 0);
415  // general tier and level limit:
416  assert(numPicTotalCurr <= 8);
417 
420  }
421 
422  Int cIdx = 0;
423  for ( i=0; i<NumPicStCurr0; i++, cIdx++)
424  {
425  rpsCurrList0[cIdx] = RefPicSetStCurr0[i];
426  }
427  for ( i=0; i<NumPicStCurr1; i++, cIdx++)
428  {
429  rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
430  }
431  for ( i=0; i<NumPicLtCurr; i++, cIdx++)
432  {
433  rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
434  }
435  assert(cIdx == numPicTotalCurr);
436 
437  if (m_eSliceType==B_SLICE)
438  {
439  cIdx = 0;
440  for ( i=0; i<NumPicStCurr1; i++, cIdx++)
441  {
442  rpsCurrList1[cIdx] = RefPicSetStCurr1[i];
443  }
444  for ( i=0; i<NumPicStCurr0; i++, cIdx++)
445  {
446  rpsCurrList1[cIdx] = RefPicSetStCurr0[i];
447  }
448  for ( i=0; i<NumPicLtCurr; i++, cIdx++)
449  {
450  rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
451  }
452  assert(cIdx == numPicTotalCurr);
453  }
454 
455  ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
456 
457  for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_0]; rIdx ++)
458  {
460  assert(cIdx >= 0 && cIdx < numPicTotalCurr);
461  m_apcRefPicList[REF_PIC_LIST_0][rIdx] = rpsCurrList0[ cIdx ];
462  m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 );
463  }
464  if ( m_eSliceType != B_SLICE )
465  {
466  m_aiNumRefIdx[REF_PIC_LIST_1] = 0;
467  ::memset( m_apcRefPicList[REF_PIC_LIST_1], 0, sizeof(m_apcRefPicList[REF_PIC_LIST_1]));
468  }
469  else
470  {
471  for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_1]; rIdx ++)
472  {
474  assert(cIdx >= 0 && cIdx < numPicTotalCurr);
475  m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ];
476  m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 );
477  }
478  }
479 }
480 
482 {
483  Int numRpsCurrTempList = 0;
484 
485  if (m_eSliceType == I_SLICE)
486  {
487  return 0;
488  }
490  {
491  if(m_pcRPS->getUsed(i))
492  {
493  numRpsCurrTempList++;
494  }
495  }
496  return numRpsCurrTempList;
497 }
498 
500 {
501  for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++)
502  {
503  for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++)
504  {
505  for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++)
506  {
507  m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false);
508  }
509  }
510  }
511 }
512 
514 {
515  Int i;
516  TComSlice* curSlice = pic->getSlice(curSliceIdx);
517  Int currColRefPOC = curSlice->getRefPOC( RefPicList(1 - curSlice->getColFromL0Flag()), curSlice->getColRefIdx());
518  TComSlice* preSlice;
519  Int preColRefPOC;
520  for(i=curSliceIdx-1; i>=0; i--)
521  {
522  preSlice = pic->getSlice(i);
523  if(preSlice->getSliceType() != I_SLICE)
524  {
525  preColRefPOC = preSlice->getRefPOC( RefPicList(1 - preSlice->getColFromL0Flag()), preSlice->getColRefIdx());
526  if(currColRefPOC != preColRefPOC)
527  {
528  printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n");
529  exit(EXIT_FAILURE);
530  }
531  else
532  {
533  break;
534  }
535  }
536  }
537 }
538 
539 Void TComSlice::checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic)
540 {
541  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
542  {
543  if(pocCRA < MAX_UINT && getPOC() > pocCRA)
544  {
545  assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA);
546  }
547  }
548  for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++)
549  {
550  if(pocCRA < MAX_UINT && getPOC() > pocCRA)
551  {
552  if (!pReferencePictureSet->getCheckLTMSBPresent(i))
553  {
554  assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA);
555  }
556  else
557  {
558  assert(pReferencePictureSet->getPOC(i) >= pocCRA);
559  }
560  }
561  }
563  {
564  pocCRA = getPOC();
565  associatedIRAPType = getNalUnitType();
566  }
567  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
568  {
569  pocCRA = getPOC();
570  associatedIRAPType = getNalUnitType();
571  }
574  || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found
575  {
576  pocCRA = getPOC();
577  associatedIRAPType = getNalUnitType();
578  }
579 }
580 
599 Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic)
600 {
601  TComPic* rpcPic;
602  Int pocCurr = getPOC();
603 
608  || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture
609  {
610  // mark all pictures as not used for reference
611  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
612  while (iterPic != rcListPic.end())
613  {
614  rpcPic = *(iterPic);
615  rpcPic->setCurrSliceIdx(0);
616  if (rpcPic->getPOC() != pocCurr)
617  {
618  rpcPic->getSlice(0)->setReferenced(false);
619  }
620  iterPic++;
621  }
625  {
626  pocCRA = pocCurr;
627  }
628 #if EFFICIENT_FIELD_IRAP
629  bRefreshPending = true;
630 #endif
631  }
632  else // CRA or No DR
633  {
634 #if EFFICIENT_FIELD_IRAP
636  {
637  if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending
638  {
639  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
640  while (iterPic != rcListPic.end())
641  {
642  rpcPic = *(iterPic);
643  if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR)
644  {
645  rpcPic->getSlice(0)->setReferenced(false);
646  }
647  iterPic++;
648  }
649  bRefreshPending = false;
650  }
651  }
652  else
653  {
654 #endif
655  if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending
656  {
657  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
658  while (iterPic != rcListPic.end())
659  {
660  rpcPic = *(iterPic);
661  if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA)
662  {
663  rpcPic->getSlice(0)->setReferenced(false);
664  }
665  iterPic++;
666  }
667  bRefreshPending = false;
668  }
669 #if EFFICIENT_FIELD_IRAP
670  }
671 #endif
672  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
673  {
674  bRefreshPending = true;
675  pocCRA = pocCurr;
676  }
677  }
678 }
679 
681 {
682  assert( pSrc != NULL );
683 
684  Int i, j, k;
685 
686  m_iPOC = pSrc->m_iPOC;
688  m_eSliceType = pSrc->m_eSliceType;
689  m_iSliceQp = pSrc->m_iSliceQp;
690 #if ADAPTIVE_QP_SELECTION
692 #endif
698 
699  for (i = 0; i < NUM_REF_PIC_LIST_01; i++)
700  {
701  m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i];
702  }
703 
704  for (i = 0; i < MAX_NUM_REF; i++)
705  {
707  }
708 
709  m_bCheckLDC = pSrc->m_bCheckLDC;
711  for (UInt component = 0; component < MAX_NUM_COMPONENT; component++)
712  {
713  m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component];
714  }
715  for (i = 0; i < NUM_REF_PIC_LIST_01; i++)
716  {
717  for (j = 0; j < MAX_NUM_REF; j++)
718  {
719  m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j];
720  m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j];
721  m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j];
722  }
724  }
725  m_iDepth = pSrc->m_iDepth;
726 
727  // referenced slice
728  m_bRefenced = pSrc->m_bRefenced;
729 
730  // access channel
731  m_pcRPS = pSrc->m_pcRPS;
732  m_iLastIDR = pSrc->m_iLastIDR;
733 
734  m_pcPic = pSrc->m_pcPic;
735 
737  m_colRefIdx = pSrc->m_colRefIdx;
738 
739  setLambdas(pSrc->getLambdas());
740 
741  for (i = 0; i < NUM_REF_PIC_LIST_01; i++)
742  {
743  for (j = 0; j < MAX_NUM_REF; j++)
744  {
745  for (k =0; k < MAX_NUM_REF; k++)
746  {
747  m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k];
748  }
749  }
750  }
751 
752  m_uiTLayer = pSrc->m_uiTLayer;
754 
755  m_sliceMode = pSrc->m_sliceMode;
759  m_sliceIdx = pSrc->m_sliceIdx;
764  m_nextSlice = pSrc->m_nextSlice;
766 
767  for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ )
768  {
769  for ( UInt n=0 ; n<MAX_NUM_REF ; n++ )
770  {
771  memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT );
772  }
773  }
774 
775  for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++)
776  {
777  m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch];
778  }
779 
781 
787 }
788 
789 
791 
799 {
800  m_uiTLayer = uiTLayer;
801 }
802 
806 {
807  TComPic* rpcPic;
808  // loop through all pictures in the reference picture buffer
809  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
810  while ( iterPic != rcListPic.end())
811  {
812  rpcPic = *(iterPic++);
813  if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC())
814  {
815  if(rpcPic->getTLayer() >= getTLayer())
816  {
817  return false;
818  }
819  }
820  }
821  return true;
822 }
823 
827 {
828  TComPic* rpcPic;
829 
830  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
831  while ( iterPic != rcListPic.end())
832  {
833  rpcPic = *(iterPic++);
834  if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC())
835  {
836  if(rpcPic->getTLayer() >= getTLayer())
837  {
838  return false;
839  }
840  }
841  }
842  return true;
843 }
844 
845 
847 {
848  TComPic* rpcPic;
849 
850  Int nalUnitType = this->getNalUnitType();
851 
852  // When a picture is a leading picture, it shall be a RADL or RASL picture.
853  if(this->getAssociatedIRAPPOC() > this->getPOC())
854  {
855  // Do not check IRAP pictures since they may get a POC lower than their associated IRAP
856  if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP ||
857  nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23)
858  {
859  assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
860  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
861  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
862  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R);
863  }
864  }
865 
866  // When a picture is a trailing picture, it shall not be a RADL or RASL picture.
867  if(this->getAssociatedIRAPPOC() < this->getPOC())
868  {
869  assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N &&
870  nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R &&
871  nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N &&
872  nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R);
873  }
874 
875  // No RASL pictures shall be present in the bitstream that are associated
876  // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP.
877  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
878  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
879  {
882  }
883 
884  // No RASL pictures shall be present in the bitstream that are associated with
885  // an IDR picture.
886  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
887  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
888  {
891  }
892 
893  // No RADL pictures shall be present in the bitstream that are associated with
894  // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated
895  // with an IDR picture having nal_unit_type equal to IDR_N_LP.
896  if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
897  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
898  {
901  }
902 
903  // loop through all pictures in the reference picture buffer
904  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
905  while ( iterPic != rcListPic.end())
906  {
907  rpcPic = *(iterPic++);
908 #if BUGFIX_INTRAPERIOD
909  if(!rpcPic->getReconMark())
910  {
911  continue;
912  }
913 #endif
914  if (rpcPic->getPOC() == this->getPOC())
915  {
916  continue;
917  }
918 
919  // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
920  // in decoding order shall precede the IRAP picture in output order.
921  // (Note that any picture following in output order would be present in the DPB)
922  if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag())
923  {
924  if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP ||
925  nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ||
926  nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL ||
927  nalUnitType == NAL_UNIT_CODED_SLICE_CRA ||
928  nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP ||
929  nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
930  {
931  assert(rpcPic->getPOC() < this->getPOC());
932  }
933  }
934 
935  // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
936  // in decoding order shall precede any RADL picture associated with the IRAP
937  // picture in output order.
938  if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
939  {
940  if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
941  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R))
942  {
943  // rpcPic precedes the IRAP in decoding order
944  if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC())
945  {
946  // rpcPic must not be the IRAP picture
947  if(this->getAssociatedIRAPPOC() != rpcPic->getPOC())
948  {
949  assert(rpcPic->getPOC() < this->getPOC());
950  }
951  }
952  }
953  }
954 
955  // When a picture is a leading picture, it shall precede, in decoding order,
956  // all trailing pictures that are associated with the same IRAP picture.
957  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
958  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
959  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
960  nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
961  {
962  if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC())
963  {
964  // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB
965  // rpcPic would violate the constraint if it was a trailing picture
966  assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
967  }
968  }
969 
970  // Any RASL picture associated with a CRA or BLA picture shall precede any
971  // RADL picture associated with the CRA or BLA picture in output order
972  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
973  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
974  {
979  this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC())
980  {
983  {
984  assert(rpcPic->getPOC() > this->getPOC());
985  }
986  }
987  }
988 
989  // Any RASL picture associated with a CRA picture shall follow, in output
990  // order, any IRAP picture that precedes the CRA picture in decoding order.
991  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
992  nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
993  {
995  {
996  if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() &&
1003  {
1004  assert(this->getPOC() > rpcPic->getSlice(0)->getPOC());
1005  }
1006  }
1007  }
1008  }
1009 }
1010 
1011 
1012 
1016 {
1017  TComPic* rpcPic;
1018  Int i, isReference;
1019 
1021 
1022  // loop through all pictures in the reference picture buffer
1023  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1024  while ( iterPic != rcListPic.end())
1025  {
1026  rpcPic = *(iterPic++);
1027 
1028  if(!rpcPic->getSlice( 0 )->isReferenced())
1029  {
1030  continue;
1031  }
1032 
1033  isReference = 0;
1034  // loop through all pictures in the Reference Picture Set
1035  // to see if the picture should be kept as reference picture
1036  for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++)
1037  {
1038  if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i))
1039  {
1040  isReference = 1;
1041  rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1042  rpcPic->setIsLongTerm(0);
1043  }
1044  }
1045  for(;i<pReferencePictureSet->getNumberOfPictures();i++)
1046  {
1047  if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
1048  {
1049  if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i))
1050  {
1051  isReference = 1;
1052  rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1053  }
1054  }
1055  else
1056  {
1057  Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
1058  Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1);
1059  Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1);
1060  if(rpcPic->getIsLongTerm() && curPoc == refPoc)
1061  {
1062  isReference = 1;
1063  rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i));
1064  }
1065  }
1066 
1067  }
1068  // mark the picture as "unused for reference" if it is not in
1069  // the Reference Picture Set
1070  if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0)
1071  {
1072  rpcPic->getSlice( 0 )->setReferenced( false );
1073  rpcPic->setUsedByCurr(0);
1074  rpcPic->setIsLongTerm(0);
1075  }
1076  //check that pictures of higher temporal layers are not used
1077  assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer());
1078  //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
1080  {
1081  assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer());
1082  }
1083  //check that pictures marked as temporal layer non-reference pictures are not used for reference
1084  if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer())
1085  {
1086  assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false);
1087  }
1088  }
1089 }
1090 
1093 #if ALLOW_RECOVERY_POINT_AS_RAP
1094 Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint)
1095 #else
1096 Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess)
1097 #endif
1098 {
1099 #if ALLOW_RECOVERY_POINT_AS_RAP
1100  Int atLeastOneUnabledByRecoveryPoint = 0;
1101  Int atLeastOneFlushedByPreviousIDR = 0;
1102 #endif
1103  TComPic* rpcPic;
1104  Int i, isAvailable;
1105  Int atLeastOneLost = 0;
1106  Int atLeastOneRemoved = 0;
1107  Int iPocLost = 0;
1108 
1109  // loop through all long-term pictures in the Reference Picture Set
1110  // to see if the picture should be kept as reference picture
1111  for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++)
1112  {
1113  isAvailable = 0;
1114  // loop through all pictures in the reference picture buffer
1115  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1116  while ( iterPic != rcListPic.end())
1117  {
1118  rpcPic = *(iterPic++);
1119  if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
1120  {
1121  if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced())
1122  {
1123 #if ALLOW_RECOVERY_POINT_AS_RAP
1124  if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
1125  {
1126  isAvailable = 0;
1127  }
1128  else
1129  {
1130  isAvailable = 1;
1131  }
1132 #else
1133  isAvailable = 1;
1134 #endif
1135  }
1136  }
1137  else
1138  {
1139  Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
1140  Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1);
1141  Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1);
1142  if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced())
1143  {
1144 #if ALLOW_RECOVERY_POINT_AS_RAP
1145  if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
1146  {
1147  isAvailable = 0;
1148  }
1149  else
1150  {
1151  isAvailable = 1;
1152  }
1153 #else
1154  isAvailable = 1;
1155 #endif
1156  }
1157  }
1158  }
1159  // if there was no such long-term check the short terms
1160  if(!isAvailable)
1161  {
1162  iterPic = rcListPic.begin();
1163  while ( iterPic != rcListPic.end())
1164  {
1165  rpcPic = *(iterPic++);
1166 
1167  Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
1168  Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC();
1169  Int refPoc = pReferencePictureSet->getPOC(i);
1170  if (!pReferencePictureSet->getCheckLTMSBPresent(i))
1171  {
1172  curPoc = curPoc & (pocCycle - 1);
1173  refPoc = refPoc & (pocCycle - 1);
1174  }
1175 
1176  if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc)
1177  {
1178 #if ALLOW_RECOVERY_POINT_AS_RAP
1179  if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
1180  {
1181  isAvailable = 0;
1182  }
1183  else
1184  {
1185  isAvailable = 1;
1186  rpcPic->setIsLongTerm(1);
1187  break;
1188  }
1189 #else
1190  isAvailable = 1;
1191  rpcPic->setIsLongTerm(1);
1192  break;
1193 #endif
1194  }
1195  }
1196  }
1197  // report that a picture is lost if it is in the Reference Picture Set
1198  // but not available as reference picture
1199  if(isAvailable == 0)
1200  {
1201  if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
1202  {
1203  if(!pReferencePictureSet->getUsed(i) )
1204  {
1205  if(printErrors)
1206  {
1207  printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1208  }
1209  atLeastOneRemoved = 1;
1210  }
1211  else
1212  {
1213  if(printErrors)
1214  {
1215  printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1216  }
1217  atLeastOneLost = 1;
1218  iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
1219  }
1220  }
1221 #if ALLOW_RECOVERY_POINT_AS_RAP
1222  else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
1223  {
1224  atLeastOneUnabledByRecoveryPoint = 1;
1225  }
1226  else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL))
1227  {
1228  atLeastOneFlushedByPreviousIDR = 1;
1229  }
1230 #endif
1231  }
1232  }
1233  // loop through all short-term pictures in the Reference Picture Set
1234  // to see if the picture should be kept as reference picture
1235  for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++)
1236  {
1237  isAvailable = 0;
1238  // loop through all pictures in the reference picture buffer
1239  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1240  while ( iterPic != rcListPic.end())
1241  {
1242  rpcPic = *(iterPic++);
1243 
1244  if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
1245  {
1246 #if ALLOW_RECOVERY_POINT_AS_RAP
1247  if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
1248  {
1249  isAvailable = 0;
1250  }
1251  else
1252  {
1253  isAvailable = 1;
1254  }
1255 #else
1256  isAvailable = 1;
1257 #endif
1258  }
1259  }
1260  // report that a picture is lost if it is in the Reference Picture Set
1261  // but not available as reference picture
1262  if(isAvailable == 0)
1263  {
1264  if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
1265  {
1266  if(!pReferencePictureSet->getUsed(i) )
1267  {
1268  if(printErrors)
1269  {
1270  printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1271  }
1272  atLeastOneRemoved = 1;
1273  }
1274  else
1275  {
1276  if(printErrors)
1277  {
1278  printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
1279  }
1280  atLeastOneLost = 1;
1281  iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
1282  }
1283  }
1284 #if ALLOW_RECOVERY_POINT_AS_RAP
1285  else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
1286  {
1287  atLeastOneUnabledByRecoveryPoint = 1;
1288  }
1289  else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL))
1290  {
1291  atLeastOneFlushedByPreviousIDR = 1;
1292  }
1293 #endif
1294  }
1295  }
1296 
1297 #if ALLOW_RECOVERY_POINT_AS_RAP
1298  if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR)
1299  {
1300  return -1;
1301  }
1302 #endif
1303  if(atLeastOneLost)
1304  {
1305  return iPocLost+1;
1306  }
1307  if(atLeastOneRemoved)
1308  {
1309  return -2;
1310  }
1311  else
1312  {
1313  return 0;
1314  }
1315 }
1316 
1319 #if ALLOW_RECOVERY_POINT_AS_RAP
1320 Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint)
1321 #else
1323 #endif
1324 {
1325  TComPic* rpcPic;
1326  Int i, j;
1327  Int k = 0;
1328  Int nrOfNegativePictures = 0;
1329  Int nrOfPositivePictures = 0;
1330  TComReferencePictureSet* pcRPS = this->getLocalRPS();
1331 #if EFFICIENT_FIELD_IRAP
1332  Bool irapIsInRPS = false;
1333 #endif
1334 
1335  // loop through all pictures in the Reference Picture Set
1336  for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++)
1337  {
1338  j = 0;
1339  // loop through all pictures in the reference picture buffer
1340  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1341  while ( iterPic != rcListPic.end())
1342  {
1343  j++;
1344  rpcPic = *(iterPic++);
1345 
1346  if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
1347  {
1348  // This picture exists as a reference picture
1349  // and should be added to the explicit Reference Picture Set
1350  pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
1351  pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
1352 #if ALLOW_RECOVERY_POINT_AS_RAP
1353  pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) );
1354 #endif
1355 
1356  if(pcRPS->getDeltaPOC(k) < 0)
1357  {
1358  nrOfNegativePictures++;
1359  }
1360  else
1361  {
1362 #if EFFICIENT_FIELD_IRAP
1363  if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1)
1364  {
1365  irapIsInRPS = true;
1366  }
1367 #endif
1368  nrOfPositivePictures++;
1369  }
1370  k++;
1371  }
1372  }
1373  }
1374 
1375 #if EFFICIENT_FIELD_IRAP
1376  Bool useNewRPS = false;
1377  // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS.
1378  if(m_pcPic->isField() && !irapIsInRPS)
1379  {
1380  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
1381  while ( iterPic != rcListPic.end())
1382  {
1383  rpcPic = *(iterPic++);
1384  if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1)
1385  {
1386  pcRPS->setDeltaPOC(k, 1);
1387  pcRPS->setUsed(k, true);
1388  nrOfPositivePictures++;
1389  k ++;
1390  useNewRPS = true;
1391  }
1392  }
1393  }
1394 #endif
1395  pcRPS->setNumberOfNegativePictures(nrOfNegativePictures);
1396  pcRPS->setNumberOfPositivePictures(nrOfPositivePictures);
1397  pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures);
1398  // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the
1399  // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet.
1400  // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled.
1401  if (!pReferencePictureSet->getInterRPSPrediction()
1402 #if EFFICIENT_FIELD_IRAP
1403  || useNewRPS
1404 #endif
1405  )
1406  {
1407  pcRPS->setInterRPSPrediction(false);
1408  pcRPS->setNumRefIdc(0);
1409  }
1410  else
1411  {
1412  Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1;
1413  Int deltaRPS = pReferencePictureSet->getDeltaRPS();
1414  const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx);
1415  Int iRefPics = pcRefRPS->getNumberOfPictures();
1416  Int iNewIdc=0;
1417  for(i=0; i<= iRefPics; i++)
1418  {
1419  Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0
1420  Int iRefIdc = 0;
1421  for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS
1422  {
1423  if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j))
1424  {
1425  if (pcRPS->getUsed(j))
1426  {
1427  iRefIdc = 1;
1428  }
1429  else
1430  {
1431  iRefIdc = 2;
1432  }
1433  }
1434  }
1435  pcRPS->setRefIdc(i, iRefIdc);
1436  iNewIdc++;
1437  }
1438  pcRPS->setInterRPSPrediction(true);
1439  pcRPS->setNumRefIdc(iNewIdc);
1440  pcRPS->setDeltaRPS(deltaRPS);
1441  pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx());
1442  }
1443 
1444  this->setRPS(pcRPS);
1445  this->setRPSidx(-1);
1446 }
1447 
1450 {
1451  wp = m_weightACDCParam;
1452 }
1453 
1456 {
1457  for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ )
1458  {
1459  m_weightACDCParam[iComp].iAC = 0;
1460  m_weightACDCParam[iComp].iDC = 0;
1461  }
1462 }
1463 
1466 {
1467  assert (e<NUM_REF_PIC_LIST_01);
1468  wp = m_weightPredTable[e][iRefIdx];
1469 }
1470 
1473 {
1474  for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ )
1475  {
1476  for ( Int i=0 ; i<MAX_NUM_REF ; i++ )
1477  {
1478  for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ )
1479  {
1480  WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]);
1481  pwp->bPresentFlag = false;
1482  pwp->uiLog2WeightDenom = 0;
1483  pwp->uiLog2WeightDenom = 0;
1484  pwp->iWeight = 1;
1485  pwp->iOffset = 0;
1486  }
1487  }
1488  }
1489 }
1490 
1493 {
1494  const Bool bUseHighPrecisionPredictionWeighting = sps->getUseHighPrecisionPredictionWeighting();
1495  for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ )
1496  {
1497  for ( Int i=0 ; i<MAX_NUM_REF ; i++ )
1498  {
1499  for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ )
1500  {
1501  WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]);
1502  if ( !pwp->bPresentFlag )
1503  {
1504  // Inferring values not present :
1505  pwp->iWeight = (1 << pwp->uiLog2WeightDenom);
1506  pwp->iOffset = 0;
1507  }
1508 
1509  const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (g_bitDepth[toChannelType(ComponentID(yuv))]-8));
1510 
1511  pwp->w = pwp->iWeight;
1512  pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used
1513  pwp->shift = pwp->uiLog2WeightDenom;
1514  pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0);
1515  }
1516  }
1517  }
1518 }
1519 
1520 // ------------------------------------------------------------------------------------------------
1521 // Video parameter set (VPS)
1522 // ------------------------------------------------------------------------------------------------
1524 : m_VPSId ( 0)
1525 , m_uiMaxTLayers ( 1)
1526 , m_uiMaxLayers ( 1)
1527 , m_bTemporalIdNestingFlag (false)
1528 , m_numHrdParameters ( 0)
1529 , m_maxNuhReservedZeroLayerId ( 0)
1530 , m_hrdParameters ()
1531 , m_hrdOpSetIdx ()
1532 , m_cprmsPresentFlag ()
1533 {
1534 
1535  for( Int i = 0; i < MAX_TLAYER; i++)
1536  {
1537  m_numReorderPics[i] = 0;
1538  m_uiMaxDecPicBuffering[i] = 1;
1539  m_uiMaxLatencyIncrease[i] = 0;
1540  }
1541 }
1542 
1544 {
1545 }
1546 
1547 // ------------------------------------------------------------------------------------------------
1548 // Sequence parameter set (SPS)
1549 // ------------------------------------------------------------------------------------------------
1550 
1552 : m_SPSId ( 0)
1553 , m_VPSId ( 0)
1554 , m_chromaFormatIdc (CHROMA_420)
1555 , m_uiMaxTLayers ( 1)
1556 // Structure
1557 , m_picWidthInLumaSamples (352)
1558 , m_picHeightInLumaSamples (288)
1559 , m_log2MinCodingBlockSize ( 0)
1560 , m_log2DiffMaxMinCodingBlockSize(0)
1561 , m_uiMaxCUWidth ( 32)
1562 , m_uiMaxCUHeight ( 32)
1563 , m_uiMaxCUDepth ( 3)
1564 , m_bLongTermRefsPresent (false)
1565 , m_uiQuadtreeTULog2MaxSize ( 0)
1566 , m_uiQuadtreeTULog2MinSize ( 0)
1567 , m_uiQuadtreeTUMaxDepthInter ( 0)
1568 , m_uiQuadtreeTUMaxDepthIntra ( 0)
1569 // Tool list
1570 , m_usePCM (false)
1571 , m_pcmLog2MaxSize ( 5)
1572 , m_uiPCMLog2MinSize ( 7)
1573 , m_useExtendedPrecision (false)
1574 , m_useHighPrecisionPredictionWeighting(false)
1575 , m_useResidualRotation (false)
1576 , m_useSingleSignificanceMapContext(false)
1577 , m_useGolombRiceParameterAdaptation(false)
1578 , m_alignCABACBeforeBypass (false)
1579 , m_bPCMFilterDisableFlag (false)
1580 , m_disableIntraReferenceSmoothing(false)
1581 , m_uiBitsForPOC ( 8)
1582 , m_numLongTermRefPicSPS ( 0)
1583 , m_uiMaxTrSize ( 32)
1584 , m_bUseSAO (false)
1585 , m_bTemporalIdNestingFlag (false)
1586 , m_scalingListEnabledFlag (false)
1587 , m_useStrongIntraSmoothing (false)
1588 , m_vuiParametersPresentFlag (false)
1589 , m_vuiParameters ()
1590 {
1591  for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
1592  {
1593  m_uiBitDepth [ch] = 8;
1594  m_uiPCMBitDepth[ch] = 8;
1595  m_qpBDOffset [ch] = 0;
1596  }
1597 
1598  for ( Int i = 0; i < MAX_TLAYER; i++ )
1599  {
1600  m_uiMaxLatencyIncrease[i] = 0;
1601  m_uiMaxDecPicBuffering[i] = 1;
1602  m_numReorderPics[i] = 0;
1603  }
1604 
1605  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
1606  {
1607  m_useResidualDPCM[signallingModeIndex] = false;
1608  }
1609 
1610  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
1611  ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
1612 }
1613 
1615 {
1616  m_RPSList.destroy();
1617 }
1618 
1620 {
1621  m_RPSList.destroy();
1622  m_RPSList.create(numRPS);
1623 }
1624 
1625 Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
1626 {
1628  {
1629  return;
1630  }
1631 
1632  TComVUI *vui = getVuiParameters();
1633  TComHRD *hrd = vui->getHrdParameters();
1634 
1635  TimingInfo *timingInfo = vui->getTimingInfo();
1636  timingInfo->setTimingInfoPresentFlag( true );
1637  switch( frameRate )
1638  {
1639  case 24:
1640  timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 );
1641  break;
1642  case 25:
1643  timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 );
1644  break;
1645  case 30:
1646  timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 );
1647  break;
1648  case 50:
1649  timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 );
1650  break;
1651  case 60:
1652  timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 );
1653  break;
1654  default:
1655  timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 );
1656  break;
1657  }
1658 
1659  Bool rateCnt = ( bitRate > 0 );
1660  hrd->setNalHrdParametersPresentFlag( rateCnt );
1661  hrd->setVclHrdParametersPresentFlag( rateCnt );
1662 
1663  hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
1664 
1665  if( hrd->getSubPicCpbParamsPresentFlag() )
1666  {
1667  hrd->setTickDivisorMinus2( 100 - 2 ); //
1668  hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU )
1670  hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
1671  }
1672  else
1673  {
1675  }
1676 
1677  hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps
1678  hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit
1679  hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit
1680 
1681  hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
1682  if( randomAccess )
1683  {
1684  hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1)
1685  hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6
1686  }
1687  else
1688  {
1689  hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10
1690  hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10
1691  }
1692 
1693 /*
1694  Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
1695 */
1696  Int i, j;
1697  UInt bitrateValue, cpbSizeValue;
1698  UInt duCpbSizeValue;
1699  UInt duBitRateValue = 0;
1700 
1701  for( i = 0; i < MAX_TLAYER; i ++ )
1702  {
1703  hrd->setFixedPicRateFlag( i, 1 );
1704  hrd->setPicDurationInTcMinus1( i, 0 );
1705  hrd->setLowDelayHrdFlag( i, 0 );
1706  hrd->setCpbCntMinus1( i, 0 );
1707 
1708  bitrateValue = bitRate;
1709  cpbSizeValue = bitRate; // 1 second
1710  duCpbSizeValue = bitRate/numDU;
1711  duBitRateValue = bitRate;
1712 
1713  for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
1714  {
1715  hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) );
1716  hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
1717  hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) );
1718  hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
1719 
1720  hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) );
1721  hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
1722  hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) );
1723  hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
1724  hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
1725  }
1726  }
1727 }
1728 
1729 const Int TComSPS::m_winUnitX[]={1,2,2,1};
1730 const Int TComSPS::m_winUnitY[]={1,2,1,1};
1731 
1733 : m_PPSId (0)
1734 , m_SPSId (0)
1735 , m_picInitQPMinus26 (0)
1736 , m_useDQP (false)
1737 , m_bConstrainedIntraPred (false)
1738 , m_bSliceChromaQpFlag (false)
1739 , m_uiMaxCuDQPDepth (0)
1740 , m_MaxCuChromaQpAdjDepth (0)
1741 , m_ChromaQpAdjTableSize (0)
1742 , m_chromaCbQpOffset (0)
1743 , m_chromaCrQpOffset (0)
1744 , m_numRefIdxL0DefaultActive (1)
1745 , m_numRefIdxL1DefaultActive (1)
1746 , m_useCrossComponentPrediction (false)
1747 , m_TransquantBypassEnableFlag (false)
1748 , m_useTransformSkip (false)
1749 , m_transformSkipLog2MaxSize (2)
1750 , m_dependentSliceSegmentsEnabledFlag(false)
1751 , m_tilesEnabledFlag (false)
1752 , m_entropyCodingSyncEnabledFlag (false)
1753 , m_loopFilterAcrossTilesEnabledFlag (true)
1754 , m_uniformSpacingFlag (false)
1755 , m_numTileColumnsMinus1 (0)
1756 , m_numTileRowsMinus1 (0)
1757 , m_signHideFlag (false)
1758 , m_cabacInitPresentFlag (false)
1759 , m_sliceHeaderExtensionPresentFlag (false)
1760 , m_loopFilterAcrossSlicesEnabledFlag(false)
1761 , m_listsModificationPresentFlag (0)
1762 , m_numExtraSliceHeaderBits (0)
1763 {
1764  for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
1765  {
1766  m_saoOffsetBitShift[ch] = 0;
1767  }
1768  m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed.
1770 }
1771 
1773 {
1774 }
1775 
1777 : m_numberOfPictures (0)
1778 , m_numberOfNegativePictures (0)
1779 , m_numberOfPositivePictures (0)
1780 , m_numberOfLongtermPictures (0)
1781 , m_interRPSPrediction (0)
1782 , m_deltaRIdxMinus1 (0)
1783 , m_deltaRPS (0)
1784 , m_numRefIdc (0)
1785 {
1786  ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) );
1787  ::memset( m_POC, 0, sizeof(m_POC) );
1788  ::memset( m_used, 0, sizeof(m_used) );
1789  ::memset( m_refIdc, 0, sizeof(m_refIdc) );
1790  ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) );
1791  ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) );
1792  ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) );
1793  ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) );
1794 }
1795 
1797 {
1798 }
1799 
1801 {
1802  m_used[bufferNum] = used;
1803 }
1804 
1806 {
1807  m_deltaPOC[bufferNum] = deltaPOC;
1808 }
1809 
1811 {
1812  m_numberOfPictures = numberOfPictures;
1813 }
1814 
1816 {
1817  return m_used[bufferNum];
1818 }
1819 
1821 {
1822  return m_deltaPOC[bufferNum];
1823 }
1824 
1826 {
1827  return m_numberOfPictures;
1828 }
1829 
1831 {
1832  return m_POC[bufferNum];
1833 }
1834 
1836 {
1837  m_POC[bufferNum] = POC;
1838 }
1839 
1841 {
1842  return m_bCheckLTMSB[bufferNum];
1843 }
1844 
1846 {
1847  m_bCheckLTMSB[bufferNum] = b;
1848 }
1849 
1852 {
1853  m_refIdc[bufferNum] = refIdc;
1854 }
1855 
1858 {
1859  return m_refIdc[bufferNum];
1860 }
1861 
1868 {
1869  // sort in increasing order (smallest first)
1870  for(Int j=1; j < getNumberOfPictures(); j++)
1871  {
1872  Int deltaPOC = getDeltaPOC(j);
1873  Bool used = getUsed(j);
1874  for (Int k=j-1; k >= 0; k--)
1875  {
1876  Int temp = getDeltaPOC(k);
1877  if (deltaPOC < temp)
1878  {
1879  setDeltaPOC(k+1, temp);
1880  setUsed(k+1, getUsed(k));
1881  setDeltaPOC(k, deltaPOC);
1882  setUsed(k, used);
1883  }
1884  }
1885  }
1886  // flip the negative values to largest first
1887  Int numNegPics = getNumberOfNegativePictures();
1888  for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--)
1889  {
1890  Int deltaPOC = getDeltaPOC(j);
1891  Bool used = getUsed(j);
1892  setDeltaPOC(j, getDeltaPOC(k));
1893  setUsed(j, getUsed(k));
1894  setDeltaPOC(k, deltaPOC);
1895  setUsed(k, used);
1896  }
1897 }
1898 
1904 {
1905  printf("DeltaPOC = { ");
1906  for(Int j=0; j < getNumberOfPictures(); j++)
1907  {
1908  printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":"");
1909  }
1910  if (getInterRPSPrediction())
1911  {
1912  printf("}, RefIdc = { ");
1913  for(Int j=0; j < getNumRefIdc(); j++)
1914  {
1915  printf("%d ", getRefIdc(j));
1916  }
1917  }
1918  printf("}\n");
1919 }
1920 
1922 : m_refPicListModificationFlagL0 (false)
1923 , m_refPicListModificationFlagL1 (false)
1924 {
1925  ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) );
1926  ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) );
1927 }
1928 
1930 {
1931 }
1932 
1934 {
1935  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
1936  {
1937  for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++)
1938  {
1939  m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
1940  }
1941  }
1942 }
1943 
1947 {
1948  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
1949  {
1950  for(UInt listId=0;listId<SCALING_LIST_NUM;listId++)
1951  {
1952  processDefaultMatrix(sizeId, listId);
1953  }
1954  }
1955 }
1960 {
1961  UInt defaultCounter=0;
1962 
1963  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
1964  {
1965  for(UInt listId=0;listId<SCALING_LIST_NUM;listId++)
1966  {
1967  if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix
1968  && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value
1969  {
1970  defaultCounter++;
1971  }
1972  }
1973  }
1974 
1975  return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true;
1976 }
1977 
1983 Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId )
1984 {
1985  ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
1986 }
1987 
1989 {
1990  Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries.
1991 
1992  for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep)
1993  {
1994  if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ?
1995  getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix
1996  && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value
1997  {
1998  setRefMatrixId(sizeId, listId, predListIdx);
1999  setScalingListPredModeFlag(sizeId, listId, false);
2000  return;
2001  }
2002  }
2003  setScalingListPredModeFlag(sizeId, listId, true);
2004 }
2005 
2006 static Void outputScalingListHelp(std::ostream &os)
2007 {
2008  os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n"
2009  "but their order is arbitrary.\n\n"
2010  "The matrices are specified by:\n"
2011  "<matrix name><unchecked data>\n"
2012  " <value>,<value>,<value>,....\n\n"
2013  " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n"
2014  " at least the number of entries for the matrix (superfluous entries are ignored).\n"
2015  " The <unchecked data> is text on the same line as the matrix that is not checked\n"
2016  " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n"
2017  " The values in the matrices are the absolute values (0-255), not the delta values as\n"
2018  " exchanged between the encoder and decoder\n\n"
2019  "The DC values (for matrix sizes larger than 8x8) are specified by:\n"
2020  "<matrix name>_DC<unchecked data>\n"
2021  " <value>\n";
2022 
2023  os << "The permitted matrix names are:\n";
2024  for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++)
2025  {
2026  for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++)
2027  {
2028  if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0))
2029  {
2030  os << " " << MatrixType[sizeIdc][listIdc] << '\n';
2031  }
2032  }
2033  }
2034 }
2035 
2037 {
2038  for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++)
2039  {
2040  const UInt size = min(8,4<<(sizeIdc));
2041  for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++)
2042  {
2043  if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0))
2044  {
2045  const Int *src = getScalingListAddress(sizeIdc, listIdc);
2046  os << (MatrixType[sizeIdc][listIdc]) << " =\n ";
2047  for(UInt y=0; y<size; y++)
2048  {
2049  for(UInt x=0; x<size; x++, src++)
2050  {
2051  os << std::setw(3) << (*src) << ", ";
2052  }
2053  os << (y+1<size?"\n ":"\n");
2054  }
2055  if(sizeIdc > SCALING_LIST_8x8)
2056  {
2057  os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n";
2058  }
2059  os << "\n";
2060  }
2061  }
2062  }
2063 }
2064 
2066 {
2067  static const Int LINE_SIZE=1024;
2068  FILE *fp = NULL;
2069  Char line[LINE_SIZE];
2070 
2071  if (pchFile == NULL)
2072  {
2073  fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n");
2074  outputScalingListHelp(std::cout);
2075  std::cout << "\n\nExample scaling list file using default values:\n\n";
2076  outputScalingLists(std::cout);
2077  exit (1);
2078  return true;
2079  }
2080  else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL)
2081  {
2082  fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile);
2083  return true;
2084  }
2085 
2086  for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++)
2087  {
2088  const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]);
2089 
2090  for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++)
2091  {
2092  Int * const src = getScalingListAddress(sizeIdc, listIdc);
2093 
2094  if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16
2095  {
2096  const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc);
2097  for(UInt i=0; i<size; i++)
2098  {
2099  src[i] = srcNextSmallerSize[i];
2100  }
2101  setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]);
2102  }
2103  else
2104  {
2105  {
2106  fseek(fp, 0, SEEK_SET);
2107  Bool bFound=false;
2108  while ((!feof(fp)) && (!bFound))
2109  {
2110  Char *ret = fgets(line, LINE_SIZE, fp);
2111  Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]);
2112  // This could be a match against the DC string as well, so verify it isn't
2113  if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL))
2114  {
2115  bFound=true;
2116  }
2117  }
2118  if (!bFound)
2119  {
2120  fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile);
2121  return true;
2122  }
2123  }
2124  for (UInt i=0; i<size; i++)
2125  {
2126  Int data;
2127  if (fscanf(fp, "%d,", &data)!=1)
2128  {
2129  fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
2130  return true;
2131  }
2132  if (data<0 || data>255)
2133  {
2134  fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
2135  return true;
2136  }
2137  src[i] = data;
2138  }
2139 
2140  //set DC value for default matrix check
2141  setScalingListDC(sizeIdc,listIdc,src[0]);
2142 
2143  if(sizeIdc > SCALING_LIST_8x8)
2144  {
2145  {
2146  fseek(fp, 0, SEEK_SET);
2147  Bool bFound=false;
2148  while ((!feof(fp)) && (!bFound))
2149  {
2150  Char *ret = fgets(line, LINE_SIZE, fp);
2151  Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]);
2152  if (findNamePosition!= NULL)
2153  {
2154  // This won't be a match against the non-DC string.
2155  bFound=true;
2156  }
2157  }
2158  if (!bFound)
2159  {
2160  fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile);
2161  return true;
2162  }
2163  }
2164  Int data;
2165  if (fscanf(fp, "%d,", &data)!=1)
2166  {
2167  fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp));
2168  return true;
2169  }
2170  if (data<0 || data>255)
2171  {
2172  fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
2173  return true;
2174  }
2175  //overwrite DC value when size of matrix is larger than 16x16
2176  setScalingListDC(sizeIdc,listIdc,data);
2177  }
2178  }
2179  }
2180  }
2181 // std::cout << "\n\nRead scaling lists of:\n\n";
2182 // outputScalingLists(std::cout);
2183 
2184  fclose(fp);
2185  return false;
2186 }
2187 
2188 
2195 {
2196  Int *src = 0;
2197  switch(sizeId)
2198  {
2199  case SCALING_LIST_4x4:
2200  src = g_quantTSDefault4x4;
2201  break;
2202  case SCALING_LIST_8x8:
2203  case SCALING_LIST_16x16:
2204  case SCALING_LIST_32x32:
2206  break;
2207  default:
2208  assert(0);
2209  src = NULL;
2210  break;
2211  }
2212  return src;
2213 }
2214 
2220 {
2221  ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
2222  setScalingListDC(sizeId,listId,SCALING_LIST_DC);
2223 }
2224 
2228 {
2229  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2230  {
2231  for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++)
2232  {
2233  //check default matrix?
2234  if(getScalingListDC(sizeId,listId) == 0)
2235  {
2236  processDefaultMatrix(sizeId, listId);
2237  }
2238  }
2239  }
2240 }
2241 
2243 : m_vpsMap(MAX_NUM_VPS)
2244 , m_spsMap(MAX_NUM_SPS)
2245 , m_ppsMap(MAX_NUM_PPS)
2246 , m_activeVPS()
2247 , m_activeSPS()
2248 {
2249  m_activeVPS.setVPSId(-1);
2250  m_activeSPS.setSPSId(-1);
2251 }
2252 
2253 
2255 {
2256 }
2257 
2261 {
2262  TComSPS *sps = m_spsMap.getPS(spsId);
2263  if (sps)
2264  {
2265  Int vpsId = sps->getVPSId();
2266  TComVPS *vps = m_vpsMap.getPS(vpsId);
2267  if (vps)
2268  {
2269  m_activeVPS = *(vps);
2270  m_activeSPS = *(sps);
2271  return true;
2272  }
2273  else
2274  {
2275  printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist.");
2276  }
2277  }
2278  else
2279  {
2280  printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message.");
2281  }
2282  return false;
2283 }
2284 
2288 {
2289  TComPPS *pps = m_ppsMap.getPS(ppsId);
2290  if (pps)
2291  {
2292  Int spsId = pps->getSPSId();
2293  if (!isIRAP && (spsId != m_activeSPS.getSPSId() ))
2294  {
2295  printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR.");
2296  return false;
2297  }
2298  TComSPS *sps = m_spsMap.getPS(spsId);
2299  if (sps)
2300  {
2301  Int vpsId = sps->getVPSId();
2302  if (!isIRAP && (vpsId != m_activeVPS.getVPSId() ))
2303  {
2304  printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR.");
2305  return false;
2306  }
2307  TComVPS *vps =m_vpsMap.getPS(vpsId);
2308  if (vps)
2309  {
2310  m_activeVPS = *(vps);
2311  m_activeSPS = *(sps);
2312  return true;
2313  }
2314  else
2315  {
2316  printf("Warning: tried to activate PPS that refers to a non-existing VPS.");
2317  }
2318  }
2319  else
2320  {
2321  printf("Warning: tried to activate a PPS that refers to a non-existing SPS.");
2322  }
2323  }
2324  else
2325  {
2326  printf("Warning: tried to activate non-existing PPS.");
2327  }
2328  return false;
2329 }
2330 
2332  : m_profileSpace (0)
2333  , m_tierFlag (Level::MAIN)
2334  , m_profileIdc (Profile::NONE)
2335  , m_levelIdc (Level::NONE)
2336  , m_progressiveSourceFlag (false)
2337  , m_interlacedSourceFlag (false)
2338  , m_nonPackedConstraintFlag(false)
2339  , m_frameOnlyConstraintFlag(false)
2340 {
2342 }
2343 
2345 {
2348 }
2349 
2350 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData)
2351 {
2352  if (!bChanged)
2353  {
2354  if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0))
2355  {
2356  bChanged=true;
2357  }
2358  else if (pOldData!=0 && pOldData!=0)
2359  {
2360  // compare the two
2361  if (pOldData->size() != pOldData->size())
2362  {
2363  bChanged=true;
2364  }
2365  else
2366  {
2367  const UChar *pNewDataArray=&(*pNewData)[0];
2368  const UChar *pOldDataArray=&(*pOldData)[0];
2369  if (memcmp(pOldDataArray, pNewDataArray, pOldData->size()))
2370  {
2371  bChanged=true;
2372  }
2373  }
2374  }
2375  }
2376 }
2377 
Void setRefPicList(TComList< TComPic * > &rcListPic, Bool checkNumPocTotalCurr=false)
Definition: TComSlice.cpp:322
Bool m_profileCompatibilityFlag[32]
Definition: TComSlice.h:190
ChromaQpAdj m_ChromaQpAdjTableIncludingNullEntry[1+6]
Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise.
Definition: TComSlice.h:993
Int getNumberOfPositivePictures() const
Definition: TComSlice.h:109
Void resetWpScaling()
reset Default WP tables settings : no weight.
Definition: TComSlice.cpp:1472
Bool getPicOutputFlag() const
Definition: TComSlice.h:1320
Bool m_bLMvdL1Zero
Definition: TComSlice.h:1290
UInt m_saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE]
Definition: TComSlice.h:1005
Void setList1IdxToList0Idx()
Definition: TComSlice.cpp:305
virtual ~TComSPS()
Definition: TComSlice.cpp:1614
Bool m_usedByCurrPicLtSPSFlag[33]
Definition: TComSlice.h:775
Void checkPredMode(UInt sizeId, UInt listId)
Definition: TComSlice.cpp:1988
virtual ~ParameterSetManager()
Definition: TComSlice.cpp:2254
Void setUsed(Int bufferNum, Bool used)
Definition: TComSlice.cpp:1800
Int getSPSId() const
Definition: TComSlice.h:1043
T * getPS(Int psId)
Definition: TComSlice.h:1607
SBAC decoder class (header)
Void setSPSId(Int i)
Definition: TComSlice.h:813
Int m_list1IdxToList0Idx[16]
Definition: TComSlice.h:1227
virtual ~TComPPS()
Definition: TComSlice.cpp:1772
Void extendPicBorder()
Definition: TComPicYuv.cpp:191
Int * getScalingListAddress(UInt sizeId, UInt listId)
get matrix coefficient
Definition: TComSlice.h:155
UInt m_ltRefPicPocLsbSps[33]
Definition: TComSlice.h:774
Int m_aiRefPOCList[NUM_REF_PIC_LIST_01][16+1]
Definition: TComSlice.h:1236
SliceType getSliceType() const
Definition: TComSlice.h:1337
Void setFixedPicRateFlag(Int layer, Bool flag)
Definition: TComSlice.h:358
Bool getTemporalLayerNonReferenceFlag()
Definition: TComSlice.h:1516
Int getSPSId() const
Definition: TComSlice.h:812
Bool checkDefaultScalingList()
Definition: TComSlice.cpp:1959
Void printDeltaPOC() const
Definition: TComSlice.cpp:1903
Void processRefMatrix(UInt sizeId, UInt listId, UInt refListId)
Definition: TComSlice.cpp:1983
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
static const Int m_winUnitY[3+1]
Definition: TComSlice.h:795
Int m_iPOC
Definition: TComSlice.h:1206
Defines constants, macros and tool parameters.
#define MAX_NUM_VPS
Definition: TypeDef.h:133
void Void
Definition: TypeDef.h:285
static const Int m_winUnitX[3+1]
Definition: TComSlice.h:794
Void setDuCpbSizeScale(UInt value)
Definition: TComSlice.h:346
Void setScalingListPredModeFlag(UInt sizeId, UInt listId, Bool bIsDPCM)
Definition: TComSlice.h:168
Int m_iLastIDR
Definition: TComSlice.h:1207
Int getUsed(Int bufferNum) const
Definition: TComSlice.cpp:1815
const Char * MatrixType[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:586
Void setNumberOfNegativePictures(Int number)
Definition: TComSlice.h:106
Int getNumRpsCurrTempList() const
Definition: TComSlice.cpp:481
Void decodingRefreshMarking(Int &pocCRA, Bool &bRefreshPending, TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:599
Int m_iDepth
Definition: TComSlice.h:1238
Bool xParseScalingList(Char *pchFile)
Definition: TComSlice.cpp:2065
Int getVPSId() const
Definition: TComSlice.h:810
Void setHrdParameters(UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess)
Definition: TComSlice.cpp:1625
UInt m_sliceArgument
Definition: TComSlice.h:1267
NalUnitType getAssociatedIRAPType() const
Definition: TComSlice.h:1336
Bool m_subLayerProfilePresentFlag[7-1]
Definition: TComSlice.h:250
#define NULL
Definition: CommonDef.h:100
union ChromaQpAdj::@2 u
UInt getBitsForPOC() const
Definition: TComSlice.h:857
TComSlice * getSlice(Int i)
Definition: TComPic.h:103
Void checkDcOfMatrix()
Definition: TComSlice.cpp:2227
Bool m_bCheckLDC
Definition: TComSlice.h:1230
Bool m_bRefenced
Definition: TComSlice.h:1241
don't use slices / slice segments
Definition: TypeDef.h:564
slice header and SPS class (header)
SliceConstraint m_sliceSegmentMode
Definition: TComSlice.h:1271
char Char
Definition: TypeDef.h:291
TComSlice * getSlice(UInt i)
Definition: TComPicSym.h:126
Void setDuCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:378
unsigned int UInt
Definition: TypeDef.h:297
Void setDeltaPOC(Int bufferNum, Int deltaPOC)
Definition: TComSlice.cpp:1805
UInt m_colRefIdx
Definition: TComSlice.h:1257
Void setRefPOCList()
Definition: TComSlice.cpp:293
Bool isStepwiseTemporalLayerSwitchingPointCandidate(TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:826
#define MAX_TLAYER
max number of temporal layer
Definition: CommonDef.h:192
Bool getIsLongTerm() const
Definition: TComPic.h:97
Bool isReferenced() const
Definition: TComSlice.h:1368
Void destroy()
Definition: TComSlice.h:140
Void checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int &pocCRA, NalUnitType &associatedIRAPType, TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:539
Int m_iSliceQp
Definition: TComSlice.h:1217
UInt m_numReorderPics[7]
Definition: TComSlice.h:442
Int m_deblockingFilterTcOffsetDiv2
Definition: TComSlice.h:1226
Void setCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:352
Void getWpAcDcParam(WPACDCParam *&wp)
get AC and DC values for weighted pred
Definition: TComSlice.cpp:1449
Void checkColRefIdx(UInt curSliceIdx, TComPic *pic)
Definition: TComSlice.cpp:513
picture class (header)
Int g_quantTSDefault4x4[4 *4]
Definition: TComRom.cpp:646
Int * getScalingListDefaultAddress(UInt sizeId, UInt listId)
get default matrix coefficient
Definition: TComSlice.cpp:2194
Void initEqualRef()
Definition: TComSlice.cpp:499
Void initWpScaling(const TComSPS *sps)
init WP table
Definition: TComSlice.cpp:1492
virtual ~TComReferencePictureSet()
Definition: TComSlice.cpp:1796
Int getScalingListDC(UInt sizeId, UInt listId) const
get DC value
Definition: TComSlice.h:166
Bool m_LFCrossSliceBoundaryFlag
Definition: TComSlice.h:1292
Int getNumRefIdx(RefPicList e) const
Definition: TComSlice.h:1353
Void setTimeScale(UInt value)
Definition: TComSlice.h:412
Void setNalHrdParametersPresentFlag(Bool flag)
Definition: TComSlice.h:320
UInt m_sliceCurStartCtuTsAddr
Definition: TComSlice.h:1268
Bool getRefPicListModificationFlagL1() const
Definition: TComSlice.h:968
Bool getRapPicFlag() const
Definition: TComSlice.cpp:182
Void setCpbSizeScale(UInt value)
Definition: TComSlice.h:344
TComVUI * getVuiParameters()
Definition: TComSlice.h:939
Void applyReferencePictureSet(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *RPSList)
Definition: TComSlice.cpp:1015
Void setDuCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:332
Bool m_deblockingFilterDisable
Definition: TComSlice.h:1223
Void setInterRPSPrediction(Bool flag)
Definition: TComSlice.h:113
TComRefPicListModification m_RefPicListModification
Definition: TComSlice.h:1214
TComPicYuv * getPicYuvRec()
Definition: TComPic.h:109
Int getRefIdc(Int bufferNum) const
get the reference idc value at uiBufferNum
Definition: TComSlice.cpp:1857
ParameterSetMap< TComVPS > m_vpsMap
Definition: TComSlice.h:1661
virtual ~TComVPS()
Definition: TComSlice.cpp:1543
Int getDeltaRIdxMinus1() const
Definition: TComSlice.h:116
Bool m_cabacInitFlag
Definition: TComSlice.h:1288
Double m_lambdas[MAX_NUM_COMPONENT]
Definition: TComSlice.h:1260
Void setPOC(Int bufferNum, Int deltaPOC)
Definition: TComSlice.cpp:1835
#define SCALING_LIST_NUM
list number for quantization matrix
Definition: TComRom.h:215
Void setRefIdc(Int bufferNum, Int refIdc)
set the reference idc value at uiBufferNum entry to the value of iRefIdc
Definition: TComSlice.cpp:1851
Int m_iSliceQpBase
Definition: TComSlice.h:1220
#define MAX_UINT
max. value of unsigned 32-bit integer
Definition: CommonDef.h:115
virtual ~TComRefPicListModification()
Definition: TComSlice.cpp:1929
Void setNumberOfPositivePictures(Int number)
Definition: TComSlice.h:108
Void setDpbOutputDelayDuLengthMinus1(UInt value)
Definition: TComSlice.h:338
Void setDeltaRPS(Int x)
Definition: TComSlice.h:117
UInt m_maxNumMergeCand
Definition: TComSlice.h:1258
#define SCALING_LIST_DC
default DC value
Definition: TComRom.h:222
WPACDCParam m_weightACDCParam[MAX_NUM_COMPONENT]
Definition: TComSlice.h:1284
#define MAX_NUM_SPS
Definition: TypeDef.h:134
Bool m_deltaPocMSBPresentFlag[16]
Definition: TComSlice.h:83
Void setScalingListDC(UInt sizeId, UInt listId, UInt u)
set DC value
Definition: TComSlice.h:165
Void copySliceInfo(TComSlice *pcSliceSrc)
Definition: TComSlice.cpp:680
Bool getUsedByCurr() const
Definition: TComPic.h:95
bool Bool
Definition: TypeDef.h:286
Int m_deblockingFilterBetaOffsetDiv2
Definition: TComSlice.h:1225
UInt m_sliceSegmentCurStartCtuTsAddr
Definition: TComSlice.h:1273
Bool m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][16+1]
Definition: TComSlice.h:1237
Bool m_nextSliceSegment
Definition: TComSlice.h:1276
Bool getSubPicCpbParamsPresentFlag() const
Definition: TComSlice.h:327
Void setBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:373
#define ADAPTIVE_QP_SELECTION
G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection.
Definition: TypeDef.h:148
Void setVclHrdParametersPresentFlag(Bool flag)
Definition: TComSlice.h:323
Int getAssociatedIRAPPOC() const
Definition: TComSlice.h:1334
Void setPicDurationInTcMinus1(Int layer, UInt value)
Definition: TComSlice.h:364
Void setCbrFlag(Int layer, Int cpbcnt, Int nalOrVcl, Bool value)
Definition: TComSlice.h:382
Bool getRefPicListModificationFlagL0() const
Definition: TComSlice.h:966
PPS class.
Definition: TComSlice.h:977
Void setVPSId(Int i)
Definition: TComSlice.h:477
Bool m_bTLayerSwitchingFlag
Definition: TComSlice.h:1264
TComPic * xGetLongTermRefPic(TComList< TComPic * > &rcListPic, Int poc, Bool pocHasMsb)
Definition: TComSlice.cpp:250
UInt m_uiTLayer
Definition: TComSlice.h:1263
WPScalingParam m_weightPredTable[NUM_REF_PIC_LIST_01][16][MAX_NUM_COMPONENT]
Definition: TComSlice.h:1283
UInt uiLog2WeightDenom
Definition: TComSlice.h:1179
TComRPSList m_RPSList
Definition: TComSlice.h:743
Int getDeltaPOC(Int bufferNum) const
Definition: TComSlice.cpp:1820
Int g_quantIntraDefault8x8[8 *8]
Definition: TComRom.cpp:654
Void checkLeadingPictureRestrictions(TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:846
Int getDeltaRPS() const
Definition: TComSlice.h:118
static ChannelType toChannelType(const ComponentID id)
Bool m_subLayerLevelPresentFlag[7-1]
Definition: TComSlice.h:251
Int m_qpBDOffset[MAX_NUM_CHANNEL_TYPE]
Definition: TComSlice.h:760
Void initWpAcDcParam()
init AC and DC values for weighted pred
Definition: TComSlice.cpp:1455
Void processDefaultMatrix(UInt sizeId, UInt listId)
Definition: TComSlice.cpp:2219
Int m_numReorderPics[7]
Definition: TComSlice.h:746
reference list 0
Definition: TypeDef.h:417
Void setUsedByCurr(Bool bUsed)
Definition: TComPic.h:96
Void createExplicitReferencePictureSetFromReference(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess=0, Bool bUseRecoveryPoint=false)
Definition: TComSlice.cpp:1320
Int m_iSliceChromaQpDelta[MAX_NUM_COMPONENT]
Definition: TComSlice.h:1234
RefPicList
reference list index
Definition: TypeDef.h:415
Bool getColFromL0Flag() const
Definition: TComSlice.h:1358
TComPicSym * getPicSym()
Definition: TComPic.h:102
Void setCheckLTMSBPresent(Int bufferNum, Bool b)
Definition: TComSlice.cpp:1845
unsigned char UChar
Definition: TypeDef.h:293
UInt m_sliceIdx
Definition: TComSlice.h:1270
Bool getCheckLTMSBPresent(Int bufferNum) const
Definition: TComSlice.cpp:1840
Bool getUseHighPrecisionPredictionWeighting() const
Definition: TComSlice.h:889
Bool getNoOutputPriorPicsFlag() const
Definition: TComSlice.h:1454
Void setNumberOfPictures(Int numberOfPictures)
Definition: TComSlice.cpp:1810
Void setCpbCntMinus1(Int layer, UInt value)
Definition: TComSlice.h:370
UInt m_uiMaxDecPicBuffering[7]
Definition: TComSlice.h:786
TComPic * xGetRefPic(TComList< TComPic * > &rcListPic, Int poc)
Definition: TComSlice.cpp:233
#define MAX_NUM_PPS
Definition: TypeDef.h:135
UInt m_uiPCMBitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComSlice.h:768
Bool m_deblockingFilterOverrideFlag
Definition: TComSlice.h:1224
#define MAX_NUM_REF
max. number of entries in picture reference list
Definition: CommonDef.h:113
Void setTLayerInfo(UInt uiTLayer)
Definition: TComSlice.cpp:798
reference list 1
Definition: TypeDef.h:418
#define MAX_MATRIX_COEF_NUM
max coefficient number for quantization matrix
Definition: TComRom.h:218
Int getPOC() const
Definition: TComSlice.h:1338
Int m_deltaPOCMSBCycleLT[16]
Definition: TComSlice.h:82
Int getPOC() const
Definition: TComPic.h:104
TimingInfo * getTimingInfo()
Definition: TComSlice.h:717
TComPic * m_apcRefPicList[NUM_REF_PIC_LIST_01][16+1]
Definition: TComSlice.h:1235
TComReferencePictureSet * m_pcRPS
Definition: TComSlice.h:1211
Context-adaptive entropy encoder class (header)
SliceType m_eSliceType
Definition: TComSlice.h:1216
Int g_bitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:548
ParameterSetMap< TComSPS > m_spsMap
Definition: TComSlice.h:1665
ParameterSetMap< TComPPS > m_ppsMap
Definition: TComSlice.h:1666
Int m_uiBitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComSlice.h:759
Void setDpbOutputDelayLengthMinus1(UInt value)
Definition: TComSlice.h:355
Void setIsLongTerm(Bool lt)
Definition: TComPic.h:98
Bool m_abEqualRef[NUM_REF_PIC_LIST_01][16][16]
Definition: TComSlice.h:1262
Int getRefPOC(RefPicList e, Int iRefIdx)
Definition: TComSlice.h:1356
Void setSubPicCpbParamsInPicTimingSEIFlag(Bool flag)
Definition: TComSlice.h:335
Void setNumUnitsInTick(UInt value)
Definition: TComSlice.h:409
std::vector< UInt > m_substreamSizes
Definition: TComSlice.h:1286
Int m_iSliceQpDelta
Definition: TComSlice.h:1233
Void setCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:376
Bool isTemporalLayerSwitchingPoint(TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:805
Int getNumberOfNegativePictures() const
Definition: TComSlice.h:107
Void setBitRateScale(UInt value)
Definition: TComSlice.h:341
TComPic * m_pcPic
Definition: TComSlice.h:1247
UInt getTLayer() const
Definition: TComPic.h:92
Void setRefMatrixId(UInt sizeId, UInt listId, UInt u)
set reference matrix ID
Definition: TComSlice.h:159
Int getNumRefIdc() const
Definition: TComSlice.h:120
Void createRPSList(Int numRPS)
Definition: TComSlice.cpp:1619
Void setDuBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:380
Void setTimingInfoPresentFlag(Bool flag)
Definition: TComSlice.h:406
Int getPOC(Int bufferNum) const
Definition: TComSlice.cpp:1830
Void setLowDelayHrdFlag(Int layer, Bool flag)
Definition: TComSlice.h:367
UInt g_scalingListSize[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:678
UInt getRefPicSetIdxL1(UInt idx) const
Definition: TComSlice.h:972
Int getNumberOfPictures() const
Definition: TComSlice.cpp:1825
Void getWpScaling(RefPicList e, Int iRefIdx, WPScalingParam *&wp)
get tables for weighted prediction
Definition: TComSlice.cpp:1465
int Int
Definition: TypeDef.h:296
const char data[10]
Void setCheckLTMSBPresent(Bool b)
Definition: TComPic.h:99
SliceType m_encCABACTableIdx
Definition: TComSlice.h:1296
Bool m_bFinalized
Definition: TComSlice.h:1279
static Void outputScalingListHelp(std::ostream &os)
Definition: TComSlice.cpp:2006
ComponentID
Definition: TypeDef.h:368
const Double * getLambdas() const
Definition: TComSlice.h:1409
Void setSubPicCpbParamsPresentFlag(Bool flag)
Definition: TComSlice.h:326
Void setTickDivisorMinus2(UInt value)
Definition: TComSlice.h:329
Void setDeltaRIdxMinus1(Int x)
Definition: TComSlice.h:115
NalUnitType
Definition: CommonDef.h:218
Void setLambdas(const Double lambdas[MAX_NUM_COMPONENT])
Definition: TComSlice.h:1408
Bool getReconMark() const
Definition: TComPic.h:132
UInt getCpbCntMinus1(Int layer) const
Definition: TComSlice.h:371
std::vector< Int > m_scalingListCoef[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
quantization matrix
Definition: TComSlice.h:182
Bool m_nextSlice
Definition: TComSlice.h:1275
Int getNumberOfLongtermPictures() const
Definition: TComSlice.h:111
Bool m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE]
Definition: TComSlice.h:1203
#define MRG_MAX_NUM_CANDS
Definition: CommonDef.h:186
Bool activatePPS(Int ppsId, Bool isIRAP)
Definition: TComSlice.cpp:2287
UInt m_RefPicSetIdxL0[REF_PIC_LIST_NUM_IDX]
Definition: TComSlice.h:956
Void create(Int numberOfEntries)
Definition: TComSlice.h:139
Int g_quantInterDefault8x8[8 *8]
Definition: TComRom.cpp:666
Int m_aiNumRefIdx[NUM_REF_PIC_LIST_01]
Definition: TComSlice.h:1228
UInt getColRefIdx() const
Definition: TComSlice.h:1359
Bool getInterRPSPrediction() const
Definition: TComSlice.h:114
UInt m_uiMaxLatencyIncrease[7]
Definition: TComSlice.h:444
Bool m_enableTMVPFlag
Definition: TComSlice.h:1294
static Int m_prevTid0POC
Definition: TComSlice.h:1210
UInt m_uiMaxDecPicBuffering[7]
Definition: TComSlice.h:443
Void outputScalingLists(std::ostream &os) const
Definition: TComSlice.cpp:2036
Reference Picture Set class.
Definition: TComSlice.h:65
NalUnitType getNalUnitType() const
Definition: TComSlice.h:1372
Bool activateSPSWithSEI(Int SPSId)
Definition: TComSlice.cpp:2260
slice header class
Definition: TComSlice.h:1198
virtual ~TComSlice()
Definition: TComSlice.cpp:150
Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector< UChar > *pOldData, const std::vector< UChar > *pNewData)
Definition: TComSlice.cpp:2350
UInt getTLayer() const
Definition: TComSlice.h:1434
Bool m_ChromaQpAdjEnabled
Definition: TComSlice.h:1222
static Void sortPicList(TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:193
UInt m_sliceCurEndCtuTsAddr
Definition: TComSlice.h:1269
Int getVPSId() const
Definition: TComSlice.h:476
UInt m_sliceSegmentArgument
Definition: TComSlice.h:1272
Void initSlice()
Definition: TComSlice.cpp:155
Void setDefaultScalingList()
Definition: TComSlice.cpp:1946
Bool m_useResidualDPCM[NUMBER_OF_RDPCM_SIGNALLING_MODES]
Definition: TComSlice.h:767
UInt m_uiMaxLatencyIncrease[7]
Definition: TComSlice.h:787
Void setReferenced(Bool b)
Definition: TComSlice.h:1367
const Char * MatrixType_DC[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:622
Int checkThatAllRefPicsAreAvailable(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess=0, Bool bUseRecoveryPoint=false)
Definition: TComSlice.cpp:1094
SliceConstraint m_sliceMode
Definition: TComSlice.h:1266
UInt m_RefPicSetIdxL1[REF_PIC_LIST_NUM_IDX]
Definition: TComSlice.h:957
NalUnitType m_eNalUnitType
Nal unit type for the slice.
Definition: TComSlice.h:1215
TComHRD * getHrdParameters()
Definition: TComSlice.h:714
Bool getVuiParametersPresentFlag() const
Definition: TComSlice.h:937
Void setInitialCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:349
UInt m_sliceSegmentCurEndCtuTsAddr
Definition: TComSlice.h:1274
Void setNumRefIdc(Int x)
Definition: TComSlice.h:119
UInt getRefPicSetIdxL0(UInt idx) const
Definition: TComSlice.h:970
Void setCurrSliceIdx(UInt i)
Definition: TComPic.h:138
const TComSPS * getSPS() const
Definition: TComSlice.h:1306
SPS class.
Definition: TComSlice.h:722
struct ChromaQpAdj::@2::@3 comp
Bool m_colFromL0Flag
Definition: TComSlice.h:1251