HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TDecTop.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-2017, 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 "NALread.h"
39 #include "TDecTop.h"
40 #include "TDecConformance.h"
41 
44 
46  : m_iMaxRefPicNum(0)
47  , m_associatedIRAPType(NAL_UNIT_INVALID)
48  , m_pocCRA(0)
49  , m_pocRandomAccess(MAX_INT)
50  , m_cListPic()
51  , m_parameterSetManager()
52  , m_apcSlicePilot(NULL)
53  , m_SEIs()
54  , m_cPrediction()
55  , m_cTrQuant()
56  , m_cGopDecoder()
57  , m_cSliceDecoder()
58  , m_cCuDecoder()
59  , m_cEntropyDecoder()
60  , m_cCavlcDecoder()
61  , m_cSbacDecoder()
62  , m_cBinCABAC()
63  , m_seiReader()
64  , m_cLoopFilter()
65  , m_cSAO()
66  , m_pcPic(NULL)
67  , m_prevPOC(MAX_INT)
68  , m_prevTid0POC(0)
69  , m_bFirstSliceInPicture(true)
70  , m_bFirstSliceInSequence(true)
71  , m_prevSliceSkipped(false)
72  , m_skippedPOC(0)
73  , m_bFirstSliceInBitstream(true)
74  , m_lastPOCNoOutputPriorPics(-1)
75  , m_isNoOutputPriorPics(false)
76  , m_craNoRaslOutputFlag(false)
78  , m_forceDecodeBitDepth(8)
79 #endif
80  , m_pDecodedSEIOutputStream(NULL)
81  , m_warningMessageSkipPicture(false)
83  , m_tmctsCheckEnabled(false)
84 #endif
85  , m_prefixSEINALUs()
86 {
87 #if ENC_DEC_TRACE
88  if (g_hTrace == NULL)
89  {
90  g_hTrace = fopen( "TraceDec.txt", "wb" );
91  }
92  g_bJustDoIt = g_bEncDecTraceDisable;
93  g_nSymbolCounter = 0;
94 #endif
95 }
96 
98 {
99 #if ENC_DEC_TRACE
100  if (g_hTrace != stdout)
101  {
102  fclose( g_hTrace );
103  }
104 #endif
105  while (!m_prefixSEINALUs.empty())
106  {
107  delete m_prefixSEINALUs.front();
108  m_prefixSEINALUs.pop_front();
109  }
110 }
111 
113 {
116  m_uiSliceIdx = 0;
117 }
118 
120 {
122 
123  delete m_apcSlicePilot;
125 
127 }
128 
130 {
131  // initialize ROM
132  initROM();
135 #if MCTS_ENC_CHECK
137 #else
139 #endif
140 }
141 
143 {
144  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
145  Int iSize = Int( m_cListPic.size() );
146 
147  for (Int i = 0; i < iSize; i++ )
148  {
149  TComPic* pcPic = *(iterPic++);
150  pcPic->destroy();
151 
152  delete pcPic;
153  pcPic = NULL;
154  }
155 
156  m_cSAO.destroy();
157 
159 
160  // destroy ROM
161  destroyROM();
162 }
163 
164 Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
165 {
166  m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
167  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
168  {
169  rpcPic = new TComPic();
170 
171 #if REDUCED_ENCODER_MEMORY
172  rpcPic->create ( sps, pps, false, true);
173 #else
174  rpcPic->create ( sps, pps, true);
175 #endif
176 
177  m_cListPic.pushBack( rpcPic );
178 
179  return;
180  }
181 
182  Bool bBufferIsAvailable = false;
183  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
184  while (iterPic != m_cListPic.end())
185  {
186  rpcPic = *(iterPic++);
187  if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false)
188  {
189  rpcPic->setOutputMark(false);
190  bBufferIsAvailable = true;
191  break;
192  }
193 
194  if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false)
195  {
196  rpcPic->setOutputMark(false);
197  rpcPic->setReconMark( false );
198  rpcPic->getPicYuvRec()->setBorderExtension( false );
199  bBufferIsAvailable = true;
200  break;
201  }
202  }
203 
204  if ( !bBufferIsAvailable )
205  {
206  //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer.
207  m_iMaxRefPicNum++;
208  rpcPic = new TComPic();
209  m_cListPic.pushBack( rpcPic );
210  }
211  rpcPic->destroy();
212 #if REDUCED_ENCODER_MEMORY
213  rpcPic->create ( sps, pps, false, true);
214 #else
215  rpcPic->create ( sps, pps, true);
216 #endif
217 }
218 
220 {
221  if (!m_pcPic)
222  {
223  /* nothing to deblock */
224  return;
225  }
226 
227  TComPic* pcPic = m_pcPic;
228 
229  // Execute Deblock + Cleanup
230 
232 
233  TComSlice::sortPicList( m_cListPic ); // sorting for application output
234  poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
235  rpcListPic = &m_cListPic;
237  m_bFirstSliceInPicture = true;
238 
239  return;
240 }
241 
243 {
244  if (!pcListPic || !m_isNoOutputPriorPics)
245  {
246  return;
247  }
248 
249  TComList<TComPic*>::iterator iterPic = pcListPic->begin();
250 
251  while (iterPic != pcListPic->end())
252  {
253  TComPic* pcPicTmp = *(iterPic++);
254  if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
255  {
256  pcPicTmp->setOutputMark(false);
257  }
258  }
259 }
260 
262 {
263  printf("\ninserting lost poc : %d\n",iLostPoc);
264  TComPic *cFillPic;
266  cFillPic->getSlice(0)->initSlice();
267 
268  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
269  Int closestPoc = 1000000;
270  while ( iterPic != m_cListPic.end())
271  {
272  TComPic * rpcPic = *(iterPic++);
273  if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
274  {
275  closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc);
276  }
277  }
278  iterPic = m_cListPic.begin();
279  while ( iterPic != m_cListPic.end())
280  {
281  TComPic *rpcPic = *(iterPic++);
282  if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
283  {
284  printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC());
285  rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec());
286  break;
287  }
288  }
289  cFillPic->setCurrSliceIdx(0);
290  for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++)
291  {
292  cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr);
293  }
294  cFillPic->getSlice(0)->setReferenced(true);
295  cFillPic->getSlice(0)->setPOC(iLostPoc);
296  xUpdatePreviousTid0POC(cFillPic->getSlice(0));
297  cFillPic->setReconMark(true);
298  cFillPic->setOutputMark(true);
300  {
301  m_pocRandomAccess = iLostPoc;
302  }
303 }
304 
305 
307 {
309  {
310  const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
311  assert (pps != 0);
312 
313  const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value
314  assert (sps != 0);
315 
318 
320  {
321  printf ("Parameter set activation failed!");
322  assert (0);
323  }
324 
326 #if MCTS_ENC_CHECK
328 #endif
329 
330 #if RExt__HIGH_BIT_DEPTH_SUPPORT==0
332  {
333  printf("High bit depth support must be enabled at compile-time in order to decode this bitstream\n");
334  assert (0);
335  exit(1);
336  }
337 #endif
338 
339  // NOTE: globals were set up here originally. You can now use:
340  // g_uiMaxCUDepth = sps->getMaxTotalCUDepth();
341  // g_uiAddCUDepth = sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize()
342 
343  // Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use.
344  xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer());
346 
347  // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
348  assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
350 
351  // we now have a real slice:
353 
354  // Update the PPS and SPS pointers with the ones of the picture.
355  pps=pSlice->getPPS();
356  sps=pSlice->getSPS();
357 
358  // Initialise the various objects for the new set of settings
362 
363 
364  Bool isField = false;
365  Bool isTopField = false;
366 
367  if(!m_SEIs.empty())
368  {
369  // Check if any new Picture Timing SEI has arrived
370  SEIMessages pictureTimingSEIs = getSeisByType(m_SEIs, SEI::PICTURE_TIMING);
371  if (pictureTimingSEIs.size()>0)
372  {
373  SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
374  isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 10) || (pictureTiming->m_picStruct == 11) || (pictureTiming->m_picStruct == 12);
375  isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11);
376  }
377  }
378 
379  //Set Field/Frame coding mode
380  m_pcPic->setField(isField);
381  m_pcPic->setTopField(isTopField);
382 
383  // transfer any SEI messages that have been received to the picture
385  m_SEIs.clear();
386 
387  // Recursive structure
389 #if MCTS_ENC_CHECK
391 #else
393 #endif
394  m_cTrQuant.init ( sps->getMaxTrSize() );
395 
397  }
398  else
399  {
400  // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
402  assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
404 
405  TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice.
406 
407  const TComSPS *sps = pSlice->getSPS();
408  const TComPPS *pps = pSlice->getPPS();
409 
410  // check that the current active PPS has not changed...
412  {
413  printf("Error - a new SPS has been decoded while processing a picture\n");
414  exit(1);
415  }
417  {
418  printf("Error - a new PPS has been decoded while processing a picture\n");
419  exit(1);
420  }
421 
423 #if MCTS_ENC_CHECK
425 #endif
426  // Check if any new SEI has arrived
427  if(!m_SEIs.empty())
428  {
429  // Currently only decoding Unit SEI message occurring between VCL NALUs copied
430  SEIMessages &picSEI = m_pcPic->getSEIs();
432  picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
434  }
435  }
436 }
437 
438 
440 {
441  while (!m_prefixSEINALUs.empty())
442  {
443  // do nothing?
444  printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n");
445  delete m_prefixSEINALUs.front();
446  }
447  // TODO: discard following suffix SEIs as well?
448 }
449 
450 
452 {
453  while (!m_prefixSEINALUs.empty())
454  {
455  InputNALUnit &nalu=*m_prefixSEINALUs.front();
457  delete m_prefixSEINALUs.front();
458  m_prefixSEINALUs.pop_front();
459  }
460 }
461 
462 #if MCTS_ENC_CHECK
464 {
466  {
468  for (SEIMessages::iterator it = mctsSEIs.begin(); it != mctsSEIs.end(); it++)
469  {
472  {
473  printf("cannot (yet) check Temporal constrained MCTS if each_tile_one_tile_set_flag is not enabled\n");
474  exit(1);
475  }
476  else
477  {
478  printf("MCTS check enabled!\n");
480  }
481  }
482  }
483 }
484 #endif
485 
486 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
487 {
488  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
489  // it is not associated with picture, sps or pps structures.
490 
492  {
493  m_uiSliceIdx = 0;
494  }
495  else
496  {
498  }
500 
508  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
510 
511 #if ENC_DEC_TRACE
512  const UInt64 originalSymbolCount = g_nSymbolCounter;
513 #endif
514 
516 
517  // set POC for dependent slices in skipped pictures
519  {
521  }
522 
524 
527 
528  //For inference of NoOutputOfPriorPicsFlag
530  {
534  {
536  }
537  //the inference for NoOutputPriorPicsFlag
539  {
541  {
543  }
544  }
545  else
546  {
548  }
549 
551  {
553  }
554  }
556  {
558  m_isNoOutputPriorPics = true;
559  }
560  else
561  {
562  m_isNoOutputPriorPics = false;
563  }
564 
565  //For inference of PicOutputFlag
567  {
568  if ( m_craNoRaslOutputFlag )
569  {
571  }
572  }
573 
574  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
575  {
577  assert (pps != 0);
579  assert (sps != 0);
580  Int iMaxPOClsb = 1 << sps->getBitsForPOC();
581  m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
583  }
584 
585  // Skip pictures due to random access
586 
587  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
588  {
589  m_prevSliceSkipped = true;
591  return false;
592  }
593  // Skip TFD pictures associated with BLA/BLANT pictures
594  if (isSkipPictureForBLA(iPOCLastDisplay))
595  {
596  m_prevSliceSkipped = true;
598  return false;
599  }
600 
601  // clear previous slice skipped flag
602  m_prevSliceSkipped = false;
603 
604  //we should only get a different poc for a new picture (with CTU address==0)
606  {
607  printf ("Warning, the first slice of a picture might have been lost!\n");
608  }
609 
610  // exit when a new picture is found
612  {
614  {
616 #if ENC_DEC_TRACE
617  //rewind the trace counter since we didn't actually decode the slice
618  g_nSymbolCounter = originalSymbolCount;
619 #endif
620  return true;
621  }
623  }
624 
625  //detect lost reference picture and insert copy of earlier frame.
626  {
627  Int lostPoc;
629  {
630  xCreateLostPicture(lostPoc-1);
631  }
632  }
633 
635  {
637  }
638 
639  // actual decoding starts here
641 
642 
644 
646  {
648  }
649 
650  m_bFirstSliceInSequence = false;
651  m_bFirstSliceInBitstream = false;
652 
653  // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
654  // Now, having set up the maps, convert them to the correct form.
657  if(!pcSlice->getDependentSliceSegmentFlag())
658  {
661  }
662 
664 
665  if (!pcSlice->getDependentSliceSegmentFlag())
666  {
667  pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
668  // Set reference list
669  pcSlice->setRefPicList( m_cListPic, true );
670 
671  // For generalized B
672  // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
673  if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
674  {
675  Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
676  pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx );
677 
678  for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
679  {
680  pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
681  }
682  }
683  if (!pcSlice->isIntra())
684  {
685  Bool bLowDelay = true;
686  Int iCurrPOC = pcSlice->getPOC();
687  Int iRefIdx = 0;
688 
689  for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
690  {
691  if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
692  {
693  bLowDelay = false;
694  }
695  }
696  if (pcSlice->isInterB())
697  {
698  for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
699  {
700  if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
701  {
702  bLowDelay = false;
703  }
704  }
705  }
706 
707  pcSlice->setCheckLDC(bLowDelay);
708  }
709 
710  //---------------
711  pcSlice->setRefPOCList();
712  }
713 
715  if(pcSlice->getSPS()->getScalingListFlag())
716  {
717  TComScalingList scalingList;
718  if(pcSlice->getPPS()->getScalingListPresentFlag())
719  {
720  scalingList = pcSlice->getPPS()->getScalingList();
721  }
722  else if (pcSlice->getSPS()->getScalingListPresentFlag())
723  {
724  scalingList = pcSlice->getSPS()->getScalingList();
725  }
726  else
727  {
728  scalingList.setDefaultScalingList();
729  }
730  m_cTrQuant.setScalingListDec(scalingList);
732  }
733  else
734  {
735  const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
736  {
739  };
740  m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
742  }
743 
744  // Decode a picture
746 
747  m_bFirstSliceInPicture = false;
748  m_uiSliceIdx++;
749 
750  return false;
751 }
752 
753 Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData)
754 {
755  TComVPS* vps = new TComVPS();
756 
758  m_parameterSetManager.storeVPS(vps, naluData);
759 }
760 
761 Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData)
762 {
763  TComSPS* sps = new TComSPS();
764 #if O0043_BEST_EFFORT_DECODING
765  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
766 #endif
768  m_parameterSetManager.storeSPS(sps, naluData);
769 }
770 
771 Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData)
772 {
773  TComPPS* pps = new TComPPS();
775  m_parameterSetManager.storePPS( pps, naluData);
776 }
777 
778 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
779 {
780  // ignore all NAL units of layers > 0
781  if (nalu.m_nuhLayerId > 0)
782  {
783  fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId);
784  return false;
785  }
786  // Initialize entropy decoder
789 
790  switch (nalu.m_nalUnitType)
791  {
792  case NAL_UNIT_VPS:
793  xDecodeVPS(nalu.getBitstream().getFifo());
794  return false;
795 
796  case NAL_UNIT_SPS:
797  xDecodeSPS(nalu.getBitstream().getFifo());
798  return false;
799 
800  case NAL_UNIT_PPS:
801  xDecodePPS(nalu.getBitstream().getFifo());
802  return false;
803 
804  case NAL_UNIT_PREFIX_SEI:
805  // Buffer up prefix SEI messages until SPS of associated VCL is known.
806  m_prefixSEINALUs.push_back(new InputNALUnit(nalu));
807  return false;
808 
809  case NAL_UNIT_SUFFIX_SEI:
810  if (m_pcPic)
811  {
813  }
814  else
815  {
816  printf ("Note: received suffix SEI but no picture currently active.\n");
817  }
818  return false;
819 
836  return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
837  break;
838 
839  case NAL_UNIT_EOS:
841  m_pocCRA = 0;
843  m_prevPOC = MAX_INT;
844  m_prevSliceSkipped = false;
845  m_skippedPOC = 0;
846  return false;
847 
849  {
850  AUDReader audReader;
851  UInt picType;
852  audReader.parseAccessUnitDelimiter(&(nalu.getBitstream()),picType);
853  printf ("Note: found NAL_UNIT_ACCESS_UNIT_DELIMITER\n");
854  return false;
855  }
856 
857  case NAL_UNIT_EOB:
858  return false;
859 
861  {
862  FDReader fdReader;
863  UInt size;
864  fdReader.parseFillerData(&(nalu.getBitstream()),size);
865  printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size);
866  return false;
867  }
868 
875 
878 
887  printf ("Note: found reserved VCL NAL unit.\n");
889  return false;
890 
898  printf ("Note: found reserved NAL unit.\n");
899  return false;
916  printf ("Note: found unspecified NAL unit.\n");
917  return false;
918  default:
919  assert (0);
920  break;
921  }
922 
923  return false;
924 }
925 
933 {
936  {
937  iPOCLastDisplay++;
938  return true;
939  }
940  return false;
941 }
942 
956 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay)
957 {
958  if (iSkipFrame)
959  {
960  iSkipFrame--; // decrement the counter
961  return true;
962  }
963  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
964  {
969  {
970  // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
972  }
974  {
975  m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
976  }
977  else
978  {
980  {
981  printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
983  }
984  return true;
985  }
986  }
987  // skip the reordered pictures, if necessary
989  {
990  iPOCLastDisplay++;
991  return true;
992  }
993  // if we reach here, then the picture is not skipped.
994  return false;
995 }
996 
Void setCheckLDC(Bool b)
Definition: TComSlice.h:1420
virtual Void destroy()
Definition: TComPic.cpp:189
Void setSliceSegmentCurEndCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1493
Void setNoOutputPriorPicsFlag(Bool val)
Definition: TComSlice.h:1467
Void executeLoopFilters(Int &poc, TComList< TComPic * > *&rpcListPic)
Definition: TDecTop.cpp:219
TDecTop()
Buffered up prefix SEI NAL Units.
Definition: TDecTop.cpp:45
Int getSPSId() const
Definition: TComSlice.h:1094
Void parseAccessUnitDelimiter(TComInputBitstream *bs, UInt &picType)
Void create(UInt uiMaxCUDepth)
TDecConformanceCheck m_conformanceCheck
Definition: TDecTop.h:94
Void setSEIs(SEIMessages &seis)
Definition: TComPic.h:169
Void initROM()
Definition: TComRom.cpp:179
Void init(TDecEntropy *pcEntropyDecoder, TDecSbac *pcSbacDecoder, TDecBinCABAC *pcBinCABAC, TDecCavlc *pcCavlcDecoder, TDecSlice *pcSliceDecoder, TComLoopFilter *pcLoopFilter, TComSampleAdaptiveOffset *pcSAO)
Definition: TDecGop.cpp:76
Bool m_isNoOutputPriorPics
Definition: TDecTop.h:108
Int getSPSId() const
Definition: TComSlice.h:824
TDecCu m_cCuDecoder
Definition: TDecTop.h:86
Bool getPPSChangedFlag(Int ppsId) const
Definition: TComSlice.h:1693
UInt getNumberOfCtusInFrame() const
Definition: TComPic.h:127
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Void setFlatScalingList(const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths)
void Void
Definition: TypeDef.h:203
Bool m_warningMessageSkipPicture
Definition: TDecTop.h:115
const TComPPSRExt & getPpsRangeExtension() const
Definition: TComSlice.h:1197
Void xUpdatePreviousTid0POC(TComSlice *pSlice)
Definition: TDecTop.h:162
const TComSPSRExt & getSpsRangeExtension() const
Definition: TComSlice.h:941
reading functionality for NAL units
Int m_prevPOC
Definition: TDecTop.h:100
Void deleteSEIs(SEIMessages &seiList)
delete list of SEI messages (freeing the referenced objects)
Definition: SEI.cpp:77
Void init()
Definition: TDecTop.cpp:129
SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
output a selection of SEI messages by payload type. Ownership stays in original message list...
Definition: SEI.cpp:42
#define NULL
Definition: CommonDef.h:107
const std::vector< uint8_t > & getFifo() const
TComSlice * m_apcSlicePilot
Definition: TDecTop.h:77
Void initCtu(TComPic *pcPic, UInt ctuRsAddr)
Definition: TComDataCU.cpp:422
TDecSbac m_cSbacDecoder
Definition: TDecTop.h:89
UInt getBitsForPOC() const
Definition: TComSlice.h:869
TComSlice * getSlice(Int i)
Definition: TComPic.h:113
Void copySliceInfo(TComSlice *pcSliceSrc)
Definition: TComSlice.cpp:665
TComPrediction m_cPrediction
Definition: TDecTop.h:82
Void xActivateParameterSets()
Definition: TDecTop.cpp:306
TComSlice * getSlice(UInt i)
Definition: TComPicSym.h:154
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:922
unsigned int UInt
Definition: TypeDef.h:212
Void setRefPOCList()
Definition: TComSlice.cpp:290
NalUnitType m_nalUnitType
nal_unit_type
Definition: NAL.h:49
Void clearSPSChangedFlag(Int spsId)
Definition: TComSlice.h:1686
Bool isReferenced() const
Definition: TComSlice.h:1387
Void initTempBuff(ChromaFormat chromaFormatIDC)
Void clearPPSChangedFlag(Int ppsId)
Definition: TComSlice.h:1694
SCALING_LIST class.
Definition: TComSlice.h:150
Void setNalUnitType(NalUnitType e)
Definition: TComSlice.h:1390
Void destroy()
Definition: TDecSlice.cpp:60
Void decompressSlice(TComInputBitstream *pcBitstream, TComPic *pcPic)
Definition: TDecGop.cpp:103
UInt getMaxCUHeight() const
Definition: TComSlice.h:859
Void create(const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction)
Definition: TComPic.cpp:71
UInt getMaxDecPicBuffering(UInt tlayer) const
Definition: TComSlice.h:926
Bool getNoRaslOutputFlag() const
Definition: TComSlice.h:1471
Bool isSkipPictureForBLA(Int &iPOCLastDisplay)
Definition: TDecTop.cpp:932
Void init(UInt uiMaxTrSize, Bool useRDOQ=false, Bool useRDOQTS=false, Bool useSelectiveRDOQ=false, Bool bEnc=false, Bool useTransformSkipFast=false, Bool bUseAdaptQpSelect=false)
Void setUseScalingList(Bool bUseScalingList)
get DeQuant Coefficent
Definition: TComTrQuant.h:180
Void setSliceCurStartCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1480
Void setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)
Definition: TComSlice.h:1349
Bool getHandleCraAsBlaFlag() const
Definition: TComSlice.h:1474
Void setField(Bool b)
Definition: TComPic.h:165
ChromaFormat getChromaFormatIdc() const
Definition: TComSlice.h:826
Void setTLayer(UInt uiTLayer)
Definition: TComPic.h:102
Void setSliceIdx(UInt i)
Definition: TComSlice.h:1484
Void setBitstream(TComInputBitstream *p)
Definition: TDecEntropy.h:142
Int getNumRefIdx(RefPicList e) const
Definition: TComSlice.h:1370
Void filterPicture(TComPic *pcPic)
Definition: TDecGop.cpp:135
UInt getCtuRsToTsAddrMap(Int ctuRsAddr) const
Definition: TComPicSym.h:185
UInt getMaxTrSize() const
Definition: TComSlice.h:891
SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
remove a selection of SEI messages by payload type from the original list and return them in a new li...
Definition: SEI.cpp:56
Void storePPS(TComPPS *pps, const std::vector< UChar > &naluData)
store picture parameter set and take ownership of it
Definition: TComSlice.h:1690
Bool isInterB() const
Definition: TComSlice.h:1424
Void setEntropyDecoder(TDecEntropyIf *p)
Definition: TDecEntropy.cpp:51
TComPicYuv * getPicYuvRec()
Definition: TComPic.h:120
Void xAnalysePrefixSEImessages()
Definition: TDecTop.cpp:463
UInt m_picStruct
Definition: SEI.h:183
TDecCavlc m_cCavlcDecoder
Definition: TDecTop.h:88
#define O0043_BEST_EFFORT_DECODING
0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort d...
Definition: TypeDef.h:130
Bool m_bFirstSliceInSequence
Definition: TDecTop.h:103
virtual ~TDecTop()
Definition: TDecTop.cpp:97
Int m_pocCRA
POC number of the latest CRA picture.
Definition: TDecTop.h:72
UInt getMaxTotalCUDepth() const
Definition: TComSlice.h:861
Bool getDependentSliceSegmentFlag() const
Definition: TComSlice.h:1357
Bool getSPSChangedFlag(Int spsId) const
Definition: TComSlice.h:1685
Void xGetNewPicBuffer(const TComSPS &sps, const TComPPS &pps, TComPic *&rpcPic, const UInt temporalLayer)
Definition: TDecTop.cpp:164
Void create(Int picWidth, Int picHeight, ChromaFormat format, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth, UInt lumaBitShift, UInt chromaBitShift)
Void setNoRaslOutputFlag(Bool val)
Definition: TComSlice.h:1470
Int m_prevTid0POC
Definition: TDecTop.h:101
Void storeVPS(TComVPS *vps, const std::vector< UChar > &naluData)
store sequence parameter set and take ownership of it
Definition: TComSlice.h:1674
Void parseFillerData(TComInputBitstream *bs, UInt &fdSize)
TComLoopFilter m_cLoopFilter
Definition: TDecTop.h:92
Void setTemporalLayerNonReferenceFlag(Bool x)
Definition: TComSlice.h:1531
std::list< InputNALUnit * > m_prefixSEINALUs
Definition: TDecTop.h:121
TComScalingList & getScalingList()
Definition: TComSlice.h:1184
Void decodeSPS(TComSPS *pcSPS)
Definition: TDecEntropy.h:146
UInt getLog2SaoOffsetScale(ChannelType type) const
Definition: TComSlice.h:1027
bool Bool
Definition: TypeDef.h:204
const TComReferencePictureSet * getRPS()
Definition: TComSlice.h:1341
Int m_iMaxRefPicNum
Definition: TDecTop.h:69
Bool isRandomAccessSkipPicture(Int &iSkipFrame, Int &iPOCLastDisplay)
Definition: TDecTop.cpp:956
TComList< TComPic * > m_cListPic
Definition: TDecTop.h:75
Void create()
Definition: TDecSlice.cpp:56
Int m_pocRandomAccess
POC number of the random access point (the first IDR or CRA picture)
Definition: TDecTop.h:73
PPS class.
Definition: TComSlice.h:1034
Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay)
Definition: TDecTop.cpp:486
Void copyToPic(TComPicYuv *pcPicYuvDst) const
Definition: TComPicYuv.cpp:198
Void setRefPic(TComPic *p, RefPicList e, Int iRefIdx)
Definition: TComSlice.h:1410
NalUnitType m_associatedIRAPType
NAL unit type of the associated IRAP picture.
Definition: TDecTop.h:71
Bool m_craNoRaslOutputFlag
Definition: TDecTop.h:109
static const Int MAX_INT
max. value of signed 32-bit integer
Definition: CommonDef.h:115
UInt getPicHeightInLumaSamples() const
Definition: TComSlice.h:836
Void setAssociatedIRAPType(NalUnitType associatedIRAPType)
Definition: TComSlice.h:1351
Void storeSPS(TComSPS *sps, const std::vector< UChar > &naluData)
store sequence parameter set and take ownership of it
Definition: TComSlice.h:1682
decoder class (header)
Void setRefPicList(TComList< TComPic * > &rcListPic, Bool checkNumPocTotalCurr=false)
Definition: TComSlice.cpp:319
Void deletePicBuffer()
Definition: TDecTop.cpp:142
Int m_lastPOCNoOutputPriorPics
Definition: TDecTop.h:107
reference list 0
Definition: TypeDef.h:372
Int getBitDepth(ChannelType type) const
Definition: TComSlice.h:894
Void parseSEImessage(TComInputBitstream *bs, SEIMessages &seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
Definition: SEIread.cpp:129
Void checkSliceActivation(const TComSlice &, const InputNALUnit &, const TComPic &, const Bool, const Bool, const Bool)
Void setSliceCurEndCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1482
static Void sortPicList(TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:190
Void xCreateLostPicture(Int iLostPOC)
Definition: TDecTop.cpp:261
TComPicSym * getPicSym()
Definition: TComPic.h:111
const BitDepths & getBitDepths() const
Definition: TComSlice.h:900
UInt getSliceSegmentCurStartCtuTsAddr() const
Definition: TComSlice.h:1492
Int getMaxLog2TrDynamicRange(ChannelType channelType) const
Definition: TComSlice.h:901
Void pushBack(const C &rcT)
Definition: TComList.h:89
Bool getNoOutputPriorPicsFlag() const
Definition: TComSlice.h:1468
const TComPPS * getPPS() const
Definition: TComSlice.h:1332
UInt getPicWidthInLumaSamples() const
Definition: TComSlice.h:834
Bool m_prevSliceSkipped
Definition: TDecTop.h:104
Int getPPSId() const
Definition: TComSlice.h:1335
TComTrQuant m_cTrQuant
Definition: TDecTop.h:83
TDecEntropy m_cEntropyDecoder
Definition: TDecTop.h:87
Void decodeSliceHeader(TComSlice *pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC)
Definition: TDecEntropy.h:148
UInt m_nuhLayerId
nuh_layer_id
Definition: NAL.h:51
const TComInputBitstream & getBitstream() const
Definition: NALread.h:64
Bool m_tmctsCheckEnabled
Definition: TDecTop.h:118
Bool isIntra() const
Definition: TComSlice.h:1423
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:1182
TComSPS * getFirstSPS()
Definition: TComSlice.h:1687
reference list 1
Definition: TypeDef.h:373
Void checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int &pocCRA, NalUnitType &associatedIRAPType, TComList< TComPic * > &rcListPic)
Definition: TComSlice.cpp:527
Int getPPSId() const
Definition: TComSlice.h:1092
Void destroy()
destroy internal buffers
Definition: TDecCu.cpp:119
TDecGop m_cGopDecoder
Definition: TDecTop.h:84
Int getPOC() const
Definition: TComSlice.h:1354
Int getPOC() const
Definition: TComPic.h:115
SEIReader m_seiReader
Definition: TDecTop.h:91
Void setOutputMark(Bool b)
Definition: TComPic.h:144
UInt getSliceCurStartCtuTsAddr() const
Definition: TComSlice.h:1481
TDecBinCABAC m_cBinCABAC
Definition: TDecTop.h:90
unsigned long long UInt64
Definition: TypeDef.h:233
Bool getScalingListFlag() const
Definition: TComSlice.h:920
const TComSPS * getActiveSPS() const
Definition: TComSlice.h:1706
UInt m_uiSliceIdx
Definition: TDecTop.h:99
TComDataCU * getCtu(UInt ctuRsAddr)
Definition: TComPic.h:116
ParameterSetManager m_parameterSetManager
Definition: TDecTop.h:76
Void setPOC(Int i)
Definition: TComSlice.h:1389
Void initSlice()
Definition: TComSlice.cpp:152
Void decodePPS(TComPPS *pcPPS)
Definition: TDecEntropy.h:147
Void destroy()
Definition: TDecTop.cpp:119
Bool m_bFirstSliceInPicture
Definition: TDecTop.h:102
Void init(TComPrediction *p, TDecConformanceCheck *pConformanceCheck)
Definition: TDecEntropy.h:131
TComPPS * getPPS(Int ppsId)
get pointer to existing picture parameter set
Definition: TComSlice.h:1692
Void decodeVPS(TComVPS *pcVPS)
Definition: TDecEntropy.h:145
Void setReconMark(Bool b)
Definition: TComPic.h:142
TComSampleAdaptiveOffset m_cSAO
Definition: TDecTop.h:93
SEIMessages m_SEIs
List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs...
Definition: TDecTop.h:79
std::ostream * m_pDecodedSEIOutputStream
Definition: TDecTop.h:113
list template
Definition: TComList.h:61
#define MCTS_ENC_CHECK
Temporal MCTS encoder constraint and decoder checks. Also requires SEITMCTSTileConstraint to be enabl...
Definition: TypeDef.h:97
UInt getSliceSegmentCurEndCtuTsAddr() const
Definition: TComSlice.h:1494
std::list< SEI * > SEIMessages
Definition: SEI.h:123
TComPPS * getFirstPPS()
Definition: TComSlice.h:1695
Void create(UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC)
create internal buffers
Definition: TDecCu.cpp:80
Void xDecodeSPS(const std::vector< UChar > &naluData)
Definition: TDecTop.cpp:761
Int m_skippedPOC
Definition: TDecTop.h:105
TDecSlice m_cSliceDecoder
Definition: TDecTop.h:85
TComScalingList & getScalingList()
Definition: TComSlice.h:924
int Int
Definition: TypeDef.h:211
Void setSliceSegmentCurStartCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1491
Bool m_bFirstSliceInBitstream
Definition: TDecTop.h:106
Void applyReferencePictureSet(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *RPSList)
Definition: TComSlice.cpp:996
TComSPS * getSPS(Int spsId)
get pointer to existing sequence parameter set
Definition: TComSlice.h:1684
Bool getRapPicFlag() const
Definition: TComSlice.cpp:179
Void destroy()
Definition: TDecGop.cpp:72
UInt getNumAllocatedSlice() const
Definition: TComPic.h:150
Void setTopField(Bool b)
Definition: TComPic.h:163
Void enableTMctsCheck(Bool enabled)
Int checkThatAllRefPicsAreAvailable(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess=0, Bool bUseRecoveryPoint=false)
Definition: TComSlice.cpp:1074
Bool getReconMark() const
Definition: TComPic.h:143
Bool activatePPS(Int ppsId, Bool isIRAP)
Definition: TComSlice.cpp:2135
Void setTLayerInfo(UInt uiTLayer)
Definition: TComSlice.cpp:781
Void xParsePrefixSEIsForUnknownVCLNal()
Definition: TDecTop.cpp:439
SEIMessages & getSEIs()
Definition: TComPic.h:174
Void setBorderExtension(Bool b)
Definition: TComPicYuv.h:170
static Bool doChecking()
Void xDecodeVPS(const std::vector< UChar > &naluData)
Definition: TDecTop.cpp:753
Void init(TDecEntropy *pcEntropyDecoder, TDecCu *pcMbDecoder, TDecConformanceCheck *pDecConformanceCheck)
Definition: TDecSlice.cpp:64
NalUnitType getNalUnitType() const
Definition: TComSlice.h:1391
Void init(TDecEntropy *pcEntropyDecoder, TComTrQuant *pcTrQuant, TComPrediction *pcPrediction, TDecConformanceCheck *pConformanceCheck)
initialize access channels
Definition: TDecCu.cpp:61
slice header class
Definition: TComSlice.h:1225
Bool getOutputMark() const
Definition: TComPic.h:145
UInt m_temporalId
temporal_id
Definition: NAL.h:50
Bool isIRAP() const
Definition: TComSlice.h:1394
UInt getTLayer() const
Definition: TComSlice.h:1453
Void setNumRefIdx(RefPicList e, Int i)
Definition: TComSlice.h:1412
Void setScalingListDec(const TComScalingList &scalingList)
TComSlice * swapSliceObject(TComSlice *p, UInt i)
Definition: TComPicSym.h:171
Bool decode(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay)
Definition: TDecTop.cpp:778
Void setPicOutputFlag(Bool b)
Definition: TComSlice.h:1336
Decoder conformance functions (header)
TComPic * m_pcPic
Definition: TDecTop.h:98
Void create()
Definition: TDecTop.cpp:112
Void setDefaultScalingList()
Definition: TComSlice.cpp:1796
Void checkNoOutputPriorPics(TComList< TComPic * > *rpcListPic)
Definition: TDecTop.cpp:242
Void setReferenced(Bool b)
Definition: TComSlice.h:1386
TComPic * getRefPic(RefPicList e, Int iRefIdx)
Definition: TComSlice.h:1373
Void destroyROM()
Definition: TComRom.cpp:263
Void xParsePrefixSEImessages()
Definition: TDecTop.cpp:451
UInt getSliceCurEndCtuTsAddr() const
Definition: TComSlice.h:1483
Bool getExtendedPrecisionProcessingFlag() const
Definition: TComSlice.h:723
Void create()
Definition: TDecGop.cpp:66
Void setCurrSliceIdx(UInt i)
Definition: TComPic.h:149
Void xDecodePPS(const std::vector< UChar > &naluData)
Definition: TDecTop.cpp:771
UInt getMaxCUWidth() const
Definition: TComSlice.h:857
const TComSPS * getSPS() const
Definition: TComSlice.h:1329
SPS class.
Definition: TComSlice.h:740
Void allocateNewSlice()
Definition: TComPic.h:151