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 | #endif |
---|
75 | #if REF_IDX_FRAMEWORK |
---|
76 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
77 | #endif |
---|
78 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
79 | m_pBLSyntaxFile = NULL; |
---|
80 | #endif |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | TDecTop::~TDecTop() |
---|
85 | { |
---|
86 | #if ENC_DEC_TRACE |
---|
87 | fclose( g_hTrace ); |
---|
88 | #endif |
---|
89 | } |
---|
90 | |
---|
91 | Void TDecTop::create() |
---|
92 | { |
---|
93 | #if SVC_EXTENSION |
---|
94 | m_cGopDecoder.create( m_layerId ); |
---|
95 | #else |
---|
96 | m_cGopDecoder.create(); |
---|
97 | #endif |
---|
98 | m_apcSlicePilot = new TComSlice; |
---|
99 | m_uiSliceIdx = 0; |
---|
100 | } |
---|
101 | |
---|
102 | Void TDecTop::destroy() |
---|
103 | { |
---|
104 | m_cGopDecoder.destroy(); |
---|
105 | |
---|
106 | delete m_apcSlicePilot; |
---|
107 | m_apcSlicePilot = NULL; |
---|
108 | |
---|
109 | m_cSliceDecoder.destroy(); |
---|
110 | #if REF_IDX_FRAMEWORK |
---|
111 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
112 | { |
---|
113 | if(m_cIlpPic[i]) |
---|
114 | { |
---|
115 | m_cIlpPic[i]->destroy(); |
---|
116 | delete m_cIlpPic[i]; |
---|
117 | m_cIlpPic[i] = NULL; |
---|
118 | } |
---|
119 | } |
---|
120 | #endif |
---|
121 | } |
---|
122 | |
---|
123 | Void TDecTop::init() |
---|
124 | { |
---|
125 | #if !SVC_EXTENSION |
---|
126 | // initialize ROM |
---|
127 | initROM(); |
---|
128 | #endif |
---|
129 | #if SVC_EXTENSION |
---|
130 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
131 | m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
132 | #else |
---|
133 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
134 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
135 | #endif |
---|
136 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
137 | } |
---|
138 | |
---|
139 | #if REF_IDX_FRAMEWORK |
---|
140 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
141 | { |
---|
142 | if(m_layerId>0) |
---|
143 | { |
---|
144 | g_bitDepthY = pcSPS->getBitDepthY(); |
---|
145 | g_bitDepthC = pcSPS->getBitDepthC(); |
---|
146 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
147 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
148 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
149 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
150 | |
---|
151 | Int numReorderPics[MAX_TLAYER]; |
---|
152 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
153 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
154 | |
---|
155 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
156 | { |
---|
157 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
158 | } |
---|
159 | |
---|
160 | if (m_cIlpPic[0] == NULL) |
---|
161 | { |
---|
162 | for (Int j=0; j< 1/*MAX_NUM_REF*/; j++) // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
163 | { |
---|
164 | |
---|
165 | m_cIlpPic[j] = new TComPic; |
---|
166 | #if SVC_UPSAMPLING |
---|
167 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
168 | #else |
---|
169 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
170 | #endif |
---|
171 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
172 | { |
---|
173 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
174 | } |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | Void TDecTop::setILRPic(TComPic *pcPic) |
---|
181 | { |
---|
182 | if(m_cIlpPic[0]) |
---|
183 | { |
---|
184 | m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec()); |
---|
185 | m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC()); |
---|
186 | m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId |
---|
187 | m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false); |
---|
188 | m_cIlpPic[0]->getPicYuvRec()->extendPicBorder(); |
---|
189 | } |
---|
190 | } |
---|
191 | #endif |
---|
192 | |
---|
193 | Void TDecTop::deletePicBuffer ( ) |
---|
194 | { |
---|
195 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
196 | Int iSize = Int( m_cListPic.size() ); |
---|
197 | |
---|
198 | for (Int i = 0; i < iSize; i++ ) |
---|
199 | { |
---|
200 | TComPic* pcPic = *(iterPic++); |
---|
201 | #if SVC_EXTENSION |
---|
202 | if( pcPic ) |
---|
203 | { |
---|
204 | pcPic->destroy(); |
---|
205 | |
---|
206 | delete pcPic; |
---|
207 | pcPic = NULL; |
---|
208 | } |
---|
209 | #else |
---|
210 | pcPic->destroy(); |
---|
211 | |
---|
212 | delete pcPic; |
---|
213 | pcPic = NULL; |
---|
214 | #endif |
---|
215 | } |
---|
216 | |
---|
217 | m_cSAO.destroy(); |
---|
218 | |
---|
219 | m_cLoopFilter. destroy(); |
---|
220 | |
---|
221 | #if !SVC_EXTENSION |
---|
222 | // destroy ROM |
---|
223 | destroyROM(); |
---|
224 | #endif |
---|
225 | } |
---|
226 | |
---|
227 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
228 | { |
---|
229 | Int numReorderPics[MAX_TLAYER]; |
---|
230 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
231 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
232 | |
---|
233 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
234 | { |
---|
235 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
236 | } |
---|
237 | |
---|
238 | #if L0323_DPB |
---|
239 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
240 | #else |
---|
241 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded |
---|
242 | #endif |
---|
243 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
244 | { |
---|
245 | rpcPic = new TComPic(); |
---|
246 | |
---|
247 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
248 | if(m_layerId > 0) |
---|
249 | { |
---|
250 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
251 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
252 | #else |
---|
253 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
254 | #endif |
---|
255 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
256 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
257 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
258 | { |
---|
259 | rpcPic->setSpatialEnhLayerFlag( true ); |
---|
260 | } |
---|
261 | } |
---|
262 | #endif |
---|
263 | |
---|
264 | #if SVC_UPSAMPLING |
---|
265 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
266 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
267 | #else |
---|
268 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
269 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
270 | #endif |
---|
271 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
272 | m_cListPic.pushBack( rpcPic ); |
---|
273 | |
---|
274 | return; |
---|
275 | } |
---|
276 | |
---|
277 | Bool bBufferIsAvailable = false; |
---|
278 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
279 | while (iterPic != m_cListPic.end()) |
---|
280 | { |
---|
281 | rpcPic = *(iterPic++); |
---|
282 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
283 | { |
---|
284 | rpcPic->setOutputMark(false); |
---|
285 | bBufferIsAvailable = true; |
---|
286 | break; |
---|
287 | } |
---|
288 | |
---|
289 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
290 | { |
---|
291 | #if !SVC_EXTENSION |
---|
292 | rpcPic->setOutputMark(false); |
---|
293 | #endif |
---|
294 | rpcPic->setReconMark( false ); |
---|
295 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
296 | bBufferIsAvailable = true; |
---|
297 | break; |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | if ( !bBufferIsAvailable ) |
---|
302 | { |
---|
303 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
304 | m_iMaxRefPicNum++; |
---|
305 | rpcPic = new TComPic(); |
---|
306 | m_cListPic.pushBack( rpcPic ); |
---|
307 | } |
---|
308 | rpcPic->destroy(); |
---|
309 | |
---|
310 | #if SVC_UPSAMPLING |
---|
311 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
312 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
313 | |
---|
314 | #else |
---|
315 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
316 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
317 | #endif |
---|
318 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
319 | } |
---|
320 | |
---|
321 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
322 | { |
---|
323 | if (!m_pcPic) |
---|
324 | { |
---|
325 | /* nothing to deblock */ |
---|
326 | return; |
---|
327 | } |
---|
328 | |
---|
329 | TComPic*& pcPic = m_pcPic; |
---|
330 | |
---|
331 | // Execute Deblock + Cleanup |
---|
332 | |
---|
333 | m_cGopDecoder.filterPicture(pcPic); |
---|
334 | |
---|
335 | #if SYNTAX_OUTPUT |
---|
336 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
337 | #endif |
---|
338 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
339 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
340 | rpcListPic = &m_cListPic; |
---|
341 | m_cCuDecoder.destroy(); |
---|
342 | m_bFirstSliceInPicture = true; |
---|
343 | |
---|
344 | return; |
---|
345 | } |
---|
346 | |
---|
347 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
348 | { |
---|
349 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
350 | TComSlice cFillSlice; |
---|
351 | #if SVC_EXTENSION |
---|
352 | cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
353 | cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
354 | cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
355 | cFillSlice.initSlice( m_layerId ); |
---|
356 | #else |
---|
357 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
358 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
359 | cFillSlice.initSlice(); |
---|
360 | #endif |
---|
361 | TComPic *cFillPic; |
---|
362 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
363 | #if SVC_EXTENSION |
---|
364 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
365 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
366 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
367 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
368 | #else |
---|
369 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
370 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
371 | cFillPic->getSlice(0)->initSlice(); |
---|
372 | #endif |
---|
373 | |
---|
374 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
375 | Int closestPoc = 1000000; |
---|
376 | while ( iterPic != m_cListPic.end()) |
---|
377 | { |
---|
378 | TComPic * rpcPic = *(iterPic++); |
---|
379 | 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()) |
---|
380 | { |
---|
381 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
382 | } |
---|
383 | } |
---|
384 | iterPic = m_cListPic.begin(); |
---|
385 | while ( iterPic != m_cListPic.end()) |
---|
386 | { |
---|
387 | TComPic *rpcPic = *(iterPic++); |
---|
388 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
389 | { |
---|
390 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
391 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
392 | break; |
---|
393 | } |
---|
394 | } |
---|
395 | cFillPic->setCurrSliceIdx(0); |
---|
396 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
397 | { |
---|
398 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
399 | } |
---|
400 | cFillPic->getSlice(0)->setReferenced(true); |
---|
401 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
402 | cFillPic->setReconMark(true); |
---|
403 | cFillPic->setOutputMark(true); |
---|
404 | if(m_pocRandomAccess == MAX_INT) |
---|
405 | { |
---|
406 | m_pocRandomAccess = iLostPoc; |
---|
407 | } |
---|
408 | } |
---|
409 | |
---|
410 | |
---|
411 | Void TDecTop::xActivateParameterSets() |
---|
412 | { |
---|
413 | #if SVC_EXTENSION |
---|
414 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
415 | |
---|
416 | TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId()); |
---|
417 | assert (pps != 0); |
---|
418 | |
---|
419 | TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId()); |
---|
420 | assert (sps != 0); |
---|
421 | |
---|
422 | if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) ) |
---|
423 | #else |
---|
424 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
425 | |
---|
426 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
427 | assert (pps != 0); |
---|
428 | |
---|
429 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
430 | assert (sps != 0); |
---|
431 | |
---|
432 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
433 | #endif |
---|
434 | { |
---|
435 | printf ("Parameter set activation failed!"); |
---|
436 | assert (0); |
---|
437 | } |
---|
438 | |
---|
439 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
440 | { |
---|
441 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
442 | |
---|
443 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
444 | { |
---|
445 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
446 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
447 | { |
---|
448 | TDecSbac* ctx = NULL; |
---|
449 | ctx = new TDecSbac; |
---|
450 | ctx->init( &m_cBinCABAC ); |
---|
451 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | m_apcSlicePilot->setPPS(pps); |
---|
457 | m_apcSlicePilot->setSPS(sps); |
---|
458 | |
---|
459 | pps->setSPS(sps); |
---|
460 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
461 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
462 | |
---|
463 | g_bitDepthY = sps->getBitDepthY(); |
---|
464 | g_bitDepthC = sps->getBitDepthC(); |
---|
465 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
466 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
467 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
468 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
469 | |
---|
470 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
471 | { |
---|
472 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
473 | } |
---|
474 | |
---|
475 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
476 | { |
---|
477 | sps->setAMPAcc( i, 0 ); |
---|
478 | } |
---|
479 | |
---|
480 | m_cSAO.destroy(); |
---|
481 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
482 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
483 | } |
---|
484 | |
---|
485 | #if SVC_EXTENSION |
---|
486 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
487 | #else |
---|
488 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
489 | #endif |
---|
490 | { |
---|
491 | TComPic*& pcPic = m_pcPic; |
---|
492 | #if SVC_EXTENSION |
---|
493 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); |
---|
494 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
495 | #else |
---|
496 | m_apcSlicePilot->initSlice(); |
---|
497 | #endif |
---|
498 | |
---|
499 | if (m_bFirstSliceInPicture) |
---|
500 | { |
---|
501 | m_uiSliceIdx = 0; |
---|
502 | } |
---|
503 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
504 | if (!m_bFirstSliceInPicture) |
---|
505 | { |
---|
506 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
507 | } |
---|
508 | |
---|
509 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
510 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
511 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
512 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
513 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
514 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
515 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
516 | |
---|
517 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
518 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
519 | |
---|
520 | #if SVC_EXTENSION |
---|
521 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); |
---|
522 | #else |
---|
523 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
524 | #endif |
---|
525 | |
---|
526 | // Skip pictures due to random access |
---|
527 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
528 | { |
---|
529 | return false; |
---|
530 | } |
---|
531 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
532 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
533 | { |
---|
534 | return false; |
---|
535 | } |
---|
536 | |
---|
537 | // exit when a new picture is found |
---|
538 | #if SVC_EXTENSION |
---|
539 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
540 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
541 | { |
---|
542 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
543 | curLayerId = m_uiPrevLayerId; |
---|
544 | m_uiPrevLayerId = m_layerId; |
---|
545 | return true; |
---|
546 | } |
---|
547 | #else |
---|
548 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
549 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
550 | { |
---|
551 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
552 | } |
---|
553 | // exit when a new picture is found |
---|
554 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
555 | { |
---|
556 | if (m_prevPOC >= m_pocRandomAccess) |
---|
557 | { |
---|
558 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
559 | return true; |
---|
560 | } |
---|
561 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
562 | } |
---|
563 | #endif |
---|
564 | // actual decoding starts here |
---|
565 | xActivateParameterSets(); |
---|
566 | |
---|
567 | if (m_apcSlicePilot->isNextSlice()) |
---|
568 | { |
---|
569 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
570 | #if SVC_EXTENSION |
---|
571 | curLayerId = m_layerId; |
---|
572 | m_uiPrevLayerId = m_layerId; |
---|
573 | #endif |
---|
574 | } |
---|
575 | m_bFirstSliceInSequence = false; |
---|
576 | //detect lost reference picture and insert copy of earlier frame. |
---|
577 | Int lostPoc; |
---|
578 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
579 | { |
---|
580 | xCreateLostPicture(lostPoc-1); |
---|
581 | } |
---|
582 | if (m_bFirstSliceInPicture) |
---|
583 | { |
---|
584 | #if AVC_BASE |
---|
585 | if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
586 | { |
---|
587 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
588 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
589 | #if ILP_DECODED_PICTURE |
---|
590 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
591 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
592 | #else |
---|
593 | const Window &conf = pBLPic->getConformanceWindow(); |
---|
594 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset(); |
---|
595 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset(); |
---|
596 | #endif |
---|
597 | |
---|
598 | if( pFile->good() ) |
---|
599 | { |
---|
600 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
601 | |
---|
602 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
603 | |
---|
604 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
605 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
606 | for( Int i = 0; i < uiHeight; i++ ) |
---|
607 | { |
---|
608 | for( Int j = 0; j < uiWidth; j++ ) |
---|
609 | { |
---|
610 | pPel[j] = pFile->get(); |
---|
611 | } |
---|
612 | pPel += uiStride; |
---|
613 | } |
---|
614 | |
---|
615 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
616 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
617 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
618 | { |
---|
619 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
620 | { |
---|
621 | pPel[j] = pFile->get(); |
---|
622 | } |
---|
623 | pPel += uiStride; |
---|
624 | } |
---|
625 | |
---|
626 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
627 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
628 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
629 | { |
---|
630 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
631 | { |
---|
632 | pPel[j] = pFile->get(); |
---|
633 | } |
---|
634 | pPel += uiStride; |
---|
635 | } |
---|
636 | } |
---|
637 | } |
---|
638 | #endif |
---|
639 | |
---|
640 | // Buffer initialize for prediction. |
---|
641 | m_cPrediction.initTempBuff(); |
---|
642 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
643 | // Get a new picture buffer |
---|
644 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
645 | |
---|
646 | // transfer any SEI messages that have been received to the picture |
---|
647 | pcPic->setSEIs(m_SEIs); |
---|
648 | m_SEIs.clear(); |
---|
649 | |
---|
650 | // Recursive structure |
---|
651 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
652 | #if SVC_EXTENSION |
---|
653 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
654 | #else |
---|
655 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
656 | #endif |
---|
657 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
658 | |
---|
659 | m_cSliceDecoder.create(); |
---|
660 | } |
---|
661 | else |
---|
662 | { |
---|
663 | // Check if any new SEI has arrived |
---|
664 | if(!m_SEIs.empty()) |
---|
665 | { |
---|
666 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
667 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
668 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
669 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
670 | deleteSEIs(m_SEIs); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | // Set picture slice pointer |
---|
675 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
676 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
677 | |
---|
678 | UInt uiCummulativeTileWidth; |
---|
679 | UInt uiCummulativeTileHeight; |
---|
680 | UInt i, j, p; |
---|
681 | |
---|
682 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
683 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
684 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
685 | |
---|
686 | //create the TComTileArray |
---|
687 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
688 | |
---|
689 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
690 | { |
---|
691 | //set the width for each tile |
---|
692 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
693 | { |
---|
694 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
695 | { |
---|
696 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
697 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
698 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
699 | } |
---|
700 | } |
---|
701 | |
---|
702 | //set the height for each tile |
---|
703 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
704 | { |
---|
705 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
706 | { |
---|
707 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
708 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
709 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
710 | } |
---|
711 | } |
---|
712 | } |
---|
713 | else |
---|
714 | { |
---|
715 | //set the width for each tile |
---|
716 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
717 | { |
---|
718 | uiCummulativeTileWidth = 0; |
---|
719 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
720 | { |
---|
721 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
722 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
723 | } |
---|
724 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
725 | } |
---|
726 | |
---|
727 | //set the height for each tile |
---|
728 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
729 | { |
---|
730 | uiCummulativeTileHeight = 0; |
---|
731 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
732 | { |
---|
733 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
734 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
735 | } |
---|
736 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
737 | } |
---|
738 | } |
---|
739 | |
---|
740 | pcPic->getPicSym()->xInitTiles(); |
---|
741 | |
---|
742 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
743 | UInt uiEncCUAddr; |
---|
744 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
745 | { |
---|
746 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
747 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
748 | } |
---|
749 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
750 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
751 | |
---|
752 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
753 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
754 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
755 | if(pcSlice->isNextSlice()) |
---|
756 | { |
---|
757 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
758 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
759 | } |
---|
760 | |
---|
761 | if (m_bFirstSliceInPicture) |
---|
762 | { |
---|
763 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
764 | { |
---|
765 | pcPic->clearSliceBuffer(); |
---|
766 | } |
---|
767 | } |
---|
768 | else |
---|
769 | { |
---|
770 | pcPic->allocateNewSlice(); |
---|
771 | } |
---|
772 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
773 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
774 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
775 | |
---|
776 | pcPic->setTLayer(nalu.m_temporalId); |
---|
777 | |
---|
778 | #if SVC_EXTENSION |
---|
779 | pcPic->setLayerId(nalu.m_layerId); |
---|
780 | pcSlice->setLayerId(nalu.m_layerId); |
---|
781 | #endif |
---|
782 | |
---|
783 | if (bNextSlice) |
---|
784 | { |
---|
785 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic ); |
---|
786 | // Set reference list |
---|
787 | #if REF_IDX_FRAMEWORK |
---|
788 | if (m_layerId == 0) |
---|
789 | #elif INTRA_BL |
---|
790 | if( m_layerId > 0 ) |
---|
791 | { |
---|
792 | pcSlice->setRefPicList( m_cListPic ); |
---|
793 | } |
---|
794 | else |
---|
795 | #endif |
---|
796 | #if FIX1071 |
---|
797 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
798 | #else |
---|
799 | pcSlice->setRefPicList( m_cListPic ); |
---|
800 | #endif |
---|
801 | |
---|
802 | #if SVC_EXTENSION |
---|
803 | if(m_layerId > 0) |
---|
804 | { |
---|
805 | #if AVC_BASE |
---|
806 | if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
807 | { |
---|
808 | pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
809 | #if AVC_SYNTAX |
---|
810 | TComPic* pBLPic = pcSlice->getBaseColPic(); |
---|
811 | if( pcSlice->getPOC() == 0 ) |
---|
812 | { |
---|
813 | // initialize partition order. |
---|
814 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
815 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
816 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
817 | } |
---|
818 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
819 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
820 | #endif |
---|
821 | } |
---|
822 | else |
---|
823 | { |
---|
824 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
825 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
826 | #else |
---|
827 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
828 | #endif |
---|
829 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
830 | pcSlice->setBaseColPic ( *cListPic, m_layerId ); |
---|
831 | } |
---|
832 | #else |
---|
833 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
834 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
835 | #else |
---|
836 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
837 | #endif |
---|
838 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
839 | pcSlice->setBaseColPic ( *cListPic, m_layerId ); |
---|
840 | #endif |
---|
841 | #if SVC_UPSAMPLING |
---|
842 | if ( pcPic->isSpatialEnhLayer()) |
---|
843 | { |
---|
844 | #if SCALED_REF_LAYER_OFFSETS |
---|
845 | m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() ); |
---|
846 | #else |
---|
847 | m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() ); |
---|
848 | #endif |
---|
849 | } |
---|
850 | else |
---|
851 | { |
---|
852 | pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() ); |
---|
853 | } |
---|
854 | pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() ); |
---|
855 | #endif |
---|
856 | } |
---|
857 | |
---|
858 | #if REF_IDX_FRAMEWORK |
---|
859 | if(m_layerId > 0) |
---|
860 | { |
---|
861 | setILRPic(pcPic); |
---|
862 | #if REF_IDX_MFM |
---|
863 | if( pcSlice->getSPS()->getMFMEnabledFlag() ) |
---|
864 | { |
---|
865 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
866 | } |
---|
867 | #endif |
---|
868 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
869 | } |
---|
870 | #endif |
---|
871 | |
---|
872 | #endif //SVC_EXTENSION |
---|
873 | |
---|
874 | // For generalized B |
---|
875 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
876 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
877 | { |
---|
878 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
879 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
880 | |
---|
881 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
882 | { |
---|
883 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
884 | } |
---|
885 | } |
---|
886 | if (!pcSlice->isIntra()) |
---|
887 | { |
---|
888 | Bool bLowDelay = true; |
---|
889 | Int iCurrPOC = pcSlice->getPOC(); |
---|
890 | Int iRefIdx = 0; |
---|
891 | |
---|
892 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
893 | { |
---|
894 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
895 | { |
---|
896 | bLowDelay = false; |
---|
897 | } |
---|
898 | } |
---|
899 | if (pcSlice->isInterB()) |
---|
900 | { |
---|
901 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
902 | { |
---|
903 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
904 | { |
---|
905 | bLowDelay = false; |
---|
906 | } |
---|
907 | } |
---|
908 | } |
---|
909 | |
---|
910 | pcSlice->setCheckLDC(bLowDelay); |
---|
911 | } |
---|
912 | |
---|
913 | //--------------- |
---|
914 | pcSlice->setRefPOCList(); |
---|
915 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
916 | pcSlice->setNoBackPredFlag( false ); |
---|
917 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
918 | { |
---|
919 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
920 | { |
---|
921 | pcSlice->setNoBackPredFlag( true ); |
---|
922 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
923 | { |
---|
924 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
925 | { |
---|
926 | pcSlice->setNoBackPredFlag( false ); |
---|
927 | break; |
---|
928 | } |
---|
929 | } |
---|
930 | } |
---|
931 | } |
---|
932 | #endif |
---|
933 | } |
---|
934 | |
---|
935 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
936 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
937 | { |
---|
938 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
939 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
940 | { |
---|
941 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
942 | } |
---|
943 | pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip()); |
---|
944 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
945 | { |
---|
946 | pcSlice->setDefaultScalingList(); |
---|
947 | } |
---|
948 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
949 | m_cTrQuant.setUseScalingList(true); |
---|
950 | } |
---|
951 | else |
---|
952 | { |
---|
953 | m_cTrQuant.setFlatScalingList(); |
---|
954 | m_cTrQuant.setUseScalingList(false); |
---|
955 | } |
---|
956 | |
---|
957 | #if SIMPLIFIED_MV_POS_SCALING |
---|
958 | if (m_layerId > 0) |
---|
959 | { |
---|
960 | #if SCALED_REF_LAYER_OFFSETS |
---|
961 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(); |
---|
962 | |
---|
963 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth(); |
---|
964 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight(); |
---|
965 | |
---|
966 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
967 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
968 | #else |
---|
969 | const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
970 | const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
971 | |
---|
972 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
973 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
974 | |
---|
975 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
976 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
977 | #endif |
---|
978 | g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
979 | g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
980 | |
---|
981 | g_posScalingFactor[m_layerId][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
982 | g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
983 | } |
---|
984 | #endif |
---|
985 | |
---|
986 | // Decode a picture |
---|
987 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
988 | |
---|
989 | m_bFirstSliceInPicture = false; |
---|
990 | m_uiSliceIdx++; |
---|
991 | |
---|
992 | return false; |
---|
993 | } |
---|
994 | |
---|
995 | Void TDecTop::xDecodeVPS() |
---|
996 | { |
---|
997 | TComVPS* vps = new TComVPS(); |
---|
998 | |
---|
999 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1000 | #if SVC_EXTENSION |
---|
1001 | m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps); |
---|
1002 | #else |
---|
1003 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
1004 | #endif |
---|
1005 | } |
---|
1006 | |
---|
1007 | Void TDecTop::xDecodeSPS() |
---|
1008 | { |
---|
1009 | TComSPS* sps = new TComSPS(); |
---|
1010 | #if SVC_EXTENSION |
---|
1011 | sps->setLayerId(m_layerId); |
---|
1012 | #endif |
---|
1013 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1014 | #if SVC_EXTENSION |
---|
1015 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps); |
---|
1016 | #else |
---|
1017 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1018 | #endif |
---|
1019 | #if REF_IDX_FRAMEWORK |
---|
1020 | if(m_numLayer>0) |
---|
1021 | { |
---|
1022 | xInitILRP(sps); |
---|
1023 | } |
---|
1024 | #endif |
---|
1025 | } |
---|
1026 | |
---|
1027 | Void TDecTop::xDecodePPS() |
---|
1028 | { |
---|
1029 | TComPPS* pps = new TComPPS(); |
---|
1030 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1031 | #if SVC_EXTENSION |
---|
1032 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps ); |
---|
1033 | #else |
---|
1034 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
1035 | #endif |
---|
1036 | |
---|
1037 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
1038 | { |
---|
1039 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
1040 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
1041 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
1042 | { |
---|
1043 | TDecSbac* ctx = NULL; |
---|
1044 | ctx = new TDecSbac; |
---|
1045 | ctx->init( &m_cBinCABAC ); |
---|
1046 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
1047 | } |
---|
1048 | } |
---|
1049 | } |
---|
1050 | |
---|
1051 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
1052 | { |
---|
1053 | #if SVC_EXTENSION |
---|
1054 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1055 | { |
---|
1056 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1057 | } |
---|
1058 | else |
---|
1059 | { |
---|
1060 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
1061 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1062 | if (activeParamSets.size()>0) |
---|
1063 | { |
---|
1064 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1065 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
1066 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1067 | if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1068 | { |
---|
1069 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1070 | } |
---|
1071 | } |
---|
1072 | } |
---|
1073 | #else |
---|
1074 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1075 | { |
---|
1076 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1077 | } |
---|
1078 | else |
---|
1079 | { |
---|
1080 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1081 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1082 | if (activeParamSets.size()>0) |
---|
1083 | { |
---|
1084 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1085 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
1086 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
1087 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
1088 | { |
---|
1089 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1090 | } |
---|
1091 | } |
---|
1092 | } |
---|
1093 | #endif |
---|
1094 | } |
---|
1095 | |
---|
1096 | #if SVC_EXTENSION |
---|
1097 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
1098 | #else |
---|
1099 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1100 | #endif |
---|
1101 | { |
---|
1102 | // Initialize entropy decoder |
---|
1103 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1104 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1105 | |
---|
1106 | switch (nalu.m_nalUnitType) |
---|
1107 | { |
---|
1108 | case NAL_UNIT_VPS: |
---|
1109 | xDecodeVPS(); |
---|
1110 | #if AVC_BASE |
---|
1111 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1112 | { |
---|
1113 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
1114 | { |
---|
1115 | printf( "Base layer YUV input reading error\n" ); |
---|
1116 | exit(EXIT_FAILURE); |
---|
1117 | } |
---|
1118 | #if AVC_SYNTAX |
---|
1119 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
1120 | { |
---|
1121 | printf( "Base layer syntax input reading error\n" ); |
---|
1122 | exit(EXIT_FAILURE); |
---|
1123 | } |
---|
1124 | #endif |
---|
1125 | } |
---|
1126 | else |
---|
1127 | { |
---|
1128 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
1129 | cListPic->clear(); |
---|
1130 | } |
---|
1131 | #endif |
---|
1132 | return false; |
---|
1133 | |
---|
1134 | case NAL_UNIT_SPS: |
---|
1135 | xDecodeSPS(); |
---|
1136 | #if AVC_BASE |
---|
1137 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1138 | { |
---|
1139 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1140 | if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
1141 | { |
---|
1142 | // using EL SPS with spsId = 1 |
---|
1143 | TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1); |
---|
1144 | Int numReorderPics[MAX_TLAYER]; |
---|
1145 | Window &conformanceWindow = sps->getConformanceWindow(); |
---|
1146 | Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
1147 | #if SVC_UPSAMPLING |
---|
1148 | #if AVC_SYNTAX |
---|
1149 | |
---|
1150 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true); |
---|
1151 | #else |
---|
1152 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
1153 | #endif |
---|
1154 | #else |
---|
1155 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
1156 | #endif |
---|
1157 | } |
---|
1158 | } |
---|
1159 | #endif |
---|
1160 | return false; |
---|
1161 | |
---|
1162 | case NAL_UNIT_PPS: |
---|
1163 | xDecodePPS(); |
---|
1164 | return false; |
---|
1165 | |
---|
1166 | case NAL_UNIT_PREFIX_SEI: |
---|
1167 | case NAL_UNIT_SUFFIX_SEI: |
---|
1168 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
1169 | return false; |
---|
1170 | |
---|
1171 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1172 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1173 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
1174 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1175 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1176 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1177 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1178 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1179 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1180 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1181 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1182 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1183 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1184 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1185 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1186 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1187 | #if SVC_EXTENSION |
---|
1188 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
1189 | #else |
---|
1190 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
1191 | #endif |
---|
1192 | break; |
---|
1193 | default: |
---|
1194 | assert (1); |
---|
1195 | } |
---|
1196 | |
---|
1197 | return false; |
---|
1198 | } |
---|
1199 | |
---|
1200 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
1201 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1202 | * \returns true if the picture should be skipped |
---|
1203 | * This function skips all TFD pictures that follow a BLA picture |
---|
1204 | * in decoding order and precede it in output order. |
---|
1205 | */ |
---|
1206 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
1207 | { |
---|
1208 | 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)) |
---|
1209 | { |
---|
1210 | iPOCLastDisplay++; |
---|
1211 | return true; |
---|
1212 | } |
---|
1213 | return false; |
---|
1214 | } |
---|
1215 | |
---|
1216 | /** Function for checking if picture should be skipped because of random access |
---|
1217 | * \param iSkipFrame skip frame counter |
---|
1218 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1219 | * \returns true if the picture shold be skipped in the random access. |
---|
1220 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
1221 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
1222 | * It also checks the type of Nal unit type at the random access point. |
---|
1223 | * 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. |
---|
1224 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
1225 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
1226 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
1227 | * access point there is no guarantee that the decoder will not crash. |
---|
1228 | */ |
---|
1229 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1230 | { |
---|
1231 | if (iSkipFrame) |
---|
1232 | { |
---|
1233 | iSkipFrame--; // decrement the counter |
---|
1234 | return true; |
---|
1235 | } |
---|
1236 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
1237 | { |
---|
1238 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
1239 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1240 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1241 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
1242 | { |
---|
1243 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
1244 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
1245 | } |
---|
1246 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1247 | { |
---|
1248 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
1249 | } |
---|
1250 | else |
---|
1251 | { |
---|
1252 | static Bool warningMessage = false; |
---|
1253 | if(!warningMessage) |
---|
1254 | { |
---|
1255 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
1256 | warningMessage = true; |
---|
1257 | } |
---|
1258 | return true; |
---|
1259 | } |
---|
1260 | } |
---|
1261 | // skip the reordered pictures, if necessary |
---|
1262 | 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)) |
---|
1263 | { |
---|
1264 | iPOCLastDisplay++; |
---|
1265 | return true; |
---|
1266 | } |
---|
1267 | // if we reach here, then the picture is not skipped. |
---|
1268 | return false; |
---|
1269 | } |
---|
1270 | |
---|
1271 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
1272 | TDecTop* TDecTop::getRefLayerDec( UInt layerId ) |
---|
1273 | { |
---|
1274 | TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS(); |
---|
1275 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
1276 | { |
---|
1277 | #if ZERO_NUM_DIRECT_LAYERS |
---|
1278 | return (TDecTop *)getLayerDec( 0 ); |
---|
1279 | #else |
---|
1280 | return NULL; |
---|
1281 | #endif |
---|
1282 | } |
---|
1283 | |
---|
1284 | // currently only one reference layer is supported |
---|
1285 | assert( vps->getNumDirectRefLayers( m_layerId ) == 1 ); |
---|
1286 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1287 | assert( vps->getMaxOneActiveRefLayerFlag() == 1 ); |
---|
1288 | #endif |
---|
1289 | |
---|
1290 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, 0 ) ); |
---|
1291 | } |
---|
1292 | #endif |
---|
1293 | |
---|
1294 | //! \} |
---|