Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibDecoder/TDecSlice.cpp
- Timestamp:
- 16 Apr 2013, 06:39:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/TDecSlice.cpp
r2 r125 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 41 41 //! \{ 42 42 43 #if SVC_EXTENSION 44 ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS); 45 #endif 46 43 47 ////////////////////////////////////////////////////////////////////// 44 48 // Construction/Destruction … … 55 59 TDecSlice::~TDecSlice() 56 60 { 57 #if DEPENDENT_SLICES58 61 for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++) 59 62 { … … 61 64 } 62 65 CTXMem.clear(); 63 #endif 64 } 65 66 #if DEPENDENT_SLICES 66 } 67 67 68 Void TDecSlice::initCtxMem( UInt i ) 68 69 { … … 74 75 CTXMem.resize(i); 75 76 } 76 #endif 77 78 Void TDecSlice::create( TComSlice* pcSlice, Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth ) 77 78 Void TDecSlice::create() 79 79 { 80 80 } … … 106 106 #if SVC_EXTENSION 107 107 Void TDecSlice::init(TDecTop** ppcDecTop,TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder) 108 { 109 m_pcEntropyDecoder = pcEntropyDecoder; 110 m_pcCuDecoder = pcCuDecoder; 111 m_ppcTDecTop = ppcDecTop; 112 } 108 113 #else 109 114 Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder) 110 #endif111 115 { 112 116 m_pcEntropyDecoder = pcEntropyDecoder; 113 117 m_pcCuDecoder = pcCuDecoder; 114 #if SVC_EXTENSION 115 m_ppcTDecTop = ppcDecTop; 116 #endif 117 } 118 119 Void TDecSlice::decompressSlice(TComInputBitstream* pcBitstream, TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders) 118 } 119 #endif 120 121 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders) 120 122 { 121 123 TComDataCU* pcCU; 122 124 UInt uiIsLast = 0; 123 Int iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->get DependentSliceCurStartCUAddr()/rpcPic->getNumPartInCU());125 Int iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()); 124 126 Int iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder); 125 127 … … 194 196 UInt uiTileStartLCU; 195 197 UInt uiTileLCUX; 196 UInt uiTileLCUY;197 UInt uiTileWidth;198 UInt uiTileHeight;199 198 Int iNumSubstreamsPerTile = 1; // if independent. 200 201 199 #if INTRA_BL 202 200 m_pcCuDecoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL); 203 201 #endif 204 #if DEPENDENT_SLICES 205 Bool bAllowDependence = false; 206 #if TILES_WPP_ENTROPYSLICES_FLAGS 207 if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getEntropySliceEnabledFlag()) ) 208 #else 209 if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getCabacIndependentFlag()) ) 210 #endif 211 { 212 bAllowDependence = true; 213 } 214 if( bAllowDependence ) 215 { 216 if( !rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice() ) 217 { 218 uiTileCol = 0; 219 #if TILES_WPP_ENTROPYSLICES_FLAGS 202 Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 203 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); 204 if( depSliceSegmentsEnabled ) 205 { 206 if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && 207 iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr()) 208 { 220 209 if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 221 #else 222 if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2) 223 #endif 224 { 210 { 211 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 225 212 m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1] );//2.LCU 213 if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) 214 { 215 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 216 uiCol = iStartCUAddr % uiWidthInLCUs; 217 if(uiCol==uiTileLCUX) 218 { 219 CTXMem[0]->loadContexts(pcSbacDecoder); 220 } 221 } 226 222 } 227 223 pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1 … … 230 226 else 231 227 { 232 #if TILES_WPP_ENTROPYSLICES_FLAGS233 228 if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 234 #else235 if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)236 #endif237 229 { 238 230 CTXMem[1]->loadContexts(pcSbacDecoder); … … 241 233 } 242 234 } 243 #endif244 235 for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) ) 245 236 { … … 249 240 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr(); 250 241 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 251 uiTileLCUY = uiTileStartLCU / uiWidthInLCUs;252 uiTileWidth = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileWidth();253 uiTileHeight = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileHeight();254 242 uiCol = iCUAddr % uiWidthInLCUs; 255 243 // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture. 256 244 uiLin = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs); 257 245 // inherit from TR if necessary, select substream to use. 258 #if DEPENDENT_SLICES 259 #if TILES_WPP_ENTROPYSLICES_FLAGS 260 if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) 261 #else 262 if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2) )) 263 #endif 264 #else 265 if( pcSlice->getPPS()->getNumSubstreams() > 1 ) 266 #endif 246 if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) 267 247 { 268 248 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. … … 272 252 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); 273 253 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 274 #if DEPENDENT_SLICES 275 #if TILES_WPP_ENTROPYSLICES_FLAGS 276 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())) 277 #else 278 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)) 279 #endif 280 #else 281 if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX) 282 #endif 254 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())) 283 255 { 284 256 // We'll sync if the TR is available. … … 296 268 ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) || 297 269 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))) 298 ))||299 (true/*bEnforceDependentSliceRestriction*/ &&300 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||301 ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getDependentSliceCurStartCUAddr()) ||302 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))303 270 )) 304 271 ) 305 272 { 306 #if DEPENDENT_SLICES307 if( (iCUAddr!=0) && ((pcCUTR->getSCUAddr()+uiMaxParts-1) >= pcSlice->getSliceCurStartCUAddr()) && bAllowDependence)308 {309 pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );310 }311 #endif312 273 // TR not available. 313 274 } … … 328 289 if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile. 329 290 (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) 330 #if DEPENDENT_SLICES 331 && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) 332 #endif 291 && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU()) 333 292 ) // !1st in frame && !1st in slice 334 293 { … … 366 325 g_bJustDoIt = g_bEncDecTraceEnable; 367 326 #endif 368 #if !SAO_LUM_CHROMA_ONOFF_FLAGS369 if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getSaoEnabledFlag() )370 #else371 327 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 372 #endif 373 { 374 #if REMOVE_APS 328 { 375 329 SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam(); 376 #else377 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();378 #endif379 330 saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag(); 380 331 if (iCUAddr == iStartCUAddr) 381 332 { 382 #if SAO_TYPE_SHARING383 333 saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma(); 384 #else385 saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagCb();386 saoParam->bSaoFlag[2] = pcSlice->getSaoEnabledFlagCr();387 #endif388 334 } 389 335 Int numCuInWidth = saoParam->numCuInWidth; … … 410 356 pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp); 411 357 } 412 #if !REMOVE_ALF 413 if(pcSlice->getSPS()->getUseALF()) 414 { 415 UInt alfEnabledFlag; 416 for(Int compIdx=0; compIdx< 3; compIdx++) 417 { 418 alfEnabledFlag = 0; 419 if(pcSlice->getAlfEnabledFlag(compIdx)) 420 { 421 pcSbacDecoder->parseAlfCtrlFlag(compIdx, alfEnabledFlag); 422 } 423 pcCU->setAlfLCUEnabled((alfEnabledFlag==1)?true:false, compIdx); 424 } 425 } 426 #endif 358 else if ( pcSlice->getSPS()->getUseSAO() ) 359 { 360 Int addr = pcCU->getAddr(); 361 SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam(); 362 for (Int cIdx=0; cIdx<3; cIdx++) 363 { 364 SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]); 365 if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma())) 366 { 367 saoLcuParam->mergeUpFlag = 0; 368 saoLcuParam->mergeLeftFlag = 0; 369 saoLcuParam->subTypeIdx = 0; 370 saoLcuParam->typeIdx = -1; 371 saoLcuParam->offset[0] = 0; 372 saoLcuParam->offset[1] = 0; 373 saoLcuParam->offset[2] = 0; 374 saoLcuParam->offset[3] = 0; 375 } 376 } 377 } 427 378 m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); 428 379 m_pcCuDecoder->decompressCU ( pcCU ); … … 431 382 g_bJustDoIt = g_bEncDecTraceDisable; 432 383 #endif 433 /*If at the end of a LCU line but not at the end of a substream, perform CABAC flush*/434 if (!uiIsLast && pcSlice->getPPS()->getNumSubstreams() > 1)435 {436 if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight))437 {438 m_pcEntropyDecoder->decodeFlush();439 }440 }441 384 pcSbacDecoders[uiSubStrm].load(pcSbacDecoder); 442 385 443 386 //Store probabilities of second LCU in line into buffer 444 #if DEPENDENT_SLICES 445 #if TILES_WPP_ENTROPYSLICES_FLAGS 446 if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ) 447 #else 448 if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc() == 2)) 449 #endif 450 #else 451 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1)) 452 #endif 387 if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ) 453 388 { 454 389 m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] ); 455 390 } 456 #if DEPENDENT_SLICES 457 if( uiIsLast && bAllowDependence ) 458 { 459 #if TILES_WPP_ENTROPYSLICES_FLAGS 391 if( uiIsLast && depSliceSegmentsEnabled ) 392 { 460 393 if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 461 #else462 if (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)463 #endif464 394 { 465 395 CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU … … 468 398 return; 469 399 } 470 #endif471 400 } 472 401 } 473 402 474 403 ParameterSetManagerDecoder::ParameterSetManagerDecoder() 404 #if SVC_EXTENSION 405 : m_spsBuffer(MAX_NUM_SPS) 406 , m_ppsBuffer(MAX_NUM_PPS) 407 #else 475 408 : m_vpsBuffer(MAX_NUM_VPS) 476 ,m_spsBuffer(256) 477 , m_ppsBuffer(16) 478 #if !REMOVE_APS 479 , m_apsBuffer(64) 480 #endif 481 { 482 409 , m_spsBuffer(MAX_NUM_SPS) 410 , m_ppsBuffer(MAX_NUM_PPS) 411 #endif 412 { 483 413 } 484 414 … … 525 455 } 526 456 527 #if !REMOVE_APS528 TComAPS* ParameterSetManagerDecoder::getPrefetchedAPS (Int apsId)529 {530 if (m_apsBuffer.getPS(apsId) != NULL )531 {532 return m_apsBuffer.getPS(apsId);533 }534 else535 {536 return getAPS(apsId);537 }538 }539 #endif540 541 457 Void ParameterSetManagerDecoder::applyPrefetchedPS() 542 458 { 543 459 m_vpsMap.mergePSList(m_vpsBuffer); 544 #if !REMOVE_APS545 m_apsMap.mergePSList(m_apsBuffer);546 #endif547 460 m_ppsMap.mergePSList(m_ppsBuffer); 548 461 m_spsMap.mergePSList(m_spsBuffer);
Note: See TracChangeset for help on using the changeset viewer.