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 | #if H_MV |
---|
58 | , m_bPicOutputFlag (false) |
---|
59 | #endif |
---|
60 | , m_uiCurrSliceIdx (0) |
---|
61 | , m_bCheckLTMSB (false) |
---|
62 | #if H_MV |
---|
63 | , m_layerId (0) |
---|
64 | , m_viewId (0) |
---|
65 | #endif |
---|
66 | { |
---|
67 | m_apcPicYuv[0] = NULL; |
---|
68 | m_apcPicYuv[1] = NULL; |
---|
69 | } |
---|
70 | |
---|
71 | TComPic::~TComPic() |
---|
72 | { |
---|
73 | } |
---|
74 | |
---|
75 | Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, |
---|
76 | Int *numReorderPics, Bool bIsVirtual) |
---|
77 | |
---|
78 | { |
---|
79 | m_apcPicSym = new TComPicSym; m_apcPicSym ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
80 | if (!bIsVirtual) |
---|
81 | { |
---|
82 | m_apcPicYuv[0] = new TComPicYuv; m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
83 | } |
---|
84 | m_apcPicYuv[1] = new TComPicYuv; m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
85 | |
---|
86 | // there are no SEI messages associated with this picture initially |
---|
87 | if (m_SEIs.size() > 0) |
---|
88 | { |
---|
89 | deleteSEIs (m_SEIs); |
---|
90 | } |
---|
91 | m_bUsedByCurr = false; |
---|
92 | |
---|
93 | /* store conformance window parameters with picture */ |
---|
94 | m_conformanceWindow = conformanceWindow; |
---|
95 | |
---|
96 | /* store display window parameters with picture */ |
---|
97 | m_defaultDisplayWindow = defaultDisplayWindow; |
---|
98 | |
---|
99 | /* store number of reorder pics with picture */ |
---|
100 | memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int)); |
---|
101 | |
---|
102 | |
---|
103 | return; |
---|
104 | } |
---|
105 | |
---|
106 | Void TComPic::destroy() |
---|
107 | { |
---|
108 | if (m_apcPicSym) |
---|
109 | { |
---|
110 | m_apcPicSym->destroy(); |
---|
111 | delete m_apcPicSym; |
---|
112 | m_apcPicSym = NULL; |
---|
113 | } |
---|
114 | |
---|
115 | if (m_apcPicYuv[0]) |
---|
116 | { |
---|
117 | m_apcPicYuv[0]->destroy(); |
---|
118 | delete m_apcPicYuv[0]; |
---|
119 | m_apcPicYuv[0] = NULL; |
---|
120 | } |
---|
121 | |
---|
122 | if (m_apcPicYuv[1]) |
---|
123 | { |
---|
124 | m_apcPicYuv[1]->destroy(); |
---|
125 | delete m_apcPicYuv[1]; |
---|
126 | m_apcPicYuv[1] = NULL; |
---|
127 | } |
---|
128 | |
---|
129 | deleteSEIs(m_SEIs); |
---|
130 | } |
---|
131 | Void TComPic::compressMotion() |
---|
132 | { |
---|
133 | TComPicSym* pPicSym = getPicSym(); |
---|
134 | for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ ) |
---|
135 | { |
---|
136 | TComDataCU* pcCU = pPicSym->getCU(uiCUAddr); |
---|
137 | pcCU->compressMV(); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr) |
---|
142 | { |
---|
143 | Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCUOrderMap(getCU(currAddr)->getSlice()->getSliceCurStartCUAddr()/getNumPartInCU())); |
---|
144 | Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr)); |
---|
145 | return (mergeCtbInSliceSeg && mergeCtbInTile); |
---|
146 | } |
---|
147 | |
---|
148 | #if H_MV |
---|
149 | Void TComPic::print( Bool legend ) |
---|
150 | { |
---|
151 | if ( legend ) |
---|
152 | std::cout << std::endl << "LId" << "\t" << "POC" << "\t" << "Rec" << "\t" << "Ref" << "\t" << "LT" << "\t" << "OutMark" << "\t" << "OutFlag" << std::endl; |
---|
153 | else |
---|
154 | std::cout << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<std::endl; |
---|
155 | } |
---|
156 | |
---|
157 | TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc ) |
---|
158 | { |
---|
159 | TComPic* pcPic = NULL; |
---|
160 | for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++) |
---|
161 | { |
---|
162 | for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++) |
---|
163 | { |
---|
164 | TComPic* currPic = (*itP); |
---|
165 | if ( ( currPic->getPOC() == poc ) && ( currPic->getLayerId() == layerIdInNuh ) ) |
---|
166 | { |
---|
167 | pcPic = currPic ; |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | return pcPic; |
---|
172 | } |
---|
173 | |
---|
174 | Void TComPicLists::print() |
---|
175 | { |
---|
176 | Bool first = true; |
---|
177 | for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++) |
---|
178 | { |
---|
179 | for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++) |
---|
180 | { |
---|
181 | if ( first ) |
---|
182 | { |
---|
183 | (*itP)->print( true ); |
---|
184 | first = false; |
---|
185 | } |
---|
186 | (*itP)->print( false ); |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag ) |
---|
192 | { |
---|
193 | TComPic* pcPic = getPic( layerIdInNuh, poc ); |
---|
194 | TComPicYuv* pcPicYuv = NULL; |
---|
195 | |
---|
196 | if (pcPic != NULL) |
---|
197 | { |
---|
198 | if( reconFlag ) |
---|
199 | { |
---|
200 | if ( pcPic->getReconMark() ) |
---|
201 | { |
---|
202 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
203 | } |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
208 | } |
---|
209 | }; |
---|
210 | |
---|
211 | return pcPicYuv; |
---|
212 | } |
---|
213 | |
---|
214 | #endif // H_MV |
---|
215 | |
---|
216 | //! \} |
---|