[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "NALread.h" |
---|
[2] | 39 | #include "../../App/TAppDecoder/TAppDecTop.h" |
---|
| 40 | #include "TDecTop.h" |
---|
| 41 | |
---|
[56] | 42 | //! \ingroup TLibDecoder |
---|
| 43 | //! \{ |
---|
[2] | 44 | |
---|
| 45 | |
---|
| 46 | CamParsCollector::CamParsCollector() |
---|
| 47 | : m_bInitialized( false ) |
---|
| 48 | { |
---|
[56] | 49 | m_aaiCodedOffset = new Int* [ MAX_VIEW_NUM ]; |
---|
| 50 | m_aaiCodedScale = new Int* [ MAX_VIEW_NUM ]; |
---|
| 51 | m_aiViewOrderIndex = new Int [ MAX_VIEW_NUM ]; |
---|
[195] | 52 | #if QC_MVHEVC_B0046 |
---|
[194] | 53 | m_aiViewId = new Int [ MAX_VIEW_NUM ]; |
---|
| 54 | #endif |
---|
[56] | 55 | m_aiViewReceived = new Int [ MAX_VIEW_NUM ]; |
---|
| 56 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
[2] | 57 | { |
---|
[56] | 58 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
| 59 | m_aaiCodedScale [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
[2] | 60 | } |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | CamParsCollector::~CamParsCollector() |
---|
| 64 | { |
---|
[56] | 65 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
[2] | 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 | |
---|
[56] | 107 | AOF( pcSlice->getSPS()->getViewId() < MAX_VIEW_NUM ); |
---|
[2] | 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 | } |
---|
[56] | 142 | ::memset( m_aiViewReceived, 0x00, MAX_VIEW_NUM * sizeof( Int ) ); |
---|
[2] | 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", |
---|
[56] | 238 | iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision ); |
---|
[2] | 239 | } |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | TDecTop::TDecTop() |
---|
| 247 | : m_SEIs(0) |
---|
[56] | 248 | , m_tAppDecTop( NULL ) |
---|
| 249 | , m_nalUnitTypeBaseView( NAL_UNIT_INVALID ) |
---|
[2] | 250 | { |
---|
[56] | 251 | m_pcPic = 0; |
---|
[2] | 252 | m_iGopSize = 0; |
---|
| 253 | m_bGopSizeSet = false; |
---|
| 254 | m_iMaxRefPicNum = 0; |
---|
| 255 | m_uiValidPS = 0; |
---|
[21] | 256 | #if SONY_COLPIC_AVAILABILITY |
---|
| 257 | m_iViewOrderIdx = 0; |
---|
| 258 | #endif |
---|
[2] | 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; |
---|
[56] | 265 | m_pocCRA = 0; |
---|
| 266 | m_pocRandomAccess = MAX_INT; |
---|
| 267 | m_prevPOC = MAX_INT; |
---|
[2] | 268 | m_bFirstSliceInPicture = true; |
---|
| 269 | m_bFirstSliceInSequence = true; |
---|
[57] | 270 | m_pcCamParsCollector = 0; |
---|
[195] | 271 | #if QC_MVHEVC_B0046 |
---|
[194] | 272 | m_bFirstNal = false; |
---|
| 273 | #endif |
---|
[2] | 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(); |
---|
[56] | 293 | |
---|
[2] | 294 | delete m_apcSlicePilot; |
---|
| 295 | m_apcSlicePilot = NULL; |
---|
[56] | 296 | |
---|
[2] | 297 | m_cSliceDecoder.destroy(); |
---|
[56] | 298 | m_tAppDecTop = NULL; |
---|
[2] | 299 | |
---|
[5] | 300 | #if DEPTH_MAP_GENERATION |
---|
[2] | 301 | m_cDepthMapGenerator.destroy(); |
---|
[5] | 302 | #endif |
---|
| 303 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 304 | m_cResidualGenerator.destroy(); |
---|
[5] | 305 | #endif |
---|
[2] | 306 | } |
---|
| 307 | |
---|
| 308 | Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance ) |
---|
| 309 | { |
---|
| 310 | // initialize ROM |
---|
| 311 | if( bFirstInstance ) |
---|
[56] | 312 | { |
---|
| 313 | initROM(); |
---|
| 314 | } |
---|
| 315 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO |
---|
[5] | 316 | #if DEPTH_MAP_GENERATION |
---|
[56] | 317 | , &m_cDepthMapGenerator |
---|
[5] | 318 | #endif |
---|
| 319 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[56] | 320 | , &m_cResidualGenerator |
---|
[5] | 321 | #endif |
---|
[56] | 322 | ); |
---|
[2] | 323 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 324 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
[56] | 325 | m_tAppDecTop = pcTAppDecTop; |
---|
[5] | 326 | #if DEPTH_MAP_GENERATION |
---|
[77] | 327 | #if VIDYO_VPS_INTEGRATION |
---|
| 328 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getVPSAccess(), m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
| 329 | #else |
---|
[56] | 330 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
[5] | 331 | #endif |
---|
[77] | 332 | #endif |
---|
[5] | 333 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 334 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
[5] | 335 | #endif |
---|
[2] | 336 | } |
---|
| 337 | |
---|
| 338 | Void TDecTop::deletePicBuffer ( ) |
---|
| 339 | { |
---|
| 340 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 341 | Int iSize = Int( m_cListPic.size() ); |
---|
[56] | 342 | |
---|
[2] | 343 | for (Int i = 0; i < iSize; i++ ) |
---|
| 344 | { |
---|
[56] | 345 | if( *iterPic ) |
---|
| 346 | { |
---|
| 347 | TComPic* pcPic = *(iterPic++); |
---|
| 348 | pcPic->destroy(); |
---|
| 349 | |
---|
| 350 | delete pcPic; |
---|
| 351 | pcPic = NULL; |
---|
| 352 | } |
---|
[2] | 353 | } |
---|
[56] | 354 | |
---|
[2] | 355 | // destroy ALF temporary buffers |
---|
| 356 | m_cAdaptiveLoopFilter.destroy(); |
---|
| 357 | |
---|
| 358 | m_cSAO.destroy(); |
---|
[56] | 359 | |
---|
[2] | 360 | m_cLoopFilter. destroy(); |
---|
[56] | 361 | |
---|
[2] | 362 | // destroy ROM |
---|
[56] | 363 | if(m_viewId == 0 && m_isDepth == false) |
---|
| 364 | { |
---|
[2] | 365 | destroyROM(); |
---|
[56] | 366 | } |
---|
[2] | 367 | } |
---|
| 368 | |
---|
[56] | 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 | |
---|
[2] | 425 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
| 426 | { |
---|
[56] | 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 |
---|
[2] | 434 | |
---|
[5] | 435 | #if DEPTH_MAP_GENERATION |
---|
[56] | 436 | UInt uiPdm = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
[21] | 437 | Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 ); |
---|
[5] | 438 | #endif |
---|
[2] | 439 | |
---|
| 440 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 441 | { |
---|
[56] | 442 | rpcPic = new TComPic(); |
---|
| 443 | |
---|
| 444 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
| 445 | |
---|
[5] | 446 | #if DEPTH_MAP_GENERATION |
---|
[2] | 447 | if( bNeedPrdDepthMapBuffer ) |
---|
| 448 | { |
---|
[21] | 449 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 450 | } |
---|
[5] | 451 | #endif |
---|
[56] | 452 | |
---|
[2] | 453 | m_cListPic.pushBack( rpcPic ); |
---|
[56] | 454 | |
---|
[2] | 455 | return; |
---|
| 456 | } |
---|
[56] | 457 | |
---|
[2] | 458 | Bool bBufferIsAvailable = false; |
---|
| 459 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 460 | while (iterPic != m_cListPic.end()) |
---|
| 461 | { |
---|
| 462 | rpcPic = *(iterPic++); |
---|
[56] | 463 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 464 | { |
---|
[56] | 465 | rpcPic->setOutputMark(false); |
---|
[2] | 466 | bBufferIsAvailable = true; |
---|
| 467 | break; |
---|
| 468 | } |
---|
[56] | 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 | } |
---|
[2] | 478 | } |
---|
[56] | 479 | |
---|
[2] | 480 | if ( !bBufferIsAvailable ) |
---|
| 481 | { |
---|
[56] | 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 ); |
---|
[2] | 486 | } |
---|
[56] | 487 | rpcPic->destroy(); |
---|
| 488 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
[5] | 489 | #if DEPTH_MAP_GENERATION |
---|
[2] | 490 | if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() ) |
---|
| 491 | { |
---|
[21] | 492 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 493 | } |
---|
[5] | 494 | #endif |
---|
[2] | 495 | } |
---|
| 496 | |
---|
[56] | 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; |
---|
[2] | 506 | |
---|
[56] | 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) |
---|
[2] | 521 | { |
---|
[56] | 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()) |
---|
[2] | 540 | { |
---|
[56] | 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()) |
---|
[2] | 543 | { |
---|
[56] | 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()); |
---|
[2] | 555 | break; |
---|
| 556 | } |
---|
| 557 | } |
---|
[56] | 558 | cFillPic->setCurrSliceIdx(0); |
---|
| 559 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
[2] | 560 | { |
---|
[56] | 561 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
[2] | 562 | } |
---|
[56] | 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 | } |
---|
[2] | 571 | } |
---|
| 572 | |
---|
[56] | 573 | |
---|
| 574 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 575 | { |
---|
[56] | 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); |
---|
[77] | 583 | #if VIDYO_VPS_INTEGRATION |
---|
| 584 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 585 | assert (vps != 0); |
---|
[195] | 586 | #if !QC_REM_IDV_B0046 |
---|
[77] | 587 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
[194] | 588 | #else |
---|
| 589 | if( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && !sps->getViewId() ) |
---|
| 590 | #endif |
---|
[77] | 591 | // VPS can only be activated on IDR or CRA... |
---|
| 592 | getTAppDecTop()->getVPSAccess()->setActiveVPSId( sps->getVPSId() ); |
---|
| 593 | #endif |
---|
[56] | 594 | m_apcSlicePilot->setPPS(pps); |
---|
| 595 | m_apcSlicePilot->setSPS(sps); |
---|
[195] | 596 | #if QC_MVHEVC_B0046 |
---|
[194] | 597 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 598 | #endif |
---|
[195] | 599 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 600 | m_apcSlicePilot->setVPS(vps); |
---|
| 601 | #endif |
---|
[56] | 602 | pps->setSPS(sps); |
---|
| 603 | |
---|
| 604 | if(sps->getUseSAO() || sps->getUseALF()|| sps->getScalingListFlag() || sps->getUseDF()) |
---|
[2] | 605 | { |
---|
[56] | 606 | m_apcSlicePilot->setAPS( m_parameterSetManagerDecoder.getAPS(m_apcSlicePilot->getAPSId()) ); |
---|
[2] | 607 | } |
---|
[56] | 608 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 609 | |
---|
| 610 | for (Int i = 0; i < sps->getMaxCUDepth() - 1; i++) |
---|
[2] | 611 | { |
---|
[56] | 612 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
[2] | 613 | } |
---|
[56] | 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 ); |
---|
[2] | 626 | } |
---|
[56] | 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 ) |
---|
[2] | 632 | #endif |
---|
| 633 | { |
---|
| 634 | TComPic*& pcPic = m_pcPic; |
---|
[56] | 635 | m_apcSlicePilot->initSlice(); |
---|
[2] | 636 | |
---|
[56] | 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)); |
---|
[195] | 641 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
| 642 | #if QC_MVHEVC_B0046 |
---|
[194] | 643 | m_apcSlicePilot->setIsDepth(false); |
---|
| 644 | #endif |
---|
[77] | 645 | m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0)); |
---|
| 646 | #endif |
---|
[56] | 647 | m_apcSlicePilot->initTiles(); |
---|
[195] | 648 | #if QC_MVHEVC_B0046 |
---|
[194] | 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 |
---|
[56] | 660 | if (m_bFirstSliceInPicture) |
---|
[2] | 661 | { |
---|
[56] | 662 | m_uiSliceIdx = 0; |
---|
| 663 | m_uiLastSliceIdx = 0; |
---|
[2] | 664 | } |
---|
[56] | 665 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 666 | if (!m_bFirstSliceInPicture) |
---|
| 667 | { |
---|
| 668 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 669 | } |
---|
[2] | 670 | |
---|
[56] | 671 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
| 672 | if( m_bFirstSliceInPicture ) |
---|
| 673 | { |
---|
[195] | 674 | #if QC_MVHEVC_B0046 |
---|
[194] | 675 | if( nalu.m_layerId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
| 676 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, 0 )->getNalUnitTypeBaseView(); } |
---|
| 677 | #else |
---|
[77] | 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 |
---|
[56] | 682 | if( nalu.m_viewId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
| 683 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); } |
---|
[77] | 684 | #endif |
---|
[194] | 685 | #endif |
---|
[56] | 686 | m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView ); |
---|
| 687 | } |
---|
[2] | 688 | |
---|
[56] | 689 | #if SONY_COLPIC_AVAILABILITY |
---|
| 690 | m_apcSlicePilot->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx()); |
---|
| 691 | #endif |
---|
[2] | 692 | |
---|
[56] | 693 | #if NAL_REF_FLAG |
---|
| 694 | m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag); |
---|
[42] | 695 | #else |
---|
[56] | 696 | m_apcSlicePilot->setReferenced(nalu.m_nalRefIDC != NAL_REF_IDC_PRIORITY_LOWEST); |
---|
| 697 | #endif |
---|
| 698 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[42] | 699 | |
---|
[56] | 700 | // ALF CU parameters should be part of the slice header -> needs to be fixed |
---|
| 701 | #if LCU_SYNTAX_ALF |
---|
| 702 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet()); |
---|
| 703 | #else |
---|
| 704 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam() ); |
---|
[42] | 705 | #endif |
---|
[56] | 706 | // byte align |
---|
| 707 | { |
---|
| 708 | Int numBitsForByteAlignment = nalu.m_Bitstream->getNumBitsUntilByteAligned(); |
---|
| 709 | if ( numBitsForByteAlignment > 0 ) |
---|
| 710 | { |
---|
| 711 | UInt bitsForByteAlignment; |
---|
| 712 | nalu.m_Bitstream->read( numBitsForByteAlignment, bitsForByteAlignment ); |
---|
| 713 | assert( bitsForByteAlignment == ( ( 1 << numBitsForByteAlignment ) - 1 ) ); |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | // exit when a new picture is found |
---|
| 718 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence) |
---|
| 719 | { |
---|
| 720 | #if START_DECODING_AT_CRA |
---|
| 721 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 722 | { |
---|
| 723 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 724 | return true; |
---|
| 725 | } |
---|
| 726 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
[2] | 727 | #else |
---|
[56] | 728 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 729 | return true; |
---|
[2] | 730 | #endif |
---|
[56] | 731 | } |
---|
| 732 | // actual decoding starts here |
---|
| 733 | xActivateParameterSets(); |
---|
| 734 | m_apcSlicePilot->initTiles(); |
---|
| 735 | |
---|
| 736 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 737 | { |
---|
| 738 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 739 | } |
---|
| 740 | m_bFirstSliceInSequence = false; |
---|
| 741 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 742 | { |
---|
| 743 | // Skip pictures due to random access |
---|
| 744 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 745 | { |
---|
| 746 | return false; |
---|
| 747 | } |
---|
| 748 | } |
---|
| 749 | //detect lost reference picture and insert copy of earlier frame. |
---|
| 750 | #if START_DECODING_AT_CRA |
---|
| 751 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess) > 0) |
---|
| 752 | #else |
---|
| 753 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true) > 0) |
---|
| 754 | #endif |
---|
| 755 | { |
---|
| 756 | xCreateLostPicture(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), false)-1); |
---|
| 757 | } |
---|
[2] | 758 | if (m_bFirstSliceInPicture) |
---|
| 759 | { |
---|
[56] | 760 | // Buffer initialize for prediction. |
---|
| 761 | m_cPrediction.initTempBuff(); |
---|
| 762 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
| 763 | // Get a new picture buffer |
---|
| 764 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
[2] | 765 | |
---|
[56] | 766 | #if SONY_COLPIC_AVAILABILITY |
---|
| 767 | pcPic->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx() ); |
---|
| 768 | #endif |
---|
[2] | 769 | |
---|
[56] | 770 | /* transfer any SEI messages that have been received to the picture */ |
---|
| 771 | pcPic->setSEIs(m_SEIs); |
---|
| 772 | m_SEIs = NULL; |
---|
[42] | 773 | |
---|
[56] | 774 | // Recursive structure |
---|
| 775 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 776 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 777 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
[42] | 778 | |
---|
[56] | 779 | m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 780 | #if DEPTH_MAP_GENERATION |
---|
| 781 | UInt uiPdm = ( m_apcSlicePilot->getSPS()->getViewId() ? m_apcSlicePilot->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
| 782 | 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) ); |
---|
| 783 | TComDepthMapGenerator* pcDMG0 = m_tAppDecTop->getDecTop0()->getDepthMapGenerator(); |
---|
| 784 | if( m_apcSlicePilot->getSPS()->getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) ) |
---|
| 785 | { |
---|
| 786 | 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) ); |
---|
| 787 | } |
---|
[42] | 788 | #endif |
---|
[56] | 789 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 790 | m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
| 791 | #endif |
---|
| 792 | } |
---|
[42] | 793 | |
---|
[56] | 794 | // Set picture slice pointer |
---|
| 795 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 796 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
[2] | 797 | |
---|
[56] | 798 | UInt uiCummulativeTileWidth; |
---|
| 799 | UInt uiCummulativeTileHeight; |
---|
| 800 | UInt i, j, p; |
---|
| 801 | |
---|
| 802 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 803 | //set the TileBoundaryIndependenceIdr |
---|
| 804 | if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1) |
---|
[2] | 805 | { |
---|
[56] | 806 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() ); |
---|
| 807 | } |
---|
| 808 | else |
---|
| 809 | { |
---|
| 810 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() ); |
---|
| 811 | } |
---|
[42] | 812 | #endif |
---|
[2] | 813 | |
---|
[56] | 814 | if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 ) |
---|
| 815 | { |
---|
| 816 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 817 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 818 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
| 819 | |
---|
| 820 | //create the TComTileArray |
---|
| 821 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 822 | |
---|
| 823 | if( pcSlice->getPPS()->getUniformSpacingIdr() == 1) |
---|
| 824 | { |
---|
| 825 | //set the width for each tile |
---|
| 826 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[2] | 827 | { |
---|
[56] | 828 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 829 | { |
---|
| 830 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 831 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 832 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 833 | } |
---|
[2] | 834 | } |
---|
| 835 | |
---|
[56] | 836 | //set the height for each tile |
---|
| 837 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 838 | { |
---|
[56] | 839 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
| 840 | { |
---|
| 841 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 842 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 843 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
| 844 | } |
---|
[2] | 845 | } |
---|
| 846 | } |
---|
[56] | 847 | else |
---|
[2] | 848 | { |
---|
[56] | 849 | //set the width for each tile |
---|
| 850 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
[2] | 851 | { |
---|
[56] | 852 | uiCummulativeTileWidth = 0; |
---|
| 853 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
| 854 | { |
---|
| 855 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 856 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
| 857 | } |
---|
| 858 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
[2] | 859 | } |
---|
| 860 | |
---|
[56] | 861 | //set the height for each tile |
---|
| 862 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 863 | { |
---|
[56] | 864 | uiCummulativeTileHeight = 0; |
---|
| 865 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 866 | { |
---|
| 867 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 868 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
| 869 | } |
---|
| 870 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
[2] | 871 | } |
---|
[56] | 872 | } |
---|
| 873 | } |
---|
| 874 | else |
---|
| 875 | { |
---|
| 876 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 877 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() ); |
---|
| 878 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() ); |
---|
[2] | 879 | |
---|
[56] | 880 | //create the TComTileArray |
---|
| 881 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
[2] | 882 | |
---|
[56] | 883 | //automatically set the column and row boundary if UniformSpacingIdr = 1 |
---|
| 884 | if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 ) |
---|
| 885 | { |
---|
| 886 | //set the width for each tile |
---|
| 887 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[2] | 888 | { |
---|
[56] | 889 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 890 | { |
---|
| 891 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 892 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 893 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 894 | } |
---|
[2] | 895 | } |
---|
[56] | 896 | |
---|
| 897 | //set the height for each tile |
---|
| 898 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 899 | { |
---|
[56] | 900 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
[2] | 901 | { |
---|
[56] | 902 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 903 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 904 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
[2] | 905 | } |
---|
| 906 | } |
---|
[56] | 907 | } |
---|
| 908 | else |
---|
| 909 | { |
---|
| 910 | //set the width for each tile |
---|
| 911 | for(j=0; j < pcSlice->getSPS()->getNumRowsMinus1()+1; j++) |
---|
| 912 | { |
---|
| 913 | uiCummulativeTileWidth = 0; |
---|
| 914 | for(i=0; i < pcSlice->getSPS()->getNumColumnsMinus1(); i++) |
---|
| 915 | { |
---|
| 916 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getSPS()->getColumnWidth(i) ); |
---|
| 917 | uiCummulativeTileWidth += pcSlice->getSPS()->getColumnWidth(i); |
---|
| 918 | } |
---|
| 919 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 920 | } |
---|
[2] | 921 | |
---|
[56] | 922 | //set the height for each tile |
---|
| 923 | for(j=0; j < pcSlice->getSPS()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 924 | { |
---|
[56] | 925 | uiCummulativeTileHeight = 0; |
---|
| 926 | for(i=0; i < pcSlice->getSPS()->getNumRowsMinus1(); i++) |
---|
| 927 | { |
---|
| 928 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getSPS()->getRowHeight(i) ); |
---|
| 929 | uiCummulativeTileHeight += pcSlice->getSPS()->getRowHeight(i); |
---|
| 930 | } |
---|
| 931 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
| 932 | } |
---|
| 933 | } |
---|
| 934 | } |
---|
[2] | 935 | |
---|
[56] | 936 | pcPic->getPicSym()->xInitTiles(); |
---|
[2] | 937 | |
---|
[56] | 938 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 939 | UInt uiEncCUAddr; |
---|
| 940 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 941 | { |
---|
| 942 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 943 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 944 | } |
---|
| 945 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 946 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 947 | |
---|
| 948 | //convert the start and end CU addresses of the slice and entropy slice into encoding order |
---|
| 949 | pcSlice->setEntropySliceCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurStartCUAddr()) ); |
---|
| 950 | pcSlice->setEntropySliceCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurEndCUAddr()) ); |
---|
| 951 | if(pcSlice->isNextSlice()) |
---|
| 952 | { |
---|
| 953 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 954 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | if (m_bFirstSliceInPicture) |
---|
| 958 | { |
---|
| 959 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 960 | { |
---|
| 961 | pcPic->clearSliceBuffer(); |
---|
| 962 | } |
---|
| 963 | } |
---|
| 964 | else |
---|
| 965 | { |
---|
| 966 | pcPic->allocateNewSlice(); |
---|
| 967 | } |
---|
| 968 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 969 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 970 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 971 | |
---|
| 972 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 973 | |
---|
| 974 | if (bNextSlice) |
---|
| 975 | { |
---|
| 976 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_cListPic); |
---|
| 977 | |
---|
| 978 | if ( !pcSlice->getPPS()->getEnableTMVPFlag() && pcPic->getTLayer() == 0 ) |
---|
| 979 | { |
---|
| 980 | pcSlice->decodingMarkingForNoTMVP( m_cListPic, pcSlice->getPOC() ); |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | // Set reference list |
---|
[195] | 984 | #if !QC_MVHEVC_B0046 |
---|
[77] | 985 | #if VIDYO_VPS_INTEGRATION |
---|
| 986 | pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) ); |
---|
| 987 | pcSlice->setIsDepth( pcSlice->getVPS()->getDepthFlag(nalu.m_layerId) ); |
---|
| 988 | #else |
---|
[56] | 989 | pcSlice->setViewId(m_viewId); |
---|
| 990 | pcSlice->setIsDepth(m_isDepth); |
---|
[77] | 991 | #endif |
---|
[194] | 992 | #endif |
---|
[56] | 993 | |
---|
[21] | 994 | #if SONY_COLPIC_AVAILABILITY |
---|
[77] | 995 | #if VIDYO_VPS_INTEGRATION |
---|
| 996 | pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) ); |
---|
| 997 | #else |
---|
[56] | 998 | pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() ); |
---|
[21] | 999 | #endif |
---|
[77] | 1000 | #endif |
---|
[21] | 1001 | |
---|
[56] | 1002 | assert( m_tAppDecTop != NULL ); |
---|
| 1003 | TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView( m_viewId, pcSlice->getPOC(), false ) : NULL; |
---|
[200] | 1004 | |
---|
[201] | 1005 | #if FLEX_CODING_ORDER_M23723 |
---|
[200] | 1006 | if (pcTexturePic != NULL) |
---|
| 1007 | { |
---|
| 1008 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
| 1009 | pcSlice->setTexturePic( pcTexturePic ); |
---|
| 1010 | } |
---|
| 1011 | #else |
---|
[56] | 1012 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
| 1013 | pcSlice->setTexturePic( pcTexturePic ); |
---|
[200] | 1014 | #endif |
---|
[2] | 1015 | |
---|
[200] | 1016 | |
---|
[56] | 1017 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
| 1018 | pcSlice->setRefPicListMvc( m_cListPic, apcInterViewRefPics ); |
---|
[2] | 1019 | |
---|
[56] | 1020 | // For generalized B |
---|
| 1021 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1022 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 1023 | { |
---|
| 1024 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1025 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
[2] | 1026 | |
---|
[56] | 1027 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 1028 | { |
---|
| 1029 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 1030 | } |
---|
| 1031 | } |
---|
| 1032 | if (pcSlice->isInterB()) |
---|
| 1033 | { |
---|
| 1034 | Bool bLowDelay = true; |
---|
| 1035 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1036 | Int iRefIdx = 0; |
---|
| 1037 | |
---|
| 1038 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 1039 | { |
---|
| 1040 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[21] | 1041 | { |
---|
[56] | 1042 | bLowDelay = false; |
---|
[21] | 1043 | } |
---|
[2] | 1044 | } |
---|
[56] | 1045 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
| 1046 | { |
---|
| 1047 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1048 | { |
---|
| 1049 | bLowDelay = false; |
---|
| 1050 | } |
---|
| 1051 | } |
---|
[2] | 1052 | |
---|
[56] | 1053 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 1054 | } |
---|
| 1055 | |
---|
| 1056 | //--------------- |
---|
| 1057 | pcSlice->setRefPOCnViewListsMvc(); |
---|
| 1058 | |
---|
| 1059 | if(!pcSlice->getRefPicListModificationFlagLC()) |
---|
| 1060 | { |
---|
| 1061 | pcSlice->generateCombinedList(); |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | if( pcSlice->getRefPicListCombinationFlag() && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE ) |
---|
| 1065 | { |
---|
| 1066 | pcSlice->setWpParamforLC(); |
---|
| 1067 | } |
---|
| 1068 | pcSlice->setNoBackPredFlag( false ); |
---|
| 1069 | if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) |
---|
| 1070 | { |
---|
| 1071 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
[2] | 1072 | { |
---|
[56] | 1073 | pcSlice->setNoBackPredFlag( true ); |
---|
| 1074 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
[2] | 1075 | { |
---|
[56] | 1076 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
| 1077 | { |
---|
| 1078 | pcSlice->setNoBackPredFlag( false ); |
---|
| 1079 | break; |
---|
| 1080 | } |
---|
[2] | 1081 | } |
---|
| 1082 | } |
---|
[56] | 1083 | } |
---|
| 1084 | } |
---|
| 1085 | |
---|
| 1086 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 1087 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 1088 | { |
---|
| 1089 | if(pcSlice->getAPS()->getScalingListEnabled()) |
---|
| 1090 | { |
---|
| 1091 | pcSlice->setScalingList ( pcSlice->getAPS()->getScalingList() ); |
---|
| 1092 | if(pcSlice->getScalingList()->getScalingListPresentFlag()) |
---|
[2] | 1093 | { |
---|
[56] | 1094 | pcSlice->setDefaultScalingList(); |
---|
[2] | 1095 | } |
---|
[56] | 1096 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
| 1097 | } |
---|
| 1098 | m_cTrQuant.setUseScalingList(true); |
---|
| 1099 | } |
---|
| 1100 | else |
---|
| 1101 | { |
---|
| 1102 | m_cTrQuant.setFlatScalingList(); |
---|
| 1103 | m_cTrQuant.setUseScalingList(false); |
---|
| 1104 | } |
---|
[2] | 1105 | |
---|
[56] | 1106 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 1107 | if( m_parameterSetManagerDecoder.getPrefetchedSPS(0)->getUseDMM() && g_aacWedgeLists.empty() ) |
---|
| 1108 | { |
---|
| 1109 | initWedgeLists(); |
---|
| 1110 | } |
---|
[2] | 1111 | #endif |
---|
| 1112 | |
---|
[56] | 1113 | // Decode a picture |
---|
| 1114 | m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false); |
---|
[42] | 1115 | |
---|
[195] | 1116 | #if QC_IV_AS_LT_B0046 |
---|
[194] | 1117 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
| 1118 | for( Int k = 0; k < apcInterViewRefPics.size(); k++ ) |
---|
| 1119 | { |
---|
| 1120 | TComPic* pcPicIv = apcInterViewRefPics[k]; |
---|
| 1121 | pcPicIv->setIsLongTerm( 0 ); |
---|
| 1122 | } |
---|
| 1123 | #endif |
---|
[57] | 1124 | if( m_pcCamParsCollector ) |
---|
| 1125 | { |
---|
| 1126 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1127 | } |
---|
| 1128 | |
---|
[56] | 1129 | m_bFirstSliceInPicture = false; |
---|
| 1130 | m_uiSliceIdx++; |
---|
| 1131 | |
---|
| 1132 | return false; |
---|
| 1133 | } |
---|
| 1134 | |
---|
[195] | 1135 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 1136 | Void TDecTop::xDecodeVPS() |
---|
| 1137 | { |
---|
| 1138 | TComVPS* vps = new TComVPS(); |
---|
| 1139 | |
---|
| 1140 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 1141 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
[195] | 1142 | #if !QC_MVHEVC_B0046 |
---|
[77] | 1143 | getTAppDecTop()->getVPSAccess()->addVPS( vps ); |
---|
[194] | 1144 | #endif |
---|
[77] | 1145 | } |
---|
| 1146 | #endif |
---|
[56] | 1147 | |
---|
| 1148 | Void TDecTop::xDecodeSPS() |
---|
| 1149 | { |
---|
| 1150 | TComSPS* sps = new TComSPS(); |
---|
| 1151 | #if RPS_IN_SPS |
---|
| 1152 | TComRPSList* rps = new TComRPSList(); |
---|
| 1153 | sps->setRPSList(rps); |
---|
| 1154 | #endif |
---|
| 1155 | #if HHI_MPI |
---|
| 1156 | m_cEntropyDecoder.decodeSPS( sps, m_isDepth ); |
---|
[42] | 1157 | #else |
---|
[56] | 1158 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
[42] | 1159 | #endif |
---|
[56] | 1160 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1161 | #if LCU_SYNTAX_ALF |
---|
| 1162 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
[21] | 1163 | #endif |
---|
[56] | 1164 | } |
---|
[2] | 1165 | |
---|
[56] | 1166 | Void TDecTop::xDecodePPS() |
---|
| 1167 | { |
---|
| 1168 | #if !RPS_IN_SPS |
---|
| 1169 | TComRPSList* rps = new TComRPSList(); |
---|
[2] | 1170 | #endif |
---|
[56] | 1171 | TComPPS* pps = new TComPPS(); |
---|
| 1172 | #if !RPS_IN_SPS |
---|
| 1173 | pps->setRPSList(rps); |
---|
| 1174 | #endif |
---|
| 1175 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 1176 | m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder ); |
---|
[2] | 1177 | #else |
---|
[56] | 1178 | m_cEntropyDecoder.decodePPS( pps ); |
---|
[2] | 1179 | #endif |
---|
[56] | 1180 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
[2] | 1181 | |
---|
[56] | 1182 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
| 1183 | m_apcSlicePilot->setPPSId(pps->getPPSId()); |
---|
| 1184 | xActivateParameterSets(); |
---|
| 1185 | m_apcSlicePilot->initTiles(); |
---|
| 1186 | } |
---|
[2] | 1187 | |
---|
[56] | 1188 | Void TDecTop::xDecodeAPS() |
---|
| 1189 | { |
---|
| 1190 | TComAPS *aps = new TComAPS(); |
---|
| 1191 | allocAPS (aps); |
---|
| 1192 | decodeAPS(aps); |
---|
| 1193 | m_parameterSetManagerDecoder.storePrefetchedAPS(aps); |
---|
| 1194 | } |
---|
[2] | 1195 | |
---|
[56] | 1196 | Void TDecTop::xDecodeSEI() |
---|
| 1197 | { |
---|
| 1198 | m_SEIs = new SEImessages; |
---|
| 1199 | m_cEntropyDecoder.decodeSEI(*m_SEIs); |
---|
| 1200 | } |
---|
[2] | 1201 | |
---|
[56] | 1202 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1203 | { |
---|
| 1204 | // Initialize entropy decoder |
---|
| 1205 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1206 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
[2] | 1207 | |
---|
[56] | 1208 | switch (nalu.m_nalUnitType) |
---|
| 1209 | { |
---|
[195] | 1210 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 1211 | case NAL_UNIT_VPS: |
---|
| 1212 | xDecodeVPS(); |
---|
| 1213 | return false; |
---|
| 1214 | #endif |
---|
[56] | 1215 | case NAL_UNIT_SPS: |
---|
| 1216 | xDecodeSPS(); |
---|
| 1217 | return false; |
---|
| 1218 | |
---|
| 1219 | case NAL_UNIT_PPS: |
---|
| 1220 | xDecodePPS(); |
---|
| 1221 | return false; |
---|
| 1222 | case NAL_UNIT_APS: |
---|
| 1223 | xDecodeAPS(); |
---|
| 1224 | return false; |
---|
| 1225 | |
---|
| 1226 | case NAL_UNIT_SEI: |
---|
| 1227 | xDecodeSEI(); |
---|
| 1228 | return false; |
---|
| 1229 | |
---|
| 1230 | case NAL_UNIT_CODED_SLICE: |
---|
| 1231 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
| 1232 | #if H0566_TLA |
---|
[195] | 1233 | #if !QC_REM_IDV_B0046 |
---|
[56] | 1234 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
[194] | 1235 | #endif |
---|
[56] | 1236 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 1237 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
| 1238 | #else |
---|
| 1239 | case NAL_UNIT_CODED_SLICE_CDR: |
---|
| 1240 | #endif |
---|
| 1241 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[2] | 1242 | break; |
---|
| 1243 | default: |
---|
| 1244 | assert (1); |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | return false; |
---|
| 1248 | } |
---|
| 1249 | |
---|
[195] | 1250 | #if QC_MVHEVC_B0046 |
---|
[194] | 1251 | Void TDecTop::xCopyVPS( TComVPS* pVPSV0 ) |
---|
| 1252 | { |
---|
| 1253 | m_parameterSetManagerDecoder.storePrefetchedVPS(pVPSV0); |
---|
| 1254 | } |
---|
| 1255 | |
---|
| 1256 | Void TDecTop::xCopySPS( TComSPS* pSPSV0 ) |
---|
| 1257 | { |
---|
| 1258 | TComSPS* sps = new TComSPS(); |
---|
| 1259 | sps = pSPSV0; |
---|
| 1260 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1261 | #if LCU_SYNTAX_ALF |
---|
| 1262 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 1263 | #endif |
---|
| 1264 | } |
---|
| 1265 | |
---|
| 1266 | Void TDecTop::xCopyPPS(TComPPS* pPPSV0 ) |
---|
| 1267 | { |
---|
| 1268 | m_parameterSetManagerDecoder.storePrefetchedPPS( pPPSV0 ); |
---|
| 1269 | |
---|
| 1270 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
| 1271 | m_apcSlicePilot->setPPSId(pPPSV0->getPPSId()); |
---|
| 1272 | xActivateParameterSets(); |
---|
| 1273 | m_apcSlicePilot->initTiles(); |
---|
| 1274 | } |
---|
| 1275 | #endif |
---|
[2] | 1276 | /** Function for checking if picture should be skipped because of random access |
---|
| 1277 | * \param iSkipFrame skip frame counter |
---|
| 1278 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1279 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1280 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1281 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1282 | * It also checks the type of Nal unit type at the random access point. |
---|
[56] | 1283 | * If the random access point is CRA, pictures with POC equal to or greater than the CRA POC are decoded. |
---|
[2] | 1284 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[56] | 1285 | * If the random access point is not IDR or CRA, a warning is issues, and decoding of pictures with POC |
---|
| 1286 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA random |
---|
[2] | 1287 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1288 | */ |
---|
| 1289 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1290 | { |
---|
[56] | 1291 | if (iSkipFrame) |
---|
[2] | 1292 | { |
---|
| 1293 | iSkipFrame--; // decrement the counter |
---|
| 1294 | return true; |
---|
| 1295 | } |
---|
[56] | 1296 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[2] | 1297 | { |
---|
[56] | 1298 | #if H0566_TLA |
---|
| 1299 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
| 1300 | #else |
---|
| 1301 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) |
---|
| 1302 | #endif |
---|
[2] | 1303 | { |
---|
[56] | 1304 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CRA. |
---|
[2] | 1305 | } |
---|
[56] | 1306 | else if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR ) |
---|
[2] | 1307 | { |
---|
[56] | 1308 | m_pocRandomAccess = 0; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
[2] | 1309 | } |
---|
[56] | 1310 | else |
---|
[2] | 1311 | { |
---|
[56] | 1312 | #if START_DECODING_AT_CRA |
---|
| 1313 | static bool warningMessage = false; |
---|
| 1314 | if(!warningMessage) |
---|
| 1315 | { |
---|
| 1316 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1317 | warningMessage = true; |
---|
| 1318 | } |
---|
| 1319 | return true; |
---|
| 1320 | #else |
---|
[2] | 1321 | printf("\nUnsafe random access point. Decoder may crash."); |
---|
[56] | 1322 | m_pocRandomAccess = 0; |
---|
| 1323 | #endif |
---|
[2] | 1324 | } |
---|
| 1325 | } |
---|
[56] | 1326 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess) // skip the reordered pictures if necessary |
---|
[2] | 1327 | { |
---|
| 1328 | iPOCLastDisplay++; |
---|
| 1329 | return true; |
---|
| 1330 | } |
---|
| 1331 | // if we reach here, then the picture is not skipped. |
---|
[56] | 1332 | return false; |
---|
[2] | 1333 | } |
---|
[56] | 1334 | |
---|
| 1335 | Void TDecTop::allocAPS (TComAPS* pAPS) |
---|
| 1336 | { |
---|
| 1337 | // we don't know the SPS before it has been activated. These fields could exist |
---|
| 1338 | // depending on the corresponding flags in the APS, but SAO/ALF allocation functions will |
---|
| 1339 | // have to be moved for that |
---|
| 1340 | pAPS->createScalingList(); |
---|
| 1341 | pAPS->createSaoParam(); |
---|
| 1342 | m_cSAO.allocSaoParam(pAPS->getSaoParam()); |
---|
| 1343 | pAPS->createAlfParam(); |
---|
| 1344 | #if !LCU_SYNTAX_ALF |
---|
| 1345 | m_cAdaptiveLoopFilter.allocALFParam(pAPS->getAlfParam()); |
---|
[2] | 1346 | #endif |
---|
[56] | 1347 | } |
---|
[2] | 1348 | |
---|
[56] | 1349 | //! \} |
---|