HEVC Test Model (HM)  HM-16.3
TComPic.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 "TComPic.h"
39 #include "SEI.h"
40 
43 
44 // ====================================================================================================================
45 // Constructor / destructor / create / destroy
46 // ====================================================================================================================
47 
49 : m_uiTLayer (0)
50 , m_bUsedByCurr (false)
51 , m_bIsLongTerm (false)
52 , m_pcPicYuvPred (NULL)
53 , m_pcPicYuvResi (NULL)
54 , m_bReconstructed (false)
55 , m_bNeededForOutput (false)
56 , m_uiCurrSliceIdx (0)
57 , m_bCheckLTMSB (false)
58 {
59  for(UInt i=0; i<NUM_PIC_YUV; i++)
60  {
61  m_apcPicYuv[i] = NULL;
62  }
63 }
64 
66 {
67 }
68 
69 Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const UInt uiMaxWidth, const UInt uiMaxHeight, const UInt uiMaxDepth, const Bool bIsVirtual)
70 {
71  const ChromaFormat chromaFormatIDC=sps.getChromaFormatIdc();
72  const Int iWidth = sps.getPicWidthInLumaSamples();
73  const Int iHeight = sps.getPicHeightInLumaSamples();
74 
75  m_picSym.create( sps, pps, uiMaxWidth, uiMaxHeight, uiMaxDepth );
76  if (!bIsVirtual)
77  {
78  m_apcPicYuv[PIC_YUV_ORG ] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
79  m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
80  }
81  m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
82 
83  // there are no SEI messages associated with this picture initially
84  if (m_SEIs.size() > 0)
85  {
87  }
88  m_bUsedByCurr = false;
89 }
90 
92 {
93  m_picSym.destroy();
94 
95  for(UInt i=0; i<NUM_PIC_YUV; i++)
96  {
97  if (m_apcPicYuv[i])
98  {
99  m_apcPicYuv[i]->destroy();
100  delete m_apcPicYuv[i];
101  m_apcPicYuv[i] = NULL;
102  }
103  }
104 
106 }
107 
109 {
110  TComPicSym* pPicSym = getPicSym();
111  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
112  {
113  TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
114  pCtu->compressMV();
115  }
116 }
117 
119 {
120  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr()));
121  Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
122  return (mergeCtbInSliceSeg && mergeCtbInTile);
123 }
124 
125 UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
126 {
127  UInt subStrm;
128  const bool bWPPEnabled=pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag();
129  const TComPicSym &picSym = *(getPicSym());
130 
131  if ((bWPPEnabled && picSym.getFrameHeightInCtus()>1) || (picSym.getNumTiles()>1)) // wavefronts, and possibly tiles being used.
132  {
133  if (bWPPEnabled)
134  {
135  const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
136  const UInt frameWidthInCtus = picSym.getFrameWidthInCtus();
137  const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr);
138  const UInt numTileColumns = (picSym.getNumTileColumnsMinus1()+1);
139  const TComTile *pTile = picSym.getTComTile(tileIndex);
140  const UInt firstCtuRsAddrOfTile = pTile->getFirstCtuRsAddr();
141  const UInt tileYInCtus = firstCtuRsAddrOfTile / frameWidthInCtus;
142  // independent tiles => substreams are "per tile"
143  const UInt ctuLine = ctuRsAddr / frameWidthInCtus;
144  const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns));
145  subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus);
146  }
147  else
148  {
149  const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
150  const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr);
151  subStrm=tileIndex;
152  }
153  }
154  else
155  {
156  // dependent tiles => substreams are "per frame".
157  subStrm = 0;
158  }
159  return subStrm;
160 }
161 
162 
virtual Void destroy()
Definition: TComPic.cpp:91
virtual ~TComPic()
Definition: TComPic.cpp:65
UInt getFirstCtuRsAddr() const
Definition: TComPicSym.h:79
Void create(const Int iPicWidth, const Int iPicHeight, const ChromaFormat chromaFormatIDC, const UInt uiMaxCUWidth, const UInt uiMaxCUHeight, const UInt uiMaxCUDepth)
Definition: TComPicYuv.cpp:81
UInt getCtuTsToRsAddrMap(Int ctuTsAddr) const
Definition: TComPicSym.h:150
picture YUV buffer class
Definition: TComPicYuv.h:55
CU data structure class.
Definition: TComDataCU.h:64
void Void
Definition: TypeDef.h:285
Void deleteSEIs(SEIMessages &seiList)
delete list of SEI messages (freeing the referenced objects)
Definition: SEI.cpp:79
Int getNumTileColumnsMinus1() const
Definition: TComPicSym.h:145
#define NULL
Definition: CommonDef.h:100
TComSlice * getSlice(Int i)
Definition: TComPic.h:103
unsigned int UInt
Definition: TypeDef.h:297
picture class (header)
ChromaFormat getChromaFormatIdc() const
Definition: TComSlice.h:814
TComPicSym m_picSym
Definition: TComPic.h:67
UInt getFrameWidthInCtus() const
Definition: TComPicSym.h:128
SEIMessages m_SEIs
Any SEI messages that have been received. If !NULL we own the object.
Definition: TComPic.h:82
Bool m_bUsedByCurr
Definition: TComPic.h:65
UInt getTileIdxMap(Int ctuRsAddr) const
Definition: TComPicSym.h:151
Bool getSAOMergeAvailability(Int currAddr, Int mergeAddr)
Definition: TComPic.cpp:118
bool Bool
Definition: TypeDef.h:286
UInt getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
Definition: TComPic.cpp:125
Int getNumTiles() const
Definition: TComPicSym.h:147
PPS class.
Definition: TComSlice.h:977
UInt getPicHeightInLumaSamples() const
Definition: TComSlice.h:824
Void destroy()
Definition: TComPicSym.cpp:131
TComPicSym * getPicSym()
Definition: TComPic.h:102
Void compressMV()
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:352
const TComPPS * getPPS() const
Definition: TComSlice.h:1309
UInt getPicWidthInLumaSamples() const
Definition: TComSlice.h:822
Void create(const TComSPS &sps, const TComPPS &pps, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth)
Definition: TComPicSym.cpp:72
UInt getFrameHeightInCtus() const
Definition: TComPicSym.h:129
UInt getTileHeightInCtus() const
Definition: TComPicSym.h:73
Bool getEntropyCodingSyncEnabledFlag() const
Definition: TComSlice.h:1127
TComDataCU * getCtu(UInt ctuRsAddr)
Definition: TComPicSym.h:133
TComDataCU * getCtu(UInt ctuRsAddr)
Definition: TComPic.h:105
Void compressMotion()
Definition: TComPic.cpp:108
TComTile * getTComTile(UInt tileIdx)
Definition: TComPicSym.h:148
UInt getNumberOfCtusInFrame() const
Definition: TComPicSym.h:132
int Int
Definition: TypeDef.h:296
TComPic()
Definition: TComPic.cpp:48
Void create(const TComSPS &sps, const TComPPS &pps, const UInt uiMaxWidth, const UInt uiMaxHeight, const UInt uiMaxDepth, const Bool bIsVirtual)
Definition: TComPic.cpp:69
TComPicYuv * m_apcPicYuv[NUM_PIC_YUV]
Definition: TComPic.h:68
slice header class
Definition: TComSlice.h:1198
Void destroy()
Definition: TComPicYuv.cpp:146
picture symbol class
Definition: TComPicSym.h:83
SPS class.
Definition: TComSlice.h:722