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