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