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 | |
---|
34 | /** \file TDecTop.cpp |
---|
35 | \brief decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "NALread.h" |
---|
39 | #include "TDecTop.h" |
---|
40 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
41 | #include "TLibCommon/TComCodingStatistics.h" |
---|
42 | #endif |
---|
43 | |
---|
44 | #if SVC_EXTENSION |
---|
45 | UInt TDecTop::m_prevPOC = MAX_UINT; |
---|
46 | UInt TDecTop::m_uiPrevLayerId = MAX_UINT; |
---|
47 | Bool TDecTop::m_bFirstSliceInSequence = true; |
---|
48 | Bool TDecTop::m_checkPocRestrictionsForCurrAu = false; |
---|
49 | Int TDecTop::m_pocResetIdcOrCurrAu = -1; |
---|
50 | Bool TDecTop::m_baseLayerIdrFlag = false; |
---|
51 | Bool TDecTop::m_baseLayerPicPresentFlag = false; |
---|
52 | Bool TDecTop::m_baseLayerIrapFlag = false; |
---|
53 | Bool TDecTop::m_nonBaseIdrPresentFlag = false; |
---|
54 | Int TDecTop::m_nonBaseIdrType = -1; |
---|
55 | Bool TDecTop::m_picNonIdrWithRadlPresentFlag = false; |
---|
56 | Bool TDecTop::m_picNonIdrNoLpPresentFlag = false; |
---|
57 | Int TDecTop::m_crossLayerPocResetPeriodId = -1; |
---|
58 | Int TDecTop::m_crossLayerPocResetIdc = -1; |
---|
59 | #endif |
---|
60 | |
---|
61 | //! \ingroup TLibDecoder |
---|
62 | //! \{ |
---|
63 | |
---|
64 | TDecTop::TDecTop() |
---|
65 | : m_pDecodedSEIOutputStream(NULL) |
---|
66 | { |
---|
67 | m_pcPic = 0; |
---|
68 | m_iMaxRefPicNum = 0; |
---|
69 | #if ENC_DEC_TRACE |
---|
70 | if (g_hTrace == NULL) |
---|
71 | { |
---|
72 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
73 | } |
---|
74 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
75 | g_nSymbolCounter = 0; |
---|
76 | #endif |
---|
77 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
78 | m_pocCRA = 0; |
---|
79 | m_pocRandomAccess = MAX_INT; |
---|
80 | #if !SVC_EXTENSION |
---|
81 | m_prevPOC = MAX_INT; |
---|
82 | #endif |
---|
83 | m_bFirstSliceInPicture = true; |
---|
84 | #if !SVC_EXTENSION |
---|
85 | m_bFirstSliceInSequence = true; |
---|
86 | #endif |
---|
87 | m_prevSliceSkipped = false; |
---|
88 | m_skippedPOC = 0; |
---|
89 | m_bFirstSliceInBitstream = true; |
---|
90 | m_lastPOCNoOutputPriorPics = -1; |
---|
91 | m_craNoRaslOutputFlag = false; |
---|
92 | m_isNoOutputPriorPics = false; |
---|
93 | |
---|
94 | #if SVC_EXTENSION |
---|
95 | m_layerId = 0; |
---|
96 | m_smallestLayerId = 0; |
---|
97 | #if AVC_BASE |
---|
98 | m_pBLReconFile = NULL; |
---|
99 | #endif |
---|
100 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
101 | m_isLastNALWasEos = false; |
---|
102 | m_lastPicHasEos = false; |
---|
103 | #if NO_CLRAS_OUTPUT_FLAG |
---|
104 | m_noClrasOutputFlag = false; |
---|
105 | m_layerInitializedFlag = false; |
---|
106 | m_firstPicInLayerDecodedFlag = false; |
---|
107 | #endif |
---|
108 | m_parseIdc = -1; |
---|
109 | m_lastPocPeriodId = -1; |
---|
110 | m_prevPicOrderCnt = 0; |
---|
111 | #if CGS_3D_ASYMLUT |
---|
112 | m_pColorMappedPic = NULL; |
---|
113 | #endif |
---|
114 | |
---|
115 | resetPocRestrictionCheckParameters(); |
---|
116 | m_pocResettingFlag = false; |
---|
117 | m_pocDecrementedInDPBFlag = false; |
---|
118 | #if CONFORMANCE_BITSTREAM_MODE |
---|
119 | m_confModeFlag = false; |
---|
120 | #endif |
---|
121 | m_isOutputLayerFlag = false; |
---|
122 | #endif //SVC_EXTENSION |
---|
123 | } |
---|
124 | |
---|
125 | TDecTop::~TDecTop() |
---|
126 | { |
---|
127 | #if ENC_DEC_TRACE |
---|
128 | if (g_hTrace != stdout) |
---|
129 | { |
---|
130 | fclose( g_hTrace ); |
---|
131 | } |
---|
132 | #endif |
---|
133 | #if CGS_3D_ASYMLUT |
---|
134 | if(m_pColorMappedPic) |
---|
135 | { |
---|
136 | m_pColorMappedPic->destroy(); |
---|
137 | delete m_pColorMappedPic; |
---|
138 | m_pColorMappedPic = NULL; |
---|
139 | } |
---|
140 | #endif |
---|
141 | } |
---|
142 | |
---|
143 | Void TDecTop::create() |
---|
144 | { |
---|
145 | #if SVC_EXTENSION |
---|
146 | m_cGopDecoder.create( m_layerId ); |
---|
147 | #else |
---|
148 | m_cGopDecoder.create(); |
---|
149 | #endif |
---|
150 | m_apcSlicePilot = new TComSlice; |
---|
151 | m_uiSliceIdx = 0; |
---|
152 | } |
---|
153 | |
---|
154 | Void TDecTop::destroy() |
---|
155 | { |
---|
156 | m_cGopDecoder.destroy(); |
---|
157 | |
---|
158 | delete m_apcSlicePilot; |
---|
159 | m_apcSlicePilot = NULL; |
---|
160 | |
---|
161 | m_cSliceDecoder.destroy(); |
---|
162 | #if SVC_EXTENSION |
---|
163 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
164 | { |
---|
165 | if(m_cIlpPic[i]) |
---|
166 | { |
---|
167 | m_cIlpPic[i]->destroy(); |
---|
168 | delete m_cIlpPic[i]; |
---|
169 | m_cIlpPic[i] = NULL; |
---|
170 | } |
---|
171 | } |
---|
172 | #endif |
---|
173 | } |
---|
174 | |
---|
175 | Void TDecTop::init() |
---|
176 | { |
---|
177 | #if !SVC_EXTENSION |
---|
178 | // initialize ROM |
---|
179 | initROM(); |
---|
180 | #endif |
---|
181 | #if SVC_EXTENSION |
---|
182 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
183 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() ); |
---|
184 | #else |
---|
185 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
186 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
187 | #endif |
---|
188 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
189 | } |
---|
190 | |
---|
191 | Void TDecTop::deletePicBuffer ( ) |
---|
192 | { |
---|
193 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
194 | Int iSize = Int( m_cListPic.size() ); |
---|
195 | |
---|
196 | for (Int i = 0; i < iSize; i++ ) |
---|
197 | { |
---|
198 | TComPic* pcPic = *(iterPic++); |
---|
199 | #if SVC_EXTENSION |
---|
200 | if( pcPic ) |
---|
201 | { |
---|
202 | pcPic->destroy(); |
---|
203 | |
---|
204 | delete pcPic; |
---|
205 | pcPic = NULL; |
---|
206 | } |
---|
207 | #else |
---|
208 | pcPic->destroy(); |
---|
209 | |
---|
210 | delete pcPic; |
---|
211 | pcPic = NULL; |
---|
212 | #endif |
---|
213 | } |
---|
214 | |
---|
215 | m_cSAO.destroy(); |
---|
216 | |
---|
217 | m_cLoopFilter. destroy(); |
---|
218 | |
---|
219 | #if !SVC_EXTENSION |
---|
220 | // destroy ROM |
---|
221 | destroyROM(); |
---|
222 | #endif |
---|
223 | } |
---|
224 | |
---|
225 | #if SVC_EXTENSION |
---|
226 | Void TDecTop::xGetNewPicBuffer( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer ) |
---|
227 | #else |
---|
228 | Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer ) |
---|
229 | #endif |
---|
230 | { |
---|
231 | #if SVC_EXTENSION |
---|
232 | if( m_commonDecoderParams->getTargetOutputLayerSetIdx() == 0 ) |
---|
233 | { |
---|
234 | assert( m_layerId == 0 ); |
---|
235 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
236 | } |
---|
237 | else |
---|
238 | { |
---|
239 | m_iMaxRefPicNum = vps.getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), vps.getLayerIdcForOls( vps.getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx()), m_layerId ), temporalLayer ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
240 | } |
---|
241 | |
---|
242 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
---|
243 | #else |
---|
244 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
245 | #endif |
---|
246 | |
---|
247 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
248 | { |
---|
249 | rpcPic = new TComPic(); |
---|
250 | |
---|
251 | #if SVC_EXTENSION |
---|
252 | if(m_layerId > 0) |
---|
253 | { |
---|
254 | xSetSpatialEnhLayerFlag( vps, sps, pps, rpcPic ); |
---|
255 | } |
---|
256 | |
---|
257 | rpcPic->create( vps, sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId); |
---|
258 | #else //SVC_EXTENSION |
---|
259 | rpcPic->create ( sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
260 | #endif //SVC_EXTENSION |
---|
261 | |
---|
262 | m_cListPic.pushBack( rpcPic ); |
---|
263 | |
---|
264 | return; |
---|
265 | } |
---|
266 | |
---|
267 | Bool bBufferIsAvailable = false; |
---|
268 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
269 | while (iterPic != m_cListPic.end()) |
---|
270 | { |
---|
271 | rpcPic = *(iterPic++); |
---|
272 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
273 | { |
---|
274 | rpcPic->setOutputMark(false); |
---|
275 | bBufferIsAvailable = true; |
---|
276 | break; |
---|
277 | } |
---|
278 | |
---|
279 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
280 | { |
---|
281 | #if !SVC_EXTENSION |
---|
282 | rpcPic->setOutputMark(false); |
---|
283 | #endif |
---|
284 | rpcPic->setReconMark( false ); |
---|
285 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
286 | bBufferIsAvailable = true; |
---|
287 | break; |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | if ( !bBufferIsAvailable ) |
---|
292 | { |
---|
293 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
294 | m_iMaxRefPicNum++; |
---|
295 | rpcPic = new TComPic(); |
---|
296 | m_cListPic.pushBack( rpcPic ); |
---|
297 | } |
---|
298 | rpcPic->destroy(); |
---|
299 | |
---|
300 | #if SVC_EXTENSION |
---|
301 | if( m_layerId > 0 ) |
---|
302 | { |
---|
303 | xSetSpatialEnhLayerFlag( vps, sps, pps, rpcPic ); |
---|
304 | } |
---|
305 | |
---|
306 | rpcPic->create( vps, sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId); |
---|
307 | #else //SVC_EXTENSION |
---|
308 | rpcPic->create ( sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
309 | #endif //SVC_EXTENSION |
---|
310 | } |
---|
311 | |
---|
312 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
313 | { |
---|
314 | if (!m_pcPic) |
---|
315 | { |
---|
316 | /* nothing to deblock */ |
---|
317 | return; |
---|
318 | } |
---|
319 | |
---|
320 | TComPic* pcPic = m_pcPic; |
---|
321 | |
---|
322 | // Execute Deblock + Cleanup |
---|
323 | |
---|
324 | m_cGopDecoder.filterPicture(pcPic); |
---|
325 | |
---|
326 | #if SVC_EXTENSION |
---|
327 | if( this->getLayerDec(pcPic->getLayerId())->m_isOutputLayerFlag == false ) |
---|
328 | { |
---|
329 | pcPic->setOutputMark( false ); |
---|
330 | } |
---|
331 | #endif |
---|
332 | |
---|
333 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
334 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
335 | rpcListPic = &m_cListPic; |
---|
336 | m_cCuDecoder.destroy(); |
---|
337 | m_bFirstSliceInPicture = true; |
---|
338 | |
---|
339 | return; |
---|
340 | } |
---|
341 | |
---|
342 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) |
---|
343 | { |
---|
344 | if (!pcListPic || !m_isNoOutputPriorPics) |
---|
345 | { |
---|
346 | return; |
---|
347 | } |
---|
348 | |
---|
349 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
350 | |
---|
351 | while (iterPic != pcListPic->end()) |
---|
352 | { |
---|
353 | TComPic* pcPicTmp = *(iterPic++); |
---|
354 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
355 | { |
---|
356 | pcPicTmp->setOutputMark(false); |
---|
357 | } |
---|
358 | } |
---|
359 | } |
---|
360 | |
---|
361 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
362 | { |
---|
363 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
364 | TComPic *cFillPic; |
---|
365 | #if SVC_EXTENSION |
---|
366 | xGetNewPicBuffer(*(m_parameterSetManager.getFirstVPS()), *(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0); |
---|
367 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
368 | #else |
---|
369 | xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0); |
---|
370 | cFillPic->getSlice(0)->initSlice(); |
---|
371 | #endif |
---|
372 | |
---|
373 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
374 | Int closestPoc = 1000000; |
---|
375 | while ( iterPic != m_cListPic.end()) |
---|
376 | { |
---|
377 | TComPic * rpcPic = *(iterPic++); |
---|
378 | 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()) |
---|
379 | { |
---|
380 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
381 | } |
---|
382 | } |
---|
383 | iterPic = m_cListPic.begin(); |
---|
384 | while ( iterPic != m_cListPic.end()) |
---|
385 | { |
---|
386 | TComPic *rpcPic = *(iterPic++); |
---|
387 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
388 | { |
---|
389 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
390 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
391 | break; |
---|
392 | } |
---|
393 | } |
---|
394 | cFillPic->setCurrSliceIdx(0); |
---|
395 | for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) |
---|
396 | { |
---|
397 | cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); |
---|
398 | } |
---|
399 | cFillPic->getSlice(0)->setReferenced(true); |
---|
400 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
401 | cFillPic->setReconMark(true); |
---|
402 | cFillPic->setOutputMark(true); |
---|
403 | if(m_pocRandomAccess == MAX_INT) |
---|
404 | { |
---|
405 | m_pocRandomAccess = iLostPoc; |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | |
---|
410 | Void TDecTop::xActivateParameterSets() |
---|
411 | { |
---|
412 | if (m_bFirstSliceInPicture) |
---|
413 | { |
---|
414 | const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value |
---|
415 | assert (pps != 0); |
---|
416 | |
---|
417 | #if SVC_EXTENSION |
---|
418 | TComSPS *updateSPS = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value |
---|
419 | #endif |
---|
420 | const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value |
---|
421 | assert (sps != 0); |
---|
422 | |
---|
423 | m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId()); |
---|
424 | m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId()); |
---|
425 | |
---|
426 | if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
427 | { |
---|
428 | printf ("Parameter set activation failed!"); |
---|
429 | assert (0); |
---|
430 | } |
---|
431 | |
---|
432 | #if SVC_EXTENSION |
---|
433 | // scaling list settings and checks |
---|
434 | TComVPS *vps = m_parameterSetManager.getVPS(sps->getVPSId()); |
---|
435 | assert (vps != 0); |
---|
436 | |
---|
437 | m_parameterSetManager.clearVPSChangedFlag(sps->getVPSId()); |
---|
438 | |
---|
439 | if( sps->getInferScalingListFlag() ) |
---|
440 | { |
---|
441 | UInt refLayerId = sps->getScalingListRefLayerId(); |
---|
442 | const TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); |
---|
443 | |
---|
444 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
445 | if( vps->getNonHEVCBaseLayerFlag() ) |
---|
446 | { |
---|
447 | assert( refLayerId > 0 ); |
---|
448 | } |
---|
449 | |
---|
450 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
451 | // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id |
---|
452 | assert( refSps->getInferScalingListFlag() == false ); |
---|
453 | |
---|
454 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
455 | // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
456 | assert( vps->getRecursiveRefLayerFlag( sps->getLayerId(), refLayerId ) == true ); |
---|
457 | } |
---|
458 | |
---|
459 | if( pps->getInferScalingListFlag() ) |
---|
460 | { |
---|
461 | UInt refLayerId = pps->getScalingListRefLayerId(); |
---|
462 | const TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); |
---|
463 | |
---|
464 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
465 | if( vps->getNonHEVCBaseLayerFlag() ) |
---|
466 | { |
---|
467 | assert( refLayerId > 0 ); |
---|
468 | } |
---|
469 | |
---|
470 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
471 | // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id |
---|
472 | assert( refPps->getInferScalingListFlag() == false ); |
---|
473 | |
---|
474 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
475 | // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
476 | assert( vps->getRecursiveRefLayerFlag( pps->getLayerId(), refLayerId ) == true ); |
---|
477 | } |
---|
478 | |
---|
479 | #if AVC_BASE |
---|
480 | if( vps->getNonHEVCBaseLayerFlag() ) |
---|
481 | { |
---|
482 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
483 | if( m_layerId > 0 && pBLPic->getPicYuvRec() == NULL ) |
---|
484 | { |
---|
485 | UInt refLayerId = 0; |
---|
486 | const RepFormat* repFormat = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(refLayerId) ); |
---|
487 | |
---|
488 | pBLPic->create( *vps, *sps, *pps, sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), true, refLayerId); |
---|
489 | |
---|
490 | // it is needed where the VPS is accessed through the slice |
---|
491 | pBLPic->getSlice(0)->setVPS( vps ); |
---|
492 | |
---|
493 | g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma(); |
---|
494 | g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma(); |
---|
495 | } |
---|
496 | } |
---|
497 | #endif |
---|
498 | |
---|
499 | if( m_layerId > 0 ) |
---|
500 | { |
---|
501 | // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1. |
---|
502 | updateSPS->setMaxTLayers( vps->getMaxTLayers() ); |
---|
503 | |
---|
504 | // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag |
---|
505 | updateSPS->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true ); |
---|
506 | |
---|
507 | // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0, |
---|
508 | // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS. |
---|
509 | for(UInt i=0; i < sps->getMaxTLayers(); i++) |
---|
510 | { |
---|
511 | // to avoid compiler warning "array subscript is above array bounds" |
---|
512 | assert( i < MAX_TLAYER ); |
---|
513 | |
---|
514 | // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, |
---|
515 | // due to MultiLayerExtSpsFlag being equal to 1, for a layer that refers to the SPS and has nuh_layer_id equal to currLayerId, |
---|
516 | // the value of sps_max_dec_pic_buffering_minus1[ i ] is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOlsIdx ][ layerIdx ][ i ] of the active VPS, |
---|
517 | // where layerIdx is equal to the value such that LayerSetLayerIdList[ TargetDecLayerSetIdx ][ layerIdx ] is equal to currLayerId. |
---|
518 | if( sps->getMultiLayerExtSpsFlag() ) |
---|
519 | { |
---|
520 | updateSPS->setMaxDecPicBuffering( vps->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), vps->getLayerIdcForOls( vps->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx() ), m_layerId ), i) + 1, i); |
---|
521 | } |
---|
522 | |
---|
523 | // The value of sps_max_dec_pic_buffering_minus1[ i ] shall be less than or equal to vps_max_dec_pic_buffering_minus1[ i ] for each value of i. |
---|
524 | assert( sps->getMaxDecPicBuffering(i) <= vps->getMaxDecPicBuffering(i) ); |
---|
525 | } |
---|
526 | |
---|
527 | UInt layerIdx = vps->getLayerIdxInVps( m_layerId ); |
---|
528 | |
---|
529 | if( vps->getBaseLayerPSCompatibilityFlag(layerIdx) ) |
---|
530 | { |
---|
531 | const RepFormat* repFormat = vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx)); |
---|
532 | |
---|
533 | assert( pps->getLayerId() == 0 ); |
---|
534 | assert( sps->getLayerId() == 0 ); |
---|
535 | assert( repFormat->getChromaFormatVpsIdc() == sps->getChromaFormatIdc() ); |
---|
536 | assert( repFormat->getSeparateColourPlaneVpsFlag() == 0 ); |
---|
537 | assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() ); |
---|
538 | assert( repFormat->getPicWidthVpsInLumaSamples() == sps->getPicWidthInLumaSamples() ); |
---|
539 | assert( repFormat->getBitDepthVpsLuma() == sps->getBitDepth(CHANNEL_TYPE_LUMA) ); |
---|
540 | assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) ); |
---|
541 | assert( repFormat->getConformanceWindowVps().getWindowLeftOffset() == sps->getConformanceWindow().getWindowLeftOffset() ); |
---|
542 | assert( repFormat->getConformanceWindowVps().getWindowRightOffset() == sps->getConformanceWindow().getWindowRightOffset() ); |
---|
543 | assert( repFormat->getConformanceWindowVps().getWindowTopOffset() == sps->getConformanceWindow().getWindowTopOffset() ); |
---|
544 | assert( repFormat->getConformanceWindowVps().getWindowBottomOffset() == sps->getConformanceWindow().getWindowBottomOffset() ); |
---|
545 | } |
---|
546 | } |
---|
547 | |
---|
548 | //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer |
---|
549 | UInt layerIdx = vps->getLayerIdxInVps(m_apcSlicePilot->getLayerId()); |
---|
550 | |
---|
551 | if ( vps->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) |
---|
552 | { |
---|
553 | assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() ); |
---|
554 | assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() ); |
---|
555 | assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() ); |
---|
556 | assert( sps->getBitDepth(CHANNEL_TYPE_LUMA) <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() ); |
---|
557 | assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA) <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() ); |
---|
558 | } |
---|
559 | else if ( vps->getVpsExtensionFlag() == 1 ) |
---|
560 | { |
---|
561 | assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()); |
---|
562 | assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples()); |
---|
563 | assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()); |
---|
564 | assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()); |
---|
565 | assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()); |
---|
566 | } |
---|
567 | #endif //SVC_EXTENSION |
---|
568 | |
---|
569 | // TODO: remove the use of the following globals: |
---|
570 | for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++) |
---|
571 | { |
---|
572 | #if SVC_EXTENSION |
---|
573 | g_bitDepth[channel] = isLuma(ChannelType(channel)) ? vps->getBitDepthY(sps, m_apcSlicePilot->getLayerId()) : vps->getBitDepthC(sps, m_apcSlicePilot->getLayerId()); |
---|
574 | #else |
---|
575 | g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel)); |
---|
576 | #endif |
---|
577 | g_maxTrDynamicRange[channel] = (sps->getUseExtendedPrecision()) ? std::max<Int>(15, (g_bitDepth[channel] + 6)) : 15; |
---|
578 | } |
---|
579 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
580 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
581 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
582 | #if SVC_EXTENSION |
---|
583 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(vps->getChromaFormatIdc(sps, m_apcSlicePilot->getLayerId()), sps->getQuadtreeTULog2MinSize())); |
---|
584 | #else |
---|
585 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize())); |
---|
586 | #endif |
---|
587 | |
---|
588 | // 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. |
---|
589 | #if SVC_EXTENSION |
---|
590 | xGetNewPicBuffer( *(vps), *(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer() ); |
---|
591 | #else |
---|
592 | xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer()); |
---|
593 | #endif |
---|
594 | |
---|
595 | #if ALIGNED_BUMPING |
---|
596 | m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); |
---|
597 | #else |
---|
598 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
599 | #endif |
---|
600 | |
---|
601 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
602 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
603 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
604 | |
---|
605 | // we now have a real slice: |
---|
606 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); |
---|
607 | |
---|
608 | // Update the PPS and SPS pointers with the ones of the picture. |
---|
609 | pps=pSlice->getPPS(); |
---|
610 | sps=pSlice->getSPS(); |
---|
611 | |
---|
612 | // Initialise the various objects for the new set of settings |
---|
613 | #if SVC_EXTENSION |
---|
614 | m_cSAO.create( pSlice->getPicWidthInLumaSamples(), pSlice->getPicHeightInLumaSamples(), pSlice->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) ); |
---|
615 | #else |
---|
616 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) ); |
---|
617 | #endif |
---|
618 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
619 | m_cPrediction.initTempBuff(sps->getChromaFormatIdc()); |
---|
620 | |
---|
621 | Bool isField = false; |
---|
622 | Bool isTopField = false; |
---|
623 | |
---|
624 | if(!m_SEIs.empty()) |
---|
625 | { |
---|
626 | // Check if any new Picture Timing SEI has arrived |
---|
627 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
628 | if (pictureTimingSEIs.size()>0) |
---|
629 | { |
---|
630 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
631 | 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); |
---|
632 | isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11); |
---|
633 | } |
---|
634 | |
---|
635 | #if Q0189_TMVP_CONSTRAINTS |
---|
636 | // Check if any new temporal motion vector prediction constraints SEI has arrived |
---|
637 | SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS); |
---|
638 | if (seiTMVPConstrainsList.size() > 0) |
---|
639 | { |
---|
640 | assert ( m_pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 0 |
---|
641 | SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin()); |
---|
642 | if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 ) |
---|
643 | { |
---|
644 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
645 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
646 | while( iterRefPic != m_cListPic.end() ) |
---|
647 | { |
---|
648 | TComPic *refPic = *iterRefPic; |
---|
649 | if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() ) |
---|
650 | { |
---|
651 | for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
652 | { |
---|
653 | TComSlice *refSlice = refPic->getSlice(i); |
---|
654 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
655 | } |
---|
656 | } |
---|
657 | iterRefPic++; |
---|
658 | } |
---|
659 | } |
---|
660 | } |
---|
661 | #endif |
---|
662 | } |
---|
663 | |
---|
664 | //Set Field/Frame coding mode |
---|
665 | m_pcPic->setField(isField); |
---|
666 | m_pcPic->setTopField(isTopField); |
---|
667 | |
---|
668 | // transfer any SEI messages that have been received to the picture |
---|
669 | m_pcPic->setSEIs(m_SEIs); |
---|
670 | m_SEIs.clear(); |
---|
671 | |
---|
672 | // Recursive structure |
---|
673 | #if SVC_EXTENSION |
---|
674 | m_cCuDecoder.create ( sps->getMaxCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), pSlice->getChromaFormatIdc() ); |
---|
675 | m_cCuDecoder.init ( m_ppcTDecTop, &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, m_layerId ); |
---|
676 | #else |
---|
677 | m_cCuDecoder.create ( sps->getMaxCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() ); |
---|
678 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
679 | #endif |
---|
680 | m_cTrQuant.init ( sps->getMaxTrSize() ); |
---|
681 | |
---|
682 | m_cSliceDecoder.create(); |
---|
683 | } |
---|
684 | else |
---|
685 | { |
---|
686 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
687 | m_pcPic->allocateNewSlice(); |
---|
688 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
689 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
690 | |
---|
691 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice. |
---|
692 | |
---|
693 | const TComSPS *sps = pSlice->getSPS(); |
---|
694 | const TComPPS *pps = pSlice->getPPS(); |
---|
695 | |
---|
696 | // check that the current active PPS has not changed... |
---|
697 | if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) ) |
---|
698 | { |
---|
699 | printf("Error - a new SPS has been decoded while processing a picture\n"); |
---|
700 | exit(1); |
---|
701 | } |
---|
702 | if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) ) |
---|
703 | { |
---|
704 | printf("Error - a new PPS has been decoded while processing a picture\n"); |
---|
705 | exit(1); |
---|
706 | } |
---|
707 | |
---|
708 | // Check if any new SEI has arrived |
---|
709 | if(!m_SEIs.empty()) |
---|
710 | { |
---|
711 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
712 | SEIMessages &picSEI = m_pcPic->getSEIs(); |
---|
713 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
714 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
715 | deleteSEIs(m_SEIs); |
---|
716 | } |
---|
717 | } |
---|
718 | |
---|
719 | } |
---|
720 | |
---|
721 | #if SVC_EXTENSION |
---|
722 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
723 | #else |
---|
724 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
725 | #endif |
---|
726 | { |
---|
727 | #if SVC_EXTENSION |
---|
728 | m_apcSlicePilot->initSlice( nalu.m_nuhLayerId ); |
---|
729 | m_apcSlicePilot->setTLayer( nalu.m_temporalId ); |
---|
730 | #else //SVC_EXTENSION |
---|
731 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
732 | // it is not associated with picture, sps or pps structures. |
---|
733 | #endif |
---|
734 | |
---|
735 | if (m_bFirstSliceInPicture) |
---|
736 | { |
---|
737 | m_uiSliceIdx = 0; |
---|
738 | } |
---|
739 | else |
---|
740 | { |
---|
741 | m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
742 | } |
---|
743 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
744 | |
---|
745 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
746 | |
---|
747 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
748 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
749 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
750 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
751 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
752 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
753 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
754 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
755 | |
---|
756 | #if ENC_DEC_TRACE |
---|
757 | const UInt64 originalSymbolCount = g_nSymbolCounter; |
---|
758 | #endif |
---|
759 | |
---|
760 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager); |
---|
761 | |
---|
762 | #if SVC_EXTENSION |
---|
763 | const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); |
---|
764 | assert (pps != 0); |
---|
765 | const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); |
---|
766 | assert (sps != 0); |
---|
767 | const TComVPS *vps = m_parameterSetManager.getVPS(sps->getVPSId()); |
---|
768 | assert (vps != 0); |
---|
769 | |
---|
770 | // Following check should go wherever the VPS is activated |
---|
771 | if( !vps->getBaseLayerAvailableFlag() ) |
---|
772 | { |
---|
773 | assert( nalu.m_nuhLayerId != 0 ); |
---|
774 | assert( vps->getNumAddLayerSets() > 0 ); |
---|
775 | |
---|
776 | if( m_commonDecoderParams->getTargetOutputLayerSetIdx() >= 0 ) |
---|
777 | { |
---|
778 | UInt layerIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
---|
779 | assert( layerIdx > vps->getVpsNumLayerSetsMinus1() ); |
---|
780 | } |
---|
781 | } |
---|
782 | |
---|
783 | setRefLayerParams(vps); |
---|
784 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
785 | #endif |
---|
786 | |
---|
787 | // set POC for dependent slices in skipped pictures |
---|
788 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
789 | { |
---|
790 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
791 | } |
---|
792 | |
---|
793 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
794 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
795 | |
---|
796 | //For inference of NoOutputOfPriorPicsFlag |
---|
797 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
798 | { |
---|
799 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
800 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
801 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
802 | { |
---|
803 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
804 | } |
---|
805 | //the inference for NoOutputPriorPicsFlag |
---|
806 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
807 | { |
---|
808 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
809 | { |
---|
810 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
811 | } |
---|
812 | } |
---|
813 | else |
---|
814 | { |
---|
815 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
816 | } |
---|
817 | |
---|
818 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
819 | { |
---|
820 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
821 | } |
---|
822 | } |
---|
823 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
824 | { |
---|
825 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
826 | m_isNoOutputPriorPics = true; |
---|
827 | } |
---|
828 | else |
---|
829 | { |
---|
830 | m_isNoOutputPriorPics = false; |
---|
831 | } |
---|
832 | |
---|
833 | //For inference of PicOutputFlag |
---|
834 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
835 | { |
---|
836 | if ( m_craNoRaslOutputFlag ) |
---|
837 | { |
---|
838 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
839 | } |
---|
840 | } |
---|
841 | |
---|
842 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
843 | { |
---|
844 | #if !SVC_EXTENSION |
---|
845 | TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); |
---|
846 | assert (pps != 0); |
---|
847 | TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); |
---|
848 | assert (sps != 0); |
---|
849 | #endif |
---|
850 | Int iMaxPOClsb = 1 << sps->getBitsForPOC(); |
---|
851 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
852 | } |
---|
853 | |
---|
854 | // Skip pictures due to random access |
---|
855 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
856 | { |
---|
857 | m_prevSliceSkipped = true; |
---|
858 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
859 | return false; |
---|
860 | } |
---|
861 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
862 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
863 | { |
---|
864 | m_prevSliceSkipped = true; |
---|
865 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
866 | return false; |
---|
867 | } |
---|
868 | |
---|
869 | // clear previous slice skipped flag |
---|
870 | m_prevSliceSkipped = false; |
---|
871 | |
---|
872 | // exit when a new picture is found |
---|
873 | #if SVC_EXTENSION |
---|
874 | bNewPOC = m_apcSlicePilot->getPOC() != m_prevPOC || ( m_apcSlicePilot->getFirstSliceInPic() && m_parseIdc == -1 ); |
---|
875 | |
---|
876 | #if NO_CLRAS_OUTPUT_FLAG |
---|
877 | if( m_layerId == m_smallestLayerId && m_apcSlicePilot->getRapPicFlag() ) |
---|
878 | { |
---|
879 | if( m_bFirstSliceInSequence ) |
---|
880 | { |
---|
881 | setNoClrasOutputFlag(true); |
---|
882 | } |
---|
883 | else if( m_lastPicHasEos ) |
---|
884 | { |
---|
885 | setNoClrasOutputFlag(true); |
---|
886 | } |
---|
887 | else if( m_apcSlicePilot->getBlaPicFlag() ) |
---|
888 | { |
---|
889 | setNoClrasOutputFlag(true); |
---|
890 | } |
---|
891 | else if( m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag() ) |
---|
892 | { |
---|
893 | setNoClrasOutputFlag(true); |
---|
894 | } |
---|
895 | else |
---|
896 | { |
---|
897 | setNoClrasOutputFlag(false); |
---|
898 | } |
---|
899 | } |
---|
900 | else |
---|
901 | { |
---|
902 | setNoClrasOutputFlag(false); |
---|
903 | } |
---|
904 | |
---|
905 | m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag, m_smallestLayerId ); |
---|
906 | #endif |
---|
907 | |
---|
908 | // Derive the value of NoOutputOfPriorPicsFlag |
---|
909 | if( bNewPOC || m_layerId!=m_uiPrevLayerId ) // i.e. new coded picture |
---|
910 | { |
---|
911 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
912 | { |
---|
913 | this->setNoOutputPriorPicsFlag( true ); |
---|
914 | } |
---|
915 | else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
916 | { |
---|
917 | this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() ); |
---|
918 | } |
---|
919 | else |
---|
920 | { |
---|
921 | if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() ) |
---|
922 | { |
---|
923 | this->setNoOutputPriorPicsFlag( true ); |
---|
924 | } |
---|
925 | } |
---|
926 | } |
---|
927 | |
---|
928 | #if SVC_POC |
---|
929 | if( m_parseIdc != -1 ) // Second pass for a POC resetting picture |
---|
930 | { |
---|
931 | m_parseIdc++; // Proceed to POC decoding and RPS derivation |
---|
932 | } |
---|
933 | |
---|
934 | if( m_parseIdc == 2 ) |
---|
935 | { |
---|
936 | bNewPOC = false; |
---|
937 | } |
---|
938 | |
---|
939 | if( (bNewPOC || m_layerId!=m_uiPrevLayerId) && (m_parseIdc == -1) ) // Will be true at the first pass |
---|
940 | { |
---|
941 | //if (bNewPOC || m_layerId!=m_uiPrevLayerId) |
---|
942 | // Check if new reset period has started - this is needed just so that the SHM decoder which calls slice header decoding twice |
---|
943 | // does not invoke the output twice |
---|
944 | //if( m_lastPocPeriodId[m_apcSlicePilot->getLayerId()] == m_apcSlicePilot->getPocResetPeriodId() ) |
---|
945 | // Update CurrAU marking |
---|
946 | if(( m_layerId < m_uiPrevLayerId) ||( ( m_layerId == m_uiPrevLayerId) && bNewPOC)) // Decoding a lower layer than or same layer as previous - mark all earlier pictures as not in current AU |
---|
947 | { |
---|
948 | // New access unit; reset all variables related to POC reset restrictions |
---|
949 | resetPocRestrictionCheckParameters(); |
---|
950 | |
---|
951 | markAllPicsAsNoCurrAu(m_apcSlicePilot->getVPS()); |
---|
952 | |
---|
953 | for( UInt i = 0; i < MAX_LAYERS; i++ ) |
---|
954 | { |
---|
955 | m_ppcTDecTop[m_apcSlicePilot->getVPS()->getLayerIdInNuh(i)]->m_pocDecrementedInDPBFlag = false; |
---|
956 | } |
---|
957 | } |
---|
958 | |
---|
959 | m_pocResettingFlag = false; |
---|
960 | |
---|
961 | if( m_apcSlicePilot->getPocResetIdc() != 0 ) |
---|
962 | { |
---|
963 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
964 | { |
---|
965 | m_pocResettingFlag = true; |
---|
966 | } |
---|
967 | else if (m_pocDecrementedInDPBFlag) |
---|
968 | { |
---|
969 | m_pocResettingFlag = false; |
---|
970 | } |
---|
971 | else |
---|
972 | { |
---|
973 | m_pocResettingFlag = true; |
---|
974 | } |
---|
975 | } |
---|
976 | |
---|
977 | if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
978 | { |
---|
979 | Int pocResetPeriodId = m_apcSlicePilot->getPocResetPeriodId(); |
---|
980 | if ( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 || |
---|
981 | ( m_apcSlicePilot->getPocResetIdc() == 3 && pocResetPeriodId != getLastPocPeriodId() ) ) |
---|
982 | { |
---|
983 | setLastPocPeriodId(pocResetPeriodId); |
---|
984 | m_parseIdc = 0; |
---|
985 | } |
---|
986 | |
---|
987 | // Check if the POC Reset period ID matches with the Reset Period ID |
---|
988 | if( pocResetPeriodId == m_crossLayerPocResetPeriodId ) |
---|
989 | { |
---|
990 | // If matching, and current poc_reset_idc = 3, then the values should match |
---|
991 | if( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
992 | { |
---|
993 | assert( ( m_apcSlicePilot->getFullPocResetFlag() == false && m_crossLayerPocResetIdc == 1 ) || |
---|
994 | ( m_apcSlicePilot->getFullPocResetFlag() == true && m_crossLayerPocResetIdc == 2 ) ); |
---|
995 | } |
---|
996 | } |
---|
997 | else |
---|
998 | { |
---|
999 | // This is the first picture of a POC resetting access unit |
---|
1000 | m_crossLayerPocResetPeriodId = pocResetPeriodId; |
---|
1001 | if( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ) |
---|
1002 | { |
---|
1003 | m_crossLayerPocResetIdc = m_apcSlicePilot->getPocResetIdc(); |
---|
1004 | } |
---|
1005 | else |
---|
1006 | { // poc_reset_idc = 3 |
---|
1007 | // In this case, the entire POC resetting access unit has been lost. |
---|
1008 | // Need more checking to ensure poc_reset_idc = 3 works. |
---|
1009 | assert ( 0 ); |
---|
1010 | } |
---|
1011 | } |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | m_parseIdc = 3; // Proceed to decoding POC and RPS |
---|
1016 | } |
---|
1017 | } |
---|
1018 | #endif |
---|
1019 | |
---|
1020 | #if ALIGNED_BUMPING |
---|
1021 | UInt affectedLayerList[MAX_LAYERS]; |
---|
1022 | Int numAffectedLayers; |
---|
1023 | |
---|
1024 | affectedLayerList[0] = m_apcSlicePilot->getLayerId(); |
---|
1025 | numAffectedLayers = 1; |
---|
1026 | |
---|
1027 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
1028 | { |
---|
1029 | for( UInt j = 0; j < vps->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++ ) |
---|
1030 | { |
---|
1031 | affectedLayerList[j + 1] = vps->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j); |
---|
1032 | } |
---|
1033 | numAffectedLayers = vps->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1; |
---|
1034 | } |
---|
1035 | |
---|
1036 | if( m_parseIdc == 1 && m_pocResettingFlag ) |
---|
1037 | { |
---|
1038 | // Invoke output of pictures if the current picture is a POC reset picture |
---|
1039 | bNewPOC = true; |
---|
1040 | /* Include reset of all POCs in the layer */ |
---|
1041 | |
---|
1042 | // This operation would do the following: |
---|
1043 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
1044 | // 2. Update the value of m_pocCRA. |
---|
1045 | // 3. Reset the POC values at the decoder for the current picture to be zero - will be done later |
---|
1046 | // 4. update value of POCLastDisplay |
---|
1047 | |
---|
1048 | //Do the reset stuff here |
---|
1049 | Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
1050 | Int pocLsbVal; |
---|
1051 | if( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
1052 | { |
---|
1053 | pocLsbVal = m_apcSlicePilot->getPocLsbVal() ; |
---|
1054 | } |
---|
1055 | else |
---|
1056 | { |
---|
1057 | pocLsbVal = (m_apcSlicePilot->getPOC() % maxPocLsb); |
---|
1058 | } |
---|
1059 | |
---|
1060 | Int pocMsbDelta = 0; |
---|
1061 | if( m_apcSlicePilot->getPocMsbValPresentFlag() ) |
---|
1062 | { |
---|
1063 | pocMsbDelta = m_apcSlicePilot->getPocMsbVal() * maxPocLsb; |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | //This MSB derivation can be made into one function. Item to do next. |
---|
1068 | Int prevPoc = this->getPrevPicOrderCnt(); |
---|
1069 | Int prevPocLsb = prevPoc & (maxPocLsb - 1); |
---|
1070 | Int prevPocMsb = prevPoc - prevPocLsb; |
---|
1071 | |
---|
1072 | pocMsbDelta = m_apcSlicePilot->getCurrMsb( pocLsbVal, prevPocLsb, prevPocMsb, maxPocLsb ); |
---|
1073 | } |
---|
1074 | |
---|
1075 | Int pocLsbDelta; |
---|
1076 | if( m_apcSlicePilot->getPocResetIdc() == 2 || ( m_apcSlicePilot->getPocResetIdc() == 3 && m_apcSlicePilot->getFullPocResetFlag() )) |
---|
1077 | { |
---|
1078 | pocLsbDelta = pocLsbVal; |
---|
1079 | } |
---|
1080 | else |
---|
1081 | { |
---|
1082 | pocLsbDelta = 0; |
---|
1083 | } |
---|
1084 | |
---|
1085 | Int deltaPocVal = pocMsbDelta + pocLsbDelta; |
---|
1086 | |
---|
1087 | for( UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++ ) |
---|
1088 | { |
---|
1089 | if (!m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag) |
---|
1090 | { |
---|
1091 | m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag = true; |
---|
1092 | TComList<TComPic*>::iterator iterPic = m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->begin(); |
---|
1093 | |
---|
1094 | while (iterPic != m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->end()) |
---|
1095 | { |
---|
1096 | TComPic *dpbPic = *iterPic; |
---|
1097 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
1098 | // needed for output, are in the same layer, and not the current picture. |
---|
1099 | assert(dpbPic->getLayerId() == affectedLayerList[layerIdx]); |
---|
1100 | |
---|
1101 | if( (dpbPic->getReconMark()) && (dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag()) ) |
---|
1102 | { |
---|
1103 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1104 | { |
---|
1105 | |
---|
1106 | TComSlice *slice = dpbPic->getSlice(i); |
---|
1107 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
1108 | slice->setPOC( slice->getPOC() - deltaPocVal ); |
---|
1109 | |
---|
1110 | // Also adjust the POC value stored in the RPS of each such slice |
---|
1111 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
1112 | { |
---|
1113 | rps->setPOC( j, rps->getPOC(j) - deltaPocVal ); |
---|
1114 | } |
---|
1115 | // Also adjust the value of refPOC |
---|
1116 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
1117 | { |
---|
1118 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
1119 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
1120 | { |
---|
1121 | slice->setRefPOC( slice->getRefPOC(list, j) - deltaPocVal, list, j); |
---|
1122 | } |
---|
1123 | } |
---|
1124 | } |
---|
1125 | } |
---|
1126 | iterPic++; |
---|
1127 | } |
---|
1128 | // Update the value of pocCRA |
---|
1129 | m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocCRA -= deltaPocVal; |
---|
1130 | } |
---|
1131 | } |
---|
1132 | |
---|
1133 | // Update value of POCLastDisplay |
---|
1134 | iPOCLastDisplay -= deltaPocVal; |
---|
1135 | } |
---|
1136 | Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
1137 | Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb(); |
---|
1138 | |
---|
1139 | if( m_pocResettingFlag && (m_parseIdc == 1 || m_parseIdc == 2) ) |
---|
1140 | { |
---|
1141 | // Set poc for current slice |
---|
1142 | if( m_apcSlicePilot->getPocResetIdc() == 1 ) |
---|
1143 | { |
---|
1144 | m_apcSlicePilot->setPOC( slicePicOrderCntLsb ); |
---|
1145 | } |
---|
1146 | else if( m_apcSlicePilot->getPocResetIdc() == 2 ) |
---|
1147 | { |
---|
1148 | m_apcSlicePilot->setPOC( 0 ); |
---|
1149 | } |
---|
1150 | else |
---|
1151 | { |
---|
1152 | Int picOrderCntMsb = m_apcSlicePilot->getCurrMsb( slicePicOrderCntLsb, m_apcSlicePilot->getFullPocResetFlag() ? 0 : m_apcSlicePilot->getPocLsbVal(), 0 , maxPocLsb ); |
---|
1153 | m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb ); |
---|
1154 | } |
---|
1155 | } |
---|
1156 | else if (m_parseIdc == 3) |
---|
1157 | { |
---|
1158 | Int picOrderCntMsb = 0; |
---|
1159 | if( m_apcSlicePilot->getPocMsbValPresentFlag() ) |
---|
1160 | { |
---|
1161 | picOrderCntMsb = m_apcSlicePilot->getPocMsbVal() * maxPocLsb; |
---|
1162 | } |
---|
1163 | else if( m_apcSlicePilot->getIdrPicFlag() ) |
---|
1164 | { |
---|
1165 | picOrderCntMsb = 0; |
---|
1166 | } |
---|
1167 | else |
---|
1168 | { |
---|
1169 | Int prevPicOrderCntLsb = this->getPrevPicOrderCnt() & ( maxPocLsb - 1); |
---|
1170 | Int prevPicOrderCntMsb = this->getPrevPicOrderCnt() - prevPicOrderCntLsb; |
---|
1171 | picOrderCntMsb = m_apcSlicePilot->getCurrMsb(slicePicOrderCntLsb, prevPicOrderCntLsb, prevPicOrderCntMsb, maxPocLsb ); |
---|
1172 | } |
---|
1173 | m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb ); |
---|
1174 | } |
---|
1175 | |
---|
1176 | if( m_parseIdc == 1 || m_parseIdc == 3) |
---|
1177 | { |
---|
1178 | // Adjust prevPicOrderCnt |
---|
1179 | if( !m_apcSlicePilot->getRaslPicFlag() |
---|
1180 | && !m_apcSlicePilot->getRadlPicFlag() |
---|
1181 | && (m_apcSlicePilot->getNalUnitType() % 2 == 1) |
---|
1182 | && ( nalu.m_temporalId == 0 ) |
---|
1183 | && !m_apcSlicePilot->getDiscardableFlag() ) |
---|
1184 | { |
---|
1185 | for( UInt i = 0; i < numAffectedLayers; i++ ) |
---|
1186 | { |
---|
1187 | m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt(m_apcSlicePilot->getPOC()); |
---|
1188 | } |
---|
1189 | } |
---|
1190 | else if( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
1191 | { |
---|
1192 | if( !m_firstPicInLayerDecodedFlag || (m_firstPicInLayerDecodedFlag && m_pocResettingFlag) ) |
---|
1193 | { |
---|
1194 | for( UInt i = 0; i < numAffectedLayers; i++ ) |
---|
1195 | { |
---|
1196 | m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() ? 0 : m_apcSlicePilot->getPocLsbVal() ); |
---|
1197 | } |
---|
1198 | } |
---|
1199 | } |
---|
1200 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
1201 | } |
---|
1202 | |
---|
1203 | if( !m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence ) |
---|
1204 | #else |
---|
1205 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
1206 | #endif |
---|
1207 | { |
---|
1208 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1209 | curLayerId = m_uiPrevLayerId; |
---|
1210 | m_uiPrevLayerId = m_layerId; |
---|
1211 | return true; |
---|
1212 | } |
---|
1213 | |
---|
1214 | m_parseIdc = -1; |
---|
1215 | |
---|
1216 | if( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 ) |
---|
1217 | { |
---|
1218 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
1219 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
1220 | |
---|
1221 | while( iterRefPic != m_cListPic.end() ) |
---|
1222 | { |
---|
1223 | TComPic *refPic = *iterRefPic; |
---|
1224 | if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() ) |
---|
1225 | { |
---|
1226 | for( Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i-- ) |
---|
1227 | { |
---|
1228 | |
---|
1229 | TComSlice *refSlice = refPic->getSlice(i); |
---|
1230 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
1231 | } |
---|
1232 | } |
---|
1233 | iterRefPic++; |
---|
1234 | } |
---|
1235 | } |
---|
1236 | m_apcSlicePilot->setAvailableForTMVPRefFlag( true ); |
---|
1237 | |
---|
1238 | // Initialize ILRP if needed, only for the current layer |
---|
1239 | // ILRP intialization should go along with activation of parameters sets, |
---|
1240 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
1241 | xInitILRP(m_apcSlicePilot); |
---|
1242 | |
---|
1243 | #else //SVC_EXTENSION |
---|
1244 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
1245 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) |
---|
1246 | { |
---|
1247 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
1248 | } |
---|
1249 | |
---|
1250 | // exit when a new picture is found |
---|
1251 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) |
---|
1252 | { |
---|
1253 | if (m_prevPOC >= m_pocRandomAccess) |
---|
1254 | { |
---|
1255 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1256 | #if ENC_DEC_TRACE |
---|
1257 | //rewind the trace counter since we didn't actually decode the slice |
---|
1258 | g_nSymbolCounter = originalSymbolCount; |
---|
1259 | #endif |
---|
1260 | return true; |
---|
1261 | } |
---|
1262 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1263 | } |
---|
1264 | #endif //SVC_EXTENSION |
---|
1265 | |
---|
1266 | //detect lost reference picture and insert copy of earlier frame. |
---|
1267 | { |
---|
1268 | Int lostPoc; |
---|
1269 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
1270 | { |
---|
1271 | xCreateLostPicture(lostPoc-1); |
---|
1272 | } |
---|
1273 | } |
---|
1274 | |
---|
1275 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
1276 | { |
---|
1277 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1278 | #if SVC_EXTENSION |
---|
1279 | curLayerId = m_layerId; |
---|
1280 | m_uiPrevLayerId = m_layerId; |
---|
1281 | #endif |
---|
1282 | } |
---|
1283 | |
---|
1284 | // actual decoding starts here |
---|
1285 | xActivateParameterSets(); |
---|
1286 | |
---|
1287 | m_bFirstSliceInSequence = false; |
---|
1288 | m_bFirstSliceInBitstream = false; |
---|
1289 | |
---|
1290 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1291 | |
---|
1292 | #if SVC_EXTENSION |
---|
1293 | if (m_bFirstSliceInPicture) |
---|
1294 | { |
---|
1295 | #if AVC_BASE |
---|
1296 | if( m_layerId > 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
1297 | { |
---|
1298 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1299 | pBLPic->getSlice(0)->setReferenced(true); |
---|
1300 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
1301 | |
---|
1302 | if( pFile->good() ) |
---|
1303 | { |
---|
1304 | Bool is16bit = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8; |
---|
1305 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y); |
---|
1306 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y); |
---|
1307 | |
---|
1308 | Int len = uiWidth * (is16bit ? 2 : 1); |
---|
1309 | UChar *buf = new UChar[len]; |
---|
1310 | |
---|
1311 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
1312 | if( is16bit ) |
---|
1313 | { |
---|
1314 | uiPos <<= 1; |
---|
1315 | } |
---|
1316 | |
---|
1317 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
1318 | |
---|
1319 | // read Y component |
---|
1320 | Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y); |
---|
1321 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y); |
---|
1322 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1323 | { |
---|
1324 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1325 | |
---|
1326 | if( !is16bit ) |
---|
1327 | { |
---|
1328 | for (Int x = 0; x < uiWidth; x++) |
---|
1329 | { |
---|
1330 | pPel[x] = buf[x]; |
---|
1331 | } |
---|
1332 | } |
---|
1333 | else |
---|
1334 | { |
---|
1335 | for (Int x = 0; x < uiWidth; x++) |
---|
1336 | { |
---|
1337 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1338 | } |
---|
1339 | } |
---|
1340 | |
---|
1341 | pPel += uiStride; |
---|
1342 | } |
---|
1343 | |
---|
1344 | len >>= 1; |
---|
1345 | uiWidth >>= 1; |
---|
1346 | uiHeight >>= 1; |
---|
1347 | |
---|
1348 | // read Cb component |
---|
1349 | pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb); |
---|
1350 | uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb); |
---|
1351 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1352 | { |
---|
1353 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1354 | |
---|
1355 | if( !is16bit ) |
---|
1356 | { |
---|
1357 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1358 | { |
---|
1359 | pPel[x] = buf[x]; |
---|
1360 | } |
---|
1361 | } |
---|
1362 | else |
---|
1363 | { |
---|
1364 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1365 | { |
---|
1366 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1367 | } |
---|
1368 | } |
---|
1369 | |
---|
1370 | pPel += uiStride; |
---|
1371 | } |
---|
1372 | |
---|
1373 | // read Cr component |
---|
1374 | pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr); |
---|
1375 | uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr); |
---|
1376 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1377 | { |
---|
1378 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1379 | |
---|
1380 | if( !is16bit ) |
---|
1381 | { |
---|
1382 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1383 | { |
---|
1384 | pPel[x] = buf[x]; |
---|
1385 | } |
---|
1386 | } |
---|
1387 | else |
---|
1388 | { |
---|
1389 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1390 | { |
---|
1391 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1392 | } |
---|
1393 | } |
---|
1394 | |
---|
1395 | pPel += uiStride; |
---|
1396 | } |
---|
1397 | |
---|
1398 | delete[] buf; |
---|
1399 | } |
---|
1400 | } |
---|
1401 | #endif |
---|
1402 | |
---|
1403 | if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() ) |
---|
1404 | { |
---|
1405 | for (UInt i = 0; i < vps->getMaxLayers(); i++) |
---|
1406 | { |
---|
1407 | m_ppcTDecTop[i]->setLayerInitializedFlag(false); |
---|
1408 | m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false); |
---|
1409 | } |
---|
1410 | } |
---|
1411 | |
---|
1412 | xCheckLayerReset(); |
---|
1413 | xSetLayerInitializedFlag(); |
---|
1414 | |
---|
1415 | #if SVC_POC |
---|
1416 | m_pcPic->setCurrAuFlag( true ); |
---|
1417 | |
---|
1418 | if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag ) |
---|
1419 | { |
---|
1420 | // IDR picture with nuh_layer_id > 0 present |
---|
1421 | m_nonBaseIdrPresentFlag = true; |
---|
1422 | m_nonBaseIdrType = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1423 | } |
---|
1424 | else |
---|
1425 | { |
---|
1426 | if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
1427 | { |
---|
1428 | // Picture with nal_unit_type not equal IDR_W_RADL present |
---|
1429 | m_picNonIdrWithRadlPresentFlag = true; |
---|
1430 | } |
---|
1431 | if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1432 | { |
---|
1433 | // Picture with nal_unit_type not equal IDR_N_LP present |
---|
1434 | m_picNonIdrNoLpPresentFlag = true; |
---|
1435 | } |
---|
1436 | } |
---|
1437 | if( !m_checkPocRestrictionsForCurrAu ) // Will be true for the first slice/picture of the AU |
---|
1438 | { |
---|
1439 | m_checkPocRestrictionsForCurrAu = true; |
---|
1440 | m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc(); |
---|
1441 | if( m_pcPic->getLayerId() == 0 ) |
---|
1442 | { |
---|
1443 | // Base layer picture is present |
---|
1444 | m_baseLayerPicPresentFlag = true; |
---|
1445 | if( m_apcSlicePilot->isIRAP() ) |
---|
1446 | { |
---|
1447 | // Base layer picture is IRAP |
---|
1448 | m_baseLayerIrapFlag = true; |
---|
1449 | } |
---|
1450 | if( m_apcSlicePilot->isIDR() ) |
---|
1451 | { |
---|
1452 | // Base layer picture is IDR |
---|
1453 | m_baseLayerIdrFlag = true; |
---|
1454 | } |
---|
1455 | else |
---|
1456 | { |
---|
1457 | if( vps->getBaseLayerInternalFlag()) |
---|
1458 | { |
---|
1459 | /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture |
---|
1460 | and vps_base_layer_internal_flag is equal to 1, the value of poc_reset_idc shall not be equal to 2 |
---|
1461 | for any picture in the access unit. */ |
---|
1462 | assert( m_apcSlicePilot->getPocResetIdc() != 2 ); |
---|
1463 | } |
---|
1464 | } |
---|
1465 | } |
---|
1466 | } |
---|
1467 | else |
---|
1468 | { |
---|
1469 | // The value of poc_reset_idc of all coded pictures that are present in the bitstream in an access unit shall be the same. |
---|
1470 | assert( m_pocResetIdcOrCurrAu == m_apcSlicePilot->getPocResetIdc() ); |
---|
1471 | |
---|
1472 | /* When the picture in an access unit with nuh_layer_id equal to 0 is an IRAP picture and vps_base_layer_internal_flag is equal to 1 |
---|
1473 | and there is at least one other picture in the same access unit that is not an IRAP picture, |
---|
1474 | the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ |
---|
1475 | if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && vps->getBaseLayerInternalFlag() ) |
---|
1476 | { |
---|
1477 | assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1478 | } |
---|
1479 | |
---|
1480 | /* When the picture with nuh_layer_id equal to 0 in an access unit is an IDR picture and |
---|
1481 | vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit, |
---|
1482 | the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */ |
---|
1483 | if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && vps->getBaseLayerInternalFlag() ) |
---|
1484 | { |
---|
1485 | assert( m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1486 | } |
---|
1487 | |
---|
1488 | /* When there is at least one picture that has nuh_layer_id greater than 0 and that is an IDR picture |
---|
1489 | with a particular value of nal_unit_type in an access unit and there is at least one other coded picture |
---|
1490 | that is present in the bitstream in the same access unit with a different value of nal_unit_type, |
---|
1491 | the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ |
---|
1492 | if( m_nonBaseIdrPresentFlag && ( |
---|
1493 | ( m_nonBaseIdrType == 1 && m_picNonIdrWithRadlPresentFlag ) || |
---|
1494 | ( m_nonBaseIdrType == 0 && m_picNonIdrNoLpPresentFlag ) |
---|
1495 | )) |
---|
1496 | { |
---|
1497 | assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1498 | } |
---|
1499 | } |
---|
1500 | #endif |
---|
1501 | } |
---|
1502 | #endif //SVC_EXTENSION |
---|
1503 | |
---|
1504 | // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. |
---|
1505 | // Now, having set up the maps, convert them to the correct form. |
---|
1506 | pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); |
---|
1507 | pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); |
---|
1508 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
1509 | { |
---|
1510 | pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); |
---|
1511 | pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); |
---|
1512 | } |
---|
1513 | |
---|
1514 | m_pcPic->setTLayer(nalu.m_temporalId); |
---|
1515 | |
---|
1516 | #if SVC_EXTENSION |
---|
1517 | m_pcPic->setLayerId(nalu.m_nuhLayerId); |
---|
1518 | pcSlice->setLayerId(nalu.m_nuhLayerId); |
---|
1519 | pcSlice->setPic(m_pcPic); |
---|
1520 | #endif |
---|
1521 | |
---|
1522 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
1523 | { |
---|
1524 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
1525 | // Set reference list |
---|
1526 | #if SVC_EXTENSION |
---|
1527 | if (m_layerId == 0) |
---|
1528 | #endif |
---|
1529 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
1530 | |
---|
1531 | #if SVC_EXTENSION |
---|
1532 | // Create upsampling reference layer pictures for all possible dependent layers and do it only once for the first slice. |
---|
1533 | // Other slices might choose which reference pictures to be used for inter-layer prediction |
---|
1534 | if( m_layerId > 0 && m_uiSliceIdx == 0 && ( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || pcSlice->isIRAP() ) ) |
---|
1535 | { |
---|
1536 | for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1537 | { |
---|
1538 | UInt refLayerIdc = i; |
---|
1539 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc); |
---|
1540 | #if AVC_BASE |
---|
1541 | if( refLayerId == 0 && m_parameterSetManager.getActiveVPS()->getNonHEVCBaseLayerFlag() ) |
---|
1542 | { |
---|
1543 | TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); |
---|
1544 | |
---|
1545 | if( pic ) |
---|
1546 | { |
---|
1547 | pcSlice->setBaseColPic ( refLayerIdc, pic ); |
---|
1548 | } |
---|
1549 | else |
---|
1550 | { |
---|
1551 | continue; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | else |
---|
1555 | { |
---|
1556 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1557 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1558 | if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) ) |
---|
1559 | { |
---|
1560 | continue; |
---|
1561 | } |
---|
1562 | } |
---|
1563 | #else |
---|
1564 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1565 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1566 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1567 | #endif |
---|
1568 | |
---|
1569 | const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
1570 | const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); |
---|
1571 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); |
---|
1572 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); |
---|
1573 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
1574 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
1575 | |
---|
1576 | // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0 |
---|
1577 | assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0); |
---|
1578 | |
---|
1579 | // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY |
---|
1580 | assert(widthEL >= widthBL && heightEL >= heightBL); |
---|
1581 | |
---|
1582 | // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0. |
---|
1583 | const ResamplingPhase &resamplingPhase = pcSlice->getPPS()->getResamplingPhase( refLayerId ); |
---|
1584 | |
---|
1585 | assert( ( (widthEL != widthBL) || (resamplingPhase.phaseHorLuma == 0 && resamplingPhase.phaseHorChroma == 0) ) |
---|
1586 | && ( (heightEL != heightBL) || (resamplingPhase.phaseVerLuma == 0 && resamplingPhase.phaseVerChroma == 0) ) ); |
---|
1587 | |
---|
1588 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
1589 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
1590 | |
---|
1591 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
1592 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
1593 | |
---|
1594 | #if CGS_3D_ASYMLUT |
---|
1595 | TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); |
---|
1596 | if( pcSlice->getPPS()->getCGSFlag() && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ) ) |
---|
1597 | { |
---|
1598 | assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() ); |
---|
1599 | assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() ); |
---|
1600 | assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() ); |
---|
1601 | assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() ); |
---|
1602 | |
---|
1603 | if( !m_pColorMappedPic ) |
---|
1604 | { |
---|
1605 | initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)); |
---|
1606 | } |
---|
1607 | |
---|
1608 | m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pColorMappedPic ); |
---|
1609 | pBaseColRec = m_pColorMappedPic; |
---|
1610 | } |
---|
1611 | #endif |
---|
1612 | |
---|
1613 | if( m_pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
1614 | { |
---|
1615 | // check for the sample prediction picture type |
---|
1616 | if( pcSlice->getVPS()->isSamplePredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), pcSlice->getVPS()->getLayerIdxInVps(refLayerId) ) ) |
---|
1617 | { |
---|
1618 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec()); |
---|
1619 | } |
---|
1620 | } |
---|
1621 | else |
---|
1622 | { |
---|
1623 | m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
1624 | } |
---|
1625 | pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1626 | } |
---|
1627 | } |
---|
1628 | |
---|
1629 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
1630 | { |
---|
1631 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1632 | { |
---|
1633 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1634 | #if AVC_BASE |
---|
1635 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && pcSlice->getVPS()->getNonHEVCBaseLayerFlag() ) |
---|
1636 | { |
---|
1637 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
1638 | } |
---|
1639 | else |
---|
1640 | { |
---|
1641 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1642 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1643 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1644 | } |
---|
1645 | #else |
---|
1646 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1647 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1648 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1649 | #endif |
---|
1650 | |
---|
1651 | pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1652 | } |
---|
1653 | |
---|
1654 | pcSlice->setILRPic( m_cIlpPic ); |
---|
1655 | |
---|
1656 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
1657 | } |
---|
1658 | else if ( m_layerId > 0 ) |
---|
1659 | { |
---|
1660 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
1661 | } |
---|
1662 | |
---|
1663 | // motion field mapping constraint |
---|
1664 | if( pcSlice->getMFMEnabledFlag() ) |
---|
1665 | { |
---|
1666 | TComPic* refPic = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() ); |
---|
1667 | |
---|
1668 | assert( refPic ); |
---|
1669 | |
---|
1670 | Int refLayerId = refPic->getLayerId(); |
---|
1671 | |
---|
1672 | if( refLayerId != pcSlice->getLayerId() ) |
---|
1673 | { |
---|
1674 | TComPic* pColBasePic = pcSlice->getBaseColPic( *m_ppcTDecTop[refLayerId]->getListPic() ); |
---|
1675 | assert( pColBasePic->checkSameRefInfo() == true ); |
---|
1676 | } |
---|
1677 | } |
---|
1678 | |
---|
1679 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() && ( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || pcSlice->isIRAP() ) ) |
---|
1680 | { |
---|
1681 | for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1682 | { |
---|
1683 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1684 | TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); |
---|
1685 | if(refpicLayer && pcSlice->isIRAP()) |
---|
1686 | { |
---|
1687 | assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType()); |
---|
1688 | } |
---|
1689 | } |
---|
1690 | } |
---|
1691 | |
---|
1692 | if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) |
---|
1693 | { |
---|
1694 | TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx()); |
---|
1695 | |
---|
1696 | assert( refPic ); |
---|
1697 | assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true ); |
---|
1698 | |
---|
1699 | // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, |
---|
1700 | // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture. |
---|
1701 | if( refPic->isILR(pcSlice->getLayerId()) ) |
---|
1702 | { |
---|
1703 | assert( pcSlice->getVPS()->isMotionPredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), refPic->getLayerIdx() ) ); |
---|
1704 | } |
---|
1705 | } |
---|
1706 | #endif //SVC_EXTENSION |
---|
1707 | |
---|
1708 | // For generalized B |
---|
1709 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1710 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1711 | { |
---|
1712 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1713 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1714 | |
---|
1715 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1716 | { |
---|
1717 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1718 | } |
---|
1719 | } |
---|
1720 | if (!pcSlice->isIntra()) |
---|
1721 | { |
---|
1722 | Bool bLowDelay = true; |
---|
1723 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1724 | Int iRefIdx = 0; |
---|
1725 | |
---|
1726 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1727 | { |
---|
1728 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1729 | { |
---|
1730 | bLowDelay = false; |
---|
1731 | } |
---|
1732 | } |
---|
1733 | if (pcSlice->isInterB()) |
---|
1734 | { |
---|
1735 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1736 | { |
---|
1737 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1738 | { |
---|
1739 | bLowDelay = false; |
---|
1740 | } |
---|
1741 | } |
---|
1742 | } |
---|
1743 | |
---|
1744 | pcSlice->setCheckLDC(bLowDelay); |
---|
1745 | } |
---|
1746 | |
---|
1747 | //--------------- |
---|
1748 | pcSlice->setRefPOCList(); |
---|
1749 | } |
---|
1750 | |
---|
1751 | m_pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1752 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1753 | { |
---|
1754 | TComScalingList scalingList; |
---|
1755 | |
---|
1756 | #if SVC_EXTENSION |
---|
1757 | if( pcSlice->getPPS()->getInferScalingListFlag() ) |
---|
1758 | { |
---|
1759 | const TComPPS *refPps = m_ppcTDecTop[pcSlice->getPPS()->getScalingListRefLayerId()]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); |
---|
1760 | scalingList = refPps->getScalingList(); |
---|
1761 | } |
---|
1762 | else |
---|
1763 | #endif |
---|
1764 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
1765 | { |
---|
1766 | scalingList = pcSlice->getPPS()->getScalingList(); |
---|
1767 | } |
---|
1768 | #if SVC_EXTENSION |
---|
1769 | else if( pcSlice->getSPS()->getInferScalingListFlag() ) |
---|
1770 | { |
---|
1771 | const TComSPS *refSps = m_ppcTDecTop[pcSlice->getSPS()->getScalingListRefLayerId()]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); |
---|
1772 | scalingList = refSps->getScalingList(); |
---|
1773 | } |
---|
1774 | #endif |
---|
1775 | else if (pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
1776 | { |
---|
1777 | scalingList = pcSlice->getSPS()->getScalingList(); |
---|
1778 | } |
---|
1779 | else |
---|
1780 | { |
---|
1781 | scalingList.setDefaultScalingList(); |
---|
1782 | } |
---|
1783 | #if SVC_EXTENSION |
---|
1784 | m_cTrQuant.setScalingListDec(scalingList, pcSlice->getChromaFormatIdc()); |
---|
1785 | #else |
---|
1786 | m_cTrQuant.setScalingListDec(scalingList, pcSlice->getSPS()->getChromaFormatIdc()); |
---|
1787 | #endif |
---|
1788 | m_cTrQuant.setUseScalingList(true); |
---|
1789 | } |
---|
1790 | else |
---|
1791 | { |
---|
1792 | #if SVC_EXTENSION |
---|
1793 | m_cTrQuant.setFlatScalingList(pcSlice->getChromaFormatIdc()); |
---|
1794 | #else |
---|
1795 | m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc()); |
---|
1796 | #endif |
---|
1797 | m_cTrQuant.setUseScalingList(false); |
---|
1798 | } |
---|
1799 | |
---|
1800 | // Decode a picture |
---|
1801 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic); |
---|
1802 | |
---|
1803 | #if SVC_EXTENSION |
---|
1804 | setFirstPicInLayerDecodedFlag(true); |
---|
1805 | m_lastPicHasEos = false; |
---|
1806 | #endif |
---|
1807 | |
---|
1808 | m_bFirstSliceInPicture = false; |
---|
1809 | m_uiSliceIdx++; |
---|
1810 | |
---|
1811 | return false; |
---|
1812 | } |
---|
1813 | |
---|
1814 | Void TDecTop::xDecodeVPS(const std::vector<UChar> *pNaluData) |
---|
1815 | { |
---|
1816 | TComVPS* vps = new TComVPS(); |
---|
1817 | |
---|
1818 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1819 | m_parameterSetManager.storeVPS(vps, pNaluData); |
---|
1820 | #if SVC_EXTENSION |
---|
1821 | checkValueOfTargetOutputLayerSetIdx(vps); |
---|
1822 | |
---|
1823 | #if AVC_BASE |
---|
1824 | if( vps->getNonHEVCBaseLayerFlag() ) |
---|
1825 | { |
---|
1826 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
1827 | { |
---|
1828 | printf( "Base layer YUV input reading error\n" ); |
---|
1829 | exit(EXIT_FAILURE); |
---|
1830 | } |
---|
1831 | } |
---|
1832 | else |
---|
1833 | { |
---|
1834 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
1835 | cListPic->clear(); |
---|
1836 | } |
---|
1837 | #endif |
---|
1838 | |
---|
1839 | xDeriveSmallestLayerId(vps); |
---|
1840 | #endif |
---|
1841 | } |
---|
1842 | |
---|
1843 | Void TDecTop::xDecodeSPS(const std::vector<UChar> *pNaluData) |
---|
1844 | { |
---|
1845 | TComSPS* sps = new TComSPS(); |
---|
1846 | #if O0043_BEST_EFFORT_DECODING |
---|
1847 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
1848 | #endif |
---|
1849 | #if SVC_EXTENSION |
---|
1850 | sps->setLayerId(m_layerId); |
---|
1851 | #endif |
---|
1852 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1853 | m_parameterSetManager.storeSPS(sps, pNaluData); |
---|
1854 | } |
---|
1855 | |
---|
1856 | #if CGS_3D_ASYMLUT |
---|
1857 | Void TDecTop::xDecodePPS( const std::vector<UChar> *pNaluData, TCom3DAsymLUT * pc3DAsymLUT ) |
---|
1858 | #else |
---|
1859 | Void TDecTop::xDecodePPS(const std::vector<UChar> *pNaluData) |
---|
1860 | #endif |
---|
1861 | { |
---|
1862 | TComPPS* pps = new TComPPS(); |
---|
1863 | |
---|
1864 | #if SVC_EXTENSION |
---|
1865 | pps->setLayerId( m_layerId ); |
---|
1866 | #endif |
---|
1867 | #if CGS_3D_ASYMLUT |
---|
1868 | m_cEntropyDecoder.decodePPS( pps, pc3DAsymLUT, m_layerId ); |
---|
1869 | #else |
---|
1870 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1871 | #endif |
---|
1872 | m_parameterSetManager.storePPS( pps, pNaluData); |
---|
1873 | } |
---|
1874 | |
---|
1875 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
1876 | { |
---|
1877 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1878 | { |
---|
1879 | #if SVC_EXTENSION |
---|
1880 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
1881 | { |
---|
1882 | return; |
---|
1883 | } |
---|
1884 | #endif |
---|
1885 | #if LAYERS_NOT_PRESENT_SEI |
---|
1886 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
1887 | #else |
---|
1888 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
1889 | #endif |
---|
1890 | } |
---|
1891 | else |
---|
1892 | { |
---|
1893 | #if LAYERS_NOT_PRESENT_SEI |
---|
1894 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
1895 | #else |
---|
1896 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
1897 | #endif |
---|
1898 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1899 | if (activeParamSets.size()>0) |
---|
1900 | { |
---|
1901 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1902 | #if R0247_SEI_ACTIVE |
---|
1903 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
1904 | if( !getLayerDec(0)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) |
---|
1905 | { |
---|
1906 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1907 | } |
---|
1908 | for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++) |
---|
1909 | { |
---|
1910 | Int layerIdx = seiAps->layerSpsIdx[c]; |
---|
1911 | if( !getLayerDec(layerIdx)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) ) |
---|
1912 | { |
---|
1913 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1914 | } |
---|
1915 | } |
---|
1916 | #else |
---|
1917 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
1918 | if (! m_parameterSetManager.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] )) |
---|
1919 | { |
---|
1920 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1921 | } |
---|
1922 | #endif |
---|
1923 | } |
---|
1924 | } |
---|
1925 | } |
---|
1926 | |
---|
1927 | #if SVC_EXTENSION |
---|
1928 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
1929 | #else |
---|
1930 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1931 | #endif |
---|
1932 | { |
---|
1933 | #if !SVC_EXTENSION |
---|
1934 | // ignore all NAL units of layers > 0 |
---|
1935 | if (nalu.m_nuhLayerId > 0) |
---|
1936 | { |
---|
1937 | fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId); |
---|
1938 | return false; |
---|
1939 | } |
---|
1940 | #endif |
---|
1941 | // Initialize entropy decoder |
---|
1942 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1943 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1944 | |
---|
1945 | #if SVC_EXTENSION |
---|
1946 | // ignore any NAL units with nuh_layer_id == 63 |
---|
1947 | if( nalu.m_nuhLayerId == 63 ) |
---|
1948 | { |
---|
1949 | return false; |
---|
1950 | } |
---|
1951 | #endif |
---|
1952 | switch (nalu.m_nalUnitType) |
---|
1953 | { |
---|
1954 | case NAL_UNIT_VPS: |
---|
1955 | #if SVC_EXTENSION |
---|
1956 | assert( nalu.m_nuhLayerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
1957 | #endif |
---|
1958 | xDecodeVPS(nalu.m_Bitstream->getFifo()); |
---|
1959 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1960 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
1961 | #endif |
---|
1962 | #if SVC_EXTENSION |
---|
1963 | m_isLastNALWasEos = false; |
---|
1964 | #endif |
---|
1965 | return false; |
---|
1966 | |
---|
1967 | case NAL_UNIT_SPS: |
---|
1968 | xDecodeSPS(nalu.m_Bitstream->getFifo()); |
---|
1969 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1970 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
1971 | #endif |
---|
1972 | return false; |
---|
1973 | |
---|
1974 | case NAL_UNIT_PPS: |
---|
1975 | #if CGS_3D_ASYMLUT |
---|
1976 | xDecodePPS( nalu.m_Bitstream->getFifo(), &m_c3DAsymLUTPPS ); |
---|
1977 | #else |
---|
1978 | xDecodePPS(nalu.m_Bitstream->getFifo()); |
---|
1979 | #endif |
---|
1980 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1981 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
1982 | #endif |
---|
1983 | return false; |
---|
1984 | |
---|
1985 | case NAL_UNIT_PREFIX_SEI: |
---|
1986 | case NAL_UNIT_SUFFIX_SEI: |
---|
1987 | #if SVC_EXTENSION |
---|
1988 | if( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI ) |
---|
1989 | { |
---|
1990 | assert( m_isLastNALWasEos == false ); |
---|
1991 | } |
---|
1992 | #endif |
---|
1993 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
1994 | return false; |
---|
1995 | |
---|
1996 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1997 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1998 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
1999 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2000 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2001 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2002 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2003 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2004 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2005 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2006 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2007 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2008 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2009 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2010 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2011 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2012 | #if SVC_EXTENSION |
---|
2013 | if( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
2014 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
2015 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
2016 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
2017 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ) |
---|
2018 | { |
---|
2019 | assert( m_isLastNALWasEos == false ); |
---|
2020 | } |
---|
2021 | else |
---|
2022 | { |
---|
2023 | m_isLastNALWasEos = false; |
---|
2024 | } |
---|
2025 | |
---|
2026 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
2027 | #else |
---|
2028 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
2029 | #endif |
---|
2030 | break; |
---|
2031 | |
---|
2032 | case NAL_UNIT_EOS: |
---|
2033 | #if SVC_EXTENSION |
---|
2034 | assert( m_isLastNALWasEos == false ); |
---|
2035 | |
---|
2036 | m_isLastNALWasEos = true; |
---|
2037 | m_lastPicHasEos = true; |
---|
2038 | #endif |
---|
2039 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
2040 | m_pocCRA = 0; |
---|
2041 | m_pocRandomAccess = MAX_INT; |
---|
2042 | m_prevPOC = MAX_INT; |
---|
2043 | m_prevSliceSkipped = false; |
---|
2044 | m_skippedPOC = 0; |
---|
2045 | return false; |
---|
2046 | |
---|
2047 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
2048 | // TODO: process AU delimiter |
---|
2049 | return false; |
---|
2050 | |
---|
2051 | case NAL_UNIT_EOB: |
---|
2052 | #if SVC_EXTENSION |
---|
2053 | //Check layer id of the nalu. if it is not 0, give a warning message. |
---|
2054 | if (nalu.m_nuhLayerId > 0) |
---|
2055 | { |
---|
2056 | printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" ); |
---|
2057 | } |
---|
2058 | #endif |
---|
2059 | return false; |
---|
2060 | |
---|
2061 | case NAL_UNIT_FILLER_DATA: |
---|
2062 | #if SVC_EXTENSION |
---|
2063 | assert( m_isLastNALWasEos == false ); |
---|
2064 | #endif |
---|
2065 | return false; |
---|
2066 | |
---|
2067 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
2068 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
2069 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
2070 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
2071 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
2072 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
2073 | |
---|
2074 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
2075 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
2076 | |
---|
2077 | case NAL_UNIT_RESERVED_VCL24: |
---|
2078 | case NAL_UNIT_RESERVED_VCL25: |
---|
2079 | case NAL_UNIT_RESERVED_VCL26: |
---|
2080 | case NAL_UNIT_RESERVED_VCL27: |
---|
2081 | case NAL_UNIT_RESERVED_VCL28: |
---|
2082 | case NAL_UNIT_RESERVED_VCL29: |
---|
2083 | case NAL_UNIT_RESERVED_VCL30: |
---|
2084 | case NAL_UNIT_RESERVED_VCL31: |
---|
2085 | |
---|
2086 | case NAL_UNIT_RESERVED_NVCL41: |
---|
2087 | case NAL_UNIT_RESERVED_NVCL42: |
---|
2088 | case NAL_UNIT_RESERVED_NVCL43: |
---|
2089 | case NAL_UNIT_RESERVED_NVCL44: |
---|
2090 | case NAL_UNIT_RESERVED_NVCL45: |
---|
2091 | case NAL_UNIT_RESERVED_NVCL46: |
---|
2092 | case NAL_UNIT_RESERVED_NVCL47: |
---|
2093 | case NAL_UNIT_UNSPECIFIED_48: |
---|
2094 | case NAL_UNIT_UNSPECIFIED_49: |
---|
2095 | case NAL_UNIT_UNSPECIFIED_50: |
---|
2096 | case NAL_UNIT_UNSPECIFIED_51: |
---|
2097 | case NAL_UNIT_UNSPECIFIED_52: |
---|
2098 | case NAL_UNIT_UNSPECIFIED_53: |
---|
2099 | case NAL_UNIT_UNSPECIFIED_54: |
---|
2100 | case NAL_UNIT_UNSPECIFIED_55: |
---|
2101 | case NAL_UNIT_UNSPECIFIED_56: |
---|
2102 | case NAL_UNIT_UNSPECIFIED_57: |
---|
2103 | case NAL_UNIT_UNSPECIFIED_58: |
---|
2104 | case NAL_UNIT_UNSPECIFIED_59: |
---|
2105 | case NAL_UNIT_UNSPECIFIED_60: |
---|
2106 | case NAL_UNIT_UNSPECIFIED_61: |
---|
2107 | case NAL_UNIT_UNSPECIFIED_62: |
---|
2108 | case NAL_UNIT_UNSPECIFIED_63: |
---|
2109 | |
---|
2110 | default: |
---|
2111 | assert (0); |
---|
2112 | break; |
---|
2113 | } |
---|
2114 | |
---|
2115 | return false; |
---|
2116 | } |
---|
2117 | |
---|
2118 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
2119 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2120 | * \returns true if the picture should be skipped |
---|
2121 | * This function skips all TFD pictures that follow a BLA picture |
---|
2122 | * in decoding order and precede it in output order. |
---|
2123 | */ |
---|
2124 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
2125 | { |
---|
2126 | if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && |
---|
2127 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
2128 | { |
---|
2129 | iPOCLastDisplay++; |
---|
2130 | return true; |
---|
2131 | } |
---|
2132 | return false; |
---|
2133 | } |
---|
2134 | |
---|
2135 | /** Function for checking if picture should be skipped because of random access |
---|
2136 | * \param iSkipFrame skip frame counter |
---|
2137 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2138 | * \returns true if the picture shold be skipped in the random access. |
---|
2139 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
2140 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
2141 | * It also checks the type of Nal unit type at the random access point. |
---|
2142 | * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped. |
---|
2143 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
2144 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
2145 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
2146 | * access point there is no guarantee that the decoder will not crash. |
---|
2147 | */ |
---|
2148 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
2149 | { |
---|
2150 | if (iSkipFrame) |
---|
2151 | { |
---|
2152 | iSkipFrame--; // decrement the counter |
---|
2153 | return true; |
---|
2154 | } |
---|
2155 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
2156 | { |
---|
2157 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
2158 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2159 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
2160 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
2161 | { |
---|
2162 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
2163 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
2164 | } |
---|
2165 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
2166 | { |
---|
2167 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
2168 | } |
---|
2169 | else |
---|
2170 | { |
---|
2171 | static Bool warningMessage = false; |
---|
2172 | if(!warningMessage) |
---|
2173 | { |
---|
2174 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
2175 | warningMessage = true; |
---|
2176 | } |
---|
2177 | return true; |
---|
2178 | } |
---|
2179 | } |
---|
2180 | // skip the reordered pictures, if necessary |
---|
2181 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
2182 | { |
---|
2183 | iPOCLastDisplay++; |
---|
2184 | return true; |
---|
2185 | } |
---|
2186 | // if we reach here, then the picture is not skipped. |
---|
2187 | return false; |
---|
2188 | } |
---|
2189 | |
---|
2190 | #if SVC_EXTENSION |
---|
2191 | Void TDecTop::xInitILRP(TComSlice *slice) |
---|
2192 | { |
---|
2193 | const TComVPS* vps = slice->getVPS(); |
---|
2194 | const TComSPS* sps = slice->getSPS(); |
---|
2195 | |
---|
2196 | Int bitDepthY = slice->getBitDepthY(); |
---|
2197 | Int bitDepthC = slice->getBitDepthC(); |
---|
2198 | |
---|
2199 | if( m_layerId > 0 ) |
---|
2200 | { |
---|
2201 | |
---|
2202 | g_bitDepth[CHANNEL_TYPE_LUMA] = bitDepthY; |
---|
2203 | g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC; |
---|
2204 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
2205 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
2206 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
2207 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
2208 | |
---|
2209 | if (m_cIlpPic[0] == NULL) |
---|
2210 | { |
---|
2211 | for (Int j=0; j < m_numDirectRefLayers; j++) |
---|
2212 | { |
---|
2213 | m_cIlpPic[j] = new TComPic; |
---|
2214 | |
---|
2215 | m_cIlpPic[j]->create(*vps, *sps, *slice->getPPS(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId); |
---|
2216 | |
---|
2217 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++) |
---|
2218 | { |
---|
2219 | m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i); |
---|
2220 | } |
---|
2221 | } |
---|
2222 | } |
---|
2223 | } |
---|
2224 | } |
---|
2225 | |
---|
2226 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdx ) |
---|
2227 | { |
---|
2228 | const TComVPS* vps = m_parameterSetManager.getActiveVPS(); |
---|
2229 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
2230 | { |
---|
2231 | return (TDecTop *)getLayerDec( 0 ); |
---|
2232 | } |
---|
2233 | |
---|
2234 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdx ) ); |
---|
2235 | } |
---|
2236 | |
---|
2237 | Void TDecTop::setRefLayerParams( const TComVPS* vps ) |
---|
2238 | { |
---|
2239 | for(UInt layerIdx = 0; layerIdx < m_numLayer; layerIdx++) |
---|
2240 | { |
---|
2241 | TDecTop *decTop = (TDecTop *)getLayerDec(vps->getLayerIdInNuh(layerIdx)); |
---|
2242 | decTop->setNumSamplePredRefLayers(0); |
---|
2243 | decTop->setNumMotionPredRefLayers(0); |
---|
2244 | decTop->setNumDirectRefLayers(0); |
---|
2245 | |
---|
2246 | for(Int j = 0; j < layerIdx; j++) |
---|
2247 | { |
---|
2248 | if (vps->getDirectDependencyFlag(layerIdx, j)) |
---|
2249 | { |
---|
2250 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layerIdx)); |
---|
2251 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
2252 | |
---|
2253 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layerIdx, j) + 1) & 1; |
---|
2254 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
2255 | |
---|
2256 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layerIdx, j) + 1) & 2) >> 1; |
---|
2257 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
2258 | } |
---|
2259 | } |
---|
2260 | } |
---|
2261 | } |
---|
2262 | |
---|
2263 | Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps) |
---|
2264 | { |
---|
2265 | CommonDecoderParams* params = this->getCommonDecoderParams(); |
---|
2266 | |
---|
2267 | if( params->getValueCheckedFlag() ) |
---|
2268 | { |
---|
2269 | return; // Already checked |
---|
2270 | } |
---|
2271 | |
---|
2272 | if( params->getTargetOutputLayerSetIdx() == -1 ) // Output layer set index not specified |
---|
2273 | { |
---|
2274 | if( params->getTargetLayerId() > vps->getMaxLayerId() ) |
---|
2275 | { |
---|
2276 | printf( "Warning: specified target layerId %d is greater than max layerId %d. Target layerId is set equal to max layerId %d.\n", params->getTargetLayerId(), vps->getMaxLayerId(), vps->getMaxLayerId() ); |
---|
2277 | params->setTargetLayerId( vps->getMaxLayerId() ); |
---|
2278 | } |
---|
2279 | |
---|
2280 | Bool layerSetMatchFound = false; |
---|
2281 | // Output layer set index not assigned. |
---|
2282 | // Based on the value of targetLayerId, check if any of the output layer matches |
---|
2283 | // Currently, the target layer ID in the encoder assumes that all the layers are decoded |
---|
2284 | // Check if any of the output layer sets match this description |
---|
2285 | for( Int i = 0; i < vps->getNumOutputLayerSets(); i++ ) |
---|
2286 | { |
---|
2287 | Bool layerSetMatchFlag = false; |
---|
2288 | Int layerSetIdx = vps->getOutputLayerSetIdx( i ); |
---|
2289 | |
---|
2290 | for( Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++ ) |
---|
2291 | { |
---|
2292 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) == params->getTargetLayerId() ) |
---|
2293 | { |
---|
2294 | layerSetMatchFlag = true; |
---|
2295 | break; |
---|
2296 | } |
---|
2297 | } |
---|
2298 | |
---|
2299 | if( layerSetMatchFlag ) // Potential output layer set candidate found |
---|
2300 | { |
---|
2301 | // If target dec layer ID list is also included - check if they match |
---|
2302 | if( params->getTargetDecLayerIdSet() ) |
---|
2303 | { |
---|
2304 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2305 | { |
---|
2306 | for( Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++ ) |
---|
2307 | { |
---|
2308 | if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j ))) |
---|
2309 | { |
---|
2310 | layerSetMatchFlag = false; |
---|
2311 | } |
---|
2312 | } |
---|
2313 | } |
---|
2314 | } |
---|
2315 | if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present |
---|
2316 | { |
---|
2317 | // Match found |
---|
2318 | layerSetMatchFound = true; |
---|
2319 | params->setTargetOutputLayerSetIdx( i ); |
---|
2320 | params->setValueCheckedFlag( true ); |
---|
2321 | break; |
---|
2322 | } |
---|
2323 | } |
---|
2324 | } |
---|
2325 | assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist |
---|
2326 | } |
---|
2327 | else // Output layer set index is assigned - check if the values match |
---|
2328 | { |
---|
2329 | // Check if the target decoded layer is the highest layer in the list |
---|
2330 | assert( params->getTargetOutputLayerSetIdx() < vps->getNumOutputLayerSets() ); |
---|
2331 | #if !CONFORMANCE_BITSTREAM_MODE |
---|
2332 | assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() ); |
---|
2333 | #endif |
---|
2334 | Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() ); // Index to the layer set |
---|
2335 | #if !CONFORMANCE_BITSTREAM_MODE |
---|
2336 | assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); |
---|
2337 | #endif |
---|
2338 | |
---|
2339 | // Check if the targetdeclayerIdlist matches the output layer set |
---|
2340 | if( params->getTargetDecLayerIdSet() ) |
---|
2341 | { |
---|
2342 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2343 | { |
---|
2344 | for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++) |
---|
2345 | { |
---|
2346 | assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i ))); |
---|
2347 | } |
---|
2348 | } |
---|
2349 | } |
---|
2350 | params->setValueCheckedFlag( true ); |
---|
2351 | |
---|
2352 | } |
---|
2353 | |
---|
2354 | // Set correct value of targetLayerId |
---|
2355 | Int targetOlsIdx = params->getTargetOutputLayerSetIdx(); |
---|
2356 | Int targetLsIdx = vps->getOutputLayerSetIdx( targetOlsIdx ); |
---|
2357 | params->setTargetLayerId( vps->getLayerSetLayerIdList( targetLsIdx, vps->getNumLayersInIdList(targetLsIdx)-1 ) ); |
---|
2358 | |
---|
2359 | // Check if the current layer is an output layer |
---|
2360 | for( Int i = 0; i < vps->getNumLayersInIdList( targetLsIdx ); i++ ) |
---|
2361 | { |
---|
2362 | if( vps->getOutputLayerFlag( targetOlsIdx, i ) ) |
---|
2363 | { |
---|
2364 | this->getLayerDec( vps->getLayerSetLayerIdList( targetLsIdx, i ) )->m_isOutputLayerFlag = true; |
---|
2365 | } |
---|
2366 | } |
---|
2367 | } |
---|
2368 | |
---|
2369 | Void TDecTop::markAllPicsAsNoCurrAu( const TComVPS *vps ) |
---|
2370 | { |
---|
2371 | for(Int i = 0; i < MAX_LAYERS; i++) |
---|
2372 | { |
---|
2373 | TComList<TComPic*>* listPic = m_ppcTDecTop[vps->getLayerIdInNuh(i)]->getListPic(); |
---|
2374 | TComList<TComPic*>::iterator iterPic = listPic->begin(); |
---|
2375 | while ( iterPic != listPic->end() ) |
---|
2376 | { |
---|
2377 | TComPic *pcPic = *(iterPic); |
---|
2378 | pcPic->setCurrAuFlag( false ); |
---|
2379 | iterPic++; |
---|
2380 | } |
---|
2381 | } |
---|
2382 | } |
---|
2383 | |
---|
2384 | #if CGS_3D_ASYMLUT |
---|
2385 | Void TDecTop::initAsymLut(TComSlice *pcSlice) |
---|
2386 | { |
---|
2387 | if(m_layerId>0) |
---|
2388 | { |
---|
2389 | if(!m_pColorMappedPic) |
---|
2390 | { |
---|
2391 | Int picWidth = pcSlice->getPicWidthInLumaSamples(); |
---|
2392 | Int picHeight = pcSlice->getPicHeightInLumaSamples(); |
---|
2393 | m_pColorMappedPic = new TComPicYuv; |
---|
2394 | m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); |
---|
2395 | } |
---|
2396 | } |
---|
2397 | } |
---|
2398 | #endif |
---|
2399 | |
---|
2400 | Void TDecTop::resetPocRestrictionCheckParameters() |
---|
2401 | { |
---|
2402 | TDecTop::m_checkPocRestrictionsForCurrAu = false; |
---|
2403 | TDecTop::m_pocResetIdcOrCurrAu = -1; |
---|
2404 | TDecTop::m_baseLayerIdrFlag = false; |
---|
2405 | TDecTop::m_baseLayerPicPresentFlag = false; |
---|
2406 | TDecTop::m_baseLayerIrapFlag = false; |
---|
2407 | TDecTop::m_nonBaseIdrPresentFlag = false; |
---|
2408 | TDecTop::m_nonBaseIdrType = -1; |
---|
2409 | TDecTop::m_picNonIdrWithRadlPresentFlag = false; |
---|
2410 | TDecTop::m_picNonIdrNoLpPresentFlag = false; |
---|
2411 | } |
---|
2412 | |
---|
2413 | Void TDecTop::xCheckLayerReset() |
---|
2414 | { |
---|
2415 | if (m_apcSlicePilot->isIRAP() && m_layerId > m_smallestLayerId) |
---|
2416 | { |
---|
2417 | Bool layerResetFlag; |
---|
2418 | UInt dolLayerId; |
---|
2419 | if (m_lastPicHasEos) |
---|
2420 | { |
---|
2421 | layerResetFlag = true; |
---|
2422 | dolLayerId = m_layerId; |
---|
2423 | } |
---|
2424 | else if ((m_apcSlicePilot->isCRA() && m_apcSlicePilot->getHandleCraAsBlaFlag()) || |
---|
2425 | (m_apcSlicePilot->isIDR() && m_apcSlicePilot->getCrossLayerBLAFlag()) || m_apcSlicePilot->isBLA()) |
---|
2426 | { |
---|
2427 | layerResetFlag = true; |
---|
2428 | dolLayerId = m_layerId; |
---|
2429 | } |
---|
2430 | else |
---|
2431 | { |
---|
2432 | layerResetFlag = false; |
---|
2433 | } |
---|
2434 | |
---|
2435 | if (layerResetFlag) |
---|
2436 | { |
---|
2437 | for (Int i = 0; i < m_apcSlicePilot->getVPS()->getNumPredictedLayers(dolLayerId); i++) |
---|
2438 | { |
---|
2439 | UInt iLayerId = m_apcSlicePilot->getVPS()->getPredictedLayerId(dolLayerId, i); |
---|
2440 | m_ppcTDecTop[iLayerId]->m_layerInitializedFlag = false; |
---|
2441 | m_ppcTDecTop[iLayerId]->m_firstPicInLayerDecodedFlag = false; |
---|
2442 | } |
---|
2443 | |
---|
2444 | for (TComList<TComPic*>::iterator i = m_cListPic.begin(); i != m_cListPic.end(); i++) |
---|
2445 | { |
---|
2446 | if ((*i)->getPOC() != m_apcSlicePilot->getPOC()) |
---|
2447 | { |
---|
2448 | (*i)->getSlice(0)->setReferenced(false); |
---|
2449 | } |
---|
2450 | } |
---|
2451 | |
---|
2452 | for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getNumPredictedLayers(dolLayerId); i++) |
---|
2453 | { |
---|
2454 | UInt predLId = m_apcSlicePilot->getVPS()->getPredictedLayerId(dolLayerId, i); |
---|
2455 | for (TComList<TComPic*>::iterator pic = m_ppcTDecTop[predLId]->getListPic()->begin(); pic != m_ppcTDecTop[predLId]->getListPic()->end(); pic++) |
---|
2456 | { |
---|
2457 | if ((*pic)->getSlice(0)->getPOC() != m_apcSlicePilot->getPOC()) |
---|
2458 | { |
---|
2459 | (*pic)->getSlice(0)->setReferenced(false); |
---|
2460 | } |
---|
2461 | } |
---|
2462 | } |
---|
2463 | } |
---|
2464 | } |
---|
2465 | } |
---|
2466 | |
---|
2467 | Void TDecTop::xSetLayerInitializedFlag() |
---|
2468 | { |
---|
2469 | if (m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
2470 | { |
---|
2471 | if (m_layerId == 0) |
---|
2472 | { |
---|
2473 | m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true); |
---|
2474 | } |
---|
2475 | else if (!m_ppcTDecTop[m_layerId]->getLayerInitializedFlag() && m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId) == 0) |
---|
2476 | { |
---|
2477 | m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true); |
---|
2478 | } |
---|
2479 | else if (!m_ppcTDecTop[m_layerId]->getLayerInitializedFlag()) |
---|
2480 | { |
---|
2481 | Bool refLayersInitialized = true; |
---|
2482 | for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); j++) |
---|
2483 | { |
---|
2484 | UInt refLayerId = m_apcSlicePilot->getVPS()->getRefLayerId(m_layerId, j); |
---|
2485 | if (!m_ppcTDecTop[refLayerId]->getLayerInitializedFlag()) |
---|
2486 | { |
---|
2487 | refLayersInitialized = false; |
---|
2488 | } |
---|
2489 | } |
---|
2490 | if (refLayersInitialized) |
---|
2491 | { |
---|
2492 | m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true); |
---|
2493 | } |
---|
2494 | } |
---|
2495 | } |
---|
2496 | } |
---|
2497 | |
---|
2498 | Void TDecTop::xDeriveSmallestLayerId(TComVPS* vps) |
---|
2499 | { |
---|
2500 | UInt smallestLayerId; |
---|
2501 | Int targetOlsIdx = m_commonDecoderParams->getTargetOutputLayerSetIdx(); |
---|
2502 | assert( targetOlsIdx >= 0 ); |
---|
2503 | |
---|
2504 | UInt targetDecLayerSetIdx = vps->getOutputLayerSetIdx(targetOlsIdx); |
---|
2505 | UInt lsIdx = targetDecLayerSetIdx; |
---|
2506 | UInt targetDecLayerIdList[MAX_LAYERS] = {0}; |
---|
2507 | |
---|
2508 | for (UInt i = 0, j = 0; i < vps->getNumLayersInIdList(lsIdx); i++) |
---|
2509 | { |
---|
2510 | if (vps->getNecessaryLayerFlag(targetOlsIdx, i)) |
---|
2511 | { |
---|
2512 | targetDecLayerIdList[j++] = vps->getLayerSetLayerIdList(lsIdx, i); |
---|
2513 | } |
---|
2514 | } |
---|
2515 | |
---|
2516 | if (targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1()) |
---|
2517 | { |
---|
2518 | smallestLayerId = 0; |
---|
2519 | } |
---|
2520 | else if (vps->getNumLayersInIdList(targetDecLayerSetIdx) == 1) |
---|
2521 | { |
---|
2522 | smallestLayerId = 0; |
---|
2523 | } |
---|
2524 | else |
---|
2525 | { |
---|
2526 | smallestLayerId = targetDecLayerIdList[0]; |
---|
2527 | } |
---|
2528 | |
---|
2529 | for( UInt layerId = 0; layerId < MAX_VPS_LAYER_IDX_PLUS1; layerId++ ) |
---|
2530 | { |
---|
2531 | m_ppcTDecTop[layerId]->m_smallestLayerId = smallestLayerId; |
---|
2532 | } |
---|
2533 | } |
---|
2534 | |
---|
2535 | Void TDecTop::xSetSpatialEnhLayerFlag( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic* pic ) |
---|
2536 | { |
---|
2537 | for(UInt i = 0; i < vps.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
2538 | { |
---|
2539 | const Window scalEL = pps.getScaledRefLayerWindowForLayer(vps.getRefLayerId(m_layerId, i)); |
---|
2540 | const Window refEL = pps.getRefLayerWindowForLayer(vps.getRefLayerId(m_layerId, i)); |
---|
2541 | Bool equalOffsets = scalEL.hasEqualOffset(refEL); |
---|
2542 | Bool zeroPhase = pps.hasZeroResamplingPhase(vps.getRefLayerId(m_layerId, i)); |
---|
2543 | |
---|
2544 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
---|
2545 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
2546 | |
---|
2547 | UInt refLayerId = vps.getRefLayerId(m_layerId, i); |
---|
2548 | Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] ); |
---|
2549 | |
---|
2550 | if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == vps.getPicWidthInLumaSamples(&sps, m_layerId) && pcPicYuvRecBase->getHeight(COMPONENT_Y) == vps.getPicHeightInLumaSamples(&sps, m_layerId) && equalOffsets && zeroPhase ) |
---|
2551 | { |
---|
2552 | pic->setEqualPictureSizeAndOffsetFlag( i, true ); |
---|
2553 | } |
---|
2554 | |
---|
2555 | if( !pic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths |
---|
2556 | #if CGS_3D_ASYMLUT |
---|
2557 | || pps.getCGSFlag() > 0 |
---|
2558 | #endif |
---|
2559 | #if LAYER_CTB |
---|
2560 | || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth() |
---|
2561 | #endif |
---|
2562 | ) |
---|
2563 | { |
---|
2564 | pic->setSpatialEnhLayerFlag( i, true ); |
---|
2565 | |
---|
2566 | //only for scalable extension |
---|
2567 | assert( vps.getScalabilityMask( SCALABILITY_ID ) == true ); |
---|
2568 | } |
---|
2569 | } |
---|
2570 | } |
---|
2571 | |
---|
2572 | #endif //SVC_EXTENSION |
---|
2573 | |
---|
2574 | |
---|
2575 | //! \} |
---|