Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncSlice.cpp
- Timestamp:
- 16 Apr 2013, 06:39:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r11 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 * … … 63 63 TEncSlice::~TEncSlice() 64 64 { 65 #if DEPENDENT_SLICES66 65 for (std::vector<TEncSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++) 67 66 { 68 67 delete (*i); 69 68 } 70 #endif71 69 } 72 70 73 #if DEPENDENT_SLICES74 71 Void TEncSlice::initCtxMem( UInt i ) 75 72 { … … 81 78 CTXMem.resize(i); 82 79 } 83 #endif84 80 85 81 Void TEncSlice::create( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth ) … … 173 169 . 174 170 \param pcPic picture class 175 \param iPOCLastPOC of last picture176 \param uiPOCCurrcurrent POC171 \param pocLast POC of last picture 172 \param pocCurr current POC 177 173 \param iNumPicRcvd number of received pictures 178 174 \param iTimeOffset POC offset for hierarchical structure … … 182 178 \param pPPS PPS associated with the slice 183 179 */ 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )180 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ) 185 181 { 186 182 Double dQP; … … 192 188 rpcSlice->setSliceBits(0); 193 189 rpcSlice->setPic( pcPic ); 194 #if S ET_SLICE_LAYER_ID190 #if SVC_EXTENSION 195 191 rpcSlice->initSlice( pcPic->getLayerId() ); 196 192 #else … … 198 194 #endif 199 195 rpcSlice->setPicOutputFlag( true ); 200 rpcSlice->setPOC( uiPOCCurr ); 201 202 #if SVC_EXTENSION && !SET_SLICE_LAYER_ID 203 rpcSlice->setLayerId( pcPic->getLayerId()); 204 #endif 205 196 rpcSlice->setPOC( pocCurr ); 197 206 198 // depth computation based on GOP size 207 int iDepth; 208 { 209 Int i, j; 210 Int iPOC = rpcSlice->getPOC()%m_pcCfg->getGOPSize(); 211 if ( iPOC == 0 ) 212 { 213 iDepth = 0; 199 Int depth; 200 { 201 Int poc = rpcSlice->getPOC()%m_pcCfg->getGOPSize(); 202 if ( poc == 0 ) 203 { 204 depth = 0; 214 205 } 215 206 else 216 207 { 217 Int iStep = m_pcCfg->getGOPSize();218 iDepth = 0;219 for( i=iStep>>1; i>=1; i>>=1 )220 { 221 for ( j=i; j<m_pcCfg->getGOPSize(); j+=iStep )222 { 223 if ( j == iPOC)208 Int step = m_pcCfg->getGOPSize(); 209 depth = 0; 210 for( Int i=step>>1; i>=1; i>>=1 ) 211 { 212 for ( Int j=i; j<m_pcCfg->getGOPSize(); j+=step ) 213 { 214 if ( j == poc ) 224 215 { 225 216 i=0; … … 227 218 } 228 219 } 229 iStep>>=1;230 iDepth++;220 step >>= 1; 221 depth++; 231 222 } 232 223 } … … 237 228 238 229 eSliceType=B_SLICE; 239 eSliceType = ( iPOCLast == 0 || uiPOCCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;230 eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 240 231 241 232 rpcSlice->setSliceType ( eSliceType ); … … 245 236 // ------------------------------------------------------------------------------------------------------------------ 246 237 247 #if TEMPORAL_LAYER_NON_REFERENCE 248 if(iPOCLast == 0) 238 if(pocLast == 0) 249 239 { 250 240 rpcSlice->setTemporalLayerNonReferenceFlag(false); … … 255 245 } 256 246 rpcSlice->setReferenced(true); 257 #else258 rpcSlice->setReferenced(m_pcCfg->getGOPEntry(iGOPid).m_refPic);259 #endif260 #if !REMOVE_NAL_REF_FLAG261 rpcSlice->setNalRefFlag(m_pcCfg->getGOPEntry(iGOPid).m_refPic);262 #endif263 #if !TEMPORAL_LAYER_NON_REFERENCE264 if(eSliceType==I_SLICE)265 {266 rpcSlice->setReferenced(true);267 }268 #endif269 247 270 248 // ------------------------------------------------------------------------------------------------------------------ … … 287 265 dQP += pdQPs[ rpcSlice->getPOC() ]; 288 266 } 267 #if !RATE_CONTROL_LAMBDA_DOMAIN 289 268 if ( m_pcCfg->getUseRateCtrl()) 290 269 { 291 270 dQP = m_pcRateCtrl->getFrameQP(rpcSlice->isReferenced(), rpcSlice->getPOC()); 292 271 } 272 #endif 293 273 // ------------------------------------------------------------------------------------------------------------------ 294 274 // Lambda computation … … 309 289 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 310 290 #if FULL_NBIT 311 Int bitdepth_luma_qp_scale = 6 * (g_ uiBitDepth - 8);291 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); 312 292 #else 313 293 Int bitdepth_luma_qp_scale = 0; … … 325 305 dLambda = dQPFactor*pow( 2.0, qp_temp/3.0 ); 326 306 327 if ( iDepth>0 )307 if ( depth>0 ) 328 308 { 329 309 #if FULL_NBIT … … 335 315 336 316 // if hadamard is used in ME process 337 if ( !m_pcCfg->getUseHADME() )317 if ( !m_pcCfg->getUseHADME() && rpcSlice->getSliceType( ) != I_SLICE ) 338 318 { 339 319 dLambda *= 0.95; … … 363 343 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 364 344 Double weight = 1.0; 365 if(iQP >= 0) 366 { 367 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 368 } 369 m_pcRdCost ->setChromaDistortionWeight( weight ); 345 Int qpc; 346 Int chromaQPOffset; 347 348 chromaQPOffset = rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb(); 349 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 350 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 351 m_pcRdCost->setCbDistortionWeight(weight); 352 353 chromaQPOffset = rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr(); 354 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 355 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 356 m_pcRdCost->setCrDistortionWeight(weight); 370 357 #endif 371 358 … … 377 364 #endif 378 365 379 #if ALF_CHROMA_LAMBDA ||SAO_CHROMA_LAMBDA380 // For ALF orSAO366 #if SAO_CHROMA_LAMBDA 367 // For SAO 381 368 rpcSlice ->setLambda( dLambda, dLambda / weight ); 382 369 #else … … 386 373 #if HB_LAMBDA_FOR_LDC 387 374 // restore original slice type 388 eSliceType = (iPOCLast == 0 || uiPOCCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 375 eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 376 389 377 #if REF_IDX_FRAMEWORK 390 378 if(m_pcCfg->getLayerId() > 0) … … 396 384 #endif 397 385 398 #if RECALCULATE_QP_ACCORDING_LAMBDA399 386 if (m_pcCfg->getUseRecalculateQPAccordingToLambda()) 400 387 { … … 402 389 iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 403 390 } 404 #endif405 391 406 392 rpcSlice->setSliceQp ( iQP ); … … 409 395 #endif 410 396 rpcSlice->setSliceQpDelta ( 0 ); 411 #if CHROMA_QP_EXTENSION412 397 rpcSlice->setSliceQpDeltaCb ( 0 ); 413 398 rpcSlice->setSliceQpDeltaCr ( 0 ); 414 #endif415 399 rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive); 416 400 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive); … … 424 408 if ( !rpcSlice->getDeblockingFilterDisable()) 425 409 { 410 if ( !m_pcCfg->getLoopFilterOffsetInPPS() && eSliceType!=I_SLICE) 411 { 412 rpcSlice->getPPS()->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset() ); 413 rpcSlice->getPPS()->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() ); 414 rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset() ); 415 rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() ); 416 } 417 else 418 { 426 419 rpcSlice->getPPS()->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getLoopFilterBetaOffset() ); 427 420 rpcSlice->getPPS()->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getLoopFilterTcOffset() ); 428 421 rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getLoopFilterBetaOffset() ); 429 422 rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getLoopFilterTcOffset() ); 430 } 431 } 432 433 rpcSlice->setDepth ( iDepth ); 423 } 424 } 425 } 426 else 427 { 428 rpcSlice->setDeblockingFilterOverrideFlag( false ); 429 rpcSlice->setDeblockingFilterDisable( false ); 430 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 431 rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 ); 432 } 433 434 rpcSlice->setDepth ( depth ); 434 435 435 436 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); … … 447 448 rpcSlice->setSliceMode ( m_pcCfg->getSliceMode() ); 448 449 rpcSlice->setSliceArgument ( m_pcCfg->getSliceArgument() ); 449 rpcSlice->set DependentSliceMode ( m_pcCfg->getDependentSliceMode() );450 rpcSlice->set DependentSliceArgument ( m_pcCfg->getDependentSliceArgument() );450 rpcSlice->setSliceSegmentMode ( m_pcCfg->getSliceSegmentMode() ); 451 rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() ); 451 452 rpcSlice->setMaxNumMergeCand ( m_pcCfg->getMaxNumMergeCand() ); 452 453 xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() ); 453 454 } 454 455 455 456 #if RATE_CONTROL_LAMBDA_DOMAIN 457 Void TEncSlice::resetQP( TComPic* pic, Int sliceQP, Double lambda ) 458 { 459 TComSlice* slice = pic->getSlice(0); 460 461 // store lambda 462 slice->setSliceQp( sliceQP ); 463 #if L0033_RC_BUGFIX 464 slice->setSliceQpBase ( sliceQP ); 465 #endif 466 m_pcRdCost ->setLambda( lambda ); 467 #if WEIGHTED_CHROMA_DISTORTION 468 // for RDO 469 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 470 Double weight; 471 Int qpc; 472 Int chromaQPOffset; 473 474 chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb(); 475 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 476 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 477 m_pcRdCost->setCbDistortionWeight(weight); 478 479 chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr(); 480 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 481 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 482 m_pcRdCost->setCrDistortionWeight(weight); 483 #endif 484 485 #if RDOQ_CHROMA_LAMBDA 486 // for RDOQ 487 m_pcTrQuant->setLambda( lambda, lambda / weight ); 488 #else 489 m_pcTrQuant->setLambda( lambda ); 490 #endif 491 492 #if SAO_CHROMA_LAMBDA 493 // For SAO 494 slice ->setLambda( lambda, lambda / weight ); 495 #else 496 slice ->setLambda( lambda ); 497 #endif 498 } 499 #else 456 500 /** 457 501 - lambda re-computation based on rate control QP … … 475 519 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 476 520 #if FULL_NBIT 477 Int bitdepth_luma_qp_scale = 6 * (g_ uiBitDepth - 8);521 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); 478 522 #else 479 523 Int bitdepth_luma_qp_scale = 0; … … 529 573 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 530 574 Double weight = 1.0; 531 if(qp >= 0) 532 { 533 weight = pow( 2.0, (qp-g_aucChromaScale[qp])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 534 } 535 m_pcRdCost ->setChromaDistortionWeight( weight ); 575 Int qpc; 576 Int chromaQPOffset; 577 578 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 579 qpc = Clip3( 0, 57, qp + chromaQPOffset); 580 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 581 m_pcRdCost->setCbDistortionWeight(weight); 582 583 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 584 qpc = Clip3( 0, 57, qp + chromaQPOffset); 585 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 586 m_pcRdCost->setCrDistortionWeight(weight); 536 587 #endif 537 588 … … 543 594 #endif 544 595 545 #if ALF_CHROMA_LAMBDA ||SAO_CHROMA_LAMBDA546 // For ALF orSAO596 #if SAO_CHROMA_LAMBDA 597 // For SAO 547 598 pcSlice ->setLambda( lambda, lambda / weight ); 548 599 #else … … 550 601 #endif 551 602 } 603 #endif 552 604 // ==================================================================================================================== 553 605 // Public member functions … … 588 640 return; 589 641 } 642 643 #if RATE_CONTROL_LAMBDA_DOMAIN 644 if ( m_pcCfg->getUseRateCtrl() ) 645 { 646 printf( "\nMultiple QP optimization is not allowed when rate control is enabled." ); 647 assert(0); 648 } 649 #endif 590 650 591 651 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); … … 595 655 Double dFrameLambda; 596 656 #if FULL_NBIT 597 Int SHIFT_QP = 12 + 6 * (g_ uiBitDepth - 8);657 Int SHIFT_QP = 12 + 6 * (g_bitDepth - 8); 598 658 #else 599 659 Int SHIFT_QP = 12; … … 622 682 // for RDO 623 683 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 624 int iQP = m_piRdPicQp [uiQpIdx];684 Int iQP = m_piRdPicQp [uiQpIdx]; 625 685 Double weight = 1.0; 626 if(iQP >= 0) 627 { 628 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 629 } 630 m_pcRdCost ->setChromaDistortionWeight( weight ); 686 Int qpc; 687 Int chromaQPOffset; 688 689 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 690 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 691 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 692 m_pcRdCost->setCbDistortionWeight(weight); 693 694 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 695 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 696 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 697 m_pcRdCost->setCrDistortionWeight(weight); 631 698 #endif 632 699 … … 637 704 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 638 705 #endif 639 #if ALF_CHROMA_LAMBDA ||SAO_CHROMA_LAMBDA640 // For ALF orSAO706 #if SAO_CHROMA_LAMBDA 707 // For SAO 641 708 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight ); 642 709 #else … … 671 738 #if WEIGHTED_CHROMA_DISTORTION 672 739 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 673 int iQP = m_piRdPicQp [uiQpIdxBest];740 Int iQP = m_piRdPicQp [uiQpIdxBest]; 674 741 Double weight = 1.0; 675 if(iQP >= 0) 676 { 677 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 678 } 679 m_pcRdCost ->setChromaDistortionWeight( weight ); 742 Int qpc; 743 Int chromaQPOffset; 744 745 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 746 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 747 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 748 m_pcRdCost->setCbDistortionWeight(weight); 749 750 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 751 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 752 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 753 m_pcRdCost->setCrDistortionWeight(weight); 680 754 #endif 681 755 … … 686 760 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 687 761 #endif 688 #if ALF_CHROMA_LAMBDA ||SAO_CHROMA_LAMBDA689 // For ALF orSAO762 #if SAO_CHROMA_LAMBDA 763 // For SAO 690 764 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 691 765 #else … … 701 775 UInt uiStartCUAddr; 702 776 UInt uiBoundingCUAddr; 703 rpcPic->getSlice(getSliceIdx())->set DependentSliceCounter(0);777 rpcPic->getSlice(getSliceIdx())->setSliceSegmentBits(0); 704 778 TEncBinCABAC* pppcRDSbacCoder = NULL; 705 779 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); … … 745 819 // Weighted Prediction implemented at Slice level. SliceMode=2 is not supported yet. 746 820 //------------------------------------------------------------------------------ 747 if ( pcSlice->getSliceMode()==2 || pcSlice->get DependentSliceMode()==2 )821 if ( pcSlice->getSliceMode()==2 || pcSlice->getSliceSegmentMode()==2 ) 748 822 { 749 823 printf("Weighted Prediction is not supported with slice mode determined by max number of bins.\n"); exit(0); … … 782 856 m_pcBufferSbacCoders = new TEncSbac [uiTilesAcross]; 783 857 m_pcBufferBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 784 for ( int ui = 0; ui < uiTilesAcross; ui++)858 for (Int ui = 0; ui < uiTilesAcross; ui++) 785 859 { 786 860 m_pcBufferSbacCoders[ui].init( &m_pcBufferBinCoderCABACs[ui] ); … … 802 876 m_pcBufferLowLatSbacCoders = new TEncSbac [uiTilesAcross]; 803 877 m_pcBufferLowLatBinCoderCABACs = new TEncBinCABAC[uiTilesAcross]; 804 for ( int ui = 0; ui < uiTilesAcross; ui++)878 for (Int ui = 0; ui < uiTilesAcross; ui++) 805 879 { 806 880 m_pcBufferLowLatSbacCoders[ui].init( &m_pcBufferLowLatBinCoderCABACs[ui] ); … … 820 894 #endif 821 895 822 823 #if DEPENDENT_SLICES 824 Bool bAllowDependence = false; 825 #if TILES_WPP_ENTROPYSLICES_FLAGS 826 if( pcSlice->getPPS()->getDependentSliceEnabledFlag()&&(!pcSlice->getPPS()->getEntropySliceEnabledFlag()) ) 827 #else 828 if( pcSlice->getPPS()->getDependentSliceEnabledFlag()&&(!pcSlice->getPPS()->getCabacIndependentFlag()) ) 829 #endif 830 { 831 bAllowDependence = true; 832 } 833 if( bAllowDependence ) 834 { 835 if(pcSlice->getDependentSliceCurStartCUAddr()!= pcSlice->getSliceCurStartCUAddr()) 896 Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 897 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 898 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 899 if( depSliceSegmentsEnabled ) 900 { 901 if((pcSlice->getSliceSegmentCurStartCUAddr()!= pcSlice->getSliceCurStartCUAddr())&&(uiCUAddr != uiTileStartLCU)) 836 902 { 837 903 if( m_pcCfg->getWaveFrontsynchro() ) 838 904 { 905 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 839 906 m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] ); 840 }841 m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( CTXMem[0] );842 if (pcSlice->getPPS()->getNumSubstreams() > 1)843 {844 907 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 845 908 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); … … 847 910 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(rpcPic->getPicSym()->getCUOrderMap(uiCUAddr))*iNumSubstreamsPerTile 848 911 + uiLin%iNumSubstreamsPerTile; 849 } 912 if ( (uiCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) 913 { 914 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 915 uiCol = uiCUAddr % uiWidthInLCUs; 916 if(uiCol==uiTileStartLCU) 917 { 918 CTXMem[0]->loadContexts(m_pcSbacCoder); 919 } 920 } 921 } 922 m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( CTXMem[0] ); 850 923 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( CTXMem[0] ); 851 924 } … … 859 932 } 860 933 } 861 #endif862 934 // for every CU in slice 863 935 UInt uiEncCUOrder; 864 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());865 936 for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU(); 866 937 uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU(); … … 874 945 #endif 875 946 947 #if !RATE_CONTROL_LAMBDA_DOMAIN 876 948 if(m_pcCfg->getUseRateCtrl()) 877 949 { … … 881 953 } 882 954 } 955 #endif 883 956 // inherit from TR if necessary, select substream to use. 884 957 if( m_pcCfg->getUseSBACRD() ) … … 902 975 uiSubStrm = uiLin % iNumSubstreams; 903 976 } 904 #if DEPENDENT_SLICES 905 if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 906 #else 907 if ( pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX) ) 908 #endif 977 if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 909 978 { 910 979 // We'll sync if the TR is available. … … 920 989 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 921 990 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 922 )||923 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||924 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getDependentSliceCurStartCUAddr()) ||925 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))926 991 ) 927 992 ) 928 993 { 929 #if DEPENDENT_SLICES930 if ( (uiCUAddr != 0) && (pcCUTR->getSCUAddr()+uiMaxParts-1 >= pcSlice->getSliceCurStartCUAddr()) && bAllowDependence)931 {932 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferSbacCoders[uiTileCol] );933 }934 #endif935 994 // TR not available. 936 995 } … … 947 1006 if( uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() && // must be first CU of tile 948 1007 uiCUAddr!=0 && // cannot be first CU of picture 949 #if DEPENDENT_SLICES 950 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr())/rpcPic->getNumPartInCU() && 951 #endif 1008 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU() && 952 1009 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) // cannot be first CU of slice 953 1010 { … … 970 1027 971 1028 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 1029 1030 #if RATE_CONTROL_LAMBDA_DOMAIN 1031 Double oldLambda = m_pcRdCost->getLambda(); 1032 if ( m_pcCfg->getUseRateCtrl() ) 1033 { 1034 Int estQP = pcSlice->getSliceQp(); 1035 Double estLambda = -1.0; 1036 Double bpp = -1.0; 1037 1038 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() ) 1039 { 1040 estQP = pcSlice->getSliceQp(); 1041 } 1042 else 1043 { 1044 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(); 1045 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1046 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1047 estQP = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP ); 1048 1049 m_pcRdCost->setLambda(estLambda); 1050 } 1051 1052 m_pcRateCtrl->setRCQP( estQP ); 1053 #if L0033_RC_BUGFIX 1054 pcCU->getSlice()->setSliceQpBase( estQP ); 1055 #endif 1056 } 1057 #endif 1058 972 1059 // run CU encoder 973 1060 m_pcCuEncoder->compressCU( pcCU ); 1061 1062 #if RATE_CONTROL_LAMBDA_DOMAIN 1063 if ( m_pcCfg->getUseRateCtrl() ) 1064 { 1065 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1066 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1067 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1068 Double MAD = (Double)SAD / (Double)(height * width); 1069 MAD = MAD * MAD; 1070 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD; 1071 1072 Int actualQP = g_RCInvalidQPValue; 1073 Double actualLambda = m_pcRdCost->getLambda(); 1074 Int actualBits = pcCU->getTotalBits(); 1075 Int numberOfEffectivePixels = 0; 1076 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ ) 1077 { 1078 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) ) 1079 { 1080 numberOfEffectivePixels = numberOfEffectivePixels + 16; 1081 break; 1082 } 1083 } 1084 1085 if ( numberOfEffectivePixels == 0 ) 1086 { 1087 actualQP = g_RCInvalidQPValue; 1088 } 1089 else 1090 { 1091 actualQP = pcCU->getQP( 0 ); 1092 } 1093 m_pcRdCost->setLambda(oldLambda); 1094 1095 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() ); 1096 } 1097 #endif 974 1098 975 1099 // restore entropy coder to an initial stage … … 984 1108 985 1109 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 986 if (m_pcCfg->getSliceMode()== AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&& ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)1110 if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 987 1111 { 988 1112 pcSlice->setNextSlice( true ); 989 1113 break; 990 1114 } 991 if (m_pcCfg->get DependentSliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_DEPENDENT_SLICE && pcSlice->getDependentSliceCounter()+pppcRDSbacCoder->getBinsCoded() > m_pcCfg->getDependentSliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getDependentSliceCurEndCUAddr())992 { 993 pcSlice->setNext DependentSlice( true );1115 if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+m_pcEntropyCoder->getNumberOfWrittenBits() > (m_pcCfg->getSliceSegmentArgument() << 3) &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr()) 1116 { 1117 pcSlice->setNextSliceSegment( true ); 994 1118 break; 995 1119 } … … 999 1123 1000 1124 //Store probabilties of second LCU in line into buffer 1001 #if DEPENDENT_SLICES 1002 if ( ( uiCol == uiTileLCUX+1) && (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro()) 1003 #else 1004 if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX+1) 1005 #endif 1125 if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro()) 1006 1126 { 1007 1127 m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]); … … 1014 1134 m_pcCuEncoder->compressCU( pcCU ); 1015 1135 m_pcCuEncoder->encodeCU( pcCU ); 1016 if (m_pcCfg->getSliceMode()== AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&& ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)1136 if (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_BYTES && ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1017 1137 { 1018 1138 pcSlice->setNextSlice( true ); 1019 1139 break; 1020 1140 } 1021 if (m_pcCfg->get DependentSliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_DEPENDENT_SLICE && pcSlice->getDependentSliceCounter()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getDependentSliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getDependentSliceCurEndCUAddr())1022 { 1023 pcSlice->setNext DependentSlice( true );1141 if (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES && pcSlice->getSliceSegmentBits()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getSliceSegmentArgument()<<3 &&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getSliceSegmentCurEndCUAddr()) 1142 { 1143 pcSlice->setNextSliceSegment( true ); 1024 1144 break; 1025 1145 } … … 1029 1149 m_dPicRdCost += pcCU->getTotalCost(); 1030 1150 m_uiPicDist += pcCU->getTotalDistortion(); 1151 #if !RATE_CONTROL_LAMBDA_DOMAIN 1031 1152 if(m_pcCfg->getUseRateCtrl()) 1032 1153 { … … 1034 1155 m_pcRateCtrl->updataRCUnitStatus(); 1035 1156 } 1036 } 1037 #if DEPENDENT_SLICES 1038 if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !bAllowDependence) 1039 #else 1040 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1041 #endif 1157 #endif 1158 } 1159 if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled) 1042 1160 { 1043 1161 pcSlice->setNextSlice( true ); 1044 1162 } 1045 #if DEPENDENT_SLICES 1046 if( bAllowDependence ) 1163 if( depSliceSegmentsEnabled ) 1047 1164 { 1048 1165 if (m_pcCfg->getWaveFrontsynchro()) … … 1052 1169 CTXMem[0]->loadContexts( m_pppcRDSbacCoder[0][CI_CURR_BEST] );//ctx end of dep.slice 1053 1170 } 1054 #endif1055 1171 xRestoreWPparam( pcSlice ); 1172 #if !RATE_CONTROL_LAMBDA_DOMAIN 1056 1173 if(m_pcCfg->getUseRateCtrl()) 1057 1174 { 1058 1175 m_pcRateCtrl->updateFrameData(m_uiPicTotalBits); 1059 1176 } 1177 #endif 1060 1178 } 1061 1179 … … 1071 1189 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 1072 1190 1073 uiStartCUAddr=pcSlice->get DependentSliceCurStartCUAddr();1074 uiBoundingCUAddr=pcSlice->get DependentSliceCurEndCUAddr();1191 uiStartCUAddr=pcSlice->getSliceSegmentCurStartCUAddr(); 1192 uiBoundingCUAddr=pcSlice->getSliceSegmentCurEndCUAddr(); 1075 1193 // choose entropy coder 1076 1194 { … … 1121 1239 UInt uiTileStartLCU = 0; 1122 1240 UInt uiTileLCUX = 0; 1123 #if DEPENDENT_SLICES 1124 Bool bAllowDependence = false; 1125 #if TILES_WPP_ENTROPYSLICES_FLAGS 1126 if( pcSlice->getPPS()->getDependentSliceEnabledFlag()&&(!pcSlice->getPPS()->getEntropySliceEnabledFlag()) ) 1127 #else 1128 if( pcSlice->getPPS()->getDependentSliceEnabledFlag()&&(!pcSlice->getPPS()->getCabacIndependentFlag()) ) 1129 #endif 1130 { 1131 bAllowDependence = true; 1132 } 1133 if( bAllowDependence ) 1134 { 1135 if(pcSlice->isNextSlice()) 1241 Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 1242 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); /* for tiles, uiStartCUAddr is NOT the real raster scan address, it is actually 1243 an encoding order index, so we need to convert the index (uiStartCUAddr) 1244 into the real raster scan address (uiCUAddr) via the CUOrderMap */ 1245 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 1246 if( depSliceSegmentsEnabled ) 1247 { 1248 if( pcSlice->isNextSlice()|| 1249 uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr()) 1136 1250 { 1137 1251 if(m_pcCfg->getWaveFrontsynchro()) … … 1145 1259 if(m_pcCfg->getWaveFrontsynchro()) 1146 1260 { 1261 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 1147 1262 m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] ); 1148 }1149 if(pcSlice->getPPS()->getNumSubstreams() > 1)1150 {1151 1263 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 1152 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());1153 1264 uiLin = uiCUAddr / uiWidthInLCUs; 1154 1265 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(rpcPic->getPicSym()->getCUOrderMap( uiCUAddr))*iNumSubstreamsPerTile 1155 1266 + uiLin%iNumSubstreamsPerTile; 1267 if ( (uiCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) 1268 { 1269 uiCol = uiCUAddr % uiWidthInLCUs; 1270 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 1271 if(uiCol==uiTileLCUX) 1272 { 1273 CTXMem[0]->loadContexts(m_pcSbacCoder); 1274 } 1275 } 1156 1276 } 1157 1277 pcSbacCoders[uiSubStrm].loadContexts( CTXMem[0] ); 1158 1278 } 1159 1279 } 1160 #endif1161 1280 1162 1281 UInt uiEncCUOrder; 1163 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); /*for tiles, uiStartCUAddr is NOT the real raster scan address, it is actually1164 an encoding order index, so we need to convert the index (uiStartCUAddr)1165 into the real raster scan address (uiCUAddr) via the CUOrderMap*/1166 1282 for( uiEncCUOrder = uiStartCUAddr /rpcPic->getNumPartInCU(); 1167 1283 uiEncCUOrder < (uiBoundingCUAddr+rpcPic->getNumPartInCU()-1)/rpcPic->getNumPartInCU(); … … 1191 1307 m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] ); 1192 1308 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 1193 #if DEPENDENT_SLICES 1194 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1195 #else 1196 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX)) 1197 #endif 1309 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1198 1310 { 1199 1311 // We'll sync if the TR is available. … … 1210 1322 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 1211 1323 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 1212 ))||1213 (true/*bEnforceDependentSliceRestriction*/ &&1214 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||1215 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getDependentSliceCurStartCUAddr()) ||1216 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))1217 1324 )) 1218 1325 ) 1219 1326 { 1220 #if DEPENDENT_SLICES1221 if ( (uiCUAddr != 0) && ( pcCUTR->getSCUAddr()+uiMaxParts-1 >= pcSlice->getSliceCurStartCUAddr() ) && bAllowDependence)1222 {1223 pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferSbacCoders[uiTileCol] );1224 }1225 #endif1226 1327 // TR not available. 1227 1328 } … … 1237 1338 if( uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() && // must be first CU of tile 1238 1339 uiCUAddr!=0 && // cannot be first CU of picture 1239 #if DEPENDENT_SLICES 1240 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr())/rpcPic->getNumPartInCU() && 1241 #endif 1340 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU() && 1242 1341 uiCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) // cannot be first CU of slice 1243 1342 { … … 1258 1357 } 1259 1358 m_pcEntropyCoder->updateContextTables( sliceType, pcSlice->getSliceQp() ); 1260 #if BYTE_ALIGNMENT1261 1359 // Byte-alignment in slice_data() when new tile 1262 1360 pcSubstreams[uiSubStrm].writeByteAlignment(); 1263 #else1264 pcSubstreams[uiSubStrm].write( 1, 1 );1265 pcSubstreams[uiSubStrm].writeAlignZero();1266 #endif1267 1361 } 1268 1362 } … … 1313 1407 1314 1408 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1315 #if !SAO_LUM_CHROMA_ONOFF_FLAGS1316 if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getSaoEnabledFlag() )1317 #else1318 1409 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 1319 #endif 1320 { 1321 #if REMOVE_APS 1410 { 1322 1411 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam(); 1323 #else1324 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();1325 #endif1326 1412 Int iNumCuInWidth = saoParam->numCuInWidth; 1327 1413 Int iCUAddrInSlice = uiCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU()); … … 1346 1432 } 1347 1433 Int addr = pcCU->getAddr(); 1348 #if SAO_SINGLE_MERGE1349 1434 allowMergeLeft = allowMergeLeft && (rx>0) && (iCUAddrInSlice!=0); 1350 1435 allowMergeUp = allowMergeUp && (ry>0) && (iCUAddrUpInSlice>=0); 1351 #if SAO_TYPE_SHARING1352 1436 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] ) 1353 #else1354 if( saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1] || saoParam->bSaoFlag[2])1355 #endif1356 1437 { 1357 1438 Int mergeLeft = saoParam->saoLcuParam[0][addr].mergeLeftFlag; … … 1359 1440 if (allowMergeLeft) 1360 1441 { 1361 #if SAO_MERGE_ONE_CTX1362 1442 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft); 1363 #else1364 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMergeLeft(mergeLeft, 0);1365 #endif1366 1443 } 1367 1444 else … … 1373 1450 if (allowMergeUp) 1374 1451 { 1375 #if SAO_MERGE_ONE_CTX1376 1452 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeUp); 1377 #else1378 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMergeUp(mergeUp);1379 #endif1380 1453 } 1381 1454 else … … 1387 1460 for (Int compIdx=0;compIdx<3;compIdx++) 1388 1461 { 1389 #if SAO_TYPE_SHARING1390 1462 if( (compIdx == 0 && saoParam->bSaoFlag[0]) || (compIdx > 0 && saoParam->bSaoFlag[1])) 1391 #else1392 if( saoParam->bSaoFlag[compIdx])1393 #endif1394 1463 { 1395 #if SAO_TYPE_SHARING1396 1464 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr], compIdx); 1397 #else1398 m_pcEntropyCoder->encodeSaoOffset(&saoParam->saoLcuParam[compIdx][addr]);1399 #endif1400 1465 } 1401 1466 } … … 1403 1468 } 1404 1469 } 1405 #else 1406 m_pcEntropyCoder->encodeSaoUnitInterleaving(0, saoParam->bSaoFlag[0], rx, ry, &(saoParam->saoLcuParam[0][addr]), iCUAddrInSlice, iCUAddrUpInSlice, allowMergeLeft, allowMergeUp); 1407 m_pcEntropyCoder->encodeSaoUnitInterleaving(1, saoParam->bSaoFlag[1], rx, ry, &(saoParam->saoLcuParam[1][addr]), iCUAddrInSlice, iCUAddrUpInSlice, allowMergeLeft, allowMergeUp); 1408 m_pcEntropyCoder->encodeSaoUnitInterleaving(2, saoParam->bSaoFlag[2], rx, ry, &(saoParam->saoLcuParam[2][addr]), iCUAddrInSlice, iCUAddrUpInSlice, allowMergeLeft, allowMergeUp); 1409 #endif 1470 } 1471 else if (pcSlice->getSPS()->getUseSAO()) 1472 { 1473 Int addr = pcCU->getAddr(); 1474 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam(); 1475 for (Int cIdx=0; cIdx<3; cIdx++) 1476 { 1477 SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]); 1478 if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma())) 1479 { 1480 saoLcuParam->mergeUpFlag = 0; 1481 saoLcuParam->mergeLeftFlag = 0; 1482 saoLcuParam->subTypeIdx = 0; 1483 saoLcuParam->typeIdx = -1; 1484 saoLcuParam->offset[0] = 0; 1485 saoLcuParam->offset[1] = 0; 1486 saoLcuParam->offset[2] = 0; 1487 saoLcuParam->offset[3] = 0; 1488 } 1489 } 1410 1490 } 1411 1491 #if ENC_DEC_TRACE 1412 1492 g_bJustDoIt = g_bEncDecTraceEnable; 1413 1493 #endif 1414 #if !REMOVE_ALF 1415 if( pcSlice->getSPS()->getUseALF()) 1416 { 1417 for(Int compIdx=0; compIdx< 3; compIdx++) 1418 { 1419 if(pcSlice->getAlfEnabledFlag(compIdx)) 1420 { 1421 m_pcEntropyCoder->encodeAlfCtrlFlag(compIdx, pcCU->getAlfLCUEnabled(compIdx)?1:0); 1422 } 1423 } 1424 } 1425 #endif 1426 if ( (m_pcCfg->getSliceMode()!=0 || m_pcCfg->getDependentSliceMode()!=0) && 1494 if ( (m_pcCfg->getSliceMode()!=0 || m_pcCfg->getSliceSegmentMode()!=0) && 1427 1495 uiCUAddr == rpcPic->getPicSym()->getCUOrderMap((uiBoundingCUAddr+rpcPic->getNumPartInCU()-1)/rpcPic->getNumPartInCU()-1) ) 1428 1496 { 1429 m_pcCuEncoder->encodeCU( pcCU , true);1497 m_pcCuEncoder->encodeCU( pcCU ); 1430 1498 } 1431 1499 else … … 1442 1510 1443 1511 //Store probabilties of second LCU in line into buffer 1444 #if DEPENDENT_SLICES 1445 if ( (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1446 #else 1447 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1)) 1448 #endif 1512 if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1449 1513 { 1450 1514 m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] ); … … 1452 1516 } 1453 1517 } 1454 #if DEPENDENT_SLICES 1455 if( bAllowDependence ) 1518 if( depSliceSegmentsEnabled ) 1456 1519 { 1457 1520 if (m_pcCfg->getWaveFrontsynchro()) … … 1461 1524 CTXMem[0]->loadContexts( m_pcSbacCoder );//ctx end of dep.slice 1462 1525 } 1463 #endif1464 1526 #if ADAPTIVE_QP_SELECTION 1465 1527 if( m_pcCfg->getUseAdaptQpSelect() ) … … 1470 1532 if (pcSlice->getPPS()->getCabacInitPresentFlag()) 1471 1533 { 1472 if (pcSlice->getPPS()->getDependentSlice EnabledFlag())1534 if (pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag()) 1473 1535 { 1474 1536 pcSlice->getPPS()->setEncCABACTableIdx( pcSlice->getSliceType() ); … … 1485 1547 * \returns Updates uiStartCUAddr, uiBoundingCUAddr with appropriate LCU address 1486 1548 */ 1487 Void TEncSlice::xDetermineStartAndBoundingCUAddr ( UInt& uiStartCUAddr, UInt& uiBoundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice )1549 Void TEncSlice::xDetermineStartAndBoundingCUAddr ( UInt& startCUAddr, UInt& boundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice ) 1488 1550 { 1489 1551 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); … … 1503 1565 switch (m_pcCfg->getSliceMode()) 1504 1566 { 1505 case AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE:1567 case FIXED_NUMBER_OF_LCU: 1506 1568 uiCUAddrIncrement = m_pcCfg->getSliceArgument(); 1507 1569 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1508 1570 break; 1509 case AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE:1571 case FIXED_NUMBER_OF_BYTES: 1510 1572 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); 1511 1573 uiBoundingCUAddrSlice = pcSlice->getSliceCurEndCUAddr(); 1512 1574 break; 1513 case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE:1575 case FIXED_NUMBER_OF_TILES: 1514 1576 tileIdx = rpcPic->getPicSym()->getTileIdxMap( 1515 1577 rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddrSlice/rpcPic->getNumPartInCU()) … … 1524 1586 tileWidthInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth(); 1525 1587 tileHeightInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight(); 1526 #if REMOVE_FGS1527 1588 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()); 1528 #else1529 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()) >> (m_pcCfg->getSliceGranularity() << 1);1530 #endif1531 1589 } 1532 1590 } … … 1539 1597 break; 1540 1598 } 1599 // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row 1600 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0)) 1601 { 1602 uiBoundingCUAddrSlice = min(uiBoundingCUAddrSlice, uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())) + (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())); 1603 } 1541 1604 pcSlice->setSliceCurEndCUAddr( uiBoundingCUAddrSlice ); 1542 1605 } … … 1546 1609 switch (m_pcCfg->getSliceMode()) 1547 1610 { 1548 case AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE:1611 case FIXED_NUMBER_OF_LCU: 1549 1612 uiCUAddrIncrement = m_pcCfg->getSliceArgument(); 1550 1613 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1551 1614 break; 1552 case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE:1615 case FIXED_NUMBER_OF_TILES: 1553 1616 tileIdx = rpcPic->getPicSym()->getTileIdxMap( 1554 1617 rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddrSlice/rpcPic->getNumPartInCU()) … … 1563 1626 tileWidthInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth(); 1564 1627 tileHeightInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight(); 1565 #if REMOVE_FGS1566 1628 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()); 1567 #else1568 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()) >> (m_pcCfg->getSliceGranularity() << 1);1569 #endif1570 1629 } 1571 1630 } … … 1578 1637 break; 1579 1638 } 1580 // set the slice end address to the end of the SCU row if the slice does not start at the beginning of an SCUrow1639 // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row 1581 1640 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0)) 1582 1641 { 1583 uiBoundingCUAddrSlice = uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())) + (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU());1642 uiBoundingCUAddrSlice = min(uiBoundingCUAddrSlice, uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())) + (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())); 1584 1643 } 1585 1644 pcSlice->setSliceCurEndCUAddr( uiBoundingCUAddrSlice ); … … 1587 1646 1588 1647 Bool tileBoundary = false; 1589 if ((m_pcCfg->getSliceMode() == AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE || m_pcCfg->getSliceMode() == AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE) &&1648 if ((m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_BYTES) && 1590 1649 (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0)) 1591 1650 { … … 1610 1669 1611 1670 // Dependent slice 1612 UInt uiStartCUAddrDependentSlice, uiBoundingCUAddrDependentSlice;1613 uiStartCUAddrDependentSlice = pcSlice->getDependentSliceCurStartCUAddr();1614 uiBoundingCUAddrDependentSlice= uiNumberOfCUsInFrame;1671 UInt startCUAddrSliceSegment, boundingCUAddrSliceSegment; 1672 startCUAddrSliceSegment = pcSlice->getSliceSegmentCurStartCUAddr(); 1673 boundingCUAddrSliceSegment = uiNumberOfCUsInFrame; 1615 1674 if (bEncodeSlice) 1616 1675 { 1617 1676 UInt uiCUAddrIncrement; 1618 switch (m_pcCfg->get DependentSliceMode())1619 { 1620 case SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE:1621 uiCUAddrIncrement = m_pcCfg->get DependentSliceArgument();1622 uiBoundingCUAddrDependentSlice = ((uiStartCUAddrDependentSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (uiStartCUAddrDependentSlice+ uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();1677 switch (m_pcCfg->getSliceSegmentMode()) 1678 { 1679 case FIXED_NUMBER_OF_LCU: 1680 uiCUAddrIncrement = m_pcCfg->getSliceSegmentArgument(); 1681 boundingCUAddrSliceSegment = ((startCUAddrSliceSegment + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (startCUAddrSliceSegment + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1623 1682 break; 1624 case SHARP_MULTIPLE_CONSTRAINT_BASED_DEPENDENT_SLICE:1683 case FIXED_NUMBER_OF_BYTES: 1625 1684 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); 1626 uiBoundingCUAddrDependentSlice = pcSlice->getDependentSliceCurEndCUAddr();1685 boundingCUAddrSliceSegment = pcSlice->getSliceSegmentCurEndCUAddr(); 1627 1686 break; 1628 #if DEPENDENT_SLICES 1629 case FIXED_NUMBER_OF_TILES_IN_DEPENDENT_SLICE: 1687 case FIXED_NUMBER_OF_TILES: 1630 1688 tileIdx = rpcPic->getPicSym()->getTileIdxMap( 1631 rpcPic->getPicSym()->getCUOrderMap(pcSlice->get DependentSliceCurStartCUAddr()/rpcPic->getNumPartInCU())1689 rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()) 1632 1690 ); 1633 1691 uiCUAddrIncrement = 0; 1634 1692 tileTotalCount = (rpcPic->getPicSym()->getNumColumnsMinus1()+1) * (rpcPic->getPicSym()->getNumRowsMinus1()+1); 1635 1693 1636 for(tileIdxIncrement = 0; tileIdxIncrement < m_pcCfg->get DependentSliceArgument(); tileIdxIncrement++)1694 for(tileIdxIncrement = 0; tileIdxIncrement < m_pcCfg->getSliceSegmentArgument(); tileIdxIncrement++) 1637 1695 { 1638 1696 if((tileIdx + tileIdxIncrement) < tileTotalCount) … … 1640 1698 tileWidthInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth(); 1641 1699 tileHeightInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight(); 1642 #if REMOVE_FGS1643 1700 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()); 1644 #else 1645 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()) >> (m_pcCfg->getSliceGranularity() << 1); 1646 #endif 1647 } 1648 } 1649 uiBoundingCUAddrDependentSlice = ((uiStartCUAddrDependentSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (uiStartCUAddrDependentSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1701 } 1702 } 1703 boundingCUAddrSliceSegment = ((startCUAddrSliceSegment + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (startCUAddrSliceSegment + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1650 1704 break; 1651 #endif1652 1705 default: 1653 1706 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); 1654 uiBoundingCUAddrDependentSlice= uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();1707 boundingCUAddrSliceSegment = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1655 1708 break; 1656 1709 } 1657 pcSlice->setDependentSliceCurEndCUAddr( uiBoundingCUAddrDependentSlice ); 1710 // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row 1711 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0)) 1712 { 1713 boundingCUAddrSliceSegment = min(boundingCUAddrSliceSegment, startCUAddrSliceSegment - (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())) + (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())); 1714 } 1715 pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment ); 1658 1716 } 1659 1717 else 1660 1718 { 1661 1719 UInt uiCUAddrIncrement; 1662 switch (m_pcCfg->get DependentSliceMode())1663 { 1664 case SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE:1665 uiCUAddrIncrement = m_pcCfg->get DependentSliceArgument();1666 uiBoundingCUAddrDependentSlice = ((uiStartCUAddrDependentSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (uiStartCUAddrDependentSlice+ uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();1720 switch (m_pcCfg->getSliceSegmentMode()) 1721 { 1722 case FIXED_NUMBER_OF_LCU: 1723 uiCUAddrIncrement = m_pcCfg->getSliceSegmentArgument(); 1724 boundingCUAddrSliceSegment = ((startCUAddrSliceSegment + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (startCUAddrSliceSegment + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1667 1725 break; 1668 #if DEPENDENT_SLICES 1669 case FIXED_NUMBER_OF_TILES_IN_DEPENDENT_SLICE: 1726 case FIXED_NUMBER_OF_TILES: 1670 1727 tileIdx = rpcPic->getPicSym()->getTileIdxMap( 1671 rpcPic->getPicSym()->getCUOrderMap(pcSlice->get DependentSliceCurStartCUAddr()/rpcPic->getNumPartInCU())1728 rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()) 1672 1729 ); 1673 1730 uiCUAddrIncrement = 0; 1674 1731 tileTotalCount = (rpcPic->getPicSym()->getNumColumnsMinus1()+1) * (rpcPic->getPicSym()->getNumRowsMinus1()+1); 1675 1732 1676 for(tileIdxIncrement = 0; tileIdxIncrement < m_pcCfg->get DependentSliceArgument(); tileIdxIncrement++)1733 for(tileIdxIncrement = 0; tileIdxIncrement < m_pcCfg->getSliceSegmentArgument(); tileIdxIncrement++) 1677 1734 { 1678 1735 if((tileIdx + tileIdxIncrement) < tileTotalCount) … … 1680 1737 tileWidthInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth(); 1681 1738 tileHeightInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight(); 1682 #if REMOVE_FGS1683 1739 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()); 1684 #else 1685 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * rpcPic->getNumPartInCU()) >> (m_pcCfg->getSliceGranularity() << 1); 1686 #endif 1687 } 1688 } 1689 uiBoundingCUAddrDependentSlice = ((uiStartCUAddrDependentSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (uiStartCUAddrDependentSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1740 } 1741 } 1742 boundingCUAddrSliceSegment = ((startCUAddrSliceSegment + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU() ) ? (startCUAddrSliceSegment + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1690 1743 break; 1691 #endif1692 1744 default: 1693 1745 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); 1694 uiBoundingCUAddrDependentSlice= uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();1746 boundingCUAddrSliceSegment = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1695 1747 break; 1696 1748 } 1697 pcSlice->setDependentSliceCurEndCUAddr( uiBoundingCUAddrDependentSlice ); 1698 } 1699 if(uiBoundingCUAddrDependentSlice>uiBoundingCUAddrSlice) 1700 { 1701 uiBoundingCUAddrDependentSlice = uiBoundingCUAddrSlice; 1702 pcSlice->setDependentSliceCurEndCUAddr(uiBoundingCUAddrSlice); 1703 } 1749 // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row 1750 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0)) 1751 { 1752 boundingCUAddrSliceSegment = min(boundingCUAddrSliceSegment, startCUAddrSliceSegment - (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())) + (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU())); 1753 } 1754 pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment ); 1755 } 1756 if ((m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_BYTES) && 1757 (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0)) 1758 { 1759 UInt lcuEncAddr = (startCUAddrSliceSegment+rpcPic->getNumPartInCU()-1)/rpcPic->getNumPartInCU(); 1760 UInt lcuAddr = rpcPic->getPicSym()->getCUOrderMap(lcuEncAddr); 1761 UInt startTileIdx = rpcPic->getPicSym()->getTileIdxMap(lcuAddr); 1762 UInt tileBoundingCUAddrSlice = 0; 1763 while (lcuEncAddr < uiNumberOfCUsInFrame && rpcPic->getPicSym()->getTileIdxMap(lcuAddr) == startTileIdx) 1764 { 1765 lcuEncAddr++; 1766 lcuAddr = rpcPic->getPicSym()->getCUOrderMap(lcuEncAddr); 1767 } 1768 tileBoundingCUAddrSlice = lcuEncAddr*rpcPic->getNumPartInCU(); 1769 1770 if (tileBoundingCUAddrSlice < boundingCUAddrSliceSegment) 1771 { 1772 boundingCUAddrSliceSegment = tileBoundingCUAddrSlice; 1773 pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment ); 1774 tileBoundary = true; 1775 } 1776 } 1777 1778 if(boundingCUAddrSliceSegment>uiBoundingCUAddrSlice) 1779 { 1780 boundingCUAddrSliceSegment = uiBoundingCUAddrSlice; 1781 pcSlice->setSliceSegmentCurEndCUAddr(uiBoundingCUAddrSlice); 1782 } 1783 1704 1784 //calculate real dependent slice start address 1705 UInt uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->get DependentSliceCurStartCUAddr()) % rpcPic->getNumPartInCU();1706 UInt uiExternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->get DependentSliceCurStartCUAddr()) / rpcPic->getNumPartInCU();1785 UInt uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurStartCUAddr()) % rpcPic->getNumPartInCU(); 1786 UInt uiExternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurStartCUAddr()) / rpcPic->getNumPartInCU(); 1707 1787 UInt uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1708 1788 UInt uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; … … 1722 1802 UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*rpcPic->getNumPartInCU()+uiInternalAddress); 1723 1803 1724 pcSlice->set DependentSliceCurStartCUAddr(uiRealStartAddress);1725 uiStartCUAddrDependentSlice=uiRealStartAddress;1804 pcSlice->setSliceSegmentCurStartCUAddr(uiRealStartAddress); 1805 startCUAddrSliceSegment=uiRealStartAddress; 1726 1806 1727 1807 //calculate real slice start address … … 1749 1829 1750 1830 // Make a joint decision based on reconstruction and dependent slice bounds 1751 uiStartCUAddr = max(uiStartCUAddrSlice , uiStartCUAddrDependentSlice);1752 uiBoundingCUAddr = min(uiBoundingCUAddrSlice, uiBoundingCUAddrDependentSlice);1831 startCUAddr = max(uiStartCUAddrSlice , startCUAddrSliceSegment ); 1832 boundingCUAddr = min(uiBoundingCUAddrSlice, boundingCUAddrSliceSegment); 1753 1833 1754 1834 … … 1757 1837 // For fixed number of LCU within an entropy and reconstruction slice we already know whether we will encounter end of entropy and/or reconstruction slice 1758 1838 // first. Set the flags accordingly. 1759 if ( (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE && m_pcCfg->getDependentSliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE) 1760 || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getDependentSliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE) 1761 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE && m_pcCfg->getDependentSliceMode()==0) 1762 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getDependentSliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE) 1763 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getDependentSliceMode()==0) 1764 #if DEPENDENT_SLICES 1765 || (m_pcCfg->getDependentSliceMode()==FIXED_NUMBER_OF_TILES_IN_DEPENDENT_SLICE && m_pcCfg->getSliceMode()==0) 1766 #endif 1839 if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1840 || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1841 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0) 1842 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1843 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0) 1844 || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0) 1767 1845 || tileBoundary 1768 1846 ) 1769 1847 { 1770 if (uiBoundingCUAddrSlice < uiBoundingCUAddrDependentSlice)1848 if (uiBoundingCUAddrSlice < boundingCUAddrSliceSegment) 1771 1849 { 1772 1850 pcSlice->setNextSlice ( true ); 1773 pcSlice->setNext DependentSlice( false );1774 } 1775 else if (uiBoundingCUAddrSlice > uiBoundingCUAddrDependentSlice)1851 pcSlice->setNextSliceSegment( false ); 1852 } 1853 else if (uiBoundingCUAddrSlice > boundingCUAddrSliceSegment) 1776 1854 { 1777 1855 pcSlice->setNextSlice ( false ); 1778 pcSlice->setNext DependentSlice( true );1856 pcSlice->setNextSliceSegment( true ); 1779 1857 } 1780 1858 else 1781 1859 { 1782 1860 pcSlice->setNextSlice ( true ); 1783 pcSlice->setNext DependentSlice( true );1861 pcSlice->setNextSliceSegment( true ); 1784 1862 } 1785 1863 } … … 1787 1865 { 1788 1866 pcSlice->setNextSlice ( false ); 1789 pcSlice->setNext DependentSlice( false );1867 pcSlice->setNextSliceSegment( false ); 1790 1868 } 1791 1869 } 1792 1870 } 1793 1871 1794 #if RECALCULATE_QP_ACCORDING_LAMBDA1795 1872 Double TEncSlice::xGetQPValueAccordingToLambda ( Double lambda ) 1796 1873 { 1797 1874 return 4.2005*log(lambda) + 13.7122; 1798 1875 } 1799 #endif1800 1876 1801 1877 //! \}
Note: See TracChangeset for help on using the changeset viewer.