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