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