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