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-2012, 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 "../../App/TAppDecoder/TAppDecTop.h" |
---|
40 | #include "TDecTop.h" |
---|
41 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | |
---|
46 | CamParsCollector::CamParsCollector() |
---|
47 | : m_bInitialized( false ) |
---|
48 | { |
---|
49 | m_aaiCodedOffset = new Int* [ MAX_VIEW_NUM ]; |
---|
50 | m_aaiCodedScale = new Int* [ MAX_VIEW_NUM ]; |
---|
51 | m_aiViewOrderIndex = new Int [ MAX_VIEW_NUM ]; |
---|
52 | #if QC_MVHEVC_B0046 |
---|
53 | m_aiViewId = new Int [ MAX_VIEW_NUM ]; |
---|
54 | #endif |
---|
55 | m_aiViewReceived = new Int [ MAX_VIEW_NUM ]; |
---|
56 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
57 | { |
---|
58 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
59 | m_aaiCodedScale [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | CamParsCollector::~CamParsCollector() |
---|
64 | { |
---|
65 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
66 | { |
---|
67 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
68 | delete [] m_aaiCodedScale [ uiId ]; |
---|
69 | } |
---|
70 | delete [] m_aaiCodedOffset; |
---|
71 | delete [] m_aaiCodedScale; |
---|
72 | delete [] m_aiViewOrderIndex; |
---|
73 | delete [] m_aiViewReceived; |
---|
74 | } |
---|
75 | |
---|
76 | Void |
---|
77 | CamParsCollector::init( FILE* pCodedScaleOffsetFile ) |
---|
78 | { |
---|
79 | m_bInitialized = true; |
---|
80 | m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; |
---|
81 | m_uiCamParsCodedPrecision = 0; |
---|
82 | m_bCamParsVaryOverTime = false; |
---|
83 | m_iLastViewId = -1; |
---|
84 | m_iLastPOC = -1; |
---|
85 | m_uiMaxViewId = 0; |
---|
86 | } |
---|
87 | |
---|
88 | Void |
---|
89 | CamParsCollector::uninit() |
---|
90 | { |
---|
91 | m_bInitialized = false; |
---|
92 | } |
---|
93 | |
---|
94 | Void |
---|
95 | CamParsCollector::setSlice( TComSlice* pcSlice ) |
---|
96 | { |
---|
97 | if( pcSlice == 0 ) |
---|
98 | { |
---|
99 | AOF( xIsComplete() ); |
---|
100 | if( m_bCamParsVaryOverTime || m_iLastPOC == 0 ) |
---|
101 | { |
---|
102 | xOutput( m_iLastPOC ); |
---|
103 | } |
---|
104 | return; |
---|
105 | } |
---|
106 | |
---|
107 | AOF( pcSlice->getSPS()->getViewId() < MAX_VIEW_NUM ); |
---|
108 | if ( pcSlice->getSPS()->isDepth () ) |
---|
109 | { |
---|
110 | return; |
---|
111 | } |
---|
112 | Bool bFirstAU = ( pcSlice->getPOC() == 0 ); |
---|
113 | Bool bFirstSliceInAU = ( pcSlice->getPOC() != Int ( m_iLastPOC ) ); |
---|
114 | Bool bFirstSliceInView = ( pcSlice->getSPS()->getViewId() != UInt( m_iLastViewId ) || bFirstSliceInAU ); |
---|
115 | AOT( bFirstSliceInAU && pcSlice->getSPS()->getViewId() != 0 ); |
---|
116 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() < UInt( m_iLastViewId ) ); |
---|
117 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() > UInt( m_iLastViewId + 1 ) ); |
---|
118 | AOT( !bFirstAU && pcSlice->getSPS()->getViewId() > m_uiMaxViewId ); |
---|
119 | if ( !bFirstSliceInView ) |
---|
120 | { |
---|
121 | if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here |
---|
122 | { |
---|
123 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
124 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
125 | { |
---|
126 | AOF( m_aaiCodedScale [ uiBaseId ][ uiViewId ] == pcSlice->getCodedScale () [ uiBaseId ] ); |
---|
127 | AOF( m_aaiCodedOffset[ uiBaseId ][ uiViewId ] == pcSlice->getCodedOffset () [ uiBaseId ] ); |
---|
128 | AOF( m_aaiCodedScale [ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedScale () [ uiBaseId ] ); |
---|
129 | AOF( m_aaiCodedOffset[ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedOffset() [ uiBaseId ] ); |
---|
130 | } |
---|
131 | } |
---|
132 | return; |
---|
133 | } |
---|
134 | |
---|
135 | if( bFirstSliceInAU ) |
---|
136 | { |
---|
137 | if( !bFirstAU ) |
---|
138 | { |
---|
139 | AOF( xIsComplete() ); |
---|
140 | xOutput( m_iLastPOC ); |
---|
141 | } |
---|
142 | ::memset( m_aiViewReceived, 0x00, MAX_VIEW_NUM * sizeof( Int ) ); |
---|
143 | } |
---|
144 | |
---|
145 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
146 | m_aiViewReceived[ uiViewId ] = 1; |
---|
147 | if( bFirstAU ) |
---|
148 | { |
---|
149 | m_uiMaxViewId = Max( m_uiMaxViewId, uiViewId ); |
---|
150 | m_aiViewOrderIndex[ uiViewId ] = pcSlice->getSPS()->getViewOrderIdx(); |
---|
151 | if( uiViewId == 1 ) |
---|
152 | { |
---|
153 | m_uiCamParsCodedPrecision = pcSlice->getSPS()->getCamParPrecision (); |
---|
154 | m_bCamParsVaryOverTime = pcSlice->getSPS()->hasCamParInSliceHeader (); |
---|
155 | } |
---|
156 | else if( uiViewId > 1 ) |
---|
157 | { |
---|
158 | AOF( m_uiCamParsCodedPrecision == pcSlice->getSPS()->getCamParPrecision () ); |
---|
159 | AOF( m_bCamParsVaryOverTime == pcSlice->getSPS()->hasCamParInSliceHeader () ); |
---|
160 | } |
---|
161 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
162 | { |
---|
163 | if( m_bCamParsVaryOverTime ) |
---|
164 | { |
---|
165 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
166 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
167 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
168 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedScale () [ uiBaseId ]; |
---|
173 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedOffset () [ uiBaseId ]; |
---|
174 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ]; |
---|
175 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ]; |
---|
176 | } |
---|
177 | } |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | AOF( m_aiViewOrderIndex[ uiViewId ] == pcSlice->getSPS()->getViewOrderIdx() ); |
---|
182 | if( m_bCamParsVaryOverTime ) |
---|
183 | { |
---|
184 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
185 | { |
---|
186 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
187 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
188 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
189 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
190 | } |
---|
191 | } |
---|
192 | } |
---|
193 | m_iLastViewId = (Int)pcSlice->getSPS()->getViewId(); |
---|
194 | m_iLastPOC = (Int)pcSlice->getPOC(); |
---|
195 | } |
---|
196 | |
---|
197 | Bool |
---|
198 | CamParsCollector::xIsComplete() |
---|
199 | { |
---|
200 | for( UInt uiView = 0; uiView <= m_uiMaxViewId; uiView++ ) |
---|
201 | { |
---|
202 | if( m_aiViewReceived[ uiView ] == 0 ) |
---|
203 | { |
---|
204 | return false; |
---|
205 | } |
---|
206 | } |
---|
207 | return true; |
---|
208 | } |
---|
209 | |
---|
210 | Void |
---|
211 | CamParsCollector::xOutput( Int iPOC ) |
---|
212 | { |
---|
213 | if( m_pCodedScaleOffsetFile ) |
---|
214 | { |
---|
215 | if( iPOC == 0 ) |
---|
216 | { |
---|
217 | fprintf( m_pCodedScaleOffsetFile, "# ViewId ViewOrderIdx\n" ); |
---|
218 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" ); |
---|
219 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
220 | { |
---|
221 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewId, m_aiViewOrderIndex[ uiViewId ] ); |
---|
222 | } |
---|
223 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
224 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetView BaseView CodedScale CodedOffset Precision\n" ); |
---|
225 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
226 | } |
---|
227 | if( iPOC == 0 || m_bCamParsVaryOverTime ) |
---|
228 | { |
---|
229 | Int iS = iPOC; |
---|
230 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
231 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
232 | { |
---|
233 | for( UInt uiBaseId = 0; uiBaseId <= m_uiMaxViewId; uiBaseId++ ) |
---|
234 | { |
---|
235 | if( uiViewId != uiBaseId ) |
---|
236 | { |
---|
237 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
238 | iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision ); |
---|
239 | } |
---|
240 | } |
---|
241 | } |
---|
242 | } |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | TDecTop::TDecTop() |
---|
247 | : m_SEIs(0) |
---|
248 | , m_tAppDecTop( NULL ) |
---|
249 | , m_nalUnitTypeBaseView( NAL_UNIT_INVALID ) |
---|
250 | { |
---|
251 | m_pcPic = 0; |
---|
252 | m_iGopSize = 0; |
---|
253 | m_bGopSizeSet = false; |
---|
254 | m_iMaxRefPicNum = 0; |
---|
255 | m_uiValidPS = 0; |
---|
256 | #if SONY_COLPIC_AVAILABILITY |
---|
257 | m_iViewOrderIdx = 0; |
---|
258 | #endif |
---|
259 | #if ENC_DEC_TRACE |
---|
260 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
261 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
262 | g_nSymbolCounter = 0; |
---|
263 | #endif |
---|
264 | m_bRefreshPending = 0; |
---|
265 | m_pocCRA = 0; |
---|
266 | m_pocRandomAccess = MAX_INT; |
---|
267 | m_prevPOC = MAX_INT; |
---|
268 | m_bFirstSliceInPicture = true; |
---|
269 | m_bFirstSliceInSequence = true; |
---|
270 | m_pcCamParsCollector = 0; |
---|
271 | #if QC_MVHEVC_B0046 |
---|
272 | m_bFirstNal = false; |
---|
273 | #endif |
---|
274 | } |
---|
275 | |
---|
276 | TDecTop::~TDecTop() |
---|
277 | { |
---|
278 | #if ENC_DEC_TRACE |
---|
279 | fclose( g_hTrace ); |
---|
280 | #endif |
---|
281 | } |
---|
282 | |
---|
283 | Void TDecTop::create() |
---|
284 | { |
---|
285 | m_cGopDecoder.create(); |
---|
286 | m_apcSlicePilot = new TComSlice; |
---|
287 | m_uiSliceIdx = m_uiLastSliceIdx = 0; |
---|
288 | } |
---|
289 | |
---|
290 | Void TDecTop::destroy() |
---|
291 | { |
---|
292 | m_cGopDecoder.destroy(); |
---|
293 | |
---|
294 | delete m_apcSlicePilot; |
---|
295 | m_apcSlicePilot = NULL; |
---|
296 | |
---|
297 | m_cSliceDecoder.destroy(); |
---|
298 | m_tAppDecTop = NULL; |
---|
299 | |
---|
300 | #if DEPTH_MAP_GENERATION |
---|
301 | m_cDepthMapGenerator.destroy(); |
---|
302 | #endif |
---|
303 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
304 | m_cResidualGenerator.destroy(); |
---|
305 | #endif |
---|
306 | } |
---|
307 | |
---|
308 | Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance ) |
---|
309 | { |
---|
310 | // initialize ROM |
---|
311 | if( bFirstInstance ) |
---|
312 | { |
---|
313 | initROM(); |
---|
314 | } |
---|
315 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO |
---|
316 | #if DEPTH_MAP_GENERATION |
---|
317 | , &m_cDepthMapGenerator |
---|
318 | #endif |
---|
319 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
320 | , &m_cResidualGenerator |
---|
321 | #endif |
---|
322 | ); |
---|
323 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
324 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
325 | m_tAppDecTop = pcTAppDecTop; |
---|
326 | #if DEPTH_MAP_GENERATION |
---|
327 | #if VIDYO_VPS_INTEGRATION |
---|
328 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getVPSAccess(), m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
329 | #else |
---|
330 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
331 | #endif |
---|
332 | #endif |
---|
333 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
334 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
335 | #endif |
---|
336 | } |
---|
337 | |
---|
338 | Void TDecTop::deletePicBuffer ( ) |
---|
339 | { |
---|
340 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
341 | Int iSize = Int( m_cListPic.size() ); |
---|
342 | |
---|
343 | for (Int i = 0; i < iSize; i++ ) |
---|
344 | { |
---|
345 | if( *iterPic ) |
---|
346 | { |
---|
347 | TComPic* pcPic = *(iterPic++); |
---|
348 | pcPic->destroy(); |
---|
349 | |
---|
350 | delete pcPic; |
---|
351 | pcPic = NULL; |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | // destroy ALF temporary buffers |
---|
356 | m_cAdaptiveLoopFilter.destroy(); |
---|
357 | |
---|
358 | m_cSAO.destroy(); |
---|
359 | |
---|
360 | m_cLoopFilter. destroy(); |
---|
361 | |
---|
362 | // destroy ROM |
---|
363 | if(m_viewId == 0 && m_isDepth == false) |
---|
364 | { |
---|
365 | destroyROM(); |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
370 | Void |
---|
371 | TDecTop::deleteExtraPicBuffers( Int iPoc ) |
---|
372 | { |
---|
373 | TComPic* pcPic = 0; |
---|
374 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
375 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
376 | for( ; cIter != cEnd; cIter++ ) |
---|
377 | { |
---|
378 | if( (*cIter)->getPOC() == iPoc ) |
---|
379 | { |
---|
380 | pcPic = *cIter; |
---|
381 | break; |
---|
382 | } |
---|
383 | } |
---|
384 | //AOF( pcPic ); |
---|
385 | if ( pcPic ) |
---|
386 | { |
---|
387 | pcPic->removeResidualBuffer (); |
---|
388 | } |
---|
389 | } |
---|
390 | #endif |
---|
391 | |
---|
392 | |
---|
393 | Void |
---|
394 | TDecTop::compressMotion( Int iPoc ) |
---|
395 | { |
---|
396 | TComPic* pcPic = 0; |
---|
397 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
398 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
399 | for( ; cIter != cEnd; cIter++ ) |
---|
400 | { |
---|
401 | if( (*cIter)->getPOC() == iPoc ) |
---|
402 | { |
---|
403 | pcPic = *cIter; |
---|
404 | break; |
---|
405 | } |
---|
406 | } |
---|
407 | // AOF( pcPic ); |
---|
408 | if ( pcPic ) |
---|
409 | { |
---|
410 | pcPic->compressMotion(); |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | Void TDecTop::xUpdateGopSize (TComSlice* pcSlice) |
---|
415 | { |
---|
416 | if ( !pcSlice->isIntra() && !m_bGopSizeSet) |
---|
417 | { |
---|
418 | m_iGopSize = pcSlice->getPOC(); |
---|
419 | m_bGopSizeSet = true; |
---|
420 | |
---|
421 | m_cGopDecoder.setGopSize(m_iGopSize); |
---|
422 | } |
---|
423 | } |
---|
424 | |
---|
425 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
426 | { |
---|
427 | xUpdateGopSize(pcSlice); |
---|
428 | |
---|
429 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
430 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded |
---|
431 | #else |
---|
432 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxNumberOfReferencePictures()+pcSlice->getSPS()->getNumReorderFrames() + 1; // +1 to have space for the picture currently being decoded |
---|
433 | #endif |
---|
434 | |
---|
435 | #if DEPTH_MAP_GENERATION |
---|
436 | UInt uiPdm = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
437 | Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 ); |
---|
438 | #endif |
---|
439 | |
---|
440 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
441 | { |
---|
442 | rpcPic = new TComPic(); |
---|
443 | |
---|
444 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
445 | |
---|
446 | #if DEPTH_MAP_GENERATION |
---|
447 | if( bNeedPrdDepthMapBuffer ) |
---|
448 | { |
---|
449 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
450 | } |
---|
451 | #endif |
---|
452 | |
---|
453 | m_cListPic.pushBack( rpcPic ); |
---|
454 | |
---|
455 | return; |
---|
456 | } |
---|
457 | |
---|
458 | Bool bBufferIsAvailable = false; |
---|
459 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
460 | while (iterPic != m_cListPic.end()) |
---|
461 | { |
---|
462 | rpcPic = *(iterPic++); |
---|
463 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
464 | { |
---|
465 | rpcPic->setOutputMark(false); |
---|
466 | bBufferIsAvailable = true; |
---|
467 | break; |
---|
468 | } |
---|
469 | |
---|
470 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
471 | { |
---|
472 | rpcPic->setOutputMark(false); |
---|
473 | rpcPic->setReconMark( false ); |
---|
474 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
475 | bBufferIsAvailable = true; |
---|
476 | break; |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | if ( !bBufferIsAvailable ) |
---|
481 | { |
---|
482 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
483 | m_iMaxRefPicNum++; |
---|
484 | rpcPic = new TComPic(); |
---|
485 | m_cListPic.pushBack( rpcPic ); |
---|
486 | } |
---|
487 | rpcPic->destroy(); |
---|
488 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
489 | #if DEPTH_MAP_GENERATION |
---|
490 | if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() ) |
---|
491 | { |
---|
492 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
493 | } |
---|
494 | #endif |
---|
495 | } |
---|
496 | |
---|
497 | Void TDecTop::executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
498 | { |
---|
499 | if (!m_pcPic) |
---|
500 | { |
---|
501 | /* nothing to deblock */ |
---|
502 | return; |
---|
503 | } |
---|
504 | |
---|
505 | TComPic*& pcPic = m_pcPic; |
---|
506 | |
---|
507 | // Execute Deblock and ALF only + Cleanup |
---|
508 | |
---|
509 | m_cGopDecoder.decompressGop(NULL, pcPic, true); |
---|
510 | |
---|
511 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
512 | ruiPOC = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
513 | rpcListPic = &m_cListPic; |
---|
514 | m_cCuDecoder.destroy(); |
---|
515 | m_bFirstSliceInPicture = true; |
---|
516 | |
---|
517 | return; |
---|
518 | } |
---|
519 | |
---|
520 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
521 | { |
---|
522 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
523 | TComSlice cFillSlice; |
---|
524 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
525 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
526 | cFillSlice.initSlice(); |
---|
527 | cFillSlice.initTiles(); |
---|
528 | TComPic *cFillPic; |
---|
529 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
530 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
531 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
532 | cFillPic->getSlice(0)->initSlice(); |
---|
533 | cFillPic->getSlice(0)->initTiles(); |
---|
534 | |
---|
535 | |
---|
536 | |
---|
537 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
538 | Int closestPoc = 1000000; |
---|
539 | while ( iterPic != m_cListPic.end()) |
---|
540 | { |
---|
541 | TComPic * rpcPic = *(iterPic++); |
---|
542 | 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()) |
---|
543 | { |
---|
544 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
545 | } |
---|
546 | } |
---|
547 | iterPic = m_cListPic.begin(); |
---|
548 | while ( iterPic != m_cListPic.end()) |
---|
549 | { |
---|
550 | TComPic *rpcPic = *(iterPic++); |
---|
551 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
552 | { |
---|
553 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
554 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
555 | break; |
---|
556 | } |
---|
557 | } |
---|
558 | cFillPic->setCurrSliceIdx(0); |
---|
559 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
560 | { |
---|
561 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
562 | } |
---|
563 | cFillPic->getSlice(0)->setReferenced(true); |
---|
564 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
565 | cFillPic->setReconMark(true); |
---|
566 | cFillPic->setOutputMark(true); |
---|
567 | if(m_pocRandomAccess == MAX_INT) |
---|
568 | { |
---|
569 | m_pocRandomAccess = iLostPoc; |
---|
570 | } |
---|
571 | } |
---|
572 | |
---|
573 | |
---|
574 | Void TDecTop::xActivateParameterSets() |
---|
575 | { |
---|
576 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
577 | |
---|
578 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
579 | assert (pps != 0); |
---|
580 | |
---|
581 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
582 | assert (sps != 0); |
---|
583 | #if VIDYO_VPS_INTEGRATION |
---|
584 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
585 | assert (vps != 0); |
---|
586 | #if !QC_REM_IDV_B0046 |
---|
587 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
588 | #else |
---|
589 | if( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && !sps->getViewId() ) |
---|
590 | #endif |
---|
591 | // VPS can only be activated on IDR or CRA... |
---|
592 | getTAppDecTop()->getVPSAccess()->setActiveVPSId( sps->getVPSId() ); |
---|
593 | #endif |
---|
594 | m_apcSlicePilot->setPPS(pps); |
---|
595 | m_apcSlicePilot->setSPS(sps); |
---|
596 | #if QC_MVHEVC_B0046 |
---|
597 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
598 | #endif |
---|
599 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
600 | m_apcSlicePilot->setVPS(vps); |
---|
601 | #endif |
---|
602 | pps->setSPS(sps); |
---|
603 | |
---|
604 | if(sps->getUseSAO() || sps->getUseALF()|| sps->getScalingListFlag() || sps->getUseDF()) |
---|
605 | { |
---|
606 | m_apcSlicePilot->setAPS( m_parameterSetManagerDecoder.getAPS(m_apcSlicePilot->getAPSId()) ); |
---|
607 | } |
---|
608 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
609 | |
---|
610 | for (Int i = 0; i < sps->getMaxCUDepth() - 1; i++) |
---|
611 | { |
---|
612 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
613 | } |
---|
614 | |
---|
615 | for (Int i = sps->getMaxCUDepth() - 1; i < sps->getMaxCUDepth(); i++) |
---|
616 | { |
---|
617 | sps->setAMPAcc( i, 0 ); |
---|
618 | } |
---|
619 | |
---|
620 | #if !LCU_SYNTAX_ALF |
---|
621 | // create ALF temporary buffer |
---|
622 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
623 | #endif |
---|
624 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
625 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
626 | } |
---|
627 | |
---|
628 | #if SKIPFRAME_BUGFIX |
---|
629 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
630 | #else |
---|
631 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay ) |
---|
632 | #endif |
---|
633 | { |
---|
634 | TComPic*& pcPic = m_pcPic; |
---|
635 | m_apcSlicePilot->initSlice(); |
---|
636 | |
---|
637 | //!!!KS: DIRTY HACK |
---|
638 | m_apcSlicePilot->setPPSId(0); |
---|
639 | m_apcSlicePilot->setPPS(m_parameterSetManagerDecoder.getPrefetchedPPS(0)); |
---|
640 | m_apcSlicePilot->setSPS(m_parameterSetManagerDecoder.getPrefetchedSPS(0)); |
---|
641 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
642 | #if QC_MVHEVC_B0046 |
---|
643 | m_apcSlicePilot->setIsDepth(false); |
---|
644 | #endif |
---|
645 | m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0)); |
---|
646 | #endif |
---|
647 | m_apcSlicePilot->initTiles(); |
---|
648 | #if QC_MVHEVC_B0046 |
---|
649 | m_apcSlicePilot->setViewId( nalu.m_layerId ); |
---|
650 | m_apcSlicePilot->setViewId( nalu.m_layerId ); |
---|
651 | m_apcSlicePilot->setViewOrderIdx(m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId), nalu.m_layerId); |
---|
652 | Int iNumDirectRef = m_apcSlicePilot->getVPS()->getNumDirectRefLayer(nalu.m_layerId); |
---|
653 | m_apcSlicePilot->getSPS()->setNumberOfUsableInterViewRefs(iNumDirectRef); |
---|
654 | for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++) |
---|
655 | { |
---|
656 | Int iDeltaLayerId = m_apcSlicePilot->getVPS()->getDirectRefLayerId( nalu.m_layerId, iNumIvRef); |
---|
657 | m_apcSlicePilot->getSPS()->setUsableInterViewRef(iNumIvRef, (iDeltaLayerId-nalu.m_layerId)); |
---|
658 | } |
---|
659 | #endif |
---|
660 | if (m_bFirstSliceInPicture) |
---|
661 | { |
---|
662 | m_uiSliceIdx = 0; |
---|
663 | m_uiLastSliceIdx = 0; |
---|
664 | } |
---|
665 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
666 | if (!m_bFirstSliceInPicture) |
---|
667 | { |
---|
668 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
669 | } |
---|
670 | |
---|
671 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
672 | if( m_bFirstSliceInPicture ) |
---|
673 | { |
---|
674 | #if QC_MVHEVC_B0046 |
---|
675 | if( nalu.m_layerId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
676 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, 0 )->getNalUnitTypeBaseView(); } |
---|
677 | #else |
---|
678 | #if VIDYO_VPS_INTEGRATION |
---|
679 | if( m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId) == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
680 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId) )->getNalUnitTypeBaseView(); } |
---|
681 | #else |
---|
682 | if( nalu.m_viewId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
683 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); } |
---|
684 | #endif |
---|
685 | #endif |
---|
686 | m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView ); |
---|
687 | } |
---|
688 | |
---|
689 | #if SONY_COLPIC_AVAILABILITY |
---|
690 | m_apcSlicePilot->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx()); |
---|
691 | #endif |
---|
692 | |
---|
693 | #if NAL_REF_FLAG |
---|
694 | m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag); |
---|
695 | #else |
---|
696 | m_apcSlicePilot->setReferenced(nalu.m_nalRefIDC != NAL_REF_IDC_PRIORITY_LOWEST); |
---|
697 | #endif |
---|
698 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
699 | |
---|
700 | // ALF CU parameters should be part of the slice header -> needs to be fixed |
---|
701 | #if LCU_SYNTAX_ALF |
---|
702 | #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
703 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet(),m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId)); |
---|
704 | #else |
---|
705 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet()); |
---|
706 | #endif |
---|
707 | #else |
---|
708 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam() ); |
---|
709 | #endif |
---|
710 | // byte align |
---|
711 | { |
---|
712 | Int numBitsForByteAlignment = nalu.m_Bitstream->getNumBitsUntilByteAligned(); |
---|
713 | if ( numBitsForByteAlignment > 0 ) |
---|
714 | { |
---|
715 | UInt bitsForByteAlignment; |
---|
716 | nalu.m_Bitstream->read( numBitsForByteAlignment, bitsForByteAlignment ); |
---|
717 | assert( bitsForByteAlignment == ( ( 1 << numBitsForByteAlignment ) - 1 ) ); |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | // exit when a new picture is found |
---|
722 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence) |
---|
723 | { |
---|
724 | #if START_DECODING_AT_CRA |
---|
725 | if (m_prevPOC >= m_pocRandomAccess) |
---|
726 | { |
---|
727 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
728 | return true; |
---|
729 | } |
---|
730 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
731 | #else |
---|
732 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
733 | return true; |
---|
734 | #endif |
---|
735 | } |
---|
736 | // actual decoding starts here |
---|
737 | xActivateParameterSets(); |
---|
738 | m_apcSlicePilot->initTiles(); |
---|
739 | |
---|
740 | if (m_apcSlicePilot->isNextSlice()) |
---|
741 | { |
---|
742 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
743 | } |
---|
744 | m_bFirstSliceInSequence = false; |
---|
745 | if (m_apcSlicePilot->isNextSlice()) |
---|
746 | { |
---|
747 | // Skip pictures due to random access |
---|
748 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
749 | { |
---|
750 | return false; |
---|
751 | } |
---|
752 | } |
---|
753 | //detect lost reference picture and insert copy of earlier frame. |
---|
754 | #if START_DECODING_AT_CRA |
---|
755 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess) > 0) |
---|
756 | #else |
---|
757 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true) > 0) |
---|
758 | #endif |
---|
759 | { |
---|
760 | xCreateLostPicture(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), false)-1); |
---|
761 | } |
---|
762 | if (m_bFirstSliceInPicture) |
---|
763 | { |
---|
764 | // Buffer initialize for prediction. |
---|
765 | m_cPrediction.initTempBuff(); |
---|
766 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
767 | // Get a new picture buffer |
---|
768 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
769 | |
---|
770 | #if SONY_COLPIC_AVAILABILITY |
---|
771 | pcPic->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx() ); |
---|
772 | #endif |
---|
773 | |
---|
774 | /* transfer any SEI messages that have been received to the picture */ |
---|
775 | pcPic->setSEIs(m_SEIs); |
---|
776 | m_SEIs = NULL; |
---|
777 | |
---|
778 | // Recursive structure |
---|
779 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
780 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
781 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
782 | |
---|
783 | m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
784 | #if DEPTH_MAP_GENERATION |
---|
785 | UInt uiPdm = ( m_apcSlicePilot->getSPS()->getViewId() ? m_apcSlicePilot->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
786 | m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
787 | TComDepthMapGenerator* pcDMG0 = m_tAppDecTop->getDecTop0()->getDepthMapGenerator(); |
---|
788 | if( m_apcSlicePilot->getSPS()->getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) ) |
---|
789 | { |
---|
790 | pcDMG0->create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
791 | } |
---|
792 | #endif |
---|
793 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
794 | m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
795 | #endif |
---|
796 | } |
---|
797 | |
---|
798 | // Set picture slice pointer |
---|
799 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
800 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
801 | |
---|
802 | UInt uiCummulativeTileWidth; |
---|
803 | UInt uiCummulativeTileHeight; |
---|
804 | UInt i, j, p; |
---|
805 | |
---|
806 | #if !REMOVE_TILE_DEPENDENCE |
---|
807 | //set the TileBoundaryIndependenceIdr |
---|
808 | if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1) |
---|
809 | { |
---|
810 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() ); |
---|
811 | } |
---|
812 | else |
---|
813 | { |
---|
814 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() ); |
---|
815 | } |
---|
816 | #endif |
---|
817 | |
---|
818 | if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 ) |
---|
819 | { |
---|
820 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
821 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
822 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
823 | |
---|
824 | //create the TComTileArray |
---|
825 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
826 | |
---|
827 | if( pcSlice->getPPS()->getUniformSpacingIdr() == 1) |
---|
828 | { |
---|
829 | //set the width for each tile |
---|
830 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
831 | { |
---|
832 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
833 | { |
---|
834 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
835 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
836 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
837 | } |
---|
838 | } |
---|
839 | |
---|
840 | //set the height for each tile |
---|
841 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
842 | { |
---|
843 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
844 | { |
---|
845 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
846 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
847 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
848 | } |
---|
849 | } |
---|
850 | } |
---|
851 | else |
---|
852 | { |
---|
853 | //set the width for each tile |
---|
854 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
855 | { |
---|
856 | uiCummulativeTileWidth = 0; |
---|
857 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
858 | { |
---|
859 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
860 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
861 | } |
---|
862 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
863 | } |
---|
864 | |
---|
865 | //set the height for each tile |
---|
866 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
867 | { |
---|
868 | uiCummulativeTileHeight = 0; |
---|
869 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
870 | { |
---|
871 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
872 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
873 | } |
---|
874 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
875 | } |
---|
876 | } |
---|
877 | } |
---|
878 | else |
---|
879 | { |
---|
880 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
881 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() ); |
---|
882 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() ); |
---|
883 | |
---|
884 | //create the TComTileArray |
---|
885 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
886 | |
---|
887 | //automatically set the column and row boundary if UniformSpacingIdr = 1 |
---|
888 | if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 ) |
---|
889 | { |
---|
890 | //set the width for each tile |
---|
891 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
892 | { |
---|
893 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
894 | { |
---|
895 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
896 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
897 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
898 | } |
---|
899 | } |
---|
900 | |
---|
901 | //set the height for each tile |
---|
902 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
903 | { |
---|
904 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
905 | { |
---|
906 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
907 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
908 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
909 | } |
---|
910 | } |
---|
911 | } |
---|
912 | else |
---|
913 | { |
---|
914 | //set the width for each tile |
---|
915 | for(j=0; j < pcSlice->getSPS()->getNumRowsMinus1()+1; j++) |
---|
916 | { |
---|
917 | uiCummulativeTileWidth = 0; |
---|
918 | for(i=0; i < pcSlice->getSPS()->getNumColumnsMinus1(); i++) |
---|
919 | { |
---|
920 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getSPS()->getColumnWidth(i) ); |
---|
921 | uiCummulativeTileWidth += pcSlice->getSPS()->getColumnWidth(i); |
---|
922 | } |
---|
923 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
924 | } |
---|
925 | |
---|
926 | //set the height for each tile |
---|
927 | for(j=0; j < pcSlice->getSPS()->getNumColumnsMinus1()+1; j++) |
---|
928 | { |
---|
929 | uiCummulativeTileHeight = 0; |
---|
930 | for(i=0; i < pcSlice->getSPS()->getNumRowsMinus1(); i++) |
---|
931 | { |
---|
932 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getSPS()->getRowHeight(i) ); |
---|
933 | uiCummulativeTileHeight += pcSlice->getSPS()->getRowHeight(i); |
---|
934 | } |
---|
935 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
936 | } |
---|
937 | } |
---|
938 | } |
---|
939 | |
---|
940 | pcPic->getPicSym()->xInitTiles(); |
---|
941 | |
---|
942 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
943 | UInt uiEncCUAddr; |
---|
944 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
945 | { |
---|
946 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
947 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
948 | } |
---|
949 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
950 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
951 | |
---|
952 | //convert the start and end CU addresses of the slice and entropy slice into encoding order |
---|
953 | pcSlice->setEntropySliceCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurStartCUAddr()) ); |
---|
954 | pcSlice->setEntropySliceCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurEndCUAddr()) ); |
---|
955 | if(pcSlice->isNextSlice()) |
---|
956 | { |
---|
957 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
958 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
959 | } |
---|
960 | |
---|
961 | if (m_bFirstSliceInPicture) |
---|
962 | { |
---|
963 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
964 | { |
---|
965 | pcPic->clearSliceBuffer(); |
---|
966 | } |
---|
967 | } |
---|
968 | else |
---|
969 | { |
---|
970 | pcPic->allocateNewSlice(); |
---|
971 | } |
---|
972 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
973 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
974 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
975 | |
---|
976 | pcPic->setTLayer(nalu.m_temporalId); |
---|
977 | |
---|
978 | if (bNextSlice) |
---|
979 | { |
---|
980 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_cListPic); |
---|
981 | |
---|
982 | if ( !pcSlice->getPPS()->getEnableTMVPFlag() && pcPic->getTLayer() == 0 ) |
---|
983 | { |
---|
984 | pcSlice->decodingMarkingForNoTMVP( m_cListPic, pcSlice->getPOC() ); |
---|
985 | } |
---|
986 | |
---|
987 | // Set reference list |
---|
988 | #if !QC_MVHEVC_B0046 |
---|
989 | #if VIDYO_VPS_INTEGRATION |
---|
990 | pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) ); |
---|
991 | pcSlice->setIsDepth( pcSlice->getVPS()->getDepthFlag(nalu.m_layerId) ); |
---|
992 | #else |
---|
993 | pcSlice->setViewId(m_viewId); |
---|
994 | pcSlice->setIsDepth(m_isDepth); |
---|
995 | #endif |
---|
996 | #endif |
---|
997 | |
---|
998 | #if SONY_COLPIC_AVAILABILITY |
---|
999 | #if VIDYO_VPS_INTEGRATION |
---|
1000 | pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) ); |
---|
1001 | #else |
---|
1002 | pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() ); |
---|
1003 | #endif |
---|
1004 | #endif |
---|
1005 | |
---|
1006 | assert( m_tAppDecTop != NULL ); |
---|
1007 | TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView( m_viewId, pcSlice->getPOC(), false ) : NULL; |
---|
1008 | |
---|
1009 | #if FLEX_CODING_ORDER_M23723 |
---|
1010 | if (pcTexturePic != NULL) |
---|
1011 | { |
---|
1012 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
1013 | pcSlice->setTexturePic( pcTexturePic ); |
---|
1014 | } |
---|
1015 | #else |
---|
1016 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
1017 | pcSlice->setTexturePic( pcTexturePic ); |
---|
1018 | #endif |
---|
1019 | |
---|
1020 | |
---|
1021 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
1022 | pcSlice->setRefPicListMvc( m_cListPic, apcInterViewRefPics ); |
---|
1023 | |
---|
1024 | // For generalized B |
---|
1025 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1026 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1027 | { |
---|
1028 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1029 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1030 | |
---|
1031 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1032 | { |
---|
1033 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1034 | } |
---|
1035 | } |
---|
1036 | if (pcSlice->isInterB()) |
---|
1037 | { |
---|
1038 | Bool bLowDelay = true; |
---|
1039 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1040 | Int iRefIdx = 0; |
---|
1041 | |
---|
1042 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1043 | { |
---|
1044 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1045 | { |
---|
1046 | bLowDelay = false; |
---|
1047 | } |
---|
1048 | } |
---|
1049 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1050 | { |
---|
1051 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1052 | { |
---|
1053 | bLowDelay = false; |
---|
1054 | } |
---|
1055 | } |
---|
1056 | |
---|
1057 | pcSlice->setCheckLDC(bLowDelay); |
---|
1058 | } |
---|
1059 | |
---|
1060 | //--------------- |
---|
1061 | pcSlice->setRefPOCnViewListsMvc(); |
---|
1062 | |
---|
1063 | if(!pcSlice->getRefPicListModificationFlagLC()) |
---|
1064 | { |
---|
1065 | pcSlice->generateCombinedList(); |
---|
1066 | } |
---|
1067 | |
---|
1068 | if( pcSlice->getRefPicListCombinationFlag() && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE ) |
---|
1069 | { |
---|
1070 | pcSlice->setWpParamforLC(); |
---|
1071 | } |
---|
1072 | pcSlice->setNoBackPredFlag( false ); |
---|
1073 | if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) |
---|
1074 | { |
---|
1075 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
1076 | { |
---|
1077 | pcSlice->setNoBackPredFlag( true ); |
---|
1078 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
1079 | { |
---|
1080 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
1081 | { |
---|
1082 | pcSlice->setNoBackPredFlag( false ); |
---|
1083 | break; |
---|
1084 | } |
---|
1085 | } |
---|
1086 | } |
---|
1087 | } |
---|
1088 | } |
---|
1089 | |
---|
1090 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1091 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1092 | { |
---|
1093 | if(pcSlice->getAPS()->getScalingListEnabled()) |
---|
1094 | { |
---|
1095 | pcSlice->setScalingList ( pcSlice->getAPS()->getScalingList() ); |
---|
1096 | if(pcSlice->getScalingList()->getScalingListPresentFlag()) |
---|
1097 | { |
---|
1098 | pcSlice->setDefaultScalingList(); |
---|
1099 | } |
---|
1100 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
1101 | } |
---|
1102 | m_cTrQuant.setUseScalingList(true); |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | m_cTrQuant.setFlatScalingList(); |
---|
1107 | m_cTrQuant.setUseScalingList(false); |
---|
1108 | } |
---|
1109 | |
---|
1110 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1111 | if( m_parameterSetManagerDecoder.getPrefetchedSPS(0)->getUseDMM() && g_aacWedgeLists.empty() ) |
---|
1112 | { |
---|
1113 | initWedgeLists(); |
---|
1114 | } |
---|
1115 | #endif |
---|
1116 | |
---|
1117 | // Decode a picture |
---|
1118 | m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false); |
---|
1119 | |
---|
1120 | #if QC_IV_AS_LT_B0046 |
---|
1121 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
1122 | for( Int k = 0; k < apcInterViewRefPics.size(); k++ ) |
---|
1123 | { |
---|
1124 | TComPic* pcPicIv = apcInterViewRefPics[k]; |
---|
1125 | pcPicIv->setIsLongTerm( 0 ); |
---|
1126 | } |
---|
1127 | #endif |
---|
1128 | if( m_pcCamParsCollector ) |
---|
1129 | { |
---|
1130 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
1131 | } |
---|
1132 | |
---|
1133 | m_bFirstSliceInPicture = false; |
---|
1134 | m_uiSliceIdx++; |
---|
1135 | |
---|
1136 | return false; |
---|
1137 | } |
---|
1138 | |
---|
1139 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
1140 | Void TDecTop::xDecodeVPS() |
---|
1141 | { |
---|
1142 | TComVPS* vps = new TComVPS(); |
---|
1143 | |
---|
1144 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1145 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
1146 | #if !QC_MVHEVC_B0046 |
---|
1147 | getTAppDecTop()->getVPSAccess()->addVPS( vps ); |
---|
1148 | #endif |
---|
1149 | } |
---|
1150 | #endif |
---|
1151 | |
---|
1152 | Void TDecTop::xDecodeSPS() |
---|
1153 | { |
---|
1154 | TComSPS* sps = new TComSPS(); |
---|
1155 | #if RPS_IN_SPS |
---|
1156 | TComRPSList* rps = new TComRPSList(); |
---|
1157 | sps->setRPSList(rps); |
---|
1158 | #endif |
---|
1159 | #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 |
---|
1160 | m_cEntropyDecoder.decodeSPS( sps, m_isDepth ); |
---|
1161 | #else |
---|
1162 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1163 | #endif |
---|
1164 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1165 | #if LCU_SYNTAX_ALF |
---|
1166 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
1167 | #endif |
---|
1168 | } |
---|
1169 | |
---|
1170 | Void TDecTop::xDecodePPS() |
---|
1171 | { |
---|
1172 | #if !RPS_IN_SPS |
---|
1173 | TComRPSList* rps = new TComRPSList(); |
---|
1174 | #endif |
---|
1175 | TComPPS* pps = new TComPPS(); |
---|
1176 | #if !RPS_IN_SPS |
---|
1177 | pps->setRPSList(rps); |
---|
1178 | #endif |
---|
1179 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
1180 | m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder ); |
---|
1181 | #else |
---|
1182 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1183 | #endif |
---|
1184 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
1185 | |
---|
1186 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
1187 | m_apcSlicePilot->setPPSId(pps->getPPSId()); |
---|
1188 | xActivateParameterSets(); |
---|
1189 | m_apcSlicePilot->initTiles(); |
---|
1190 | } |
---|
1191 | |
---|
1192 | Void TDecTop::xDecodeAPS() |
---|
1193 | { |
---|
1194 | TComAPS *aps = new TComAPS(); |
---|
1195 | allocAPS (aps); |
---|
1196 | decodeAPS(aps); |
---|
1197 | m_parameterSetManagerDecoder.storePrefetchedAPS(aps); |
---|
1198 | } |
---|
1199 | |
---|
1200 | Void TDecTop::xDecodeSEI() |
---|
1201 | { |
---|
1202 | m_SEIs = new SEImessages; |
---|
1203 | m_cEntropyDecoder.decodeSEI(*m_SEIs); |
---|
1204 | } |
---|
1205 | |
---|
1206 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1207 | { |
---|
1208 | // Initialize entropy decoder |
---|
1209 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1210 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1211 | |
---|
1212 | switch (nalu.m_nalUnitType) |
---|
1213 | { |
---|
1214 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
1215 | case NAL_UNIT_VPS: |
---|
1216 | xDecodeVPS(); |
---|
1217 | return false; |
---|
1218 | #endif |
---|
1219 | case NAL_UNIT_SPS: |
---|
1220 | xDecodeSPS(); |
---|
1221 | return false; |
---|
1222 | |
---|
1223 | case NAL_UNIT_PPS: |
---|
1224 | xDecodePPS(); |
---|
1225 | return false; |
---|
1226 | case NAL_UNIT_APS: |
---|
1227 | xDecodeAPS(); |
---|
1228 | return false; |
---|
1229 | |
---|
1230 | case NAL_UNIT_SEI: |
---|
1231 | xDecodeSEI(); |
---|
1232 | return false; |
---|
1233 | |
---|
1234 | case NAL_UNIT_CODED_SLICE: |
---|
1235 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
1236 | #if H0566_TLA |
---|
1237 | #if !QC_REM_IDV_B0046 |
---|
1238 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
1239 | #endif |
---|
1240 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1241 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
1242 | #else |
---|
1243 | case NAL_UNIT_CODED_SLICE_CDR: |
---|
1244 | #endif |
---|
1245 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
1246 | break; |
---|
1247 | default: |
---|
1248 | assert (1); |
---|
1249 | } |
---|
1250 | |
---|
1251 | return false; |
---|
1252 | } |
---|
1253 | |
---|
1254 | #if QC_MVHEVC_B0046 |
---|
1255 | Void TDecTop::xCopyVPS( TComVPS* pVPSV0 ) |
---|
1256 | { |
---|
1257 | m_parameterSetManagerDecoder.storePrefetchedVPS(pVPSV0); |
---|
1258 | } |
---|
1259 | |
---|
1260 | Void TDecTop::xCopySPS( TComSPS* pSPSV0 ) |
---|
1261 | { |
---|
1262 | TComSPS* sps = new TComSPS(); |
---|
1263 | sps = pSPSV0; |
---|
1264 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1265 | #if LCU_SYNTAX_ALF |
---|
1266 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
1267 | #endif |
---|
1268 | } |
---|
1269 | |
---|
1270 | Void TDecTop::xCopyPPS(TComPPS* pPPSV0 ) |
---|
1271 | { |
---|
1272 | m_parameterSetManagerDecoder.storePrefetchedPPS( pPPSV0 ); |
---|
1273 | |
---|
1274 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
1275 | m_apcSlicePilot->setPPSId(pPPSV0->getPPSId()); |
---|
1276 | xActivateParameterSets(); |
---|
1277 | m_apcSlicePilot->initTiles(); |
---|
1278 | } |
---|
1279 | #endif |
---|
1280 | /** Function for checking if picture should be skipped because of random access |
---|
1281 | * \param iSkipFrame skip frame counter |
---|
1282 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1283 | * \returns true if the picture shold be skipped in the random access. |
---|
1284 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
1285 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
1286 | * It also checks the type of Nal unit type at the random access point. |
---|
1287 | * If the random access point is CRA, pictures with POC equal to or greater than the CRA POC are decoded. |
---|
1288 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
1289 | * If the random access point is not IDR or CRA, a warning is issues, and decoding of pictures with POC |
---|
1290 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA random |
---|
1291 | * access point there is no guarantee that the decoder will not crash. |
---|
1292 | */ |
---|
1293 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1294 | { |
---|
1295 | if (iSkipFrame) |
---|
1296 | { |
---|
1297 | iSkipFrame--; // decrement the counter |
---|
1298 | return true; |
---|
1299 | } |
---|
1300 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
1301 | { |
---|
1302 | #if H0566_TLA |
---|
1303 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
1304 | #else |
---|
1305 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) |
---|
1306 | #endif |
---|
1307 | { |
---|
1308 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CRA. |
---|
1309 | } |
---|
1310 | else if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR ) |
---|
1311 | { |
---|
1312 | m_pocRandomAccess = 0; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
1313 | } |
---|
1314 | else |
---|
1315 | { |
---|
1316 | #if START_DECODING_AT_CRA |
---|
1317 | static bool warningMessage = false; |
---|
1318 | if(!warningMessage) |
---|
1319 | { |
---|
1320 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
1321 | warningMessage = true; |
---|
1322 | } |
---|
1323 | return true; |
---|
1324 | #else |
---|
1325 | printf("\nUnsafe random access point. Decoder may crash."); |
---|
1326 | m_pocRandomAccess = 0; |
---|
1327 | #endif |
---|
1328 | } |
---|
1329 | } |
---|
1330 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess) // skip the reordered pictures if necessary |
---|
1331 | { |
---|
1332 | iPOCLastDisplay++; |
---|
1333 | return true; |
---|
1334 | } |
---|
1335 | // if we reach here, then the picture is not skipped. |
---|
1336 | return false; |
---|
1337 | } |
---|
1338 | |
---|
1339 | Void TDecTop::allocAPS (TComAPS* pAPS) |
---|
1340 | { |
---|
1341 | // we don't know the SPS before it has been activated. These fields could exist |
---|
1342 | // depending on the corresponding flags in the APS, but SAO/ALF allocation functions will |
---|
1343 | // have to be moved for that |
---|
1344 | pAPS->createScalingList(); |
---|
1345 | pAPS->createSaoParam(); |
---|
1346 | m_cSAO.allocSaoParam(pAPS->getSaoParam()); |
---|
1347 | pAPS->createAlfParam(); |
---|
1348 | #if !LCU_SYNTAX_ALF |
---|
1349 | m_cAdaptiveLoopFilter.allocALFParam(pAPS->getAlfParam()); |
---|
1350 | #endif |
---|
1351 | } |
---|
1352 | |
---|
1353 | //! \} |
---|