0
|
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-2014, ITU/ISO/IEC
|
|
7 * All rights reserved.
|
|
8 *
|
|
9 * Redistribution and use in source and binary forms, with or without
|
|
10 * modification, are permitted provided that the following conditions are met:
|
|
11 *
|
|
12 * * Redistributions of source code must retain the above copyright notice,
|
|
13 * this list of conditions and the following disclaimer.
|
|
14 * * Redistributions in binary form must reproduce the above copyright notice,
|
|
15 * this list of conditions and the following disclaimer in the documentation
|
|
16 * and/or other materials provided with the distribution.
|
|
17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
|
|
18 * be used to endorse or promote products derived from this software without
|
|
19 * specific prior written permission.
|
|
20 *
|
|
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
31 * THE POSSIBILITY OF SUCH DAMAGE.
|
|
32 */
|
|
33
|
|
34 /** \file TComPic.cpp
|
|
35 \brief picture class
|
|
36 */
|
|
37
|
|
38 #include "TComPic.h"
|
|
39 #include "SEI.h"
|
|
40
|
|
41 //! \ingroup TLibCommon
|
|
42 //! \{
|
|
43
|
|
44 // ====================================================================================================================
|
|
45 // Constructor / destructor / create / destroy
|
|
46 // ====================================================================================================================
|
|
47
|
|
48 TComPic::TComPic()
|
|
49 : m_uiTLayer (0)
|
|
50 , m_bUsedByCurr (false)
|
|
51 , m_bIsLongTerm (false)
|
|
52 , m_apcPicSym (NULL)
|
|
53 , m_pcPicYuvPred (NULL)
|
|
54 , m_pcPicYuvResi (NULL)
|
|
55 , m_bReconstructed (false)
|
|
56 , m_bNeededForOutput (false)
|
|
57 , m_uiCurrSliceIdx (0)
|
|
58 , m_bCheckLTMSB (false)
|
|
59 {
|
|
60 for(UInt i=0; i<NUM_PIC_YUV; i++)
|
|
61 {
|
|
62 m_apcPicYuv[i] = NULL;
|
|
63 }
|
|
64 }
|
|
65
|
|
66 TComPic::~TComPic()
|
|
67 {
|
|
68 }
|
|
69
|
|
70 Void TComPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
|
|
71 Int *numReorderPics, Bool bIsVirtual)
|
|
72 {
|
|
73 m_apcPicSym = new TComPicSym; m_apcPicSym ->create( chromaFormatIDC, iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
|
|
74 if (!bIsVirtual)
|
|
75 {
|
|
76 m_apcPicYuv[PIC_YUV_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
|
|
77 m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
|
|
78 }
|
|
79 m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth );
|
|
80
|
|
81 // there are no SEI messages associated with this picture initially
|
|
82 if (m_SEIs.size() > 0)
|
|
83 {
|
|
84 deleteSEIs (m_SEIs);
|
|
85 }
|
|
86 m_bUsedByCurr = false;
|
|
87
|
|
88 /* store conformance window parameters with picture */
|
|
89 m_conformanceWindow = conformanceWindow;
|
|
90
|
|
91 /* store display window parameters with picture */
|
|
92 m_defaultDisplayWindow = defaultDisplayWindow;
|
|
93
|
|
94 /* store number of reorder pics with picture */
|
|
95 memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
|
|
96
|
|
97 return;
|
|
98 }
|
|
99
|
|
100 Void TComPic::destroy()
|
|
101 {
|
|
102 if (m_apcPicSym)
|
|
103 {
|
|
104 m_apcPicSym->destroy();
|
|
105 delete m_apcPicSym;
|
|
106 m_apcPicSym = NULL;
|
|
107 }
|
|
108
|
|
109 for(UInt i=0; i<NUM_PIC_YUV; i++)
|
|
110 {
|
|
111 if (m_apcPicYuv[i])
|
|
112 {
|
|
113 m_apcPicYuv[i]->destroy();
|
|
114 delete m_apcPicYuv[i];
|
|
115 m_apcPicYuv[i] = NULL;
|
|
116 }
|
|
117 }
|
|
118
|
|
119 deleteSEIs(m_SEIs);
|
|
120 }
|
|
121
|
|
122 Void TComPic::compressMotion()
|
|
123 {
|
|
124 TComPicSym* pPicSym = getPicSym();
|
|
125 for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
|
|
126 {
|
|
127 TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
|
|
128 pCtu->compressMV();
|
|
129 }
|
|
130 }
|
|
131
|
|
132 Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
|
|
133 {
|
|
134 Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr()));
|
|
135 Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
|
|
136 return (mergeCtbInSliceSeg && mergeCtbInTile);
|
|
137 }
|
|
138
|
|
139 UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
|
|
140 {
|
|
141 UInt subStrm;
|
|
142
|
|
143 if (pcSlice->getPPS()->getNumSubstreams() > 1) // wavefronts, and possibly tiles being used.
|
|
144 {
|
|
145 if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
|
|
146 {
|
|
147 const TComPicSym &picSym = *(getPicSym());
|
|
148 const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
|
|
149 const UInt frameWidthInCtus = picSym.getFrameWidthInCtus();
|
|
150 const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr);
|
|
151 const UInt numTileColumns = (picSym.getNumTileColumnsMinus1()+1);
|
|
152 const TComTile *pTile = picSym.getTComTile(tileIndex);
|
|
153 const UInt firstCtuRsAddrOfTile = pTile->getFirstCtuRsAddr();
|
|
154 const UInt tileYInCtus = firstCtuRsAddrOfTile / frameWidthInCtus;
|
|
155 // independent tiles => substreams are "per tile"
|
|
156 const UInt ctuLine = ctuRsAddr / frameWidthInCtus;
|
|
157 const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns));
|
|
158 subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus);
|
|
159 }
|
|
160 else
|
|
161 {
|
|
162 const TComPicSym &picSym = *(getPicSym());
|
|
163 const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
|
|
164 const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr);
|
|
165 subStrm=tileIndex;
|
|
166 }
|
|
167 }
|
|
168 else
|
|
169 {
|
|
170 // dependent tiles => substreams are "per frame".
|
|
171 subStrm = 0;
|
|
172 }
|
|
173 return subStrm;
|
|
174 }
|
|
175
|
|
176
|
|
177 //! \}
|