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