1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file 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 | #if POC_RESET_RESTRICTIONS |
---|
49 | Bool TDecTop::m_checkPocRestrictionsForCurrAu = false; |
---|
50 | Int TDecTop::m_pocResetIdcOrCurrAu = -1; |
---|
51 | Bool TDecTop::m_baseLayerIdrFlag = false; |
---|
52 | Bool TDecTop::m_baseLayerPicPresentFlag = false; |
---|
53 | Bool TDecTop::m_baseLayerIrapFlag = false; |
---|
54 | Bool TDecTop::m_nonBaseIdrPresentFlag = false; |
---|
55 | Int TDecTop::m_nonBaseIdrType = -1; |
---|
56 | Bool TDecTop::m_picNonIdrWithRadlPresentFlag = false; |
---|
57 | Bool TDecTop::m_picNonIdrNoLpPresentFlag = false; |
---|
58 | #endif |
---|
59 | #if POC_RESET_VALUE_RESTRICTION |
---|
60 | Int TDecTop::m_crossLayerPocResetPeriodId = -1; |
---|
61 | Int TDecTop::m_crossLayerPocResetIdc = -1; |
---|
62 | #endif |
---|
63 | #endif |
---|
64 | |
---|
65 | //! \ingroup TLibDecoder |
---|
66 | //! \{ |
---|
67 | |
---|
68 | TDecTop::TDecTop() |
---|
69 | : m_pDecodedSEIOutputStream(NULL) |
---|
70 | { |
---|
71 | m_pcPic = 0; |
---|
72 | m_iMaxRefPicNum = 0; |
---|
73 | #if ENC_DEC_TRACE |
---|
74 | if (g_hTrace == NULL) |
---|
75 | { |
---|
76 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
77 | } |
---|
78 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
79 | g_nSymbolCounter = 0; |
---|
80 | #endif |
---|
81 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
82 | m_pocCRA = 0; |
---|
83 | m_pocRandomAccess = MAX_INT; |
---|
84 | #if !SVC_EXTENSION |
---|
85 | m_prevPOC = MAX_INT; |
---|
86 | #endif |
---|
87 | m_bFirstSliceInPicture = true; |
---|
88 | #if !SVC_EXTENSION |
---|
89 | m_bFirstSliceInSequence = true; |
---|
90 | #endif |
---|
91 | #if SVC_EXTENSION |
---|
92 | m_layerId = 0; |
---|
93 | #if AVC_BASE |
---|
94 | m_pBLReconFile = NULL; |
---|
95 | #endif |
---|
96 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
97 | #endif |
---|
98 | m_prevSliceSkipped = false; |
---|
99 | m_skippedPOC = 0; |
---|
100 | m_bFirstSliceInBitstream = true; |
---|
101 | m_lastPOCNoOutputPriorPics = -1; |
---|
102 | m_craNoRaslOutputFlag = false; |
---|
103 | m_isNoOutputPriorPics = false; |
---|
104 | #if Q0177_EOS_CHECKS |
---|
105 | m_isLastNALWasEos = false; |
---|
106 | #endif |
---|
107 | #if NO_CLRAS_OUTPUT_FLAG |
---|
108 | m_noClrasOutputFlag = false; |
---|
109 | m_layerInitializedFlag = false; |
---|
110 | m_firstPicInLayerDecodedFlag = false; |
---|
111 | #endif |
---|
112 | #if RESOLUTION_BASED_DPB |
---|
113 | m_subDpbIdx = -1; |
---|
114 | #endif |
---|
115 | #if POC_RESET_IDC_DECODER |
---|
116 | m_parseIdc = -1; |
---|
117 | m_lastPocPeriodId = -1; |
---|
118 | m_prevPicOrderCnt = 0; |
---|
119 | #endif |
---|
120 | #if Q0048_CGS_3D_ASYMLUT |
---|
121 | m_pColorMappedPic = NULL; |
---|
122 | #endif |
---|
123 | |
---|
124 | #if POC_RESET_RESTRICTIONS |
---|
125 | resetPocRestrictionCheckParameters(); |
---|
126 | #endif |
---|
127 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
128 | m_pocResettingFlag = false; |
---|
129 | m_pocDecrementedInDPBFlag = false; |
---|
130 | #endif |
---|
131 | #if CONFORMANCE_BITSTREAM_MODE |
---|
132 | m_confModeFlag = false; |
---|
133 | #endif |
---|
134 | } |
---|
135 | |
---|
136 | TDecTop::~TDecTop() |
---|
137 | { |
---|
138 | #if ENC_DEC_TRACE |
---|
139 | if (g_hTrace != stdout) |
---|
140 | { |
---|
141 | fclose( g_hTrace ); |
---|
142 | } |
---|
143 | #endif |
---|
144 | #if Q0048_CGS_3D_ASYMLUT |
---|
145 | if(m_pColorMappedPic) |
---|
146 | { |
---|
147 | m_pColorMappedPic->destroy(); |
---|
148 | delete m_pColorMappedPic; |
---|
149 | m_pColorMappedPic = NULL; |
---|
150 | } |
---|
151 | #endif |
---|
152 | } |
---|
153 | |
---|
154 | Void TDecTop::create() |
---|
155 | { |
---|
156 | #if SVC_EXTENSION |
---|
157 | m_cGopDecoder.create( m_layerId ); |
---|
158 | #else |
---|
159 | m_cGopDecoder.create(); |
---|
160 | #endif |
---|
161 | m_apcSlicePilot = new TComSlice; |
---|
162 | m_uiSliceIdx = 0; |
---|
163 | } |
---|
164 | |
---|
165 | Void TDecTop::destroy() |
---|
166 | { |
---|
167 | m_cGopDecoder.destroy(); |
---|
168 | |
---|
169 | delete m_apcSlicePilot; |
---|
170 | m_apcSlicePilot = NULL; |
---|
171 | |
---|
172 | m_cSliceDecoder.destroy(); |
---|
173 | #if SVC_EXTENSION |
---|
174 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
175 | { |
---|
176 | if(m_cIlpPic[i]) |
---|
177 | { |
---|
178 | m_cIlpPic[i]->destroy(); |
---|
179 | delete m_cIlpPic[i]; |
---|
180 | m_cIlpPic[i] = NULL; |
---|
181 | } |
---|
182 | } |
---|
183 | #endif |
---|
184 | } |
---|
185 | |
---|
186 | Void TDecTop::init() |
---|
187 | { |
---|
188 | #if !SVC_EXTENSION |
---|
189 | // initialize ROM |
---|
190 | initROM(); |
---|
191 | #endif |
---|
192 | #if SVC_EXTENSION |
---|
193 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
194 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() ); |
---|
195 | #else |
---|
196 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
197 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
198 | #endif |
---|
199 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
200 | } |
---|
201 | |
---|
202 | Void TDecTop::deletePicBuffer ( ) |
---|
203 | { |
---|
204 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
205 | Int iSize = Int( m_cListPic.size() ); |
---|
206 | |
---|
207 | for (Int i = 0; i < iSize; i++ ) |
---|
208 | { |
---|
209 | TComPic* pcPic = *(iterPic++); |
---|
210 | #if SVC_EXTENSION |
---|
211 | if( pcPic ) |
---|
212 | { |
---|
213 | pcPic->destroy(); |
---|
214 | |
---|
215 | delete pcPic; |
---|
216 | pcPic = NULL; |
---|
217 | } |
---|
218 | #else |
---|
219 | pcPic->destroy(); |
---|
220 | |
---|
221 | delete pcPic; |
---|
222 | pcPic = NULL; |
---|
223 | #endif |
---|
224 | } |
---|
225 | |
---|
226 | m_cSAO.destroy(); |
---|
227 | |
---|
228 | m_cLoopFilter. destroy(); |
---|
229 | |
---|
230 | #if !SVC_EXTENSION |
---|
231 | // destroy ROM |
---|
232 | destroyROM(); |
---|
233 | #endif |
---|
234 | } |
---|
235 | |
---|
236 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
237 | { |
---|
238 | Int numReorderPics[MAX_TLAYER]; |
---|
239 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
240 | Window &conformanceWindow = pcSlice->getConformanceWindow(); |
---|
241 | #else |
---|
242 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
243 | #endif |
---|
244 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
245 | |
---|
246 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
247 | { |
---|
248 | #if USE_DPB_SIZE_TABLE |
---|
249 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
250 | { |
---|
251 | assert( this->getLayerId() == 0 ); |
---|
252 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
253 | } |
---|
254 | else |
---|
255 | { |
---|
256 | TComVPS *vps = pcSlice->getVPS(); |
---|
257 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
---|
258 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
---|
259 | } |
---|
260 | #else |
---|
261 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
262 | #endif |
---|
263 | } |
---|
264 | |
---|
265 | #if USE_DPB_SIZE_TABLE |
---|
266 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
267 | { |
---|
268 | assert( this->getLayerId() == 0 ); |
---|
269 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
270 | } |
---|
271 | else |
---|
272 | { |
---|
273 | #if RESOLUTION_BASED_DPB |
---|
274 | Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
---|
275 | Int layerIdx = pcSlice->getVPS()->findLayerIdxInLayerSet( layerSetIdxForOutputLayerSet, pcSlice->getLayerId() ); assert( layerIdx != -1 ); |
---|
276 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
277 | #else |
---|
278 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
279 | //TODO: HENDRY -- Do the checking here. |
---|
280 | #endif |
---|
281 | } |
---|
282 | #else |
---|
283 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
284 | #endif |
---|
285 | |
---|
286 | #if SVC_EXTENSION |
---|
287 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
---|
288 | #endif |
---|
289 | |
---|
290 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
291 | { |
---|
292 | rpcPic = new TComPic(); |
---|
293 | |
---|
294 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
295 | if(m_layerId > 0) |
---|
296 | { |
---|
297 | for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
298 | { |
---|
299 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
300 | #if O0098_SCALED_REF_LAYER_ID |
---|
301 | const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
---|
302 | #else |
---|
303 | const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(i); |
---|
304 | #endif |
---|
305 | #else |
---|
306 | #if O0098_SCALED_REF_LAYER_ID |
---|
307 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
---|
308 | #else |
---|
309 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); |
---|
310 | #endif |
---|
311 | #endif |
---|
312 | #if REF_REGION_OFFSET |
---|
313 | const Window refEL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
---|
314 | #if RESAMPLING_FIX |
---|
315 | Bool equalOffsets = scalEL.hasEqualOffset(refEL); |
---|
316 | #if R0209_GENERIC_PHASE |
---|
317 | Bool zeroPhase = pcSlice->getPPS()->hasZeroResamplingPhase(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
---|
318 | #endif |
---|
319 | #else |
---|
320 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 |
---|
321 | && refEL.getWindowLeftOffset() == 0 && refEL.getWindowRightOffset() == 0 && refEL.getWindowTopOffset() == 0 && refEL.getWindowBottomOffset() == 0 ); |
---|
322 | #endif |
---|
323 | #else |
---|
324 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
325 | #endif |
---|
326 | |
---|
327 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
328 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
---|
329 | #else |
---|
330 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
331 | #endif |
---|
332 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
333 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
334 | #if REPN_FORMAT_IN_VPS |
---|
335 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
336 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i); |
---|
337 | 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] ); |
---|
338 | |
---|
339 | #if REF_IDX_MFM |
---|
340 | if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase ) |
---|
341 | { |
---|
342 | rpcPic->setEqualPictureSizeAndOffsetFlag( i, true ); |
---|
343 | } |
---|
344 | |
---|
345 | if( !rpcPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths |
---|
346 | #else |
---|
347 | if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !sameBitDepths |
---|
348 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
349 | || !equalOffsets |
---|
350 | #if R0209_GENERIC_PHASE |
---|
351 | || !zeroPhase |
---|
352 | #endif |
---|
353 | #else |
---|
354 | || !zeroOffsets |
---|
355 | #endif |
---|
356 | #endif |
---|
357 | #if Q0048_CGS_3D_ASYMLUT |
---|
358 | || pcSlice->getPPS()->getCGSFlag() > 0 |
---|
359 | #endif |
---|
360 | #if LAYER_CTB |
---|
361 | || 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() |
---|
362 | #endif |
---|
363 | ) |
---|
364 | #else |
---|
365 | if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() |
---|
366 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
367 | || !equalOffsets |
---|
368 | #if R0209_GENERIC_PHASE |
---|
369 | || !zeroPhase |
---|
370 | #endif |
---|
371 | #else |
---|
372 | || !zeroOffsets |
---|
373 | #endif |
---|
374 | ) |
---|
375 | #endif |
---|
376 | #else |
---|
377 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() |
---|
378 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
379 | || !equalOffsets |
---|
380 | #if R0209_GENERIC_PHASE |
---|
381 | || !zeroPhase |
---|
382 | #endif |
---|
383 | #else |
---|
384 | || !zeroOffsets |
---|
385 | #endif |
---|
386 | ) |
---|
387 | #endif |
---|
388 | { |
---|
389 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
390 | |
---|
391 | //only for scalable extension |
---|
392 | assert( pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) == true ); |
---|
393 | } |
---|
394 | } |
---|
395 | } |
---|
396 | |
---|
397 | #if REPN_FORMAT_IN_VPS |
---|
398 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
399 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
400 | #else |
---|
401 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
402 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
403 | #endif |
---|
404 | |
---|
405 | #else //SVC_EXTENSION |
---|
406 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
407 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
408 | #endif //SVC_EXTENSION |
---|
409 | |
---|
410 | m_cListPic.pushBack( rpcPic ); |
---|
411 | |
---|
412 | return; |
---|
413 | } |
---|
414 | |
---|
415 | Bool bBufferIsAvailable = false; |
---|
416 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
417 | while (iterPic != m_cListPic.end()) |
---|
418 | { |
---|
419 | rpcPic = *(iterPic++); |
---|
420 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
421 | { |
---|
422 | rpcPic->setOutputMark(false); |
---|
423 | bBufferIsAvailable = true; |
---|
424 | break; |
---|
425 | } |
---|
426 | |
---|
427 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
428 | { |
---|
429 | #if !SVC_EXTENSION |
---|
430 | rpcPic->setOutputMark(false); |
---|
431 | #endif |
---|
432 | rpcPic->setReconMark( false ); |
---|
433 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
434 | bBufferIsAvailable = true; |
---|
435 | break; |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | if ( !bBufferIsAvailable ) |
---|
440 | { |
---|
441 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
442 | m_iMaxRefPicNum++; |
---|
443 | rpcPic = new TComPic(); |
---|
444 | m_cListPic.pushBack( rpcPic ); |
---|
445 | } |
---|
446 | rpcPic->destroy(); |
---|
447 | |
---|
448 | #if SVC_EXTENSION |
---|
449 | #if REPN_FORMAT_IN_VPS |
---|
450 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
451 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
452 | #else |
---|
453 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
454 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
455 | #endif |
---|
456 | #else //SVC_EXTENSION |
---|
457 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
458 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
459 | #endif //SVC_EXTENSION |
---|
460 | } |
---|
461 | |
---|
462 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
463 | { |
---|
464 | if (!m_pcPic) |
---|
465 | { |
---|
466 | /* nothing to deblock */ |
---|
467 | return; |
---|
468 | } |
---|
469 | |
---|
470 | TComPic* pcPic = m_pcPic; |
---|
471 | |
---|
472 | // Execute Deblock + Cleanup |
---|
473 | |
---|
474 | m_cGopDecoder.filterPicture(pcPic); |
---|
475 | |
---|
476 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
477 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
478 | rpcListPic = &m_cListPic; |
---|
479 | m_cCuDecoder.destroy(); |
---|
480 | m_bFirstSliceInPicture = true; |
---|
481 | |
---|
482 | return; |
---|
483 | } |
---|
484 | |
---|
485 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) |
---|
486 | { |
---|
487 | if (!pcListPic || !m_isNoOutputPriorPics) return; |
---|
488 | |
---|
489 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
490 | |
---|
491 | while (iterPic != pcListPic->end()) |
---|
492 | { |
---|
493 | TComPic* pcPicTmp = *(iterPic++); |
---|
494 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
495 | { |
---|
496 | pcPicTmp->setOutputMark(false); |
---|
497 | } |
---|
498 | } |
---|
499 | } |
---|
500 | |
---|
501 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
502 | { |
---|
503 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
504 | TComSlice cFillSlice; |
---|
505 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
506 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
507 | #if SVC_EXTENSION |
---|
508 | cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
---|
509 | cFillSlice.initSlice( m_layerId ); |
---|
510 | #else |
---|
511 | cFillSlice.initSlice(); |
---|
512 | #endif |
---|
513 | TComPic *cFillPic; |
---|
514 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
515 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
516 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
517 | #if SVC_EXTENSION |
---|
518 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
---|
519 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
520 | #else |
---|
521 | cFillPic->getSlice(0)->initSlice(); |
---|
522 | #endif |
---|
523 | |
---|
524 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
525 | Int closestPoc = 1000000; |
---|
526 | while ( iterPic != m_cListPic.end()) |
---|
527 | { |
---|
528 | TComPic * rpcPic = *(iterPic++); |
---|
529 | 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()) |
---|
530 | { |
---|
531 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
532 | } |
---|
533 | } |
---|
534 | iterPic = m_cListPic.begin(); |
---|
535 | while ( iterPic != m_cListPic.end()) |
---|
536 | { |
---|
537 | TComPic *rpcPic = *(iterPic++); |
---|
538 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
539 | { |
---|
540 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
541 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
542 | break; |
---|
543 | } |
---|
544 | } |
---|
545 | cFillPic->setCurrSliceIdx(0); |
---|
546 | for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) |
---|
547 | { |
---|
548 | cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); |
---|
549 | } |
---|
550 | cFillPic->getSlice(0)->setReferenced(true); |
---|
551 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
552 | cFillPic->setReconMark(true); |
---|
553 | cFillPic->setOutputMark(true); |
---|
554 | if(m_pocRandomAccess == MAX_INT) |
---|
555 | { |
---|
556 | m_pocRandomAccess = iLostPoc; |
---|
557 | } |
---|
558 | } |
---|
559 | |
---|
560 | |
---|
561 | Void TDecTop::xActivateParameterSets() |
---|
562 | { |
---|
563 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
564 | |
---|
565 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
566 | assert (pps != 0); |
---|
567 | |
---|
568 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
569 | assert (sps != 0); |
---|
570 | |
---|
571 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
572 | { |
---|
573 | printf ("Parameter set activation failed!"); |
---|
574 | assert (0); |
---|
575 | } |
---|
576 | |
---|
577 | #if SCALINGLIST_INFERRING |
---|
578 | // scaling list settings and checks |
---|
579 | TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS(); |
---|
580 | TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS(); |
---|
581 | TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS(); |
---|
582 | |
---|
583 | if( activeSPS->getInferScalingListFlag() ) |
---|
584 | { |
---|
585 | UInt refLayerId = activeSPS->getScalingListRefLayerId(); |
---|
586 | TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); |
---|
587 | |
---|
588 | // 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 |
---|
589 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
590 | if( activeVPS->getNonHEVCBaseLayerFlag() ) |
---|
591 | #else |
---|
592 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
593 | #endif |
---|
594 | { |
---|
595 | assert( refLayerId > 0 ); |
---|
596 | } |
---|
597 | |
---|
598 | // 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 |
---|
599 | // 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 |
---|
600 | assert( refSps->getInferScalingListFlag() == false ); |
---|
601 | |
---|
602 | // 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, |
---|
603 | // 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 |
---|
604 | assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true ); |
---|
605 | |
---|
606 | if( activeSPS->getScalingList() != refSps->getScalingList() ) |
---|
607 | { |
---|
608 | // delete created instance of scaling list since it will be inferred |
---|
609 | delete activeSPS->getScalingList(); |
---|
610 | |
---|
611 | // infer scaling list |
---|
612 | activeSPS->setScalingList( refSps->getScalingList() ); |
---|
613 | } |
---|
614 | } |
---|
615 | |
---|
616 | if( activePPS->getInferScalingListFlag() ) |
---|
617 | { |
---|
618 | UInt refLayerId = activePPS->getScalingListRefLayerId(); |
---|
619 | TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); |
---|
620 | |
---|
621 | // 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 |
---|
622 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
623 | if( activeVPS->getNonHEVCBaseLayerFlag() ) |
---|
624 | #else |
---|
625 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
626 | #endif |
---|
627 | { |
---|
628 | assert( refLayerId > 0 ); |
---|
629 | } |
---|
630 | |
---|
631 | // 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 |
---|
632 | // 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 |
---|
633 | assert( refPps->getInferScalingListFlag() == false ); |
---|
634 | |
---|
635 | // 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, |
---|
636 | // 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 |
---|
637 | assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true ); |
---|
638 | |
---|
639 | if( activePPS->getScalingList() != refPps->getScalingList() ) |
---|
640 | { |
---|
641 | // delete created instance of scaling list since it will be inferred |
---|
642 | delete activePPS->getScalingList(); |
---|
643 | |
---|
644 | // infer scaling list |
---|
645 | activePPS->setScalingList( refPps->getScalingList() ); |
---|
646 | } |
---|
647 | |
---|
648 | } |
---|
649 | #endif |
---|
650 | |
---|
651 | #if AVC_BASE |
---|
652 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
653 | if( activeVPS->getNonHEVCBaseLayerFlag() ) |
---|
654 | #else |
---|
655 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
656 | #endif |
---|
657 | { |
---|
658 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
659 | if( m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
660 | { |
---|
661 | UInt refLayerId = 0; |
---|
662 | RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) ); |
---|
663 | |
---|
664 | Int numReorderPics[MAX_TLAYER]; |
---|
665 | #if !R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
666 | Window conformanceWindow; |
---|
667 | #endif |
---|
668 | Window defaultDisplayWindow; |
---|
669 | |
---|
670 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
671 | #if AUXILIARY_PICTURES |
---|
672 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true); |
---|
673 | #else |
---|
674 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true); |
---|
675 | #endif |
---|
676 | #else |
---|
677 | #if AUXILIARY_PICTURES |
---|
678 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
679 | #else |
---|
680 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
681 | #endif |
---|
682 | #endif |
---|
683 | // it is needed where the VPS is accessed through the slice |
---|
684 | pBLPic->getSlice(0)->setVPS( activeVPS ); |
---|
685 | |
---|
686 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
687 | g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma(); |
---|
688 | g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma(); |
---|
689 | #endif |
---|
690 | } |
---|
691 | } |
---|
692 | #endif |
---|
693 | |
---|
694 | #if P0312_VERT_PHASE_ADJ |
---|
695 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
696 | if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) |
---|
697 | { |
---|
698 | for(Int i = 0; i < activePPS->getNumScaledRefLayerOffsets(); i++) |
---|
699 | { |
---|
700 | UInt scaledRefLayerId = activePPS->getScaledRefLayerId(i); |
---|
701 | if( activePPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) ) |
---|
702 | { |
---|
703 | printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId ); |
---|
704 | break; |
---|
705 | } |
---|
706 | } |
---|
707 | } |
---|
708 | #else |
---|
709 | if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) |
---|
710 | { |
---|
711 | for(Int i = 0; i < activeSPS->getNumScaledRefLayerOffsets(); i++) |
---|
712 | { |
---|
713 | UInt scaledRefLayerId = activeSPS->getScaledRefLayerId(i); |
---|
714 | if( activeSPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) ) |
---|
715 | { |
---|
716 | printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId ); |
---|
717 | break; |
---|
718 | } |
---|
719 | } |
---|
720 | } |
---|
721 | #endif |
---|
722 | #endif |
---|
723 | |
---|
724 | #if SPS_DPB_PARAMS |
---|
725 | if( m_layerId > 0 ) |
---|
726 | { |
---|
727 | // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1. |
---|
728 | sps->setMaxTLayers( activeVPS->getMaxTLayers() ); |
---|
729 | |
---|
730 | // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag |
---|
731 | #if Q0177_SPS_TEMP_NESTING_FIX |
---|
732 | sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? activeVPS->getTemporalNestingFlag() : true ); |
---|
733 | #else |
---|
734 | sps->setTemporalIdNestingFlag( activeVPS->getTemporalNestingFlag() ); |
---|
735 | #endif |
---|
736 | |
---|
737 | // 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, |
---|
738 | // 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. |
---|
739 | for(UInt i=0; i < sps->getMaxTLayers(); i++) |
---|
740 | { |
---|
741 | // to avoid compiler warning "array subscript is above array bounds" |
---|
742 | assert( i < MAX_TLAYER ); |
---|
743 | #if LAYER_DECPICBUFF_PARAM && RESOLUTION_BASED_DPB |
---|
744 | sps->setMaxDecPicBuffering( activeVPS->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i); |
---|
745 | #else |
---|
746 | sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i); |
---|
747 | #endif |
---|
748 | } |
---|
749 | } |
---|
750 | #endif |
---|
751 | |
---|
752 | #if R0227_REP_FORMAT_CONSTRAINT //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 |
---|
753 | if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) |
---|
754 | { |
---|
755 | UInt layerId = m_apcSlicePilot->getLayerId(); |
---|
756 | assert( sps->getPicWidthInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples() ); |
---|
757 | assert( sps->getPicHeightInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples() ); |
---|
758 | assert( sps->getChromaFormatIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc() ); |
---|
759 | assert( sps->getBitDepth(CHANNEL_TYPE_LUMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma() ); |
---|
760 | assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma() ); |
---|
761 | } |
---|
762 | else if ( activeVPS->getVpsExtensionFlag() == 1 ) |
---|
763 | { |
---|
764 | UInt layerId = m_apcSlicePilot->getLayerId(); |
---|
765 | assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicWidthVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicWidthVpsInLumaSamples()); |
---|
766 | assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicHeightVpsInLumaSamples()); |
---|
767 | assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getChromaFormatVpsIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getChromaFormatVpsIdc()); |
---|
768 | assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsLuma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsLuma()); |
---|
769 | assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsChroma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsChroma()); |
---|
770 | } |
---|
771 | #endif |
---|
772 | |
---|
773 | m_apcSlicePilot->setPPS(pps); |
---|
774 | m_apcSlicePilot->setSPS(sps); |
---|
775 | pps->setSPS(sps); |
---|
776 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1))); |
---|
777 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
778 | pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) ); |
---|
779 | |
---|
780 | for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++) |
---|
781 | { |
---|
782 | #if REPN_FORMAT_IN_VPS |
---|
783 | g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC(); |
---|
784 | #else |
---|
785 | g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel)); |
---|
786 | #endif |
---|
787 | |
---|
788 | if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6)); |
---|
789 | else g_maxTrDynamicRange[channel] = 15; |
---|
790 | } |
---|
791 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
792 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
793 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
794 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize())); |
---|
795 | |
---|
796 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
797 | { |
---|
798 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
799 | } |
---|
800 | |
---|
801 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
802 | { |
---|
803 | sps->setAMPAcc( i, 0 ); |
---|
804 | } |
---|
805 | |
---|
806 | m_cSAO.destroy(); |
---|
807 | #if REPN_FORMAT_IN_VPS |
---|
808 | 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) ); |
---|
809 | #endif |
---|
810 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
811 | } |
---|
812 | |
---|
813 | #if SVC_EXTENSION |
---|
814 | #if POC_RESET_FLAG |
---|
815 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
816 | #else |
---|
817 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
818 | #endif |
---|
819 | #else |
---|
820 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
821 | #endif |
---|
822 | { |
---|
823 | #if SVC_EXTENSION |
---|
824 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); |
---|
825 | #if OUTPUT_LAYER_SET_INDEX |
---|
826 | // Following check should go wherever the VPS is activated |
---|
827 | checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS()); |
---|
828 | #endif |
---|
829 | #if RESOLUTION_BASED_DPB |
---|
830 | // Following assignment should go wherever a new VPS is activated |
---|
831 | assignSubDpbs(m_apcSlicePilot->getVPS()); |
---|
832 | #endif |
---|
833 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
834 | #else //SVC_EXTENSION |
---|
835 | m_apcSlicePilot->initSlice(); |
---|
836 | #endif |
---|
837 | |
---|
838 | if (m_bFirstSliceInPicture) |
---|
839 | { |
---|
840 | m_uiSliceIdx = 0; |
---|
841 | } |
---|
842 | else |
---|
843 | { |
---|
844 | m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
845 | } |
---|
846 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
847 | |
---|
848 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
849 | #if POC_RESET_RESTRICTIONS |
---|
850 | m_apcSlicePilot->setTLayer( nalu.m_temporalId ); |
---|
851 | #endif |
---|
852 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
853 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
854 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
855 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
856 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
857 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
858 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
859 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
860 | |
---|
861 | #if ENC_DEC_TRACE |
---|
862 | const UInt64 originalSymbolCount = g_nSymbolCounter; |
---|
863 | #endif |
---|
864 | |
---|
865 | #if SVC_EXTENSION |
---|
866 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
867 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
---|
868 | #endif |
---|
869 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
870 | #endif |
---|
871 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
872 | |
---|
873 | // set POC for dependent slices in skipped pictures |
---|
874 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
875 | { |
---|
876 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
877 | } |
---|
878 | |
---|
879 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
880 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
881 | |
---|
882 | //For inference of NoOutputOfPriorPicsFlag |
---|
883 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
884 | { |
---|
885 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
886 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
887 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
888 | { |
---|
889 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
890 | } |
---|
891 | //the inference for NoOutputPriorPicsFlag |
---|
892 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
893 | { |
---|
894 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
895 | { |
---|
896 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
897 | } |
---|
898 | } |
---|
899 | else |
---|
900 | { |
---|
901 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
902 | } |
---|
903 | |
---|
904 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
905 | { |
---|
906 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
907 | } |
---|
908 | } |
---|
909 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
910 | { |
---|
911 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
912 | m_isNoOutputPriorPics = true; |
---|
913 | } |
---|
914 | else |
---|
915 | { |
---|
916 | m_isNoOutputPriorPics = false; |
---|
917 | } |
---|
918 | |
---|
919 | //For inference of PicOutputFlag |
---|
920 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
921 | { |
---|
922 | if ( m_craNoRaslOutputFlag ) |
---|
923 | { |
---|
924 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
925 | } |
---|
926 | } |
---|
927 | |
---|
928 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
929 | { |
---|
930 | Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
931 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
932 | } |
---|
933 | |
---|
934 | // Skip pictures due to random access |
---|
935 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
936 | { |
---|
937 | m_prevSliceSkipped = true; |
---|
938 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
939 | return false; |
---|
940 | } |
---|
941 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
942 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
943 | { |
---|
944 | m_prevSliceSkipped = true; |
---|
945 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
946 | return false; |
---|
947 | } |
---|
948 | |
---|
949 | // clear previous slice skipped flag |
---|
950 | m_prevSliceSkipped = false; |
---|
951 | |
---|
952 | // exit when a new picture is found |
---|
953 | #if SVC_EXTENSION |
---|
954 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
955 | |
---|
956 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
957 | #if NO_CLRAS_OUTPUT_FLAG |
---|
958 | if (m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() ) |
---|
959 | { |
---|
960 | if (m_bFirstSliceInSequence) |
---|
961 | { |
---|
962 | setNoClrasOutputFlag(true); |
---|
963 | } |
---|
964 | else if ( m_apcSlicePilot->getBlaPicFlag() ) |
---|
965 | { |
---|
966 | setNoClrasOutputFlag(true); |
---|
967 | } |
---|
968 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
969 | else if (m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag()) |
---|
970 | { |
---|
971 | setNoClrasOutputFlag(true); |
---|
972 | } |
---|
973 | #endif |
---|
974 | else |
---|
975 | { |
---|
976 | setNoClrasOutputFlag(false); |
---|
977 | } |
---|
978 | } |
---|
979 | else |
---|
980 | { |
---|
981 | setNoClrasOutputFlag(false); |
---|
982 | } |
---|
983 | |
---|
984 | m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag ); |
---|
985 | #endif |
---|
986 | |
---|
987 | // Derive the value of NoOutputOfPriorPicsFlag |
---|
988 | if( bNewPOC || m_layerId!=m_uiPrevLayerId ) // i.e. new coded picture |
---|
989 | { |
---|
990 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
991 | { |
---|
992 | this->setNoOutputPriorPicsFlag( true ); |
---|
993 | } |
---|
994 | else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
995 | { |
---|
996 | this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() ); |
---|
997 | } |
---|
998 | else |
---|
999 | { |
---|
1000 | if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() ) |
---|
1001 | { |
---|
1002 | this->setNoOutputPriorPicsFlag( true ); |
---|
1003 | } |
---|
1004 | } |
---|
1005 | } |
---|
1006 | #endif |
---|
1007 | |
---|
1008 | #if POC_RESET_IDC_DECODER |
---|
1009 | if( m_parseIdc != -1 ) // Second pass for a POC resetting picture |
---|
1010 | { |
---|
1011 | m_parseIdc++; // Proceed to POC decoding and RPS derivation |
---|
1012 | } |
---|
1013 | |
---|
1014 | if( m_parseIdc == 2 ) |
---|
1015 | { |
---|
1016 | bNewPOC = false; |
---|
1017 | } |
---|
1018 | |
---|
1019 | if( (bNewPOC || m_layerId!=m_uiPrevLayerId) && (m_parseIdc == -1) ) // Will be true at the first pass |
---|
1020 | { |
---|
1021 | //if (bNewPOC || m_layerId!=m_uiPrevLayerId) |
---|
1022 | // Check if new reset period has started - this is needed just so that the SHM decoder which calls slice header decoding twice |
---|
1023 | // does not invoke the output twice |
---|
1024 | //if( m_lastPocPeriodId[m_apcSlicePilot->getLayerId()] == m_apcSlicePilot->getPocResetPeriodId() ) |
---|
1025 | // Update CurrAU marking |
---|
1026 | 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 |
---|
1027 | { |
---|
1028 | #if POC_RESET_RESTRICTIONS |
---|
1029 | // New access unit; reset all variables related to POC reset restrictions |
---|
1030 | resetPocRestrictionCheckParameters(); |
---|
1031 | #endif |
---|
1032 | markAllPicsAsNoCurrAu(); |
---|
1033 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1034 | for (UInt i = 0; i < MAX_LAYERS; i++) |
---|
1035 | { |
---|
1036 | m_ppcTDecTop[i]->m_pocDecrementedInDPBFlag = false; |
---|
1037 | } |
---|
1038 | #endif |
---|
1039 | } |
---|
1040 | |
---|
1041 | |
---|
1042 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1043 | m_pocResettingFlag = false; |
---|
1044 | |
---|
1045 | if (m_apcSlicePilot->getPocResetIdc() != 0) |
---|
1046 | { |
---|
1047 | if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag()) |
---|
1048 | { |
---|
1049 | m_pocResettingFlag = true; |
---|
1050 | } |
---|
1051 | else if (m_pocDecrementedInDPBFlag) |
---|
1052 | { |
---|
1053 | m_pocResettingFlag = false; |
---|
1054 | } |
---|
1055 | else |
---|
1056 | { |
---|
1057 | m_pocResettingFlag = true; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | #endif |
---|
1061 | |
---|
1062 | if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
1063 | { |
---|
1064 | Int pocResetPeriodId = m_apcSlicePilot->getPocResetPeriodId(); |
---|
1065 | if ( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 || |
---|
1066 | ( m_apcSlicePilot->getPocResetIdc() == 3 && pocResetPeriodId != getLastPocPeriodId() ) ) |
---|
1067 | { |
---|
1068 | setLastPocPeriodId(pocResetPeriodId); |
---|
1069 | m_parseIdc = 0; |
---|
1070 | } |
---|
1071 | #if POC_RESET_VALUE_RESTRICTION |
---|
1072 | // Check if the POC Reset period ID matches with the Reset Period ID |
---|
1073 | if( pocResetPeriodId == m_crossLayerPocResetPeriodId ) |
---|
1074 | { |
---|
1075 | // If matching, and current poc_reset_idc = 3, then the values should match |
---|
1076 | if( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
1077 | { |
---|
1078 | assert( ( m_apcSlicePilot->getFullPocResetFlag() == false && m_crossLayerPocResetIdc == 1 ) || |
---|
1079 | ( m_apcSlicePilot->getFullPocResetFlag() == true && m_crossLayerPocResetIdc == 2 ) ); |
---|
1080 | } |
---|
1081 | } |
---|
1082 | else |
---|
1083 | { |
---|
1084 | // This is the first picture of a POC resetting access unit |
---|
1085 | m_crossLayerPocResetPeriodId = pocResetPeriodId; |
---|
1086 | if( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ) |
---|
1087 | { |
---|
1088 | m_crossLayerPocResetIdc = m_apcSlicePilot->getPocResetIdc(); |
---|
1089 | } |
---|
1090 | else |
---|
1091 | { // poc_reset_idc = 3 |
---|
1092 | // In this case, the entire POC resetting access unit has been lost. |
---|
1093 | // Need more checking to ensure poc_reset_idc = 3 works. |
---|
1094 | assert ( 0 ); |
---|
1095 | } |
---|
1096 | } |
---|
1097 | #endif |
---|
1098 | } |
---|
1099 | else |
---|
1100 | { |
---|
1101 | m_parseIdc = 3; // Proceed to decoding POC and RPS |
---|
1102 | } |
---|
1103 | } |
---|
1104 | #endif |
---|
1105 | |
---|
1106 | #if ALIGNED_BUMPING |
---|
1107 | #if POC_RESET_IDC_DECODER |
---|
1108 | |
---|
1109 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1110 | UInt affectedLayerList[MAX_NUM_LAYER_IDS]; |
---|
1111 | Int numAffectedLayers; |
---|
1112 | |
---|
1113 | affectedLayerList[0] = m_apcSlicePilot->getLayerId(); |
---|
1114 | numAffectedLayers = 1; |
---|
1115 | |
---|
1116 | if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag()) |
---|
1117 | { |
---|
1118 | for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++) |
---|
1119 | { |
---|
1120 | affectedLayerList[j + 1] = m_apcSlicePilot->getVPS()->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j); |
---|
1121 | } |
---|
1122 | numAffectedLayers = m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1; |
---|
1123 | } |
---|
1124 | #endif |
---|
1125 | |
---|
1126 | //if( (bNewPOC || m_layerId != m_uiPrevLayerId) && ( m_parseIdc != 1) ) |
---|
1127 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1128 | if (m_parseIdc == 1 && m_pocResettingFlag) |
---|
1129 | #else |
---|
1130 | if (m_parseIdc == 1) |
---|
1131 | #endif |
---|
1132 | { |
---|
1133 | // Invoke output of pictures if the current picture is a POC reset picture |
---|
1134 | bNewPOC = true; |
---|
1135 | /* Include reset of all POCs in the layer */ |
---|
1136 | |
---|
1137 | // This operation would do the following: |
---|
1138 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
1139 | // 2. Update the value of m_pocCRA. |
---|
1140 | // 3. Reset the POC values at the decoder for the current picture to be zero - will be done later |
---|
1141 | // 4. update value of POCLastDisplay |
---|
1142 | |
---|
1143 | //Do the reset stuff here |
---|
1144 | Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
1145 | Int pocLsbVal; |
---|
1146 | if( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
1147 | { |
---|
1148 | pocLsbVal = m_apcSlicePilot->getPocLsbVal() ; |
---|
1149 | } |
---|
1150 | else |
---|
1151 | { |
---|
1152 | pocLsbVal = (m_apcSlicePilot->getPOC() % maxPocLsb); |
---|
1153 | } |
---|
1154 | |
---|
1155 | Int pocMsbDelta = 0; |
---|
1156 | if ( m_apcSlicePilot->getPocMsbValPresentFlag() ) |
---|
1157 | { |
---|
1158 | pocMsbDelta = m_apcSlicePilot->getPocMsbVal() * maxPocLsb; |
---|
1159 | } |
---|
1160 | else |
---|
1161 | { |
---|
1162 | //This MSB derivation can be made into one function. Item to do next. |
---|
1163 | Int prevPoc = this->getPrevPicOrderCnt(); |
---|
1164 | Int prevPocLsb = prevPoc & (maxPocLsb - 1); |
---|
1165 | Int prevPocMsb = prevPoc - prevPocLsb; |
---|
1166 | |
---|
1167 | pocMsbDelta = m_apcSlicePilot->getCurrMsb( pocLsbVal, prevPocLsb, prevPocMsb, maxPocLsb ); |
---|
1168 | } |
---|
1169 | |
---|
1170 | Int pocLsbDelta; |
---|
1171 | if( m_apcSlicePilot->getPocResetIdc() == 2 || ( m_apcSlicePilot->getPocResetIdc() == 3 && m_apcSlicePilot->getFullPocResetFlag() )) |
---|
1172 | { |
---|
1173 | pocLsbDelta = pocLsbVal; |
---|
1174 | } |
---|
1175 | else |
---|
1176 | { |
---|
1177 | pocLsbDelta = 0; |
---|
1178 | } |
---|
1179 | |
---|
1180 | Int deltaPocVal = pocMsbDelta + pocLsbDelta; |
---|
1181 | |
---|
1182 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1183 | for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++) |
---|
1184 | { |
---|
1185 | if (!m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag) |
---|
1186 | { |
---|
1187 | m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag = true; |
---|
1188 | TComList<TComPic*>::iterator iterPic = m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->begin(); |
---|
1189 | while (iterPic != m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->end()) |
---|
1190 | #else |
---|
1191 | //Reset all POC for DPB -> basically do it for each slice in the picutre |
---|
1192 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
1193 | |
---|
1194 | // Iterate through all picture in DPB |
---|
1195 | while( iterPic != m_cListPic.end() ) |
---|
1196 | #endif |
---|
1197 | { |
---|
1198 | TComPic *dpbPic = *iterPic; |
---|
1199 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
1200 | // needed for output, are in the same layer, and not the current picture. |
---|
1201 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1202 | assert(dpbPic->getLayerId() == affectedLayerList[layerIdx]); |
---|
1203 | if ( (dpbPic->getReconMark()) && (dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag()) ) |
---|
1204 | #else |
---|
1205 | if ( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
---|
1206 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
---|
1207 | && ( dpbPic->getReconMark() ) && ( dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag() )) |
---|
1208 | #endif |
---|
1209 | { |
---|
1210 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1211 | { |
---|
1212 | |
---|
1213 | TComSlice *slice = dpbPic->getSlice(i); |
---|
1214 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
1215 | slice->setPOC( slice->getPOC() - deltaPocVal ); |
---|
1216 | |
---|
1217 | // Also adjust the POC value stored in the RPS of each such slice |
---|
1218 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
1219 | { |
---|
1220 | rps->setPOC( j, rps->getPOC(j) - deltaPocVal ); |
---|
1221 | } |
---|
1222 | // Also adjust the value of refPOC |
---|
1223 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
1224 | { |
---|
1225 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
1226 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
1227 | { |
---|
1228 | slice->setRefPOC( slice->getRefPOC(list, j) - deltaPocVal, list, j); |
---|
1229 | } |
---|
1230 | } |
---|
1231 | } |
---|
1232 | } |
---|
1233 | iterPic++; |
---|
1234 | } |
---|
1235 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1236 | // Update the value of pocCRA |
---|
1237 | m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocCRA -= deltaPocVal; |
---|
1238 | } |
---|
1239 | } |
---|
1240 | #else |
---|
1241 | // Update the value of pocCRA |
---|
1242 | m_pocCRA -= deltaPocVal; |
---|
1243 | #endif |
---|
1244 | |
---|
1245 | // Update value of POCLastDisplay |
---|
1246 | iPOCLastDisplay -= deltaPocVal; |
---|
1247 | } |
---|
1248 | Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
1249 | Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb(); |
---|
1250 | |
---|
1251 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1252 | if (m_pocResettingFlag && (m_parseIdc == 1 || m_parseIdc == 2)) |
---|
1253 | #else |
---|
1254 | if (m_parseIdc == 1 || m_parseIdc == 2) // TODO This should be replaced by pocResettingFlag. |
---|
1255 | #endif |
---|
1256 | { |
---|
1257 | // Set poc for current slice |
---|
1258 | if( m_apcSlicePilot->getPocResetIdc() == 1 ) |
---|
1259 | { |
---|
1260 | m_apcSlicePilot->setPOC( slicePicOrderCntLsb ); |
---|
1261 | } |
---|
1262 | else if( m_apcSlicePilot->getPocResetIdc() == 2 ) |
---|
1263 | { |
---|
1264 | m_apcSlicePilot->setPOC( 0 ); |
---|
1265 | } |
---|
1266 | else |
---|
1267 | { |
---|
1268 | Int picOrderCntMsb = m_apcSlicePilot->getCurrMsb( slicePicOrderCntLsb, m_apcSlicePilot->getFullPocResetFlag() ? 0 : m_apcSlicePilot->getPocLsbVal(), 0 , maxPocLsb ); |
---|
1269 | m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb ); |
---|
1270 | } |
---|
1271 | } |
---|
1272 | else if (m_parseIdc == 3) |
---|
1273 | { |
---|
1274 | Int picOrderCntMsb = 0; |
---|
1275 | if( m_apcSlicePilot->getPocMsbValPresentFlag() ) |
---|
1276 | { |
---|
1277 | picOrderCntMsb = m_apcSlicePilot->getPocMsbVal() * maxPocLsb; |
---|
1278 | } |
---|
1279 | else if( m_apcSlicePilot->getIdrPicFlag() ) |
---|
1280 | { |
---|
1281 | picOrderCntMsb = 0; |
---|
1282 | } |
---|
1283 | else |
---|
1284 | { |
---|
1285 | Int prevPicOrderCntLsb = this->getPrevPicOrderCnt() & ( maxPocLsb - 1); |
---|
1286 | Int prevPicOrderCntMsb = this->getPrevPicOrderCnt() - prevPicOrderCntLsb; |
---|
1287 | picOrderCntMsb = m_apcSlicePilot->getCurrMsb(slicePicOrderCntLsb, prevPicOrderCntLsb, prevPicOrderCntMsb, maxPocLsb ); |
---|
1288 | } |
---|
1289 | m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb ); |
---|
1290 | } |
---|
1291 | |
---|
1292 | if( m_parseIdc == 1 || m_parseIdc == 3) |
---|
1293 | { |
---|
1294 | // Adjust prevPicOrderCnt |
---|
1295 | if( !m_apcSlicePilot->getRaslPicFlag() |
---|
1296 | && !m_apcSlicePilot->getRadlPicFlag() |
---|
1297 | && (m_apcSlicePilot->getNalUnitType() % 2 == 1) |
---|
1298 | && ( nalu.m_temporalId == 0 ) |
---|
1299 | && !m_apcSlicePilot->getDiscardableFlag() ) |
---|
1300 | { |
---|
1301 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1302 | for (UInt i = 0; i < numAffectedLayers; i++) |
---|
1303 | { |
---|
1304 | m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt(m_apcSlicePilot->getPOC()); |
---|
1305 | } |
---|
1306 | #else |
---|
1307 | this->setPrevPicOrderCnt( m_apcSlicePilot->getPOC() ); |
---|
1308 | #endif |
---|
1309 | } |
---|
1310 | else if ( m_apcSlicePilot->getPocResetIdc() == 3 ) |
---|
1311 | { |
---|
1312 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1313 | if (!m_firstPicInLayerDecodedFlag || (m_firstPicInLayerDecodedFlag && m_pocResettingFlag)) |
---|
1314 | { |
---|
1315 | for (UInt i = 0; i < numAffectedLayers; i++) |
---|
1316 | { |
---|
1317 | m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() |
---|
1318 | ? 0 : m_apcSlicePilot->getPocLsbVal() ); |
---|
1319 | } |
---|
1320 | } |
---|
1321 | #else |
---|
1322 | this->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() |
---|
1323 | ? 0 : m_apcSlicePilot->getPocLsbVal() ); |
---|
1324 | #endif |
---|
1325 | } |
---|
1326 | #else |
---|
1327 | if (bNewPOC || m_layerId!=m_uiPrevLayerId) |
---|
1328 | { |
---|
1329 | #endif |
---|
1330 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
1331 | } |
---|
1332 | #endif |
---|
1333 | #if POC_RESET_IDC_DECODER |
---|
1334 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence ) |
---|
1335 | #else |
---|
1336 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
1337 | #endif |
---|
1338 | { |
---|
1339 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1340 | curLayerId = m_uiPrevLayerId; |
---|
1341 | m_uiPrevLayerId = m_layerId; |
---|
1342 | return true; |
---|
1343 | } |
---|
1344 | |
---|
1345 | #if POC_RESET_IDC_DECODER |
---|
1346 | m_parseIdc = -1; |
---|
1347 | #endif |
---|
1348 | |
---|
1349 | |
---|
1350 | #if R0226_SLICE_TMVP |
---|
1351 | if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 ) |
---|
1352 | { |
---|
1353 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
1354 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
1355 | while( iterRefPic != m_cListPic.end() ) |
---|
1356 | { |
---|
1357 | TComPic *refPic = *iterRefPic; |
---|
1358 | if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() ) |
---|
1359 | { |
---|
1360 | for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1361 | { |
---|
1362 | |
---|
1363 | TComSlice *refSlice = refPic->getSlice(i); |
---|
1364 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
1365 | } |
---|
1366 | } |
---|
1367 | iterRefPic++; |
---|
1368 | } |
---|
1369 | } |
---|
1370 | m_apcSlicePilot->setAvailableForTMVPRefFlag( true ); |
---|
1371 | #endif |
---|
1372 | |
---|
1373 | // actual decoding starts here |
---|
1374 | xActivateParameterSets(); |
---|
1375 | |
---|
1376 | #if REPN_FORMAT_IN_VPS |
---|
1377 | // Initialize ILRP if needed, only for the current layer |
---|
1378 | // ILRP intialization should go along with activation of parameters sets, |
---|
1379 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
1380 | xInitILRP(m_apcSlicePilot); |
---|
1381 | #endif |
---|
1382 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
1383 | { |
---|
1384 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1385 | curLayerId = m_layerId; |
---|
1386 | m_uiPrevLayerId = m_layerId; |
---|
1387 | } |
---|
1388 | m_bFirstSliceInSequence = false; |
---|
1389 | m_bFirstSliceInBitstream = false; |
---|
1390 | #if POC_RESET_FLAG |
---|
1391 | // This operation would do the following: |
---|
1392 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
1393 | // 2. Update the value of m_pocCRA. |
---|
1394 | // 3. Reset the POC values at the decoder for the current picture to be zero. |
---|
1395 | // 4. update value of POCLastDisplay |
---|
1396 | if( m_apcSlicePilot->getPocResetFlag() ) |
---|
1397 | { |
---|
1398 | if( m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
1399 | { |
---|
1400 | Int pocAdjustValue = m_apcSlicePilot->getPOC(); |
---|
1401 | |
---|
1402 | #if PREVTID0_POC_RESET |
---|
1403 | m_apcSlicePilot->adjustPrevTid0POC(pocAdjustValue); |
---|
1404 | #endif |
---|
1405 | // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre |
---|
1406 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
1407 | |
---|
1408 | // Iterate through all picture in DPB |
---|
1409 | while( iterPic != m_cListPic.end() ) |
---|
1410 | { |
---|
1411 | TComPic *dpbPic = *iterPic; |
---|
1412 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
1413 | // needed for output, are in the same layer, and not the current picture. |
---|
1414 | if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
---|
1415 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
---|
1416 | && ( dpbPic->getReconMark() ) |
---|
1417 | ) |
---|
1418 | { |
---|
1419 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1420 | { |
---|
1421 | |
---|
1422 | TComSlice *slice = dpbPic->getSlice(i); |
---|
1423 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
1424 | slice->setPOC( slice->getPOC() - pocAdjustValue ); |
---|
1425 | |
---|
1426 | // Also adjust the POC value stored in the RPS of each such slice |
---|
1427 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
1428 | { |
---|
1429 | rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); |
---|
1430 | } |
---|
1431 | // Also adjust the value of refPOC |
---|
1432 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
1433 | { |
---|
1434 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
1435 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
1436 | { |
---|
1437 | slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); |
---|
1438 | } |
---|
1439 | } |
---|
1440 | } |
---|
1441 | } |
---|
1442 | iterPic++; |
---|
1443 | } |
---|
1444 | // Update the value of pocCRA |
---|
1445 | m_pocCRA -= pocAdjustValue; |
---|
1446 | // Update value of POCLastDisplay |
---|
1447 | iPOCLastDisplay -= pocAdjustValue; |
---|
1448 | } |
---|
1449 | // Reset current poc for current slice and RPS |
---|
1450 | m_apcSlicePilot->setPOC( 0 ); |
---|
1451 | } |
---|
1452 | #endif |
---|
1453 | // Alignment of TSA and STSA pictures across AU |
---|
1454 | #if !Q0108_TSA_STSA |
---|
1455 | if( m_apcSlicePilot->getLayerId() > 0 ) |
---|
1456 | { |
---|
1457 | // Check for TSA alignment |
---|
1458 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
1459 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R |
---|
1460 | ) |
---|
1461 | { |
---|
1462 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1463 | { |
---|
1464 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1465 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); |
---|
1466 | if( refpicLayer ) |
---|
1467 | { |
---|
1468 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
1469 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R ); // TSA pictures should be aligned among depenedent layers |
---|
1470 | } |
---|
1471 | } |
---|
1472 | } |
---|
1473 | // Check for STSA alignment |
---|
1474 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
1475 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R |
---|
1476 | ) |
---|
1477 | { |
---|
1478 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1479 | { |
---|
1480 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1481 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); // STSA pictures should be aligned among dependent layers |
---|
1482 | if( refpicLayer ) |
---|
1483 | |
---|
1484 | { |
---|
1485 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
1486 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R ); |
---|
1487 | } |
---|
1488 | } |
---|
1489 | } |
---|
1490 | } |
---|
1491 | #endif |
---|
1492 | |
---|
1493 | #else //SVC_EXTENSION |
---|
1494 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
1495 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) |
---|
1496 | { |
---|
1497 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
1498 | } |
---|
1499 | |
---|
1500 | // exit when a new picture is found |
---|
1501 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) |
---|
1502 | { |
---|
1503 | if (m_prevPOC >= m_pocRandomAccess) |
---|
1504 | { |
---|
1505 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1506 | #if ENC_DEC_TRACE |
---|
1507 | //rewind the trace counter since we didn't actually decode the slice |
---|
1508 | g_nSymbolCounter = originalSymbolCount; |
---|
1509 | #endif |
---|
1510 | return true; |
---|
1511 | } |
---|
1512 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1513 | } |
---|
1514 | |
---|
1515 | // actual decoding starts here |
---|
1516 | xActivateParameterSets(); |
---|
1517 | |
---|
1518 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
1519 | { |
---|
1520 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1521 | } |
---|
1522 | m_bFirstSliceInSequence = false; |
---|
1523 | m_bFirstSliceInBitstream = false; |
---|
1524 | #endif //SVC_EXTENSION |
---|
1525 | //detect lost reference picture and insert copy of earlier frame. |
---|
1526 | Int lostPoc; |
---|
1527 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
1528 | { |
---|
1529 | xCreateLostPicture(lostPoc-1); |
---|
1530 | } |
---|
1531 | if (m_bFirstSliceInPicture) |
---|
1532 | { |
---|
1533 | #if AVC_BASE |
---|
1534 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
1535 | if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() ) |
---|
1536 | #else |
---|
1537 | if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1538 | #endif |
---|
1539 | { |
---|
1540 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1541 | pBLPic->getSlice(0)->setReferenced(true); |
---|
1542 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
1543 | |
---|
1544 | if( pFile->good() ) |
---|
1545 | { |
---|
1546 | Bool is16bit = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8; |
---|
1547 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y); |
---|
1548 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y); |
---|
1549 | |
---|
1550 | Int len = uiWidth * (is16bit ? 2 : 1); |
---|
1551 | UChar *buf = new UChar[len]; |
---|
1552 | |
---|
1553 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
1554 | if( is16bit ) |
---|
1555 | { |
---|
1556 | uiPos <<= 1; |
---|
1557 | } |
---|
1558 | |
---|
1559 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
1560 | |
---|
1561 | // read Y component |
---|
1562 | Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y); |
---|
1563 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y); |
---|
1564 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1565 | { |
---|
1566 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1567 | |
---|
1568 | if( !is16bit ) |
---|
1569 | { |
---|
1570 | for (Int x = 0; x < uiWidth; x++) |
---|
1571 | { |
---|
1572 | pPel[x] = buf[x]; |
---|
1573 | } |
---|
1574 | } |
---|
1575 | else |
---|
1576 | { |
---|
1577 | for (Int x = 0; x < uiWidth; x++) |
---|
1578 | { |
---|
1579 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1580 | } |
---|
1581 | } |
---|
1582 | |
---|
1583 | pPel += uiStride; |
---|
1584 | } |
---|
1585 | |
---|
1586 | len >>= 1; |
---|
1587 | uiWidth >>= 1; |
---|
1588 | uiHeight >>= 1; |
---|
1589 | |
---|
1590 | // read Cb component |
---|
1591 | pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb); |
---|
1592 | uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb); |
---|
1593 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1594 | { |
---|
1595 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1596 | |
---|
1597 | if( !is16bit ) |
---|
1598 | { |
---|
1599 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1600 | { |
---|
1601 | pPel[x] = buf[x]; |
---|
1602 | } |
---|
1603 | } |
---|
1604 | else |
---|
1605 | { |
---|
1606 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1607 | { |
---|
1608 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1609 | } |
---|
1610 | } |
---|
1611 | |
---|
1612 | pPel += uiStride; |
---|
1613 | } |
---|
1614 | |
---|
1615 | // read Cr component |
---|
1616 | pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr); |
---|
1617 | uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr); |
---|
1618 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1619 | { |
---|
1620 | pFile->read(reinterpret_cast<Char*>(buf), len); |
---|
1621 | |
---|
1622 | if( !is16bit ) |
---|
1623 | { |
---|
1624 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1625 | { |
---|
1626 | pPel[x] = buf[x]; |
---|
1627 | } |
---|
1628 | } |
---|
1629 | else |
---|
1630 | { |
---|
1631 | for( Int x = 0; x < uiWidth; x++ ) |
---|
1632 | { |
---|
1633 | pPel[x] = (buf[2*x+1] << 8) | buf[2*x]; |
---|
1634 | } |
---|
1635 | } |
---|
1636 | |
---|
1637 | pPel += uiStride; |
---|
1638 | } |
---|
1639 | |
---|
1640 | delete[] buf; |
---|
1641 | } |
---|
1642 | } |
---|
1643 | #endif |
---|
1644 | |
---|
1645 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
1646 | if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() ) |
---|
1647 | { |
---|
1648 | for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++) |
---|
1649 | { |
---|
1650 | m_ppcTDecTop[i]->setLayerInitializedFlag(false); |
---|
1651 | m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false); |
---|
1652 | } |
---|
1653 | } |
---|
1654 | #endif |
---|
1655 | // Buffer initialize for prediction. |
---|
1656 | m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc()); |
---|
1657 | #if ALIGNED_BUMPING |
---|
1658 | m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); |
---|
1659 | #else |
---|
1660 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
1661 | #endif |
---|
1662 | // Get a new picture buffer |
---|
1663 | xGetNewPicBuffer (m_apcSlicePilot, m_pcPic); |
---|
1664 | |
---|
1665 | #if POC_RESET_IDC_DECODER |
---|
1666 | m_pcPic->setCurrAuFlag( true ); |
---|
1667 | #if POC_RESET_RESTRICTIONS |
---|
1668 | if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag ) |
---|
1669 | { |
---|
1670 | // IDR picture with nuh_layer_id > 0 present |
---|
1671 | m_nonBaseIdrPresentFlag = true; |
---|
1672 | m_nonBaseIdrType = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1673 | } |
---|
1674 | else |
---|
1675 | { |
---|
1676 | if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
1677 | { |
---|
1678 | // Picture with nal_unit_type not equal IDR_W_RADL present |
---|
1679 | m_picNonIdrWithRadlPresentFlag = true; |
---|
1680 | } |
---|
1681 | if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1682 | { |
---|
1683 | // Picture with nal_unit_type not equal IDR_N_LP present |
---|
1684 | m_picNonIdrNoLpPresentFlag = true; |
---|
1685 | } |
---|
1686 | } |
---|
1687 | if( !m_checkPocRestrictionsForCurrAu ) // Will be true for the first slice/picture of the AU |
---|
1688 | { |
---|
1689 | m_checkPocRestrictionsForCurrAu = true; |
---|
1690 | m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc(); |
---|
1691 | if( m_pcPic->getLayerId() == 0 ) |
---|
1692 | { |
---|
1693 | // Base layer picture is present |
---|
1694 | m_baseLayerPicPresentFlag = true; |
---|
1695 | if( m_apcSlicePilot->isIRAP() ) |
---|
1696 | { |
---|
1697 | // Base layer picture is IRAP |
---|
1698 | m_baseLayerIrapFlag = true; |
---|
1699 | } |
---|
1700 | if( m_apcSlicePilot->isIDR() ) |
---|
1701 | { |
---|
1702 | // Base layer picture is IDR |
---|
1703 | m_baseLayerIdrFlag = true; |
---|
1704 | } |
---|
1705 | else |
---|
1706 | { |
---|
1707 | if( m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag()) |
---|
1708 | { |
---|
1709 | /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture |
---|
1710 | and vps_base_layer_internal_flag is equal to 1, the value of poc_reset_idc shall not be equal to 2 |
---|
1711 | for any picture in the access unit. */ |
---|
1712 | assert( m_apcSlicePilot->getPocResetIdc() != 2 ); |
---|
1713 | } |
---|
1714 | } |
---|
1715 | } |
---|
1716 | } |
---|
1717 | else |
---|
1718 | { |
---|
1719 | // The value of poc_reset_idc of all coded pictures that are present in the bitstream in an access unit shall be the same. |
---|
1720 | assert( m_pocResetIdcOrCurrAu == m_apcSlicePilot->getPocResetIdc() ); |
---|
1721 | |
---|
1722 | /* 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 |
---|
1723 | and there is at least one other picture in the same access unit that is not an IRAP picture, |
---|
1724 | the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ |
---|
1725 | if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() ) |
---|
1726 | { |
---|
1727 | assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1728 | } |
---|
1729 | |
---|
1730 | /* When the picture with nuh_layer_id equal to 0 in an access unit is an IDR picture and |
---|
1731 | vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit, |
---|
1732 | the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */ |
---|
1733 | if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() ) |
---|
1734 | { |
---|
1735 | assert( m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1736 | } |
---|
1737 | |
---|
1738 | /* When there is at least one picture that has nuh_layer_id greater than 0 and that is an IDR picture |
---|
1739 | with a particular value of nal_unit_type in an access unit and there is at least one other coded picture |
---|
1740 | that is present in the bitstream in the same access unit with a different value of nal_unit_type, |
---|
1741 | the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ |
---|
1742 | if( m_nonBaseIdrPresentFlag && ( |
---|
1743 | ( m_nonBaseIdrType == 1 && m_picNonIdrWithRadlPresentFlag ) || |
---|
1744 | ( m_nonBaseIdrType == 0 && m_picNonIdrNoLpPresentFlag ) |
---|
1745 | )) |
---|
1746 | { |
---|
1747 | assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); |
---|
1748 | } |
---|
1749 | } |
---|
1750 | #endif |
---|
1751 | #endif |
---|
1752 | |
---|
1753 | Bool isField = false; |
---|
1754 | Bool isTff = false; |
---|
1755 | |
---|
1756 | if(!m_SEIs.empty()) |
---|
1757 | { |
---|
1758 | // Check if any new Picture Timing SEI has arrived |
---|
1759 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
1760 | if (pictureTimingSEIs.size()>0) |
---|
1761 | { |
---|
1762 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
1763 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
---|
1764 | isTff = (pictureTiming->m_picStruct == 1); |
---|
1765 | } |
---|
1766 | |
---|
1767 | #if R0226_CONSTRAINT_TMVP_SEI |
---|
1768 | // Check if any new temporal motion vector prediction constraints SEI has arrived |
---|
1769 | SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS); |
---|
1770 | if (seiTMVPConstrainsList.size() > 0) |
---|
1771 | { |
---|
1772 | assert ( m_pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 0 |
---|
1773 | SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin()); |
---|
1774 | if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 ) |
---|
1775 | { |
---|
1776 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
1777 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
1778 | while( iterRefPic != m_cListPic.end() ) |
---|
1779 | { |
---|
1780 | TComPic *refPic = *iterRefPic; |
---|
1781 | if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() ) |
---|
1782 | { |
---|
1783 | for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1784 | { |
---|
1785 | TComSlice *refSlice = refPic->getSlice(i); |
---|
1786 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
1787 | } |
---|
1788 | } |
---|
1789 | iterRefPic++; |
---|
1790 | } |
---|
1791 | } |
---|
1792 | } |
---|
1793 | #endif |
---|
1794 | } |
---|
1795 | |
---|
1796 | //Set Field/Frame coding mode |
---|
1797 | m_pcPic->setField(isField); |
---|
1798 | m_pcPic->setTopField(isTff); |
---|
1799 | |
---|
1800 | // transfer any SEI messages that have been received to the picture |
---|
1801 | m_pcPic->setSEIs(m_SEIs); |
---|
1802 | m_SEIs.clear(); |
---|
1803 | |
---|
1804 | // Recursive structure |
---|
1805 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() ); |
---|
1806 | #if SVC_EXTENSION |
---|
1807 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
1808 | #else |
---|
1809 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
1810 | #endif |
---|
1811 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
1812 | |
---|
1813 | m_cSliceDecoder.create(); |
---|
1814 | } |
---|
1815 | else |
---|
1816 | { |
---|
1817 | // Check if any new SEI has arrived |
---|
1818 | if(!m_SEIs.empty()) |
---|
1819 | { |
---|
1820 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
1821 | SEIMessages &picSEI = m_pcPic->getSEIs(); |
---|
1822 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
1823 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
1824 | deleteSEIs(m_SEIs); |
---|
1825 | } |
---|
1826 | } |
---|
1827 | |
---|
1828 | // Set picture slice pointer |
---|
1829 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
1830 | |
---|
1831 | m_pcPic->getPicSym()->initTiles(pcSlice->getPPS()); |
---|
1832 | m_pcPic->getPicSym()->initCtuTsRsAddrMaps(); |
---|
1833 | |
---|
1834 | // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. |
---|
1835 | // Now, having set up the maps, convert them to the correct form. |
---|
1836 | pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); |
---|
1837 | pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); |
---|
1838 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
1839 | { |
---|
1840 | pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); |
---|
1841 | pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); |
---|
1842 | } |
---|
1843 | |
---|
1844 | if (m_bFirstSliceInPicture) |
---|
1845 | { |
---|
1846 | if(m_pcPic->getNumAllocatedSlice() != 1) |
---|
1847 | { |
---|
1848 | m_pcPic->clearSliceBuffer(); |
---|
1849 | } |
---|
1850 | } |
---|
1851 | else |
---|
1852 | { |
---|
1853 | m_pcPic->allocateNewSlice(); |
---|
1854 | } |
---|
1855 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
1856 | m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1857 | m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
1858 | |
---|
1859 | m_pcPic->setTLayer(nalu.m_temporalId); |
---|
1860 | |
---|
1861 | #if SVC_EXTENSION |
---|
1862 | m_pcPic->setLayerId(nalu.m_layerId); |
---|
1863 | pcSlice->setLayerId(nalu.m_layerId); |
---|
1864 | pcSlice->setPic(m_pcPic); |
---|
1865 | #endif |
---|
1866 | |
---|
1867 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
1868 | { |
---|
1869 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
1870 | // Set reference list |
---|
1871 | #if SVC_EXTENSION |
---|
1872 | if (m_layerId == 0) |
---|
1873 | #endif |
---|
1874 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
1875 | |
---|
1876 | #if SVC_EXTENSION |
---|
1877 | // Create upsampling reference layer pictures for all possible dependent layers and do it only once for the first slice. |
---|
1878 | // Other slices might choose which reference pictures to be used for inter-layer prediction |
---|
1879 | if( m_layerId > 0 && m_uiSliceIdx == 0 ) |
---|
1880 | { |
---|
1881 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1882 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
---|
1883 | #endif |
---|
1884 | for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1885 | { |
---|
1886 | UInt refLayerIdc = i; |
---|
1887 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc); |
---|
1888 | #if AVC_BASE |
---|
1889 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
1890 | if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() ) |
---|
1891 | #else |
---|
1892 | if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
1893 | #endif |
---|
1894 | { |
---|
1895 | TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); |
---|
1896 | |
---|
1897 | if( pic ) |
---|
1898 | { |
---|
1899 | pcSlice->setBaseColPic ( refLayerIdc, pic ); |
---|
1900 | } |
---|
1901 | else |
---|
1902 | { |
---|
1903 | continue; |
---|
1904 | } |
---|
1905 | } |
---|
1906 | else |
---|
1907 | { |
---|
1908 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1909 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1910 | #else |
---|
1911 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1912 | #endif |
---|
1913 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1914 | if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) ) |
---|
1915 | { |
---|
1916 | continue; |
---|
1917 | } |
---|
1918 | } |
---|
1919 | #else |
---|
1920 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1921 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1922 | #else |
---|
1923 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1924 | #endif |
---|
1925 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1926 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1927 | #endif |
---|
1928 | |
---|
1929 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
1930 | #if O0098_SCALED_REF_LAYER_ID |
---|
1931 | const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
1932 | #else |
---|
1933 | const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
1934 | #endif |
---|
1935 | #else |
---|
1936 | #if O0098_SCALED_REF_LAYER_ID |
---|
1937 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
1938 | #else |
---|
1939 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
1940 | #endif |
---|
1941 | #endif |
---|
1942 | |
---|
1943 | #if REF_REGION_OFFSET |
---|
1944 | const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); |
---|
1945 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); |
---|
1946 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); |
---|
1947 | #else |
---|
1948 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y); |
---|
1949 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y); |
---|
1950 | #if Q0200_CONFORMANCE_BL_SIZE |
---|
1951 | Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc(); |
---|
1952 | const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow(); |
---|
1953 | widthBL -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
1954 | heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
1955 | #endif |
---|
1956 | #endif |
---|
1957 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
1958 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
1959 | |
---|
1960 | #if RESAMPLING_FIX |
---|
1961 | #if REF_REGION_OFFSET |
---|
1962 | // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0 |
---|
1963 | assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0); |
---|
1964 | |
---|
1965 | // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY |
---|
1966 | assert(widthEL >= widthBL && heightEL >= heightBL); |
---|
1967 | |
---|
1968 | #if R0209_GENERIC_PHASE |
---|
1969 | // 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. |
---|
1970 | Int phaseHorLuma = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc); |
---|
1971 | Int phaseVerLuma = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc); |
---|
1972 | Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc); |
---|
1973 | Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc); |
---|
1974 | assert( ( (widthEL != widthBL) || (phaseHorLuma == 0 && phaseHorChroma == 0) ) |
---|
1975 | && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) ); |
---|
1976 | #endif |
---|
1977 | #endif |
---|
1978 | #endif |
---|
1979 | |
---|
1980 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
1981 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
1982 | |
---|
1983 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
1984 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
1985 | |
---|
1986 | #if Q0048_CGS_3D_ASYMLUT |
---|
1987 | TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); |
---|
1988 | if( pcSlice->getPPS()->getCGSFlag() |
---|
1989 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
1990 | && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ) |
---|
1991 | #endif |
---|
1992 | ) |
---|
1993 | { |
---|
1994 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
1995 | assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() ); |
---|
1996 | assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() ); |
---|
1997 | assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() ); |
---|
1998 | assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() ); |
---|
1999 | #endif |
---|
2000 | if(!m_pColorMappedPic) |
---|
2001 | { |
---|
2002 | initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)); |
---|
2003 | } |
---|
2004 | m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pColorMappedPic ); |
---|
2005 | pBaseColRec = m_pColorMappedPic; |
---|
2006 | } |
---|
2007 | #endif |
---|
2008 | #if SVC_EXTENSION |
---|
2009 | if( m_pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
2010 | { |
---|
2011 | // check for the sample prediction picture type |
---|
2012 | if( m_ppcTDecTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) ) |
---|
2013 | { |
---|
2014 | #if O0215_PHASE_ALIGNMENT |
---|
2015 | #if O0194_JOINT_US_BITSHIFT |
---|
2016 | #if Q0048_CGS_3D_ASYMLUT |
---|
2017 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
2018 | #else |
---|
2019 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
2020 | #endif |
---|
2021 | #else |
---|
2022 | #if Q0048_CGS_3D_ASYMLUT |
---|
2023 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
2024 | m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
2025 | #else |
---|
2026 | m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
2027 | #endif |
---|
2028 | #else |
---|
2029 | m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
2030 | #endif |
---|
2031 | #endif |
---|
2032 | #else |
---|
2033 | #if O0194_JOINT_US_BITSHIFT |
---|
2034 | #if Q0048_CGS_3D_ASYMLUT |
---|
2035 | #if REF_REGION_OFFSET |
---|
2036 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL, altRL ); |
---|
2037 | #else |
---|
2038 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); |
---|
2039 | #endif |
---|
2040 | #else |
---|
2041 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); |
---|
2042 | #endif |
---|
2043 | #else |
---|
2044 | #if Q0048_CGS_3D_ASYMLUT |
---|
2045 | m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); |
---|
2046 | #else |
---|
2047 | m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); |
---|
2048 | #endif |
---|
2049 | #endif |
---|
2050 | #endif |
---|
2051 | } |
---|
2052 | } |
---|
2053 | else |
---|
2054 | { |
---|
2055 | m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
2056 | } |
---|
2057 | pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
2058 | #endif //SVC_EXTENSION |
---|
2059 | } |
---|
2060 | } |
---|
2061 | |
---|
2062 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
2063 | { |
---|
2064 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
2065 | { |
---|
2066 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
2067 | #if AVC_BASE |
---|
2068 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2069 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() ) |
---|
2070 | #else |
---|
2071 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
2072 | #endif |
---|
2073 | { |
---|
2074 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
2075 | } |
---|
2076 | else |
---|
2077 | { |
---|
2078 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2079 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
2080 | #else |
---|
2081 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
2082 | #endif |
---|
2083 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
2084 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
2085 | } |
---|
2086 | #else |
---|
2087 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2088 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
2089 | #else |
---|
2090 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
2091 | #endif |
---|
2092 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
2093 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
2094 | #endif |
---|
2095 | |
---|
2096 | pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
2097 | } |
---|
2098 | |
---|
2099 | pcSlice->setILRPic( m_cIlpPic ); |
---|
2100 | |
---|
2101 | #if REF_IDX_MFM |
---|
2102 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
2103 | } |
---|
2104 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2105 | else if ( m_layerId > 0 ) |
---|
2106 | { |
---|
2107 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
2108 | } |
---|
2109 | #endif |
---|
2110 | #if MFM_ENCCONSTRAINT |
---|
2111 | if( pcSlice->getMFMEnabledFlag() ) |
---|
2112 | { |
---|
2113 | TComPic* refPic = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() ); |
---|
2114 | |
---|
2115 | assert( refPic ); |
---|
2116 | |
---|
2117 | Int refLayerId = refPic->getLayerId(); |
---|
2118 | |
---|
2119 | if( refLayerId != pcSlice->getLayerId() ) |
---|
2120 | { |
---|
2121 | TComPic* pColBasePic = pcSlice->getBaseColPic( *m_ppcTDecTop[refLayerId]->getListPic() ); |
---|
2122 | assert( pColBasePic->checkSameRefInfo() == true ); |
---|
2123 | } |
---|
2124 | } |
---|
2125 | #endif |
---|
2126 | #endif |
---|
2127 | |
---|
2128 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
2129 | { |
---|
2130 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2131 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
---|
2132 | #endif |
---|
2133 | for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
2134 | { |
---|
2135 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
2136 | TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); |
---|
2137 | if(refpicLayer && pcSlice->isIRAP()) |
---|
2138 | { |
---|
2139 | assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType()); |
---|
2140 | } |
---|
2141 | } |
---|
2142 | } |
---|
2143 | |
---|
2144 | if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) |
---|
2145 | { |
---|
2146 | TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx()); |
---|
2147 | |
---|
2148 | assert( refPic ); |
---|
2149 | #if R0226_SLICE_TMVP |
---|
2150 | assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true ); |
---|
2151 | #endif |
---|
2152 | |
---|
2153 | // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, |
---|
2154 | // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture. |
---|
2155 | if( refPic->isILR(pcSlice->getLayerId()) ) |
---|
2156 | { |
---|
2157 | assert( m_ppcTDecTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) ); |
---|
2158 | } |
---|
2159 | } |
---|
2160 | #endif //SVC_EXTENSION |
---|
2161 | |
---|
2162 | // For generalized B |
---|
2163 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
2164 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
2165 | { |
---|
2166 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
2167 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
2168 | |
---|
2169 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
2170 | { |
---|
2171 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
2172 | } |
---|
2173 | } |
---|
2174 | if (!pcSlice->isIntra()) |
---|
2175 | { |
---|
2176 | Bool bLowDelay = true; |
---|
2177 | Int iCurrPOC = pcSlice->getPOC(); |
---|
2178 | Int iRefIdx = 0; |
---|
2179 | |
---|
2180 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
2181 | { |
---|
2182 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
2183 | { |
---|
2184 | bLowDelay = false; |
---|
2185 | } |
---|
2186 | } |
---|
2187 | if (pcSlice->isInterB()) |
---|
2188 | { |
---|
2189 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
2190 | { |
---|
2191 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
2192 | { |
---|
2193 | bLowDelay = false; |
---|
2194 | } |
---|
2195 | } |
---|
2196 | } |
---|
2197 | |
---|
2198 | pcSlice->setCheckLDC(bLowDelay); |
---|
2199 | } |
---|
2200 | |
---|
2201 | //--------------- |
---|
2202 | pcSlice->setRefPOCList(); |
---|
2203 | } |
---|
2204 | |
---|
2205 | m_pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
2206 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
2207 | { |
---|
2208 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
2209 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
2210 | { |
---|
2211 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
2212 | } |
---|
2213 | #if SCALINGLIST_INFERRING |
---|
2214 | if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) ) |
---|
2215 | #endif |
---|
2216 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
2217 | { |
---|
2218 | pcSlice->setDefaultScalingList(); |
---|
2219 | } |
---|
2220 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc()); |
---|
2221 | m_cTrQuant.setUseScalingList(true); |
---|
2222 | } |
---|
2223 | else |
---|
2224 | { |
---|
2225 | m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc()); |
---|
2226 | m_cTrQuant.setUseScalingList(false); |
---|
2227 | } |
---|
2228 | |
---|
2229 | // Decode a picture |
---|
2230 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic); |
---|
2231 | |
---|
2232 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2233 | setFirstPicInLayerDecodedFlag(true); |
---|
2234 | #endif |
---|
2235 | |
---|
2236 | m_bFirstSliceInPicture = false; |
---|
2237 | m_uiSliceIdx++; |
---|
2238 | |
---|
2239 | return false; |
---|
2240 | } |
---|
2241 | |
---|
2242 | Void TDecTop::xDecodeVPS() |
---|
2243 | { |
---|
2244 | TComVPS* vps = new TComVPS(); |
---|
2245 | |
---|
2246 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
2247 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
2248 | } |
---|
2249 | |
---|
2250 | #if SVC_EXTENSION |
---|
2251 | Void TDecTop::xDecodeSPS() |
---|
2252 | { |
---|
2253 | TComSPS* sps = new TComSPS(); |
---|
2254 | #if O0043_BEST_EFFORT_DECODING |
---|
2255 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
2256 | #endif |
---|
2257 | sps->setLayerId(m_layerId); |
---|
2258 | #if SPS_DPB_PARAMS |
---|
2259 | m_cEntropyDecoder.decodeSPS( sps ); // it should be removed after macro clean up |
---|
2260 | #else |
---|
2261 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder ); |
---|
2262 | #endif |
---|
2263 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
2264 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
---|
2265 | if(m_numLayer>0) |
---|
2266 | { |
---|
2267 | xInitILRP(sps); |
---|
2268 | } |
---|
2269 | #endif |
---|
2270 | } |
---|
2271 | |
---|
2272 | Void TDecTop::xDecodePPS( |
---|
2273 | #if Q0048_CGS_3D_ASYMLUT |
---|
2274 | TCom3DAsymLUT * pc3DAsymLUT |
---|
2275 | #endif |
---|
2276 | ) |
---|
2277 | { |
---|
2278 | TComPPS* pps = new TComPPS(); |
---|
2279 | |
---|
2280 | #if SCALINGLIST_INFERRING |
---|
2281 | pps->setLayerId( m_layerId ); |
---|
2282 | #endif |
---|
2283 | |
---|
2284 | m_cEntropyDecoder.decodePPS( pps |
---|
2285 | #if Q0048_CGS_3D_ASYMLUT |
---|
2286 | , pc3DAsymLUT , m_layerId |
---|
2287 | #endif |
---|
2288 | ); |
---|
2289 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
2290 | } |
---|
2291 | #else |
---|
2292 | Void TDecTop::xDecodeSPS() |
---|
2293 | { |
---|
2294 | TComSPS* sps = new TComSPS(); |
---|
2295 | #if O0043_BEST_EFFORT_DECODING |
---|
2296 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
2297 | #endif |
---|
2298 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
2299 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
2300 | } |
---|
2301 | |
---|
2302 | Void TDecTop::xDecodePPS() |
---|
2303 | { |
---|
2304 | TComPPS* pps = new TComPPS(); |
---|
2305 | m_cEntropyDecoder.decodePPS( pps ); |
---|
2306 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
2307 | } |
---|
2308 | #endif //SVC_EXTENSION |
---|
2309 | |
---|
2310 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
2311 | { |
---|
2312 | #if SVC_EXTENSION |
---|
2313 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
2314 | { |
---|
2315 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
2316 | { |
---|
2317 | return; |
---|
2318 | } |
---|
2319 | #if LAYERS_NOT_PRESENT_SEI |
---|
2320 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2321 | #else |
---|
2322 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2323 | #endif |
---|
2324 | } |
---|
2325 | else |
---|
2326 | { |
---|
2327 | #if LAYERS_NOT_PRESENT_SEI |
---|
2328 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2329 | #else |
---|
2330 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2331 | #endif |
---|
2332 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
2333 | if (activeParamSets.size()>0) |
---|
2334 | { |
---|
2335 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
2336 | #if !R0247_SEI_ACTIVE |
---|
2337 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
2338 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
2339 | if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) |
---|
2340 | { |
---|
2341 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
2342 | } |
---|
2343 | #else |
---|
2344 | getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
2345 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
2346 | if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) |
---|
2347 | { |
---|
2348 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
2349 | } |
---|
2350 | for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++) |
---|
2351 | { |
---|
2352 | Int layerIdx = seiAps->layerSpsIdx[c]; |
---|
2353 | getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
2354 | if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) ) |
---|
2355 | { |
---|
2356 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
2357 | } |
---|
2358 | } |
---|
2359 | #endif |
---|
2360 | } |
---|
2361 | } |
---|
2362 | #else |
---|
2363 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
2364 | { |
---|
2365 | #if LAYERS_NOT_PRESENT_SEI |
---|
2366 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2367 | #else |
---|
2368 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2369 | |
---|
2370 | #endif |
---|
2371 | } |
---|
2372 | else |
---|
2373 | { |
---|
2374 | #if LAYERS_NOT_PRESENT_SEI |
---|
2375 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2376 | #else |
---|
2377 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
2378 | #endif |
---|
2379 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
2380 | if (activeParamSets.size()>0) |
---|
2381 | { |
---|
2382 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
2383 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
2384 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
2385 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] )) |
---|
2386 | { |
---|
2387 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
2388 | } |
---|
2389 | } |
---|
2390 | } |
---|
2391 | #endif |
---|
2392 | } |
---|
2393 | |
---|
2394 | #if SVC_EXTENSION |
---|
2395 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
2396 | #else |
---|
2397 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
2398 | #endif |
---|
2399 | { |
---|
2400 | // Initialize entropy decoder |
---|
2401 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
2402 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
2403 | |
---|
2404 | #if O0137_MAX_LAYERID |
---|
2405 | // ignore any NAL units with nuh_layer_id == 63 |
---|
2406 | if (nalu.m_layerId == 63 ) |
---|
2407 | { |
---|
2408 | return false; |
---|
2409 | } |
---|
2410 | #endif |
---|
2411 | switch (nalu.m_nalUnitType) |
---|
2412 | { |
---|
2413 | case NAL_UNIT_VPS: |
---|
2414 | #if SVC_EXTENSION |
---|
2415 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
2416 | #endif |
---|
2417 | xDecodeVPS(); |
---|
2418 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2419 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
2420 | #endif |
---|
2421 | #if Q0177_EOS_CHECKS |
---|
2422 | m_isLastNALWasEos = false; |
---|
2423 | #endif |
---|
2424 | #if AVC_BASE |
---|
2425 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2426 | if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() ) |
---|
2427 | #else |
---|
2428 | if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
2429 | #endif |
---|
2430 | { |
---|
2431 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
2432 | { |
---|
2433 | printf( "Base layer YUV input reading error\n" ); |
---|
2434 | exit(EXIT_FAILURE); |
---|
2435 | } |
---|
2436 | } |
---|
2437 | else |
---|
2438 | { |
---|
2439 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
2440 | cListPic->clear(); |
---|
2441 | } |
---|
2442 | #endif |
---|
2443 | return false; |
---|
2444 | |
---|
2445 | case NAL_UNIT_SPS: |
---|
2446 | xDecodeSPS(); |
---|
2447 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2448 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
2449 | #endif |
---|
2450 | return false; |
---|
2451 | |
---|
2452 | case NAL_UNIT_PPS: |
---|
2453 | xDecodePPS( |
---|
2454 | #if Q0048_CGS_3D_ASYMLUT |
---|
2455 | &m_c3DAsymLUTPPS |
---|
2456 | #endif |
---|
2457 | ); |
---|
2458 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2459 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); |
---|
2460 | #endif |
---|
2461 | return false; |
---|
2462 | |
---|
2463 | case NAL_UNIT_PREFIX_SEI: |
---|
2464 | case NAL_UNIT_SUFFIX_SEI: |
---|
2465 | #if Q0177_EOS_CHECKS |
---|
2466 | if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI ) |
---|
2467 | { |
---|
2468 | assert( m_isLastNALWasEos == false ); |
---|
2469 | } |
---|
2470 | #endif |
---|
2471 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
2472 | return false; |
---|
2473 | |
---|
2474 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2475 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2476 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2477 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2478 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2479 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2480 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2481 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2482 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2483 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2484 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2485 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2486 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2487 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2488 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2489 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2490 | #if Q0177_EOS_CHECKS |
---|
2491 | if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
2492 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
2493 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
2494 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
2495 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ) |
---|
2496 | { |
---|
2497 | assert( m_isLastNALWasEos == false ); |
---|
2498 | } |
---|
2499 | else |
---|
2500 | { |
---|
2501 | m_isLastNALWasEos = false; |
---|
2502 | } |
---|
2503 | #endif |
---|
2504 | #if SVC_EXTENSION |
---|
2505 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
2506 | #else |
---|
2507 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
2508 | #endif |
---|
2509 | break; |
---|
2510 | |
---|
2511 | case NAL_UNIT_EOS: |
---|
2512 | #if Q0177_EOS_CHECKS |
---|
2513 | assert( m_isLastNALWasEos == false ); |
---|
2514 | //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything. |
---|
2515 | if (nalu.m_layerId > 0) |
---|
2516 | { |
---|
2517 | printf( "\nThis bitstream has EOS with non-zero layer id.\n" ); |
---|
2518 | return false; |
---|
2519 | } |
---|
2520 | m_isLastNALWasEos = true; |
---|
2521 | #endif |
---|
2522 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
2523 | m_pocCRA = 0; |
---|
2524 | m_pocRandomAccess = MAX_INT; |
---|
2525 | m_prevPOC = MAX_INT; |
---|
2526 | m_prevSliceSkipped = false; |
---|
2527 | m_skippedPOC = 0; |
---|
2528 | return false; |
---|
2529 | |
---|
2530 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
2531 | // TODO: process AU delimiter |
---|
2532 | return false; |
---|
2533 | |
---|
2534 | case NAL_UNIT_EOB: |
---|
2535 | #if P0130_EOB |
---|
2536 | //Check layer id of the nalu. if it is not 0, give a warning message. |
---|
2537 | if (nalu.m_layerId > 0) |
---|
2538 | { |
---|
2539 | printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" ); |
---|
2540 | } |
---|
2541 | #endif |
---|
2542 | return false; |
---|
2543 | |
---|
2544 | case NAL_UNIT_FILLER_DATA: |
---|
2545 | #if Q0177_EOS_CHECKS |
---|
2546 | assert( m_isLastNALWasEos == false ); |
---|
2547 | #endif |
---|
2548 | return false; |
---|
2549 | |
---|
2550 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
2551 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
2552 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
2553 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
2554 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
2555 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
2556 | |
---|
2557 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
2558 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
2559 | |
---|
2560 | case NAL_UNIT_RESERVED_VCL24: |
---|
2561 | case NAL_UNIT_RESERVED_VCL25: |
---|
2562 | case NAL_UNIT_RESERVED_VCL26: |
---|
2563 | case NAL_UNIT_RESERVED_VCL27: |
---|
2564 | case NAL_UNIT_RESERVED_VCL28: |
---|
2565 | case NAL_UNIT_RESERVED_VCL29: |
---|
2566 | case NAL_UNIT_RESERVED_VCL30: |
---|
2567 | case NAL_UNIT_RESERVED_VCL31: |
---|
2568 | |
---|
2569 | case NAL_UNIT_RESERVED_NVCL41: |
---|
2570 | case NAL_UNIT_RESERVED_NVCL42: |
---|
2571 | case NAL_UNIT_RESERVED_NVCL43: |
---|
2572 | case NAL_UNIT_RESERVED_NVCL44: |
---|
2573 | case NAL_UNIT_RESERVED_NVCL45: |
---|
2574 | case NAL_UNIT_RESERVED_NVCL46: |
---|
2575 | case NAL_UNIT_RESERVED_NVCL47: |
---|
2576 | case NAL_UNIT_UNSPECIFIED_48: |
---|
2577 | case NAL_UNIT_UNSPECIFIED_49: |
---|
2578 | case NAL_UNIT_UNSPECIFIED_50: |
---|
2579 | case NAL_UNIT_UNSPECIFIED_51: |
---|
2580 | case NAL_UNIT_UNSPECIFIED_52: |
---|
2581 | case NAL_UNIT_UNSPECIFIED_53: |
---|
2582 | case NAL_UNIT_UNSPECIFIED_54: |
---|
2583 | case NAL_UNIT_UNSPECIFIED_55: |
---|
2584 | case NAL_UNIT_UNSPECIFIED_56: |
---|
2585 | case NAL_UNIT_UNSPECIFIED_57: |
---|
2586 | case NAL_UNIT_UNSPECIFIED_58: |
---|
2587 | case NAL_UNIT_UNSPECIFIED_59: |
---|
2588 | case NAL_UNIT_UNSPECIFIED_60: |
---|
2589 | case NAL_UNIT_UNSPECIFIED_61: |
---|
2590 | case NAL_UNIT_UNSPECIFIED_62: |
---|
2591 | case NAL_UNIT_UNSPECIFIED_63: |
---|
2592 | |
---|
2593 | default: |
---|
2594 | assert (0); |
---|
2595 | break; |
---|
2596 | } |
---|
2597 | |
---|
2598 | return false; |
---|
2599 | } |
---|
2600 | |
---|
2601 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
2602 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2603 | * \returns true if the picture should be skipped |
---|
2604 | * This function skips all TFD pictures that follow a BLA picture |
---|
2605 | * in decoding order and precede it in output order. |
---|
2606 | */ |
---|
2607 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
2608 | { |
---|
2609 | 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) && |
---|
2610 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
2611 | { |
---|
2612 | iPOCLastDisplay++; |
---|
2613 | return true; |
---|
2614 | } |
---|
2615 | return false; |
---|
2616 | } |
---|
2617 | |
---|
2618 | /** Function for checking if picture should be skipped because of random access |
---|
2619 | * \param iSkipFrame skip frame counter |
---|
2620 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2621 | * \returns true if the picture shold be skipped in the random access. |
---|
2622 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
2623 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
2624 | * It also checks the type of Nal unit type at the random access point. |
---|
2625 | * 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. |
---|
2626 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
2627 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
2628 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
2629 | * access point there is no guarantee that the decoder will not crash. |
---|
2630 | */ |
---|
2631 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
2632 | { |
---|
2633 | if (iSkipFrame) |
---|
2634 | { |
---|
2635 | iSkipFrame--; // decrement the counter |
---|
2636 | return true; |
---|
2637 | } |
---|
2638 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
2639 | { |
---|
2640 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
2641 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2642 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
2643 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
2644 | { |
---|
2645 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
2646 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
2647 | } |
---|
2648 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
2649 | { |
---|
2650 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
2651 | } |
---|
2652 | else |
---|
2653 | { |
---|
2654 | static Bool warningMessage = false; |
---|
2655 | if(!warningMessage) |
---|
2656 | { |
---|
2657 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
2658 | warningMessage = true; |
---|
2659 | } |
---|
2660 | return true; |
---|
2661 | } |
---|
2662 | } |
---|
2663 | // skip the reordered pictures, if necessary |
---|
2664 | 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)) |
---|
2665 | { |
---|
2666 | iPOCLastDisplay++; |
---|
2667 | return true; |
---|
2668 | } |
---|
2669 | // if we reach here, then the picture is not skipped. |
---|
2670 | return false; |
---|
2671 | } |
---|
2672 | |
---|
2673 | #if SVC_EXTENSION |
---|
2674 | #if !REPN_FORMAT_IN_VPS |
---|
2675 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
2676 | #else |
---|
2677 | Void TDecTop::xInitILRP(TComSlice *slice) |
---|
2678 | #endif |
---|
2679 | { |
---|
2680 | #if REPN_FORMAT_IN_VPS |
---|
2681 | TComSPS* pcSPS = slice->getSPS(); |
---|
2682 | Int bitDepthY = slice->getBitDepthY(); |
---|
2683 | Int bitDepthC = slice->getBitDepthC(); |
---|
2684 | Int picWidth = slice->getPicWidthInLumaSamples(); |
---|
2685 | Int picHeight = slice->getPicHeightInLumaSamples(); |
---|
2686 | #endif |
---|
2687 | if(m_layerId>0) |
---|
2688 | { |
---|
2689 | #if REPN_FORMAT_IN_VPS |
---|
2690 | g_bitDepth[CHANNEL_TYPE_LUMA] = bitDepthY; |
---|
2691 | g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC; |
---|
2692 | #else |
---|
2693 | g_bitDepth[CHANNEL_TYPE_LUMA] = pcSPS->getBitDepthY(); |
---|
2694 | g_bitDepth[CHANNEL_TYPE_CHROMA] = pcSPS->getBitDepthC(); |
---|
2695 | #endif |
---|
2696 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
2697 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
2698 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
2699 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
2700 | |
---|
2701 | Int numReorderPics[MAX_TLAYER]; |
---|
2702 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
2703 | Window &conformanceWindow = slice->getConformanceWindow(); |
---|
2704 | #else |
---|
2705 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
2706 | #endif |
---|
2707 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
2708 | |
---|
2709 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
2710 | { |
---|
2711 | #if USE_DPB_SIZE_TABLE |
---|
2712 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
2713 | { |
---|
2714 | assert( this->getLayerId() == 0 ); |
---|
2715 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
2716 | } |
---|
2717 | else |
---|
2718 | { |
---|
2719 | TComVPS *vps = slice->getVPS(); |
---|
2720 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
---|
2721 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
---|
2722 | } |
---|
2723 | #else |
---|
2724 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
2725 | #endif |
---|
2726 | } |
---|
2727 | |
---|
2728 | if (m_cIlpPic[0] == NULL) |
---|
2729 | { |
---|
2730 | for (Int j=0; j < m_numDirectRefLayers; j++) |
---|
2731 | { |
---|
2732 | |
---|
2733 | m_cIlpPic[j] = new TComPic; |
---|
2734 | |
---|
2735 | #if AUXILIARY_PICTURES |
---|
2736 | #if REPN_FORMAT_IN_VPS |
---|
2737 | m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
2738 | #else |
---|
2739 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
2740 | #endif |
---|
2741 | #else |
---|
2742 | #if REPN_FORMAT_IN_VPS |
---|
2743 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
2744 | #else |
---|
2745 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
2746 | #endif |
---|
2747 | #endif |
---|
2748 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++) |
---|
2749 | { |
---|
2750 | m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i); |
---|
2751 | } |
---|
2752 | } |
---|
2753 | } |
---|
2754 | } |
---|
2755 | } |
---|
2756 | |
---|
2757 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2758 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
---|
2759 | { |
---|
2760 | TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS(); |
---|
2761 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
2762 | { |
---|
2763 | return (TDecTop *)getLayerDec( 0 ); |
---|
2764 | } |
---|
2765 | |
---|
2766 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
2767 | } |
---|
2768 | #endif |
---|
2769 | |
---|
2770 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2771 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
---|
2772 | { |
---|
2773 | for(UInt layer = 0; layer < m_numLayer; layer++) |
---|
2774 | { |
---|
2775 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
---|
2776 | decTop->setNumSamplePredRefLayers(0); |
---|
2777 | decTop->setNumMotionPredRefLayers(0); |
---|
2778 | decTop->setNumDirectRefLayers(0); |
---|
2779 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
2780 | { |
---|
2781 | decTop->setSamplePredEnabledFlag(i, false); |
---|
2782 | decTop->setMotionPredEnabledFlag(i, false); |
---|
2783 | decTop->setSamplePredRefLayerId(i, 0); |
---|
2784 | decTop->setMotionPredRefLayerId(i, 0); |
---|
2785 | } |
---|
2786 | for(Int j = 0; j < layer; j++) |
---|
2787 | { |
---|
2788 | if (vps->getDirectDependencyFlag(layer, j)) |
---|
2789 | { |
---|
2790 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
---|
2791 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
2792 | |
---|
2793 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
---|
2794 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
---|
2795 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
2796 | |
---|
2797 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
---|
2798 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
---|
2799 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
2800 | } |
---|
2801 | } |
---|
2802 | } |
---|
2803 | for( Int i = 1; i < m_numLayer; i++ ) |
---|
2804 | { |
---|
2805 | Int mIdx = 0, sIdx = 0; |
---|
2806 | Int iNuhLId = vps->getLayerIdInNuh(i); |
---|
2807 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
---|
2808 | for ( Int j = 0; j < i; j++ ) |
---|
2809 | { |
---|
2810 | if (decTop->getMotionPredEnabledFlag(j)) |
---|
2811 | { |
---|
2812 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
---|
2813 | } |
---|
2814 | if (decTop->getSamplePredEnabledFlag(j)) |
---|
2815 | { |
---|
2816 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
---|
2817 | } |
---|
2818 | } |
---|
2819 | } |
---|
2820 | } |
---|
2821 | #endif |
---|
2822 | |
---|
2823 | #if EARLY_REF_PIC_MARKING |
---|
2824 | Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) |
---|
2825 | { |
---|
2826 | UInt currTid = m_pcPic->getTLayer(); |
---|
2827 | UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); |
---|
2828 | UInt latestDecLayerId = m_layerId; |
---|
2829 | UInt numTargetDecLayers = 0; |
---|
2830 | Int targetDecLayerIdList[MAX_LAYERS]; |
---|
2831 | UInt latestDecIdx = 0; |
---|
2832 | TComSlice* pcSlice = m_pcPic->getSlice(0); |
---|
2833 | |
---|
2834 | if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer |
---|
2835 | { |
---|
2836 | return; |
---|
2837 | } |
---|
2838 | |
---|
2839 | // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture |
---|
2840 | if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
2841 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
2842 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
2843 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
2844 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
2845 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || |
---|
2846 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || |
---|
2847 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) |
---|
2848 | { |
---|
2849 | return; |
---|
2850 | } |
---|
2851 | |
---|
2852 | if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers |
---|
2853 | { |
---|
2854 | return; |
---|
2855 | } |
---|
2856 | |
---|
2857 | for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) |
---|
2858 | { |
---|
2859 | if ( latestDecLayerId == (*it) ) |
---|
2860 | { |
---|
2861 | latestDecIdx = numTargetDecLayers; |
---|
2862 | } |
---|
2863 | targetDecLayerIdList[numTargetDecLayers++] = (*it); |
---|
2864 | } |
---|
2865 | |
---|
2866 | Int remainingInterLayerReferencesFlag = 0; |
---|
2867 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
2868 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
2869 | { |
---|
2870 | Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); |
---|
2871 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) |
---|
2872 | { |
---|
2873 | #else |
---|
2874 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) |
---|
2875 | { |
---|
2876 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
2877 | { |
---|
2878 | #endif |
---|
2879 | for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) |
---|
2880 | { |
---|
2881 | if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) |
---|
2882 | { |
---|
2883 | remainingInterLayerReferencesFlag = 1; |
---|
2884 | } |
---|
2885 | } |
---|
2886 | } |
---|
2887 | } |
---|
2888 | |
---|
2889 | if ( remainingInterLayerReferencesFlag == 0 ) |
---|
2890 | { |
---|
2891 | pcSlice->setReferenced(false); |
---|
2892 | } |
---|
2893 | } |
---|
2894 | #endif |
---|
2895 | |
---|
2896 | #if OUTPUT_LAYER_SET_INDEX |
---|
2897 | Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps) |
---|
2898 | { |
---|
2899 | CommonDecoderParams* params = this->getCommonDecoderParams(); |
---|
2900 | |
---|
2901 | assert( params->getTargetLayerId() < vps->getMaxLayers() ); |
---|
2902 | |
---|
2903 | if( params->getValueCheckedFlag() ) |
---|
2904 | { |
---|
2905 | return; // Already checked |
---|
2906 | } |
---|
2907 | if( params->getTargetOutputLayerSetIdx() == -1 ) // Output layer set index not specified |
---|
2908 | { |
---|
2909 | Bool layerSetMatchFound = false; |
---|
2910 | // Output layer set index not assigned. |
---|
2911 | // Based on the value of targetLayerId, check if any of the output layer matches |
---|
2912 | // Currently, the target layer ID in the encoder assumes that all the layers are decoded |
---|
2913 | // Check if any of the output layer sets match this description |
---|
2914 | for(Int i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
2915 | { |
---|
2916 | Bool layerSetMatchFlag = true; |
---|
2917 | Int layerSetIdx = vps->getOutputLayerSetIdx( i ); |
---|
2918 | if( vps->getNumLayersInIdList( layerSetIdx ) == params->getTargetLayerId() + 1 ) |
---|
2919 | { |
---|
2920 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2921 | { |
---|
2922 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
---|
2923 | { |
---|
2924 | layerSetMatchFlag = false; |
---|
2925 | break; |
---|
2926 | } |
---|
2927 | } |
---|
2928 | } |
---|
2929 | else |
---|
2930 | { |
---|
2931 | layerSetMatchFlag = false; |
---|
2932 | } |
---|
2933 | |
---|
2934 | if( layerSetMatchFlag ) // Potential output layer set candidate found |
---|
2935 | { |
---|
2936 | // If target dec layer ID list is also included - check if they match |
---|
2937 | if( params->getTargetDecLayerIdSet() ) |
---|
2938 | { |
---|
2939 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2940 | { |
---|
2941 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2942 | { |
---|
2943 | if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j ))) |
---|
2944 | { |
---|
2945 | layerSetMatchFlag = false; |
---|
2946 | } |
---|
2947 | } |
---|
2948 | } |
---|
2949 | } |
---|
2950 | if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present |
---|
2951 | { |
---|
2952 | // Match found |
---|
2953 | layerSetMatchFound = true; |
---|
2954 | params->setTargetOutputLayerSetIdx( i ); |
---|
2955 | params->setValueCheckedFlag( true ); |
---|
2956 | break; |
---|
2957 | } |
---|
2958 | } |
---|
2959 | } |
---|
2960 | assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist |
---|
2961 | } |
---|
2962 | else // Output layer set index is assigned - check if the values match |
---|
2963 | { |
---|
2964 | // Check if the target decoded layer is the highest layer in the list |
---|
2965 | #if !CONFORMANCE_BITSTREAM_MODE |
---|
2966 | assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() ); |
---|
2967 | #endif |
---|
2968 | Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() ); // Index to the layer set |
---|
2969 | #if !CONFORMANCE_BITSTREAM_MODE |
---|
2970 | assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); |
---|
2971 | #endif |
---|
2972 | |
---|
2973 | Bool layerSetMatchFlag = true; |
---|
2974 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2975 | { |
---|
2976 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
---|
2977 | { |
---|
2978 | layerSetMatchFlag = false; |
---|
2979 | break; |
---|
2980 | } |
---|
2981 | } |
---|
2982 | |
---|
2983 | assert(layerSetMatchFlag); // Signaled output layer set index does not match targetOutputLayerId. |
---|
2984 | |
---|
2985 | // Check if the targetdeclayerIdlist matches the output layer set |
---|
2986 | if( params->getTargetDecLayerIdSet() ) |
---|
2987 | { |
---|
2988 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2989 | { |
---|
2990 | for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++) |
---|
2991 | { |
---|
2992 | assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i ))); |
---|
2993 | } |
---|
2994 | } |
---|
2995 | } |
---|
2996 | params->setValueCheckedFlag( true ); |
---|
2997 | |
---|
2998 | } |
---|
2999 | } |
---|
3000 | #endif |
---|
3001 | #if RESOLUTION_BASED_DPB |
---|
3002 | Void TDecTop::assignSubDpbs(TComVPS *vps) |
---|
3003 | { |
---|
3004 | if( m_subDpbIdx == -1 ) // Sub-DPB index is not already assigned |
---|
3005 | { |
---|
3006 | Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
---|
3007 | |
---|
3008 | Int layerIdx = vps->findLayerIdxInLayerSet( lsIdx, getLayerId() ); |
---|
3009 | assert( layerIdx != -1 ); // Current layer should be found in the layer set. |
---|
3010 | |
---|
3011 | // Copy from the active VPS based on the layer ID. |
---|
3012 | m_subDpbIdx = vps->getSubDpbAssigned( lsIdx, layerIdx ); |
---|
3013 | } |
---|
3014 | } |
---|
3015 | #endif |
---|
3016 | #if POC_RESET_IDC_DECODER |
---|
3017 | Void TDecTop::markAllPicsAsNoCurrAu() |
---|
3018 | { |
---|
3019 | for(Int i = 0; i < MAX_LAYERS; i++) |
---|
3020 | { |
---|
3021 | TComList<TComPic*>* listPic = this->getLayerDec(i)->getListPic(); |
---|
3022 | TComList<TComPic*>::iterator iterPic = listPic->begin(); |
---|
3023 | while ( iterPic != listPic->end() ) |
---|
3024 | { |
---|
3025 | TComPic *pcPic = *(iterPic); |
---|
3026 | pcPic->setCurrAuFlag( false ); |
---|
3027 | iterPic++; |
---|
3028 | } |
---|
3029 | } |
---|
3030 | } |
---|
3031 | #endif |
---|
3032 | #if Q0048_CGS_3D_ASYMLUT |
---|
3033 | Void TDecTop::initAsymLut(TComSlice *pcSlice) |
---|
3034 | { |
---|
3035 | if(m_layerId>0) |
---|
3036 | { |
---|
3037 | if(!m_pColorMappedPic) |
---|
3038 | { |
---|
3039 | Int picWidth = pcSlice->getPicWidthInLumaSamples(); |
---|
3040 | Int picHeight = pcSlice->getPicHeightInLumaSamples(); |
---|
3041 | m_pColorMappedPic = new TComPicYuv; |
---|
3042 | m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); |
---|
3043 | } |
---|
3044 | } |
---|
3045 | } |
---|
3046 | #endif |
---|
3047 | #if POC_RESET_RESTRICTIONS |
---|
3048 | Void TDecTop::resetPocRestrictionCheckParameters() |
---|
3049 | { |
---|
3050 | TDecTop::m_checkPocRestrictionsForCurrAu = false; |
---|
3051 | TDecTop::m_pocResetIdcOrCurrAu = -1; |
---|
3052 | TDecTop::m_baseLayerIdrFlag = false; |
---|
3053 | TDecTop::m_baseLayerPicPresentFlag = false; |
---|
3054 | TDecTop::m_baseLayerIrapFlag = false; |
---|
3055 | TDecTop::m_nonBaseIdrPresentFlag = false; |
---|
3056 | TDecTop::m_nonBaseIdrType = -1; |
---|
3057 | TDecTop::m_picNonIdrWithRadlPresentFlag = false; |
---|
3058 | TDecTop::m_picNonIdrNoLpPresentFlag = false; |
---|
3059 | } |
---|
3060 | #endif |
---|
3061 | #endif //SVC_EXTENSION |
---|
3062 | |
---|
3063 | |
---|
3064 | //! \} |
---|