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 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
650 | #else |
---|
651 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
652 | #endif |
---|
653 | { |
---|
654 | TComPic*& pcPic = m_pcPic; |
---|
655 | #if SVC_EXTENSION |
---|
656 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); |
---|
657 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
658 | #else |
---|
659 | m_apcSlicePilot->initSlice(); |
---|
660 | #endif |
---|
661 | |
---|
662 | if (m_bFirstSliceInPicture) |
---|
663 | { |
---|
664 | m_uiSliceIdx = 0; |
---|
665 | } |
---|
666 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
667 | if (!m_bFirstSliceInPicture) |
---|
668 | { |
---|
669 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
670 | } |
---|
671 | |
---|
672 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
673 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
674 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
675 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
676 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
677 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
678 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
679 | |
---|
680 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
681 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
682 | |
---|
683 | #if SVC_EXTENSION |
---|
684 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
685 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
---|
686 | #endif |
---|
687 | #if M0457_COL_PICTURE_SIGNALING |
---|
688 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
689 | #endif |
---|
690 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
691 | m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() ); |
---|
692 | #endif |
---|
693 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); |
---|
694 | #else |
---|
695 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
696 | #endif |
---|
697 | |
---|
698 | #if HM12_RANDOM_ACCESS |
---|
699 | // set POC for dependent slices in skipped pictures |
---|
700 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
701 | { |
---|
702 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
703 | } |
---|
704 | #endif |
---|
705 | |
---|
706 | // Skip pictures due to random access |
---|
707 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
708 | { |
---|
709 | #if HM12_RANDOM_ACCESS |
---|
710 | m_prevSliceSkipped = true; |
---|
711 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
712 | #endif |
---|
713 | return false; |
---|
714 | } |
---|
715 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
716 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
717 | { |
---|
718 | #if HM12_RANDOM_ACCESS |
---|
719 | m_prevSliceSkipped = true; |
---|
720 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
721 | #endif |
---|
722 | return false; |
---|
723 | } |
---|
724 | |
---|
725 | #if HM12_RANDOM_ACCESS |
---|
726 | // clear previous slice skipped flag |
---|
727 | m_prevSliceSkipped = false; |
---|
728 | #endif |
---|
729 | |
---|
730 | // exit when a new picture is found |
---|
731 | #if SVC_EXTENSION |
---|
732 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
733 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
734 | { |
---|
735 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
736 | curLayerId = m_uiPrevLayerId; |
---|
737 | m_uiPrevLayerId = m_layerId; |
---|
738 | return true; |
---|
739 | } |
---|
740 | #else |
---|
741 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
742 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
743 | { |
---|
744 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
745 | } |
---|
746 | // exit when a new picture is found |
---|
747 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
748 | { |
---|
749 | if (m_prevPOC >= m_pocRandomAccess) |
---|
750 | { |
---|
751 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
752 | return true; |
---|
753 | } |
---|
754 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
755 | } |
---|
756 | #endif |
---|
757 | // actual decoding starts here |
---|
758 | xActivateParameterSets(); |
---|
759 | #if 0 // N0147_IRAP_ALIGN_FLAG Disabled for now! |
---|
760 | //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 |
---|
761 | if( m_layerId > 0 && m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag()) |
---|
762 | assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0); |
---|
763 | //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 |
---|
764 | // to be added after poc_reset_flag is integrated. |
---|
765 | #endif |
---|
766 | |
---|
767 | #if REPN_FORMAT_IN_VPS |
---|
768 | // Initialize ILRP if needed, only for the current layer |
---|
769 | // ILRP intialization should go along with activation of parameters sets, |
---|
770 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
771 | xInitILRP(m_apcSlicePilot); |
---|
772 | #endif |
---|
773 | if (m_apcSlicePilot->isNextSlice()) |
---|
774 | { |
---|
775 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
776 | #if SVC_EXTENSION |
---|
777 | curLayerId = m_layerId; |
---|
778 | m_uiPrevLayerId = m_layerId; |
---|
779 | #endif |
---|
780 | } |
---|
781 | m_bFirstSliceInSequence = false; |
---|
782 | //detect lost reference picture and insert copy of earlier frame. |
---|
783 | Int lostPoc; |
---|
784 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
785 | { |
---|
786 | xCreateLostPicture(lostPoc-1); |
---|
787 | } |
---|
788 | if (m_bFirstSliceInPicture) |
---|
789 | { |
---|
790 | #if AVC_BASE |
---|
791 | if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
792 | { |
---|
793 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
794 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
795 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
796 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
797 | |
---|
798 | if( pFile->good() ) |
---|
799 | { |
---|
800 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
801 | |
---|
802 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
803 | |
---|
804 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
805 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
806 | for( Int i = 0; i < uiHeight; i++ ) |
---|
807 | { |
---|
808 | for( Int j = 0; j < uiWidth; j++ ) |
---|
809 | { |
---|
810 | pPel[j] = pFile->get(); |
---|
811 | } |
---|
812 | pPel += uiStride; |
---|
813 | } |
---|
814 | |
---|
815 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
816 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
817 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
818 | { |
---|
819 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
820 | { |
---|
821 | pPel[j] = pFile->get(); |
---|
822 | } |
---|
823 | pPel += uiStride; |
---|
824 | } |
---|
825 | |
---|
826 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
827 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
828 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
829 | { |
---|
830 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
831 | { |
---|
832 | pPel[j] = pFile->get(); |
---|
833 | } |
---|
834 | pPel += uiStride; |
---|
835 | } |
---|
836 | } |
---|
837 | } |
---|
838 | #endif |
---|
839 | |
---|
840 | // Buffer initialize for prediction. |
---|
841 | m_cPrediction.initTempBuff(); |
---|
842 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
843 | // Get a new picture buffer |
---|
844 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
845 | |
---|
846 | // transfer any SEI messages that have been received to the picture |
---|
847 | pcPic->setSEIs(m_SEIs); |
---|
848 | m_SEIs.clear(); |
---|
849 | |
---|
850 | // Recursive structure |
---|
851 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
852 | #if SVC_EXTENSION |
---|
853 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
854 | #else |
---|
855 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
856 | #endif |
---|
857 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
858 | |
---|
859 | m_cSliceDecoder.create(); |
---|
860 | } |
---|
861 | else |
---|
862 | { |
---|
863 | // Check if any new SEI has arrived |
---|
864 | if(!m_SEIs.empty()) |
---|
865 | { |
---|
866 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
867 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
868 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
869 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
870 | deleteSEIs(m_SEIs); |
---|
871 | } |
---|
872 | } |
---|
873 | |
---|
874 | // Set picture slice pointer |
---|
875 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
876 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
877 | |
---|
878 | UInt uiCummulativeTileWidth; |
---|
879 | UInt uiCummulativeTileHeight; |
---|
880 | UInt i, j, p; |
---|
881 | |
---|
882 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
883 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
884 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
885 | |
---|
886 | //create the TComTileArray |
---|
887 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
888 | |
---|
889 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
890 | { |
---|
891 | //set the width for each tile |
---|
892 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
893 | { |
---|
894 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
895 | { |
---|
896 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
897 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
898 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
899 | } |
---|
900 | } |
---|
901 | |
---|
902 | //set the height for each tile |
---|
903 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
904 | { |
---|
905 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
906 | { |
---|
907 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
908 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
909 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
910 | } |
---|
911 | } |
---|
912 | } |
---|
913 | else |
---|
914 | { |
---|
915 | //set the width for each tile |
---|
916 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
917 | { |
---|
918 | uiCummulativeTileWidth = 0; |
---|
919 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
920 | { |
---|
921 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
922 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
923 | } |
---|
924 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
925 | } |
---|
926 | |
---|
927 | //set the height for each tile |
---|
928 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
929 | { |
---|
930 | uiCummulativeTileHeight = 0; |
---|
931 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
932 | { |
---|
933 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
934 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
935 | } |
---|
936 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
937 | } |
---|
938 | } |
---|
939 | |
---|
940 | pcPic->getPicSym()->xInitTiles(); |
---|
941 | |
---|
942 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
943 | UInt uiEncCUAddr; |
---|
944 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
945 | { |
---|
946 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
947 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
948 | } |
---|
949 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
950 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
951 | |
---|
952 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
953 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
954 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
955 | if(pcSlice->isNextSlice()) |
---|
956 | { |
---|
957 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
958 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
959 | } |
---|
960 | |
---|
961 | if (m_bFirstSliceInPicture) |
---|
962 | { |
---|
963 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
964 | { |
---|
965 | pcPic->clearSliceBuffer(); |
---|
966 | } |
---|
967 | } |
---|
968 | else |
---|
969 | { |
---|
970 | pcPic->allocateNewSlice(); |
---|
971 | } |
---|
972 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
973 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
974 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
975 | |
---|
976 | pcPic->setTLayer(nalu.m_temporalId); |
---|
977 | |
---|
978 | #if SVC_EXTENSION |
---|
979 | pcPic->setLayerId(nalu.m_layerId); |
---|
980 | pcSlice->setLayerId(nalu.m_layerId); |
---|
981 | #endif |
---|
982 | |
---|
983 | if (bNextSlice) |
---|
984 | { |
---|
985 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic ); |
---|
986 | // Set reference list |
---|
987 | #if SVC_EXTENSION |
---|
988 | if (m_layerId == 0) |
---|
989 | #endif |
---|
990 | #if FIX1071 |
---|
991 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
992 | #else |
---|
993 | pcSlice->setRefPicList( m_cListPic ); |
---|
994 | #endif |
---|
995 | |
---|
996 | #if SVC_EXTENSION |
---|
997 | if(m_layerId > 0) |
---|
998 | { |
---|
999 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1000 | { |
---|
1001 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1002 | #if AVC_BASE |
---|
1003 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
1004 | { |
---|
1005 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
1006 | #if AVC_SYNTAX |
---|
1007 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
---|
1008 | if( pcSlice->getPOC() == 0 ) |
---|
1009 | { |
---|
1010 | // initialize partition order. |
---|
1011 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
1012 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
1013 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
1014 | } |
---|
1015 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
1016 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
1017 | #endif |
---|
1018 | } |
---|
1019 | else |
---|
1020 | { |
---|
1021 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1022 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1023 | #else |
---|
1024 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1025 | #endif |
---|
1026 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1027 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1028 | } |
---|
1029 | #else |
---|
1030 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1031 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1032 | #else |
---|
1033 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1034 | #endif |
---|
1035 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1036 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1037 | #endif |
---|
1038 | |
---|
1039 | #if SCALED_REF_LAYER_OFFSETS |
---|
1040 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
1041 | |
---|
1042 | |
---|
1043 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); |
---|
1044 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); |
---|
1045 | |
---|
1046 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
1047 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
1048 | #else |
---|
1049 | const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
1050 | const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
1051 | |
---|
1052 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
1053 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
1054 | |
---|
1055 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
1056 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
1057 | #endif |
---|
1058 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
1059 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
1060 | |
---|
1061 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
1062 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
1063 | |
---|
1064 | #if SVC_UPSAMPLING |
---|
1065 | if( pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
1066 | { |
---|
1067 | #if SCALED_REF_LAYER_OFFSETS |
---|
1068 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) ); |
---|
1069 | #else |
---|
1070 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() ); |
---|
1071 | #endif |
---|
1072 | } |
---|
1073 | else |
---|
1074 | { |
---|
1075 | pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
1076 | } |
---|
1077 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1078 | #endif |
---|
1079 | } |
---|
1080 | } |
---|
1081 | |
---|
1082 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
1083 | { |
---|
1084 | setILRPic(pcPic); |
---|
1085 | #if REF_IDX_MFM |
---|
1086 | #if M0457_COL_PICTURE_SIGNALING |
---|
1087 | if( pcSlice->getMFMEnabledFlag() ) |
---|
1088 | #else |
---|
1089 | if( pcSlice->getSPS()->getMFMEnabledFlag() ) |
---|
1090 | #endif |
---|
1091 | { |
---|
1092 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
1093 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1094 | pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); |
---|
1095 | #endif |
---|
1096 | } |
---|
1097 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
1098 | } |
---|
1099 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1100 | else if ( m_layerId > 0 ) |
---|
1101 | { |
---|
1102 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
1103 | } |
---|
1104 | #endif |
---|
1105 | #endif |
---|
1106 | |
---|
1107 | #endif //SVC_EXTENSION |
---|
1108 | |
---|
1109 | #if N0147_IRAP_ALIGN_FLAG |
---|
1110 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag()) |
---|
1111 | { |
---|
1112 | if(pcSlice->isIRAP()) |
---|
1113 | { |
---|
1114 | for(Int depedentLayerId = 0; depedentLayerId < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); depedentLayerId++) |
---|
1115 | assert(pcSlice->getNalUnitType() == pcSlice->getBaseColPic(depedentLayerId)->getSlice(0)->getNalUnitType()); |
---|
1116 | } |
---|
1117 | } |
---|
1118 | #endif |
---|
1119 | // For generalized B |
---|
1120 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1121 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1122 | { |
---|
1123 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1124 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1125 | |
---|
1126 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1127 | { |
---|
1128 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1129 | } |
---|
1130 | } |
---|
1131 | if (!pcSlice->isIntra()) |
---|
1132 | { |
---|
1133 | Bool bLowDelay = true; |
---|
1134 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1135 | Int iRefIdx = 0; |
---|
1136 | |
---|
1137 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1138 | { |
---|
1139 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1140 | { |
---|
1141 | bLowDelay = false; |
---|
1142 | } |
---|
1143 | } |
---|
1144 | if (pcSlice->isInterB()) |
---|
1145 | { |
---|
1146 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1147 | { |
---|
1148 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1149 | { |
---|
1150 | bLowDelay = false; |
---|
1151 | } |
---|
1152 | } |
---|
1153 | } |
---|
1154 | |
---|
1155 | pcSlice->setCheckLDC(bLowDelay); |
---|
1156 | } |
---|
1157 | |
---|
1158 | //--------------- |
---|
1159 | pcSlice->setRefPOCList(); |
---|
1160 | } |
---|
1161 | |
---|
1162 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1163 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1164 | { |
---|
1165 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
1166 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
1167 | { |
---|
1168 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
1169 | } |
---|
1170 | pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip()); |
---|
1171 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
1172 | { |
---|
1173 | pcSlice->setDefaultScalingList(); |
---|
1174 | } |
---|
1175 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
1176 | m_cTrQuant.setUseScalingList(true); |
---|
1177 | } |
---|
1178 | else |
---|
1179 | { |
---|
1180 | m_cTrQuant.setFlatScalingList(); |
---|
1181 | m_cTrQuant.setUseScalingList(false); |
---|
1182 | } |
---|
1183 | |
---|
1184 | // Decode a picture |
---|
1185 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
1186 | |
---|
1187 | m_bFirstSliceInPicture = false; |
---|
1188 | m_uiSliceIdx++; |
---|
1189 | |
---|
1190 | return false; |
---|
1191 | } |
---|
1192 | |
---|
1193 | Void TDecTop::xDecodeVPS() |
---|
1194 | { |
---|
1195 | TComVPS* vps = new TComVPS(); |
---|
1196 | |
---|
1197 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1198 | #if SVC_EXTENSION |
---|
1199 | m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps); |
---|
1200 | #else |
---|
1201 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
1202 | #endif |
---|
1203 | } |
---|
1204 | |
---|
1205 | Void TDecTop::xDecodeSPS() |
---|
1206 | { |
---|
1207 | TComSPS* sps = new TComSPS(); |
---|
1208 | #if SVC_EXTENSION |
---|
1209 | sps->setLayerId(m_layerId); |
---|
1210 | #endif |
---|
1211 | #if SPS_SUB_LAYER_INFO |
---|
1212 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder[0] ); |
---|
1213 | #else |
---|
1214 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1215 | #endif |
---|
1216 | #if SVC_EXTENSION |
---|
1217 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps); |
---|
1218 | #else |
---|
1219 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1220 | #endif |
---|
1221 | #if SVC_EXTENSION |
---|
1222 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
---|
1223 | if(m_numLayer>0) |
---|
1224 | { |
---|
1225 | xInitILRP(sps); |
---|
1226 | } |
---|
1227 | #endif |
---|
1228 | #endif |
---|
1229 | } |
---|
1230 | |
---|
1231 | Void TDecTop::xDecodePPS() |
---|
1232 | { |
---|
1233 | TComPPS* pps = new TComPPS(); |
---|
1234 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1235 | #if SVC_EXTENSION |
---|
1236 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps ); |
---|
1237 | #else |
---|
1238 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
1239 | #endif |
---|
1240 | |
---|
1241 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
1242 | { |
---|
1243 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
1244 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
1245 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
1246 | { |
---|
1247 | TDecSbac* ctx = NULL; |
---|
1248 | ctx = new TDecSbac; |
---|
1249 | ctx->init( &m_cBinCABAC ); |
---|
1250 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
1251 | } |
---|
1252 | } |
---|
1253 | } |
---|
1254 | |
---|
1255 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
1256 | { |
---|
1257 | #if SVC_EXTENSION |
---|
1258 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1259 | { |
---|
1260 | #if RANDOM_ACCESS_SEI_FIX |
---|
1261 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
1262 | { |
---|
1263 | return; |
---|
1264 | } |
---|
1265 | #endif |
---|
1266 | #if M0043_LAYERS_PRESENT_SEI |
---|
1267 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1268 | #else |
---|
1269 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1270 | #endif |
---|
1271 | } |
---|
1272 | else |
---|
1273 | { |
---|
1274 | #if M0043_LAYERS_PRESENT_SEI |
---|
1275 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1276 | #else |
---|
1277 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1278 | #endif |
---|
1279 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1280 | if (activeParamSets.size()>0) |
---|
1281 | { |
---|
1282 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1283 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
1284 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1285 | if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1286 | { |
---|
1287 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1288 | } |
---|
1289 | } |
---|
1290 | } |
---|
1291 | #else |
---|
1292 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1293 | { |
---|
1294 | #if M0043_LAYERS_PRESENT_SEI |
---|
1295 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1296 | #else |
---|
1297 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1298 | #endif |
---|
1299 | } |
---|
1300 | else |
---|
1301 | { |
---|
1302 | #if M0043_LAYERS_PRESENT_SEI |
---|
1303 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1304 | #else |
---|
1305 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1306 | #endif |
---|
1307 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1308 | if (activeParamSets.size()>0) |
---|
1309 | { |
---|
1310 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1311 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
1312 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1313 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1314 | { |
---|
1315 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1316 | } |
---|
1317 | } |
---|
1318 | } |
---|
1319 | #endif |
---|
1320 | } |
---|
1321 | |
---|
1322 | #if SVC_EXTENSION |
---|
1323 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
1324 | #else |
---|
1325 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1326 | #endif |
---|
1327 | { |
---|
1328 | // Initialize entropy decoder |
---|
1329 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1330 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1331 | |
---|
1332 | switch (nalu.m_nalUnitType) |
---|
1333 | { |
---|
1334 | case NAL_UNIT_VPS: |
---|
1335 | #if VPS_NUH_LAYER_ID |
---|
1336 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
1337 | #endif |
---|
1338 | xDecodeVPS(); |
---|
1339 | #if AVC_BASE |
---|
1340 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1341 | { |
---|
1342 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
1343 | { |
---|
1344 | printf( "Base layer YUV input reading error\n" ); |
---|
1345 | exit(EXIT_FAILURE); |
---|
1346 | } |
---|
1347 | #if AVC_SYNTAX |
---|
1348 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
1349 | { |
---|
1350 | printf( "Base layer syntax input reading error\n" ); |
---|
1351 | exit(EXIT_FAILURE); |
---|
1352 | } |
---|
1353 | #endif |
---|
1354 | } |
---|
1355 | else |
---|
1356 | { |
---|
1357 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
1358 | cListPic->clear(); |
---|
1359 | } |
---|
1360 | #endif |
---|
1361 | return false; |
---|
1362 | |
---|
1363 | case NAL_UNIT_SPS: |
---|
1364 | xDecodeSPS(); |
---|
1365 | #if AVC_BASE |
---|
1366 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1367 | { |
---|
1368 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1369 | if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
1370 | { |
---|
1371 | // using EL SPS with spsId = 1 |
---|
1372 | TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1); |
---|
1373 | Int numReorderPics[MAX_TLAYER]; |
---|
1374 | Window &conformanceWindow = sps->getConformanceWindow(); |
---|
1375 | Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
1376 | #if SVC_UPSAMPLING |
---|
1377 | #if AVC_SYNTAX |
---|
1378 | |
---|
1379 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true); |
---|
1380 | #else |
---|
1381 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
1382 | #endif |
---|
1383 | #else |
---|
1384 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
1385 | #endif |
---|
1386 | } |
---|
1387 | } |
---|
1388 | #endif |
---|
1389 | return false; |
---|
1390 | |
---|
1391 | case NAL_UNIT_PPS: |
---|
1392 | xDecodePPS(); |
---|
1393 | return false; |
---|
1394 | |
---|
1395 | case NAL_UNIT_PREFIX_SEI: |
---|
1396 | case NAL_UNIT_SUFFIX_SEI: |
---|
1397 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
1398 | return false; |
---|
1399 | |
---|
1400 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1401 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1402 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
1403 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1404 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1405 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1406 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1407 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1408 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1409 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1410 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1411 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1412 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1413 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1414 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1415 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1416 | #if SVC_EXTENSION |
---|
1417 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
1418 | #else |
---|
1419 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
1420 | #endif |
---|
1421 | break; |
---|
1422 | default: |
---|
1423 | assert (1); |
---|
1424 | } |
---|
1425 | |
---|
1426 | return false; |
---|
1427 | } |
---|
1428 | |
---|
1429 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
1430 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1431 | * \returns true if the picture should be skipped |
---|
1432 | * This function skips all TFD pictures that follow a BLA picture |
---|
1433 | * in decoding order and precede it in output order. |
---|
1434 | */ |
---|
1435 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
1436 | { |
---|
1437 | 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)) |
---|
1438 | { |
---|
1439 | iPOCLastDisplay++; |
---|
1440 | return true; |
---|
1441 | } |
---|
1442 | return false; |
---|
1443 | } |
---|
1444 | |
---|
1445 | /** Function for checking if picture should be skipped because of random access |
---|
1446 | * \param iSkipFrame skip frame counter |
---|
1447 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1448 | * \returns true if the picture shold be skipped in the random access. |
---|
1449 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
1450 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
1451 | * It also checks the type of Nal unit type at the random access point. |
---|
1452 | * 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. |
---|
1453 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
1454 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
1455 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
1456 | * access point there is no guarantee that the decoder will not crash. |
---|
1457 | */ |
---|
1458 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1459 | { |
---|
1460 | if (iSkipFrame) |
---|
1461 | { |
---|
1462 | iSkipFrame--; // decrement the counter |
---|
1463 | return true; |
---|
1464 | } |
---|
1465 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
1466 | { |
---|
1467 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
1468 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1469 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1470 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
1471 | { |
---|
1472 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
1473 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
1474 | } |
---|
1475 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1476 | { |
---|
1477 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
1478 | } |
---|
1479 | else |
---|
1480 | { |
---|
1481 | static Bool warningMessage = false; |
---|
1482 | if(!warningMessage) |
---|
1483 | { |
---|
1484 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
1485 | warningMessage = true; |
---|
1486 | } |
---|
1487 | return true; |
---|
1488 | } |
---|
1489 | } |
---|
1490 | // skip the reordered pictures, if necessary |
---|
1491 | 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)) |
---|
1492 | { |
---|
1493 | iPOCLastDisplay++; |
---|
1494 | return true; |
---|
1495 | } |
---|
1496 | // if we reach here, then the picture is not skipped. |
---|
1497 | return false; |
---|
1498 | } |
---|
1499 | |
---|
1500 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1501 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
---|
1502 | { |
---|
1503 | TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS(); |
---|
1504 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
1505 | { |
---|
1506 | return (TDecTop *)getLayerDec( 0 ); |
---|
1507 | } |
---|
1508 | |
---|
1509 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
1510 | } |
---|
1511 | #endif |
---|
1512 | |
---|
1513 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1514 | |
---|
1515 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
---|
1516 | { |
---|
1517 | for(UInt layer = 0; layer < m_numLayer; layer++) |
---|
1518 | { |
---|
1519 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
---|
1520 | decTop->setNumSamplePredRefLayers(0); |
---|
1521 | decTop->setNumMotionPredRefLayers(0); |
---|
1522 | decTop->setNumDirectRefLayers(0); |
---|
1523 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
1524 | { |
---|
1525 | decTop->setSamplePredEnabledFlag(i, false); |
---|
1526 | decTop->setMotionPredEnabledFlag(i, false); |
---|
1527 | decTop->setSamplePredRefLayerId(i, 0); |
---|
1528 | decTop->setMotionPredRefLayerId(i, 0); |
---|
1529 | } |
---|
1530 | for(Int j = 0; j < layer; j++) |
---|
1531 | { |
---|
1532 | if (vps->getDirectDependencyFlag(layer, j)) |
---|
1533 | { |
---|
1534 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
---|
1535 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
1536 | |
---|
1537 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
---|
1538 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
---|
1539 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
1540 | |
---|
1541 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
---|
1542 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
---|
1543 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
1544 | } |
---|
1545 | } |
---|
1546 | } |
---|
1547 | for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ ) |
---|
1548 | { |
---|
1549 | Int iNuhLId = vps->getLayerIdInNuh(i); |
---|
1550 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
---|
1551 | for ( Int j = 0; j < i; j++ ) |
---|
1552 | { |
---|
1553 | if (decTop->getMotionPredEnabledFlag(j)) |
---|
1554 | { |
---|
1555 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
---|
1556 | } |
---|
1557 | if (decTop->getSamplePredEnabledFlag(j)) |
---|
1558 | { |
---|
1559 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
---|
1560 | } |
---|
1561 | } |
---|
1562 | } |
---|
1563 | } |
---|
1564 | |
---|
1565 | #endif |
---|
1566 | |
---|
1567 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1568 | TComPic* TDecTop::getMotionPredIlp(TComSlice* pcSlice) |
---|
1569 | { |
---|
1570 | TComPic* ilpPic = NULL; |
---|
1571 | Int activeMotionPredReflayerIdx = 0; |
---|
1572 | |
---|
1573 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1574 | { |
---|
1575 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1576 | if( getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) ) |
---|
1577 | { |
---|
1578 | if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx()) |
---|
1579 | { |
---|
1580 | ilpPic = m_cIlpPic[refLayerIdc]; |
---|
1581 | break; |
---|
1582 | } |
---|
1583 | else |
---|
1584 | { |
---|
1585 | activeMotionPredReflayerIdx++; |
---|
1586 | } |
---|
1587 | } |
---|
1588 | } |
---|
1589 | |
---|
1590 | assert(ilpPic != NULL); |
---|
1591 | |
---|
1592 | return ilpPic; |
---|
1593 | } |
---|
1594 | #endif |
---|
1595 | |
---|
1596 | //! \} |
---|