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_pocCRA = 0; |
---|
60 | m_prevRAPisBLA = false; |
---|
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 | #if HM12_RANDOM_ACCESS |
---|
80 | m_prevSliceSkipped = false; |
---|
81 | m_skippedPOC = 0; |
---|
82 | #endif |
---|
83 | } |
---|
84 | |
---|
85 | TDecTop::~TDecTop() |
---|
86 | { |
---|
87 | #if ENC_DEC_TRACE |
---|
88 | fclose( g_hTrace ); |
---|
89 | #endif |
---|
90 | } |
---|
91 | |
---|
92 | Void TDecTop::create() |
---|
93 | { |
---|
94 | #if SVC_EXTENSION |
---|
95 | m_cGopDecoder.create( m_layerId ); |
---|
96 | #else |
---|
97 | m_cGopDecoder.create(); |
---|
98 | #endif |
---|
99 | m_apcSlicePilot = new TComSlice; |
---|
100 | m_uiSliceIdx = 0; |
---|
101 | } |
---|
102 | |
---|
103 | Void TDecTop::destroy() |
---|
104 | { |
---|
105 | m_cGopDecoder.destroy(); |
---|
106 | |
---|
107 | delete m_apcSlicePilot; |
---|
108 | m_apcSlicePilot = NULL; |
---|
109 | |
---|
110 | m_cSliceDecoder.destroy(); |
---|
111 | #if SVC_EXTENSION |
---|
112 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
113 | { |
---|
114 | if(m_cIlpPic[i]) |
---|
115 | { |
---|
116 | m_cIlpPic[i]->destroy(); |
---|
117 | delete m_cIlpPic[i]; |
---|
118 | m_cIlpPic[i] = NULL; |
---|
119 | } |
---|
120 | } |
---|
121 | #endif |
---|
122 | } |
---|
123 | |
---|
124 | Void TDecTop::init() |
---|
125 | { |
---|
126 | #if !SVC_EXTENSION |
---|
127 | // initialize ROM |
---|
128 | initROM(); |
---|
129 | #endif |
---|
130 | #if SVC_EXTENSION |
---|
131 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
132 | m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
133 | #else |
---|
134 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
135 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
136 | #endif |
---|
137 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
138 | } |
---|
139 | |
---|
140 | #if SVC_EXTENSION |
---|
141 | #if !REPN_FORMAT_IN_VPS |
---|
142 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
143 | #else |
---|
144 | Void TDecTop::xInitILRP(TComSlice *slice) |
---|
145 | #endif |
---|
146 | { |
---|
147 | #if REPN_FORMAT_IN_VPS |
---|
148 | TComSPS* pcSPS = slice->getSPS(); |
---|
149 | Int bitDepthY = slice->getBitDepthY(); |
---|
150 | Int bitDepthC = slice->getBitDepthC(); |
---|
151 | Int picWidth = slice->getPicWidthInLumaSamples(); |
---|
152 | Int picHeight = slice->getPicHeightInLumaSamples(); |
---|
153 | #endif |
---|
154 | if(m_layerId>0) |
---|
155 | { |
---|
156 | #if REPN_FORMAT_IN_VPS |
---|
157 | g_bitDepthY = bitDepthY; |
---|
158 | g_bitDepthC = bitDepthC; |
---|
159 | #else |
---|
160 | g_bitDepthY = pcSPS->getBitDepthY(); |
---|
161 | g_bitDepthC = pcSPS->getBitDepthC(); |
---|
162 | #endif |
---|
163 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
164 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
165 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
166 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
167 | |
---|
168 | Int numReorderPics[MAX_TLAYER]; |
---|
169 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
170 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
171 | |
---|
172 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
173 | { |
---|
174 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
175 | } |
---|
176 | |
---|
177 | if (m_cIlpPic[0] == NULL) |
---|
178 | { |
---|
179 | for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
180 | { |
---|
181 | |
---|
182 | m_cIlpPic[j] = new TComPic; |
---|
183 | #if REPN_FORMAT_IN_VPS |
---|
184 | #if SVC_UPSAMPLING |
---|
185 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
186 | #else |
---|
187 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
188 | #endif |
---|
189 | #else |
---|
190 | #if SVC_UPSAMPLING |
---|
191 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
192 | #else |
---|
193 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
194 | #endif |
---|
195 | #endif |
---|
196 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
197 | { |
---|
198 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
199 | } |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | |
---|
206 | |
---|
207 | Void TDecTop::setILRPic(TComPic *pcPic) |
---|
208 | { |
---|
209 | for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) |
---|
210 | { |
---|
211 | Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); |
---|
212 | |
---|
213 | if(m_cIlpPic[refLayerIdc]) |
---|
214 | { |
---|
215 | m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec()); |
---|
216 | m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC()); |
---|
217 | m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId |
---|
218 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); |
---|
219 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
220 | for (Int j=0; j<m_cIlpPic[refLayerIdc]->getPicSym()->getNumberOfCUsInFrame(); j++) // set reference CU layerId |
---|
221 | { |
---|
222 | m_cIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId(m_cIlpPic[refLayerIdc]->getLayerId()); |
---|
223 | } |
---|
224 | } |
---|
225 | } |
---|
226 | } |
---|
227 | #endif |
---|
228 | |
---|
229 | Void TDecTop::deletePicBuffer ( ) |
---|
230 | { |
---|
231 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
232 | Int iSize = Int( m_cListPic.size() ); |
---|
233 | |
---|
234 | for (Int i = 0; i < iSize; i++ ) |
---|
235 | { |
---|
236 | TComPic* pcPic = *(iterPic++); |
---|
237 | #if SVC_EXTENSION |
---|
238 | if( pcPic ) |
---|
239 | { |
---|
240 | pcPic->destroy(); |
---|
241 | |
---|
242 | delete pcPic; |
---|
243 | pcPic = NULL; |
---|
244 | } |
---|
245 | #else |
---|
246 | pcPic->destroy(); |
---|
247 | |
---|
248 | delete pcPic; |
---|
249 | pcPic = NULL; |
---|
250 | #endif |
---|
251 | } |
---|
252 | |
---|
253 | m_cSAO.destroy(); |
---|
254 | |
---|
255 | m_cLoopFilter. destroy(); |
---|
256 | |
---|
257 | #if !SVC_EXTENSION |
---|
258 | // destroy ROM |
---|
259 | destroyROM(); |
---|
260 | #endif |
---|
261 | } |
---|
262 | |
---|
263 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
264 | { |
---|
265 | Int numReorderPics[MAX_TLAYER]; |
---|
266 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
267 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
268 | |
---|
269 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
270 | { |
---|
271 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
272 | } |
---|
273 | |
---|
274 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
275 | |
---|
276 | #if SVC_EXTENSION |
---|
277 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
---|
278 | #endif |
---|
279 | |
---|
280 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
281 | { |
---|
282 | rpcPic = new TComPic(); |
---|
283 | |
---|
284 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
285 | if(m_layerId > 0) |
---|
286 | { |
---|
287 | for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
288 | { |
---|
289 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); |
---|
290 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
291 | |
---|
292 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
293 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
---|
294 | #else |
---|
295 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
296 | #endif |
---|
297 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
298 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
299 | #if REPN_FORMAT_IN_VPS |
---|
300 | if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
301 | #else |
---|
302 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
303 | #endif |
---|
304 | { |
---|
305 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
306 | |
---|
307 | //only for scalable extension |
---|
308 | #if SCALABILITY_MASK_E0104 |
---|
309 | assert( pcSlice->getVPS()->getScalabilityMask(2) == true ); |
---|
310 | #else |
---|
311 | assert( pcSlice->getVPS()->getScalabilityMask(1) == true ); |
---|
312 | #endif |
---|
313 | } |
---|
314 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
315 | #if SCALABILITY_MASK_E0104 |
---|
316 | if(pcSlice->getVPS()->getScalabilityMask(2)) |
---|
317 | #else |
---|
318 | if(pcSlice->getVPS()->getScalabilityMask(1)) |
---|
319 | #endif |
---|
320 | { |
---|
321 | pcSlice->setPic(rpcPic); |
---|
322 | } |
---|
323 | #endif |
---|
324 | } |
---|
325 | } |
---|
326 | #endif |
---|
327 | |
---|
328 | #if REPN_FORMAT_IN_VPS |
---|
329 | #if SVC_UPSAMPLING |
---|
330 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
331 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
332 | #else |
---|
333 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
334 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
335 | #endif |
---|
336 | #else |
---|
337 | #if SVC_UPSAMPLING |
---|
338 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
339 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
340 | #else |
---|
341 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
342 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
343 | #endif |
---|
344 | #endif |
---|
345 | |
---|
346 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
347 | m_cListPic.pushBack( rpcPic ); |
---|
348 | |
---|
349 | return; |
---|
350 | } |
---|
351 | |
---|
352 | Bool bBufferIsAvailable = false; |
---|
353 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
354 | while (iterPic != m_cListPic.end()) |
---|
355 | { |
---|
356 | rpcPic = *(iterPic++); |
---|
357 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
358 | { |
---|
359 | rpcPic->setOutputMark(false); |
---|
360 | bBufferIsAvailable = true; |
---|
361 | break; |
---|
362 | } |
---|
363 | |
---|
364 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
365 | { |
---|
366 | #if !SVC_EXTENSION |
---|
367 | rpcPic->setOutputMark(false); |
---|
368 | #endif |
---|
369 | rpcPic->setReconMark( false ); |
---|
370 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
371 | bBufferIsAvailable = true; |
---|
372 | break; |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | if ( !bBufferIsAvailable ) |
---|
377 | { |
---|
378 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
379 | m_iMaxRefPicNum++; |
---|
380 | rpcPic = new TComPic(); |
---|
381 | m_cListPic.pushBack( rpcPic ); |
---|
382 | } |
---|
383 | rpcPic->destroy(); |
---|
384 | |
---|
385 | #if REPN_FORMAT_IN_VPS |
---|
386 | #if SVC_UPSAMPLING |
---|
387 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
388 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
389 | |
---|
390 | #else |
---|
391 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
392 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
393 | #endif |
---|
394 | #else |
---|
395 | #if SVC_UPSAMPLING |
---|
396 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
397 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
398 | |
---|
399 | #else |
---|
400 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
401 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
402 | #endif |
---|
403 | #endif |
---|
404 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
405 | } |
---|
406 | |
---|
407 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
408 | { |
---|
409 | if (!m_pcPic) |
---|
410 | { |
---|
411 | /* nothing to deblock */ |
---|
412 | return; |
---|
413 | } |
---|
414 | |
---|
415 | TComPic*& pcPic = m_pcPic; |
---|
416 | |
---|
417 | // Execute Deblock + Cleanup |
---|
418 | |
---|
419 | m_cGopDecoder.filterPicture(pcPic); |
---|
420 | |
---|
421 | #if SYNTAX_OUTPUT |
---|
422 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
423 | #endif |
---|
424 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
425 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
426 | rpcListPic = &m_cListPic; |
---|
427 | m_cCuDecoder.destroy(); |
---|
428 | m_bFirstSliceInPicture = true; |
---|
429 | |
---|
430 | return; |
---|
431 | } |
---|
432 | |
---|
433 | #if EARLY_REF_PIC_MARKING |
---|
434 | Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) |
---|
435 | { |
---|
436 | UInt currTid = m_pcPic->getTLayer(); |
---|
437 | UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); |
---|
438 | UInt latestDecLayerId = m_layerId; |
---|
439 | UInt numTargetDecLayers = 0; |
---|
440 | Int targetDecLayerIdList[MAX_LAYERS]; |
---|
441 | UInt latestDecIdx = 0; |
---|
442 | TComSlice* pcSlice = m_pcPic->getSlice(0); |
---|
443 | |
---|
444 | if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer |
---|
445 | { |
---|
446 | return; |
---|
447 | } |
---|
448 | |
---|
449 | // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture |
---|
450 | if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
451 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
452 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
453 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
454 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
455 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || |
---|
456 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || |
---|
457 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) |
---|
458 | { |
---|
459 | return; |
---|
460 | } |
---|
461 | |
---|
462 | if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers |
---|
463 | { |
---|
464 | return; |
---|
465 | } |
---|
466 | |
---|
467 | for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) |
---|
468 | { |
---|
469 | if ( latestDecLayerId == (*it) ) |
---|
470 | { |
---|
471 | latestDecIdx = numTargetDecLayers; |
---|
472 | } |
---|
473 | targetDecLayerIdList[numTargetDecLayers++] = (*it); |
---|
474 | } |
---|
475 | |
---|
476 | Int remainingInterLayerReferencesFlag = 0; |
---|
477 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) |
---|
478 | { |
---|
479 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
480 | { |
---|
481 | for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) |
---|
482 | { |
---|
483 | if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) |
---|
484 | { |
---|
485 | remainingInterLayerReferencesFlag = 1; |
---|
486 | } |
---|
487 | } |
---|
488 | } |
---|
489 | } |
---|
490 | |
---|
491 | if ( remainingInterLayerReferencesFlag == 0 ) |
---|
492 | { |
---|
493 | pcSlice->setReferenced(false); |
---|
494 | } |
---|
495 | } |
---|
496 | #endif |
---|
497 | |
---|
498 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
499 | { |
---|
500 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
501 | TComSlice cFillSlice; |
---|
502 | #if SVC_EXTENSION |
---|
503 | cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
504 | cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
505 | cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
506 | cFillSlice.initSlice( m_layerId ); |
---|
507 | #else |
---|
508 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
509 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
510 | cFillSlice.initSlice(); |
---|
511 | #endif |
---|
512 | TComPic *cFillPic; |
---|
513 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
514 | #if SVC_EXTENSION |
---|
515 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
516 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
517 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
518 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
519 | #else |
---|
520 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
521 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
522 | cFillPic->getSlice(0)->initSlice(); |
---|
523 | #endif |
---|
524 | |
---|
525 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
526 | Int closestPoc = 1000000; |
---|
527 | while ( iterPic != m_cListPic.end()) |
---|
528 | { |
---|
529 | TComPic * rpcPic = *(iterPic++); |
---|
530 | 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()) |
---|
531 | { |
---|
532 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
533 | } |
---|
534 | } |
---|
535 | iterPic = m_cListPic.begin(); |
---|
536 | while ( iterPic != m_cListPic.end()) |
---|
537 | { |
---|
538 | TComPic *rpcPic = *(iterPic++); |
---|
539 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
540 | { |
---|
541 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
542 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
543 | break; |
---|
544 | } |
---|
545 | } |
---|
546 | cFillPic->setCurrSliceIdx(0); |
---|
547 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
548 | { |
---|
549 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
550 | } |
---|
551 | cFillPic->getSlice(0)->setReferenced(true); |
---|
552 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
553 | cFillPic->setReconMark(true); |
---|
554 | cFillPic->setOutputMark(true); |
---|
555 | if(m_pocRandomAccess == MAX_INT) |
---|
556 | { |
---|
557 | m_pocRandomAccess = iLostPoc; |
---|
558 | } |
---|
559 | } |
---|
560 | |
---|
561 | |
---|
562 | Void TDecTop::xActivateParameterSets() |
---|
563 | { |
---|
564 | #if SVC_EXTENSION |
---|
565 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
566 | |
---|
567 | TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId()); |
---|
568 | assert (pps != 0); |
---|
569 | |
---|
570 | TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId()); |
---|
571 | assert (sps != 0); |
---|
572 | |
---|
573 | if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) ) |
---|
574 | #else |
---|
575 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
576 | |
---|
577 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
578 | assert (pps != 0); |
---|
579 | |
---|
580 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
581 | assert (sps != 0); |
---|
582 | |
---|
583 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
584 | #endif |
---|
585 | { |
---|
586 | printf ("Parameter set activation failed!"); |
---|
587 | assert (0); |
---|
588 | } |
---|
589 | |
---|
590 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
591 | { |
---|
592 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
593 | |
---|
594 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
595 | { |
---|
596 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
597 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
598 | { |
---|
599 | TDecSbac* ctx = NULL; |
---|
600 | ctx = new TDecSbac; |
---|
601 | ctx->init( &m_cBinCABAC ); |
---|
602 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
603 | } |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | m_apcSlicePilot->setPPS(pps); |
---|
608 | m_apcSlicePilot->setSPS(sps); |
---|
609 | pps->setSPS(sps); |
---|
610 | #if REPN_FORMAT_IN_VPS |
---|
611 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
612 | #else |
---|
613 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
614 | #endif |
---|
615 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
616 | |
---|
617 | #if REPN_FORMAT_IN_VPS |
---|
618 | g_bitDepthY = m_apcSlicePilot->getBitDepthY(); |
---|
619 | g_bitDepthC = m_apcSlicePilot->getBitDepthC(); |
---|
620 | #else |
---|
621 | g_bitDepthY = sps->getBitDepthY(); |
---|
622 | g_bitDepthC = sps->getBitDepthC(); |
---|
623 | #endif |
---|
624 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
625 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
626 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
627 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
628 | |
---|
629 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
630 | { |
---|
631 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
632 | } |
---|
633 | |
---|
634 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
635 | { |
---|
636 | sps->setAMPAcc( i, 0 ); |
---|
637 | } |
---|
638 | |
---|
639 | m_cSAO.destroy(); |
---|
640 | #if REPN_FORMAT_IN_VPS |
---|
641 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
642 | #else |
---|
643 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
644 | #endif |
---|
645 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
646 | } |
---|
647 | |
---|
648 | #if SVC_EXTENSION |
---|
649 | #if POC_RESET_FLAG |
---|
650 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
651 | #else |
---|
652 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
653 | #endif |
---|
654 | #else |
---|
655 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
656 | #endif |
---|
657 | { |
---|
658 | TComPic*& pcPic = m_pcPic; |
---|
659 | #if SVC_EXTENSION |
---|
660 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); |
---|
661 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
662 | #else |
---|
663 | m_apcSlicePilot->initSlice(); |
---|
664 | #endif |
---|
665 | |
---|
666 | if (m_bFirstSliceInPicture) |
---|
667 | { |
---|
668 | m_uiSliceIdx = 0; |
---|
669 | } |
---|
670 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
671 | if (!m_bFirstSliceInPicture) |
---|
672 | { |
---|
673 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
674 | } |
---|
675 | |
---|
676 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
677 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
678 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
679 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
680 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
681 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
682 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
683 | |
---|
684 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
685 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
686 | |
---|
687 | #if SVC_EXTENSION |
---|
688 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
689 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
---|
690 | #endif |
---|
691 | #if M0457_COL_PICTURE_SIGNALING |
---|
692 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
693 | #endif |
---|
694 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
695 | m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() ); |
---|
696 | #endif |
---|
697 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); |
---|
698 | #else |
---|
699 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
700 | #endif |
---|
701 | |
---|
702 | #if HM12_RANDOM_ACCESS |
---|
703 | // set POC for dependent slices in skipped pictures |
---|
704 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
705 | { |
---|
706 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
707 | } |
---|
708 | #endif |
---|
709 | |
---|
710 | // Skip pictures due to random access |
---|
711 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
712 | { |
---|
713 | #if HM12_RANDOM_ACCESS |
---|
714 | m_prevSliceSkipped = true; |
---|
715 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
716 | #endif |
---|
717 | return false; |
---|
718 | } |
---|
719 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
720 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
721 | { |
---|
722 | #if HM12_RANDOM_ACCESS |
---|
723 | m_prevSliceSkipped = true; |
---|
724 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
725 | #endif |
---|
726 | return false; |
---|
727 | } |
---|
728 | |
---|
729 | #if HM12_RANDOM_ACCESS |
---|
730 | // clear previous slice skipped flag |
---|
731 | m_prevSliceSkipped = false; |
---|
732 | #endif |
---|
733 | |
---|
734 | // exit when a new picture is found |
---|
735 | #if SVC_EXTENSION |
---|
736 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
737 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
738 | { |
---|
739 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
740 | curLayerId = m_uiPrevLayerId; |
---|
741 | m_uiPrevLayerId = m_layerId; |
---|
742 | return true; |
---|
743 | } |
---|
744 | #else |
---|
745 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
746 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
747 | { |
---|
748 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
749 | } |
---|
750 | // exit when a new picture is found |
---|
751 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
752 | { |
---|
753 | if (m_prevPOC >= m_pocRandomAccess) |
---|
754 | { |
---|
755 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
756 | return true; |
---|
757 | } |
---|
758 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
759 | } |
---|
760 | #endif |
---|
761 | // actual decoding starts here |
---|
762 | xActivateParameterSets(); |
---|
763 | #if 0 // N0147_IRAP_ALIGN_FLAG Disabled for now! |
---|
764 | //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 |
---|
765 | if( m_layerId > 0 && m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag()) |
---|
766 | assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0); |
---|
767 | //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 |
---|
768 | // to be added after poc_reset_flag is integrated. |
---|
769 | #endif |
---|
770 | |
---|
771 | #if REPN_FORMAT_IN_VPS |
---|
772 | // Initialize ILRP if needed, only for the current layer |
---|
773 | // ILRP intialization should go along with activation of parameters sets, |
---|
774 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
775 | xInitILRP(m_apcSlicePilot); |
---|
776 | #endif |
---|
777 | if (m_apcSlicePilot->isNextSlice()) |
---|
778 | { |
---|
779 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
780 | #if SVC_EXTENSION |
---|
781 | curLayerId = m_layerId; |
---|
782 | m_uiPrevLayerId = m_layerId; |
---|
783 | #endif |
---|
784 | } |
---|
785 | m_bFirstSliceInSequence = false; |
---|
786 | #if POC_RESET_FLAG |
---|
787 | // This operation would do the following: |
---|
788 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
789 | // 2. Update the value of m_pocCRA. |
---|
790 | // 3. Reset the POC values at the decoder for the current picture to be zero. |
---|
791 | // 4. update value of POCLastDisplay |
---|
792 | if( m_apcSlicePilot->getPocResetFlag() ) |
---|
793 | { |
---|
794 | if( m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
795 | { |
---|
796 | Int pocAdjustValue = m_apcSlicePilot->getPOC(); |
---|
797 | |
---|
798 | // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre |
---|
799 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
800 | |
---|
801 | // Iterate through all picture in DPB |
---|
802 | while( iterPic != m_cListPic.end() ) |
---|
803 | { |
---|
804 | TComPic *dpbPic = *iterPic; |
---|
805 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
806 | // needed for output, are in the same layer, and not the current picture. |
---|
807 | if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
---|
808 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
---|
809 | && ( dpbPic->getReconMark() ) |
---|
810 | ) |
---|
811 | { |
---|
812 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
813 | { |
---|
814 | |
---|
815 | TComSlice *slice = dpbPic->getSlice(i); |
---|
816 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
817 | slice->setPOC( slice->getPOC() - pocAdjustValue ); |
---|
818 | |
---|
819 | // Also adjust the POC value stored in the RPS of each such slice |
---|
820 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
821 | { |
---|
822 | rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); |
---|
823 | } |
---|
824 | // Also adjust the value of refPOC |
---|
825 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
826 | { |
---|
827 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
828 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
829 | { |
---|
830 | slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); |
---|
831 | } |
---|
832 | } |
---|
833 | } |
---|
834 | } |
---|
835 | iterPic++; |
---|
836 | } |
---|
837 | // Update the value of pocCRA |
---|
838 | m_pocCRA -= pocAdjustValue; |
---|
839 | // Update value of POCLastDisplay |
---|
840 | iPOCLastDisplay -= pocAdjustValue; |
---|
841 | } |
---|
842 | // Reset current poc for current slice and RPS |
---|
843 | m_apcSlicePilot->setPOC( 0 ); |
---|
844 | } |
---|
845 | #endif |
---|
846 | //detect lost reference picture and insert copy of earlier frame. |
---|
847 | Int lostPoc; |
---|
848 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
849 | { |
---|
850 | xCreateLostPicture(lostPoc-1); |
---|
851 | } |
---|
852 | if (m_bFirstSliceInPicture) |
---|
853 | { |
---|
854 | #if AVC_BASE |
---|
855 | if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
856 | { |
---|
857 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
858 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
859 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
860 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
861 | |
---|
862 | if( pFile->good() ) |
---|
863 | { |
---|
864 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
865 | |
---|
866 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
867 | |
---|
868 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
869 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
870 | for( Int i = 0; i < uiHeight; i++ ) |
---|
871 | { |
---|
872 | for( Int j = 0; j < uiWidth; j++ ) |
---|
873 | { |
---|
874 | pPel[j] = pFile->get(); |
---|
875 | } |
---|
876 | pPel += uiStride; |
---|
877 | } |
---|
878 | |
---|
879 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
880 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
881 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
882 | { |
---|
883 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
884 | { |
---|
885 | pPel[j] = pFile->get(); |
---|
886 | } |
---|
887 | pPel += uiStride; |
---|
888 | } |
---|
889 | |
---|
890 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
891 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
892 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
893 | { |
---|
894 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
895 | { |
---|
896 | pPel[j] = pFile->get(); |
---|
897 | } |
---|
898 | pPel += uiStride; |
---|
899 | } |
---|
900 | } |
---|
901 | } |
---|
902 | #endif |
---|
903 | |
---|
904 | // Buffer initialize for prediction. |
---|
905 | m_cPrediction.initTempBuff(); |
---|
906 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
907 | // Get a new picture buffer |
---|
908 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
909 | |
---|
910 | // transfer any SEI messages that have been received to the picture |
---|
911 | pcPic->setSEIs(m_SEIs); |
---|
912 | m_SEIs.clear(); |
---|
913 | |
---|
914 | // Recursive structure |
---|
915 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
916 | #if SVC_EXTENSION |
---|
917 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
918 | #else |
---|
919 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
920 | #endif |
---|
921 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
922 | |
---|
923 | m_cSliceDecoder.create(); |
---|
924 | } |
---|
925 | else |
---|
926 | { |
---|
927 | // Check if any new SEI has arrived |
---|
928 | if(!m_SEIs.empty()) |
---|
929 | { |
---|
930 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
931 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
932 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
933 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
934 | deleteSEIs(m_SEIs); |
---|
935 | } |
---|
936 | } |
---|
937 | |
---|
938 | // Set picture slice pointer |
---|
939 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
940 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
941 | |
---|
942 | UInt uiCummulativeTileWidth; |
---|
943 | UInt uiCummulativeTileHeight; |
---|
944 | UInt i, j, p; |
---|
945 | |
---|
946 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
947 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
948 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
949 | |
---|
950 | //create the TComTileArray |
---|
951 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
952 | |
---|
953 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
954 | { |
---|
955 | //set the width for each tile |
---|
956 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
957 | { |
---|
958 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
959 | { |
---|
960 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
961 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
962 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
963 | } |
---|
964 | } |
---|
965 | |
---|
966 | //set the height for each tile |
---|
967 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
968 | { |
---|
969 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
970 | { |
---|
971 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
972 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
973 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
974 | } |
---|
975 | } |
---|
976 | } |
---|
977 | else |
---|
978 | { |
---|
979 | //set the width for each tile |
---|
980 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
981 | { |
---|
982 | uiCummulativeTileWidth = 0; |
---|
983 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
984 | { |
---|
985 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
986 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
987 | } |
---|
988 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
989 | } |
---|
990 | |
---|
991 | //set the height for each tile |
---|
992 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
993 | { |
---|
994 | uiCummulativeTileHeight = 0; |
---|
995 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
996 | { |
---|
997 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
998 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
999 | } |
---|
1000 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
1001 | } |
---|
1002 | } |
---|
1003 | |
---|
1004 | pcPic->getPicSym()->xInitTiles(); |
---|
1005 | |
---|
1006 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
1007 | UInt uiEncCUAddr; |
---|
1008 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
1009 | { |
---|
1010 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
1011 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
1012 | } |
---|
1013 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
1014 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
1015 | |
---|
1016 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
1017 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
1018 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
1019 | if(pcSlice->isNextSlice()) |
---|
1020 | { |
---|
1021 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
1022 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
1023 | } |
---|
1024 | |
---|
1025 | if (m_bFirstSliceInPicture) |
---|
1026 | { |
---|
1027 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
1028 | { |
---|
1029 | pcPic->clearSliceBuffer(); |
---|
1030 | } |
---|
1031 | } |
---|
1032 | else |
---|
1033 | { |
---|
1034 | pcPic->allocateNewSlice(); |
---|
1035 | } |
---|
1036 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
1037 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1038 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
1039 | |
---|
1040 | pcPic->setTLayer(nalu.m_temporalId); |
---|
1041 | |
---|
1042 | #if SVC_EXTENSION |
---|
1043 | pcPic->setLayerId(nalu.m_layerId); |
---|
1044 | pcSlice->setLayerId(nalu.m_layerId); |
---|
1045 | #endif |
---|
1046 | |
---|
1047 | if (bNextSlice) |
---|
1048 | { |
---|
1049 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic ); |
---|
1050 | // Set reference list |
---|
1051 | #if SVC_EXTENSION |
---|
1052 | if (m_layerId == 0) |
---|
1053 | #endif |
---|
1054 | #if FIX1071 |
---|
1055 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
1056 | #else |
---|
1057 | pcSlice->setRefPicList( m_cListPic ); |
---|
1058 | #endif |
---|
1059 | |
---|
1060 | #if SVC_EXTENSION |
---|
1061 | if(m_layerId > 0) |
---|
1062 | { |
---|
1063 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1064 | { |
---|
1065 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1066 | #if AVC_BASE |
---|
1067 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
1068 | { |
---|
1069 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
1070 | #if AVC_SYNTAX |
---|
1071 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
---|
1072 | if( pcSlice->getPOC() == 0 ) |
---|
1073 | { |
---|
1074 | // initialize partition order. |
---|
1075 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
1076 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
1077 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
1078 | } |
---|
1079 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
1080 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
1081 | #endif |
---|
1082 | } |
---|
1083 | else |
---|
1084 | { |
---|
1085 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1086 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1087 | #else |
---|
1088 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1089 | #endif |
---|
1090 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1091 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1092 | } |
---|
1093 | #else |
---|
1094 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1095 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1096 | #else |
---|
1097 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1098 | #endif |
---|
1099 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1100 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1101 | #endif |
---|
1102 | |
---|
1103 | #if SCALED_REF_LAYER_OFFSETS |
---|
1104 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
1105 | |
---|
1106 | |
---|
1107 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); |
---|
1108 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); |
---|
1109 | |
---|
1110 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
1111 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
1112 | #else |
---|
1113 | const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
1114 | const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
1115 | |
---|
1116 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
1117 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
1118 | |
---|
1119 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
1120 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
1121 | #endif |
---|
1122 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
1123 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
1124 | |
---|
1125 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
1126 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
1127 | |
---|
1128 | #if SVC_UPSAMPLING |
---|
1129 | if( pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
1130 | { |
---|
1131 | #if SCALED_REF_LAYER_OFFSETS |
---|
1132 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) ); |
---|
1133 | #else |
---|
1134 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() ); |
---|
1135 | #endif |
---|
1136 | } |
---|
1137 | else |
---|
1138 | { |
---|
1139 | pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
1140 | } |
---|
1141 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1142 | #endif |
---|
1143 | } |
---|
1144 | } |
---|
1145 | |
---|
1146 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
1147 | { |
---|
1148 | setILRPic(pcPic); |
---|
1149 | #if REF_IDX_MFM |
---|
1150 | #if M0457_COL_PICTURE_SIGNALING |
---|
1151 | if( pcSlice->getMFMEnabledFlag() ) |
---|
1152 | #else |
---|
1153 | if( pcSlice->getSPS()->getMFMEnabledFlag() ) |
---|
1154 | #endif |
---|
1155 | { |
---|
1156 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
1157 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1158 | pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); |
---|
1159 | #endif |
---|
1160 | } |
---|
1161 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
1162 | } |
---|
1163 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1164 | else if ( m_layerId > 0 ) |
---|
1165 | { |
---|
1166 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
1167 | } |
---|
1168 | #endif |
---|
1169 | #endif |
---|
1170 | |
---|
1171 | #endif //SVC_EXTENSION |
---|
1172 | |
---|
1173 | #if N0147_IRAP_ALIGN_FLAG |
---|
1174 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag()) |
---|
1175 | { |
---|
1176 | for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) |
---|
1177 | { |
---|
1178 | Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); |
---|
1179 | |
---|
1180 | if(m_cIlpPic[refLayerIdc] && m_cIlpPic[refLayerIdc]->getSlice(0)->isIRAP()) |
---|
1181 | { |
---|
1182 | assert(pcSlice->getNalUnitType() == m_cIlpPic[refLayerIdc]->getSlice(0)->getNalUnitType()); |
---|
1183 | } |
---|
1184 | } |
---|
1185 | } |
---|
1186 | #endif |
---|
1187 | |
---|
1188 | // For generalized B |
---|
1189 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1190 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1191 | { |
---|
1192 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1193 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1194 | |
---|
1195 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1196 | { |
---|
1197 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1198 | } |
---|
1199 | } |
---|
1200 | if (!pcSlice->isIntra()) |
---|
1201 | { |
---|
1202 | Bool bLowDelay = true; |
---|
1203 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1204 | Int iRefIdx = 0; |
---|
1205 | |
---|
1206 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1207 | { |
---|
1208 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1209 | { |
---|
1210 | bLowDelay = false; |
---|
1211 | } |
---|
1212 | } |
---|
1213 | if (pcSlice->isInterB()) |
---|
1214 | { |
---|
1215 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1216 | { |
---|
1217 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1218 | { |
---|
1219 | bLowDelay = false; |
---|
1220 | } |
---|
1221 | } |
---|
1222 | } |
---|
1223 | |
---|
1224 | pcSlice->setCheckLDC(bLowDelay); |
---|
1225 | } |
---|
1226 | |
---|
1227 | //--------------- |
---|
1228 | pcSlice->setRefPOCList(); |
---|
1229 | } |
---|
1230 | |
---|
1231 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1232 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1233 | { |
---|
1234 | #if IL_SL_SIGNALLING_N0371 |
---|
1235 | pcSlice->getSPS()->getScalingList()->setLayerId( m_layerId ); |
---|
1236 | #endif |
---|
1237 | |
---|
1238 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
1239 | |
---|
1240 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
1241 | { |
---|
1242 | #if IL_SL_SIGNALLING_N0371 |
---|
1243 | pcSlice->getPPS()->getScalingList()->setLayerId( m_layerId ); |
---|
1244 | #endif |
---|
1245 | |
---|
1246 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
1247 | } |
---|
1248 | pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip()); |
---|
1249 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
1250 | { |
---|
1251 | #if IL_SL_SIGNALLING_N0371 |
---|
1252 | pcSlice->setDefaultScalingList( m_layerId ); |
---|
1253 | #else |
---|
1254 | pcSlice->setDefaultScalingList(); |
---|
1255 | #endif |
---|
1256 | } |
---|
1257 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
1258 | m_cTrQuant.setUseScalingList(true); |
---|
1259 | } |
---|
1260 | else |
---|
1261 | { |
---|
1262 | #if IL_SL_SIGNALLING_N0371 |
---|
1263 | m_cTrQuant.setFlatScalingList( m_layerId ); |
---|
1264 | #else |
---|
1265 | m_cTrQuant.setFlatScalingList(); |
---|
1266 | #endif |
---|
1267 | m_cTrQuant.setUseScalingList(false); |
---|
1268 | } |
---|
1269 | |
---|
1270 | // Decode a picture |
---|
1271 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
1272 | |
---|
1273 | m_bFirstSliceInPicture = false; |
---|
1274 | m_uiSliceIdx++; |
---|
1275 | |
---|
1276 | return false; |
---|
1277 | } |
---|
1278 | |
---|
1279 | Void TDecTop::xDecodeVPS() |
---|
1280 | { |
---|
1281 | TComVPS* vps = new TComVPS(); |
---|
1282 | |
---|
1283 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1284 | #if SVC_EXTENSION |
---|
1285 | m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps); |
---|
1286 | #else |
---|
1287 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
1288 | #endif |
---|
1289 | } |
---|
1290 | |
---|
1291 | Void TDecTop::xDecodeSPS() |
---|
1292 | { |
---|
1293 | TComSPS* sps = new TComSPS(); |
---|
1294 | #if SVC_EXTENSION |
---|
1295 | sps->setLayerId(m_layerId); |
---|
1296 | #endif |
---|
1297 | |
---|
1298 | #if SPS_SUB_LAYER_INFO |
---|
1299 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder[0] ); |
---|
1300 | #else |
---|
1301 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1302 | #endif |
---|
1303 | #if SVC_EXTENSION |
---|
1304 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps); |
---|
1305 | #else |
---|
1306 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1307 | #endif |
---|
1308 | #if SVC_EXTENSION |
---|
1309 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
---|
1310 | if(m_numLayer>0) |
---|
1311 | { |
---|
1312 | xInitILRP(sps); |
---|
1313 | } |
---|
1314 | #endif |
---|
1315 | #endif |
---|
1316 | } |
---|
1317 | |
---|
1318 | Void TDecTop::xDecodePPS() |
---|
1319 | { |
---|
1320 | TComPPS* pps = new TComPPS(); |
---|
1321 | |
---|
1322 | #if IL_SL_SIGNALLING_N0371 |
---|
1323 | pps->setLayerId(m_layerId); |
---|
1324 | #endif |
---|
1325 | |
---|
1326 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1327 | #if SVC_EXTENSION |
---|
1328 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps ); |
---|
1329 | #else |
---|
1330 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
1331 | #endif |
---|
1332 | |
---|
1333 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
1334 | { |
---|
1335 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
1336 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
1337 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
1338 | { |
---|
1339 | TDecSbac* ctx = NULL; |
---|
1340 | ctx = new TDecSbac; |
---|
1341 | ctx->init( &m_cBinCABAC ); |
---|
1342 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
1343 | } |
---|
1344 | } |
---|
1345 | } |
---|
1346 | |
---|
1347 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
1348 | { |
---|
1349 | #if SVC_EXTENSION |
---|
1350 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1351 | { |
---|
1352 | #if RANDOM_ACCESS_SEI_FIX |
---|
1353 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
1354 | { |
---|
1355 | return; |
---|
1356 | } |
---|
1357 | #endif |
---|
1358 | #if M0043_LAYERS_PRESENT_SEI |
---|
1359 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1360 | #else |
---|
1361 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1362 | #endif |
---|
1363 | } |
---|
1364 | else |
---|
1365 | { |
---|
1366 | #if M0043_LAYERS_PRESENT_SEI |
---|
1367 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1368 | #else |
---|
1369 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1370 | #endif |
---|
1371 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1372 | if (activeParamSets.size()>0) |
---|
1373 | { |
---|
1374 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1375 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
1376 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1377 | if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1378 | { |
---|
1379 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1380 | } |
---|
1381 | } |
---|
1382 | } |
---|
1383 | #else |
---|
1384 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1385 | { |
---|
1386 | #if M0043_LAYERS_PRESENT_SEI |
---|
1387 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1388 | #else |
---|
1389 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1390 | #endif |
---|
1391 | } |
---|
1392 | else |
---|
1393 | { |
---|
1394 | #if M0043_LAYERS_PRESENT_SEI |
---|
1395 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1396 | #else |
---|
1397 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1398 | #endif |
---|
1399 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1400 | if (activeParamSets.size()>0) |
---|
1401 | { |
---|
1402 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1403 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
1404 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1405 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1406 | { |
---|
1407 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1408 | } |
---|
1409 | } |
---|
1410 | } |
---|
1411 | #endif |
---|
1412 | } |
---|
1413 | |
---|
1414 | #if SVC_EXTENSION |
---|
1415 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
1416 | #else |
---|
1417 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1418 | #endif |
---|
1419 | { |
---|
1420 | // Initialize entropy decoder |
---|
1421 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1422 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1423 | |
---|
1424 | switch (nalu.m_nalUnitType) |
---|
1425 | { |
---|
1426 | case NAL_UNIT_VPS: |
---|
1427 | #if VPS_NUH_LAYER_ID |
---|
1428 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
1429 | #endif |
---|
1430 | xDecodeVPS(); |
---|
1431 | #if AVC_BASE |
---|
1432 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1433 | { |
---|
1434 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
1435 | { |
---|
1436 | printf( "Base layer YUV input reading error\n" ); |
---|
1437 | exit(EXIT_FAILURE); |
---|
1438 | } |
---|
1439 | #if AVC_SYNTAX |
---|
1440 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
1441 | { |
---|
1442 | printf( "Base layer syntax input reading error\n" ); |
---|
1443 | exit(EXIT_FAILURE); |
---|
1444 | } |
---|
1445 | #endif |
---|
1446 | } |
---|
1447 | else |
---|
1448 | { |
---|
1449 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
1450 | cListPic->clear(); |
---|
1451 | } |
---|
1452 | #endif |
---|
1453 | return false; |
---|
1454 | |
---|
1455 | case NAL_UNIT_SPS: |
---|
1456 | xDecodeSPS(); |
---|
1457 | #if AVC_BASE |
---|
1458 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1459 | { |
---|
1460 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1461 | if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
1462 | { |
---|
1463 | // using EL SPS with spsId = 1 |
---|
1464 | TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1); |
---|
1465 | Int numReorderPics[MAX_TLAYER]; |
---|
1466 | Window &conformanceWindow = sps->getConformanceWindow(); |
---|
1467 | Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
1468 | #if SVC_UPSAMPLING |
---|
1469 | #if AVC_SYNTAX |
---|
1470 | |
---|
1471 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true); |
---|
1472 | #else |
---|
1473 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
1474 | #endif |
---|
1475 | #else |
---|
1476 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
1477 | #endif |
---|
1478 | } |
---|
1479 | } |
---|
1480 | #endif |
---|
1481 | return false; |
---|
1482 | |
---|
1483 | case NAL_UNIT_PPS: |
---|
1484 | xDecodePPS(); |
---|
1485 | return false; |
---|
1486 | |
---|
1487 | case NAL_UNIT_PREFIX_SEI: |
---|
1488 | case NAL_UNIT_SUFFIX_SEI: |
---|
1489 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
1490 | return false; |
---|
1491 | |
---|
1492 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1493 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1494 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
1495 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1496 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1497 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1498 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1499 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1500 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1501 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1502 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1503 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1504 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1505 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1506 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1507 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1508 | #if SVC_EXTENSION |
---|
1509 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
1510 | #else |
---|
1511 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
1512 | #endif |
---|
1513 | break; |
---|
1514 | default: |
---|
1515 | assert (1); |
---|
1516 | } |
---|
1517 | |
---|
1518 | return false; |
---|
1519 | } |
---|
1520 | |
---|
1521 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
1522 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1523 | * \returns true if the picture should be skipped |
---|
1524 | * This function skips all TFD pictures that follow a BLA picture |
---|
1525 | * in decoding order and precede it in output order. |
---|
1526 | */ |
---|
1527 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
1528 | { |
---|
1529 | if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
1530 | { |
---|
1531 | iPOCLastDisplay++; |
---|
1532 | return true; |
---|
1533 | } |
---|
1534 | return false; |
---|
1535 | } |
---|
1536 | |
---|
1537 | /** Function for checking if picture should be skipped because of random access |
---|
1538 | * \param iSkipFrame skip frame counter |
---|
1539 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1540 | * \returns true if the picture shold be skipped in the random access. |
---|
1541 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
1542 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
1543 | * It also checks the type of Nal unit type at the random access point. |
---|
1544 | * 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. |
---|
1545 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
1546 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
1547 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
1548 | * access point there is no guarantee that the decoder will not crash. |
---|
1549 | */ |
---|
1550 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1551 | { |
---|
1552 | if (iSkipFrame) |
---|
1553 | { |
---|
1554 | iSkipFrame--; // decrement the counter |
---|
1555 | return true; |
---|
1556 | } |
---|
1557 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
1558 | { |
---|
1559 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
1560 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1561 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1562 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
1563 | { |
---|
1564 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
1565 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
1566 | } |
---|
1567 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1568 | { |
---|
1569 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | static Bool warningMessage = false; |
---|
1574 | if(!warningMessage) |
---|
1575 | { |
---|
1576 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
1577 | warningMessage = true; |
---|
1578 | } |
---|
1579 | return true; |
---|
1580 | } |
---|
1581 | } |
---|
1582 | // skip the reordered pictures, if necessary |
---|
1583 | 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)) |
---|
1584 | { |
---|
1585 | iPOCLastDisplay++; |
---|
1586 | return true; |
---|
1587 | } |
---|
1588 | // if we reach here, then the picture is not skipped. |
---|
1589 | return false; |
---|
1590 | } |
---|
1591 | |
---|
1592 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1593 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
---|
1594 | { |
---|
1595 | TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS(); |
---|
1596 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
1597 | { |
---|
1598 | return (TDecTop *)getLayerDec( 0 ); |
---|
1599 | } |
---|
1600 | |
---|
1601 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
1602 | } |
---|
1603 | #endif |
---|
1604 | |
---|
1605 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1606 | |
---|
1607 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
---|
1608 | { |
---|
1609 | for(UInt layer = 0; layer < m_numLayer; layer++) |
---|
1610 | { |
---|
1611 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
---|
1612 | decTop->setNumSamplePredRefLayers(0); |
---|
1613 | decTop->setNumMotionPredRefLayers(0); |
---|
1614 | decTop->setNumDirectRefLayers(0); |
---|
1615 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
1616 | { |
---|
1617 | decTop->setSamplePredEnabledFlag(i, false); |
---|
1618 | decTop->setMotionPredEnabledFlag(i, false); |
---|
1619 | decTop->setSamplePredRefLayerId(i, 0); |
---|
1620 | decTop->setMotionPredRefLayerId(i, 0); |
---|
1621 | } |
---|
1622 | for(Int j = 0; j < layer; j++) |
---|
1623 | { |
---|
1624 | if (vps->getDirectDependencyFlag(layer, j)) |
---|
1625 | { |
---|
1626 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
---|
1627 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
1628 | |
---|
1629 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
---|
1630 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
---|
1631 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
1632 | |
---|
1633 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
---|
1634 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
---|
1635 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
1636 | } |
---|
1637 | } |
---|
1638 | } |
---|
1639 | for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ ) |
---|
1640 | { |
---|
1641 | Int iNuhLId = vps->getLayerIdInNuh(i); |
---|
1642 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
---|
1643 | for ( Int j = 0; j < i; j++ ) |
---|
1644 | { |
---|
1645 | if (decTop->getMotionPredEnabledFlag(j)) |
---|
1646 | { |
---|
1647 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
---|
1648 | } |
---|
1649 | if (decTop->getSamplePredEnabledFlag(j)) |
---|
1650 | { |
---|
1651 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
---|
1652 | } |
---|
1653 | } |
---|
1654 | } |
---|
1655 | } |
---|
1656 | |
---|
1657 | #endif |
---|
1658 | |
---|
1659 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1660 | TComPic* TDecTop::getMotionPredIlp(TComSlice* pcSlice) |
---|
1661 | { |
---|
1662 | TComPic* ilpPic = NULL; |
---|
1663 | Int activeMotionPredReflayerIdx = 0; |
---|
1664 | |
---|
1665 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1666 | { |
---|
1667 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1668 | if( getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) ) |
---|
1669 | { |
---|
1670 | if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx()) |
---|
1671 | { |
---|
1672 | ilpPic = m_cIlpPic[refLayerIdc]; |
---|
1673 | break; |
---|
1674 | } |
---|
1675 | else |
---|
1676 | { |
---|
1677 | activeMotionPredReflayerIdx++; |
---|
1678 | } |
---|
1679 | } |
---|
1680 | } |
---|
1681 | |
---|
1682 | assert(ilpPic != NULL); |
---|
1683 | |
---|
1684 | return ilpPic; |
---|
1685 | } |
---|
1686 | #endif |
---|
1687 | |
---|
1688 | //! \} |
---|